Exemple #1
0
def create_annual_billing(service_id, free_sms_fragment_limit,
                          financial_year_start):
    annual_billing = AnnualBilling(
        service_id=service_id,
        free_sms_fragment_limit=free_sms_fragment_limit,
        financial_year_start=financial_year_start)
    db.session.add(annual_billing)
    db.session.commit()

    return annual_billing
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:
        result.free_sms_fragment_limit = free_sms_fragment_limit
    else:
        result = AnnualBilling(service_id=service_id, financial_year_start=financial_year_start,
                               free_sms_fragment_limit=free_sms_fragment_limit)
    db.session.add(result)
    return result
def dao_insert_annual_billing_for_this_year(service, free_sms_fragment_limit):
    """
    This method is called from create_service which is wrapped in a transaction.
    """
    annual_billing = AnnualBilling(
        free_sms_fragment_limit=free_sms_fragment_limit,
        financial_year_start=get_current_financial_year_start_year(),
        service=service,
    )

    db.session.add(annual_billing)