make radio button for min / avg / max growth value be pushed into which_growth in the DB for bill_type row, then also delete estimated bills for that bill_type, and then calling /bills, causes the estimated bills to be filled back in based on the new chosen growth model

This commit is contained in:
2025-08-21 18:20:32 +10:00
parent ada6dfa3f5
commit 3521d4c126
4 changed files with 47 additions and 8 deletions

View File

@@ -71,6 +71,20 @@ def add_missing_monthly_bills_in_yr( bill_type, bill_info, yr ):
new_bill( bill_type, amt, new_date, 1 )
return
# given the bill_type has a which_growth contain min/avg/max, return the corresponding growth number
def get_growth_value( bt, bill_type ):
for el in bt:
if el['id'] == bill_type:
which = el['which_growth']
break
if which == 'avg':
return el['ann_growth_avg']
elif which == 'min':
return el['ann_growth_min']
else:
return el['ann_growth_max']
# go through the bill data from the DB, put it into more friendly formats, then
# work out and then add missing bill data (might be b/c we have monthly bills,
@@ -94,7 +108,7 @@ def process_bill_data(bd, bt, bf):
# new bill type
if not bill_type in bill_info:
bill_info[bill_type]={}
bill_info[bill_type]['growth'] = bt_id_ann_growth_avg[bill_type]
bill_info[bill_type]['growth'] = get_growth_value( bt, bill_type )
bill_info[bill_type]['num_ann_bills'] = bf_id_num[bt_id_freq[bill_type]]
bill_info[bill_type]['first_bill']={}
bill_info[bill_type]['last_bill']={}