now have a calc_future_totals func that is used to allow html to show the bills as a simple annualised cost per year

This commit is contained in:
2025-08-30 13:58:29 +10:00
parent 4a2dd4d2da
commit de32bdc7ff

View File

@@ -329,6 +329,7 @@ def process_bill_data(bd, bt, bf):
continue
add_missing_bills_for_yr( bill_type, bill_info, yr )
derive_ann_growth( bill_type, bill_info )
return bill_info
################################################################################
# add_missing_bills_for_yr -- wrapper to call right func based on bill freq
@@ -444,3 +445,19 @@ def derive_ann_growth( bill_type, bill_info ):
else:
# failsafe (just in case fill bills failed to add enough bills to average out)
print( f"{bill_type}: Unable to calculate growth!" )
################################################################################
# just go through this year to END_YEAR, total any bills for each year up
# so we can display the annual estimated bills onwards...
################################################################################
def calc_future_totals(bill_info, bill_types):
total={}
now_yr = datetime.date.today().year
for bt in bill_types:
total[bt['id']]={}
for yr in range( now_yr, END_YEAR+1):
total[bt['id']][yr]=0
if bt['id'] in bill_info and yr in bill_info[bt['id']]['year']:
for b in bill_info[bt['id']]['year'][yr]:
total[bt['id']][yr] += b['amount']
return total