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:
9
TODO
9
TODO
@@ -1,6 +1,15 @@
|
||||
UI:
|
||||
|
||||
For bills:
|
||||
* gas bills are a mess and more than 4 per year... *SIGH* try this:
|
||||
- if len(bills) > num_ann_bills (effectively too many bills for what we expect)
|
||||
- normalise by looping over *EVERY* year of bills
|
||||
- for each bill in yr:
|
||||
- pb=find_prev_bill( bill )...
|
||||
- calc days between pb and bill to get daily cost
|
||||
- work out qtr() and take # days from bill in Qtr X and add it to Q[X]
|
||||
- if # days i X+1 add those to Q[X+1]
|
||||
- then need to be careful when working out totals/growth to use Q[...] not bill['year']
|
||||
* growth for internet/monthly is a bit skewed.... Really think min/avg/max might need to be smarter
|
||||
- at least max, its 114-134 BUT, not in 1 year, really that changed from 2022 to 2025, so 3 years... (or max = 18% over 3 years, or 6%)
|
||||
-- so ann_growth_avg or max needs to factor in years of same prices
|
||||
|
||||
7
bills.py
7
bills.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user