mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge branch 'master' into refactor-letter-rates
This commit is contained in:
@@ -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,14 +26,10 @@ 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_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
|
||||
AnnualBilling.financial_year_start > financial_year_start
|
||||
).update(
|
||||
{'free_sms_fragment_limit': free_sms_fragment_limit}
|
||||
)
|
||||
@@ -61,12 +53,12 @@ def dao_get_all_free_sms_fragment_limit(service_id):
|
||||
).order_by(AnnualBilling.financial_year_start).all()
|
||||
|
||||
|
||||
def dao_insert_annual_billing(service):
|
||||
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=service.free_sms_fragment_limit,
|
||||
free_sms_fragment_limit=free_sms_fragment_limit,
|
||||
financial_year_start=get_current_financial_year_start_year(),
|
||||
service=service,
|
||||
)
|
||||
|
||||
@@ -459,6 +459,13 @@ def dao_get_notifications_by_to_field(service_id, search_term, statuses=None):
|
||||
return results
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_notifications_by_references(references):
|
||||
return Notification.query.filter(
|
||||
Notification.reference.in_(references)
|
||||
).all()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_created_scheduled_notification(scheduled_notification):
|
||||
db.session.add(scheduled_notification)
|
||||
|
||||
@@ -41,7 +41,6 @@ from app.models import (
|
||||
)
|
||||
from app.statsd_decorators import statsd
|
||||
from app.utils import get_london_month_from_utc_column, get_london_midnight_in_utc
|
||||
from app.dao.annual_billing_dao import dao_insert_annual_billing
|
||||
|
||||
DEFAULT_SERVICE_PERMISSIONS = [
|
||||
SMS_TYPE,
|
||||
@@ -163,9 +162,6 @@ def dao_create_service(service, user, service_id=None, service_permissions=None)
|
||||
if service_permissions is None:
|
||||
service_permissions = DEFAULT_SERVICE_PERMISSIONS
|
||||
|
||||
if service.free_sms_fragment_limit is None:
|
||||
service.free_sms_fragment_limit = current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT']
|
||||
|
||||
from app.dao.permissions_dao import permission_dao
|
||||
service.users.append(user)
|
||||
permission_dao.add_default_service_permissions_for_user(user, service)
|
||||
@@ -180,7 +176,6 @@ def dao_create_service(service, user, service_id=None, service_permissions=None)
|
||||
|
||||
# do we just add the default - or will we get a value from FE?
|
||||
insert_service_sms_sender(service, current_app.config['FROM_NUMBER'])
|
||||
dao_insert_annual_billing(service)
|
||||
db.session.add(service)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user