hack to handle gass bills (for now), seems we have more than 4 for a quarterly cycle, and they are all over the shop/inconsistent. Added thoughts on how to tackle in TODO

This commit is contained in:
2025-08-23 10:48:29 +10:00
parent 54c4c38403
commit 4b5b713c20
2 changed files with 15 additions and 1 deletions

View File

@@ -259,7 +259,7 @@ def derive_ann_growth( bill_type, bill_info ):
total={}
for yr in range( bill_info[bill_type]['first_bill_year'], now_yr+1):
# if not enough bills in this year (or none), then try next year (first year might have not enough bills)
if yr not in bill_info[bill_type]['year'] or len(bill_info[bill_type]['year'][yr]) != bill_info[bill_type]['num_ann_bills']:
if yr not in bill_info[bill_type]['year'] or len(bill_info[bill_type]['year'][yr]) < bill_info[bill_type]['num_ann_bills']:
continue;
# just going to make sure we dont use estimated data in the last year of real data - can skew growths
@@ -274,6 +274,8 @@ def derive_ann_growth( bill_type, bill_info ):
total[yr] = 0
for b in bill_info[bill_type]['year'][yr]:
total[yr] += b['amount']
if bill_type == 3:
print( f"total[{yr}]={total[yr]}" )
# once we have all yr totals:
growth = {}
@@ -293,6 +295,9 @@ def derive_ann_growth( bill_type, bill_info ):
if growth > max_growth:
max_growth = growth
if count:
if min_growth< 0: min_growth=0
if avg_growth< 0 or avg_growth > 10: avg_growth = 3*count
if max_growth>10 : max_growth = 9.99
set_bill_type_growth( bill_type, min_growth, avg_growth/count, max_growth )
else:
# failsafe (just in case fill bills failed to add enough bills to average out)