make sure POST /free-sms-fragment-limit always creates

refactored billing/rest.py and annual_billing_dao.py to remove logic
from the dao, and simplify the process around creating new rows. Make
sure that the POST always creates (it previously wouldn't create rows
for years that don't already exist). Clean up some tests that were
doing too much set-up/data verification via rest calls rather than
directly inserting test data in to the DB.
This commit is contained in:
Leo Hemsted
2017-12-06 11:03:42 +00:00
parent 4cdcc4e035
commit 78099de776
4 changed files with 81 additions and 106 deletions

View File

@@ -7,11 +7,7 @@ from app.dao.date_util import get_current_financial_year_start_year
@transactional
def dao_create_or_update_annual_billing_for_year(service_id, free_sms_fragment_limit, financial_year_start=None):
if not financial_year_start:
financial_year_start = get_current_financial_year_start_year()
def dao_create_or_update_annual_billing_for_year(service_id, free_sms_fragment_limit, financial_year_start):
result = dao_get_free_sms_fragment_limit_for_year(service_id, financial_year_start)
if result:
@@ -30,11 +26,7 @@ def dao_get_annual_billing(service_id):
@transactional
def dao_update_annual_billing_for_current_and_future_years(service_id, free_sms_fragment_limit,
financial_year_start=None):
if not financial_year_start:
financial_year_start = get_current_financial_year_start_year()
def dao_update_annual_billing_for_current_and_future_years(service_id, free_sms_fragment_limit, financial_year_start):
AnnualBilling.query.filter(
AnnualBilling.service_id == service_id,
AnnualBilling.financial_year_start >= financial_year_start