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,8 +1,8 @@
from datetime import datetime
import uuid
from app.dao.jobs_dao import dao_create_job
from app.dao.provider_rates_dao import create_sms_rate
from app.dao.service_inbound_api_dao import save_service_inbound_api
from app.models import (
Service,
@@ -11,6 +11,7 @@ from app.models import (
Notification,
ScheduledNotification,
ServicePermission,
Rate,
Job,
InboundSms,
Organisation,
@@ -239,3 +240,9 @@ def create_organisation(colour='blue', logo='test_x2.png', name='test_org_1'):
dao_create_organisation(organisation)
return organisation
def create_rate(start_date, value, notification_type):
rate = Rate(id=uuid.uuid4(), valid_from=start_date, rate=value, notification_type=notification_type)
create_sms_rate(rate)
return rate