Monthly billing - part 1

This is still a work in progress but it would be good to get some eyes on it.
This commit includes creating and updating a row in the monthly billing table and a method to fetch the results.
There is a command to populate the monthly billing for a service and month so we can try it out.
The total cost at the moment are wrong, they do not take into account the free allowance - see notes below about adding that to the table.
Left to do:
create a nightly task to run to update the monthly totals.
create an endpoint to return the yearly billing, the current day will need to be calculated on the fly and added to the totals.
Add the free allowance into the total costs.
This commit is contained in:
Rebecca Law
2017-07-18 18:21:35 +01:00
parent 4b05c32b62
commit 9400988d72
13 changed files with 240 additions and 37 deletions

View File

@@ -1,4 +1,8 @@
from app.dao.date_util import get_financial_year, get_april_fools
from datetime import datetime
import pytest
from app.dao.date_util import get_financial_year, get_april_fools, get_month_start_end_date
def test_get_financial_year():
@@ -11,3 +15,16 @@ def test_get_april_fools():
april_fools = get_april_fools(2016)
assert str(april_fools) == '2016-03-31 23:00:00'
assert april_fools.tzinfo is None
@pytest.mark.parametrize("month, year, expected_end",
[(7, 2017, 31),
(2, 2016, 29),
(2, 2017, 28),
(9, 2018, 30),
(12, 2019, 31)])
def test_get_month_start_end_date(month, year, expected_end):
month_year = datetime(year, month, 10, 13, 30, 00)
result = get_month_start_end_date(month_year)
assert result[0] == datetime(year, month, 1, 0, 0, 0, 0)
assert result[1] == datetime(year, month, expected_end, 23, 59, 59, 99999)