Adjust command to backfill (less granular)

Rates began from 05-2016

This adjusts the command to backfill by year.

If 2016, let's backfill from May.
If 2017, let's backfill from the beginning of the year.
This commit is contained in:
Imdad Ahad
2017-08-01 11:36:30 +01:00
parent 20f3be0bae
commit a08de0939b

View File

@@ -153,12 +153,19 @@ class PopulateMonthlyBilling(Command):
option_list = (
Option('-s', '-service-id', dest='service_id',
help="Service id to populate monthly billing for"),
Option('-m', '-month', dest="month", help="Use for integer value for month, e.g. 7 for July"),
Option('-y', '-year', dest="year", help="Use for integer value for year, e.g. 2017")
)
def run(self, service_id, month, year):
print('Starting populating monthly billing')
def run(self, service_id, year):
start, end = 1, 13
if year == '2016':
start = 6
print('Starting populating monthly billing for {}'.format(year))
for i in range(start, end):
self.populate(service_id, year, i)
def populate(self, service_id, year, month):
create_or_update_monthly_billing_sms(service_id, datetime(int(year), int(month), 1))
results = get_monthly_billing_sms(service_id, datetime(int(year), int(month), 1))
print("Finished populating data for {} for service id {}".format(month, service_id))