mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-13 16:52:23 -05:00
We need to rebuild the monthly billing for one service for the month of March.
This change makes that possible without affecting any other data in the table.
This commit is contained in:
@@ -185,9 +185,12 @@ def fix_notification_statuses_not_in_sync():
|
||||
|
||||
@notify_command()
|
||||
@click.option('-y', '--year', required=True, help="e.g. 2017", type=int)
|
||||
def populate_monthly_billing(year):
|
||||
@click.option('-s', '--service_id', required=False, help="Enter the service id", type=click.UUID)
|
||||
@click.option('-m', '--month', required=False, help="e.g. 1 for January", type=int)
|
||||
def populate_monthly_billing(year, service_id=None, month=None):
|
||||
"""
|
||||
Populate monthly billing table for all services for a given year.
|
||||
If service_id and month provided then only rebuild monthly billing for that month.
|
||||
"""
|
||||
def populate(service_id, year, month):
|
||||
create_or_update_monthly_billing(service_id, datetime(year, month, 1))
|
||||
@@ -201,11 +204,14 @@ def populate_monthly_billing(year):
|
||||
service_id, datetime(year, month, 1), 'letter'
|
||||
)
|
||||
|
||||
print("Finished populating data for {} for service id {}".format(month, str(service_id)))
|
||||
print("Finished populating data for {}-{} for service id {}".format(month, year, str(service_id)))
|
||||
print('SMS: {}'.format(sms_res.monthly_totals))
|
||||
print('Email: {}'.format(email_res.monthly_totals))
|
||||
print('Letter: {}'.format(letter_res.monthly_totals))
|
||||
|
||||
if service_id and month:
|
||||
populate(service_id, year, month)
|
||||
|
||||
service_ids = get_service_ids_that_need_billing_populated(
|
||||
start_date=datetime(2016, 5, 1), end_date=datetime(2017, 8, 16)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user