This is an application I wrote for a coding challenge. It is a simple Flask app with RESTful(ish) APIs backed by SQLAlchemy.
- Install Python 3.6 or newer and ensure the bin directory is on the path (the directory is called "Scripts" on Windows)
- Change to the src directory and run
pip install .
- Change back to the root directory (where this readme is)
- Run the app.
Linux:
export FLASK_APP=src/invoice_service/app.py
export CCINVOICE_CONFIG=ccinvoice.cfg
flask run
Windows:
set FLASK_APP=src\invoice_service\app.py
set CCINVOICE_CONFIG=ccinvoice.cfg
flask run
Gets the active (not part of a finalized invoice) line items, filtered by any filters set with the filters API
Updates a line item
Payload should be a JSON dictionary with the format:
{
"adjustments": 1234.5
}
Sets a filter on the line items
Payload:
{
"field_name": "name of line item field to filter", # , e.g. "campaign_id"
"operation": "eq", #one of "eq" or "in"
"values": # for "eq", a single value, for "in" a list of values
}
Gets the total for the current filtered line items
Gets the subtotals grouped by campaign id for filtered line items
Finalizes the invoice with the current filtered line items.
- Install pytest with
pip install pytest
- Run tests with
pytest
(it should find the tests automatically)