Compare commits
4 Commits
24c581a35a
...
2937866617
| Author | SHA1 | Date | |
|---|---|---|---|
| 2937866617 | |||
| 0ab0a112e4 | |||
| 4c96a9b576 | |||
| 7ad767759f |
3
BUGS
3
BUGS
@@ -1,2 +1,5 @@
|
|||||||
* added an electricity bill by accident for 2018, that kills lots :(
|
* added an electricity bill by accident for 2018, that kills lots :(
|
||||||
- something to do with missing year of data in quarterly bills - still an issue
|
- something to do with missing year of data in quarterly bills - still an issue
|
||||||
|
|
||||||
|
* UI: add bills, but growth figures dont update?
|
||||||
|
* UI: change which_growth and cost goes to many decimals not .2f
|
||||||
|
|||||||
14
bills.py
14
bills.py
@@ -110,6 +110,10 @@ def find_previous_bill( bill_type, bill_info, bill_date ):
|
|||||||
# okay, we have the previous billing year, and we wanted one for a year in the future,
|
# okay, we have the previous billing year, and we wanted one for a year in the future,
|
||||||
# just return the last one in this year as its the most recent
|
# just return the last one in this year as its the most recent
|
||||||
if wanted_year > yr:
|
if wanted_year > yr:
|
||||||
|
# small chance of future bills having estimates and reals (kayo did this)
|
||||||
|
for tmp in bill_info[bill_type]['year'][yr]:
|
||||||
|
if tmp['estimated'] == 0:
|
||||||
|
return tmp
|
||||||
return bill_info[bill_type]['year'][yr][0]
|
return bill_info[bill_type]['year'][yr][0]
|
||||||
else:
|
else:
|
||||||
# lets go through the newest to oldest of these bills
|
# lets go through the newest to oldest of these bills
|
||||||
@@ -219,12 +223,13 @@ def add_missing_monthly_bills_in_yr( bill_type, bill_info, yr ):
|
|||||||
for i in range( start_m+1, 13 ):
|
for i in range( start_m+1, 13 ):
|
||||||
bill_found=False
|
bill_found=False
|
||||||
new_date = f'{yr}-{i:02d}-{dd}'
|
new_date = f'{yr}-{i:02d}-{dd}'
|
||||||
|
new_date_yymm=f'{yr}-{i:02d}'
|
||||||
if yr in bill_info[bill_type]['year']:
|
if yr in bill_info[bill_type]['year']:
|
||||||
for b in bill_info[bill_type]['year'][yr]:
|
for b in bill_info[bill_type]['year'][yr]:
|
||||||
# this bill exists, skip adding it (this occurs when called to
|
# this bill exists, skip adding it (this occurs when called to
|
||||||
# add bills as there are < 12 bills in first_year, BUT, we
|
# add bills as there are < 12 bills in first_year, BUT, we
|
||||||
# don't fill before first_bill so the < 12 ALWAYS triggers
|
# don't fill before first_bill so the < 12 ALWAYS triggers
|
||||||
if str(b['bill_date']) == new_date:
|
if new_date_yymm in str(b['bill_date']):
|
||||||
bill_found=True
|
bill_found=True
|
||||||
break
|
break
|
||||||
if not bill_found:
|
if not bill_found:
|
||||||
@@ -429,17 +434,20 @@ def derive_ann_growth( bill_type, bill_info ):
|
|||||||
max_growth = growth
|
max_growth = growth
|
||||||
# data to work with
|
# data to work with
|
||||||
if count:
|
if count:
|
||||||
|
# strt with 0, set it if we can below
|
||||||
|
simple_growth=0
|
||||||
if simple_first_yr != simple_last_yr:
|
if simple_first_yr != simple_last_yr:
|
||||||
# calculate a simple growth with full year consecutive totals -> last - first / years
|
# calculate a simple growth with full year consecutive totals -> last - first / years
|
||||||
simple_growth=( ((total[simple_last_yr]-total[simple_first_yr])/(simple_last_yr-simple_first_yr)) / total[simple_first_yr] )*100.0
|
simple_growth=( ((total[simple_last_yr]-total[simple_first_yr])/(simple_last_yr-simple_first_yr)) / total[simple_first_yr] )*100.0
|
||||||
else:
|
else:
|
||||||
# calculate a simple growth based on last - first / years - only 1 consecutive year I guess, so can't use it, use real first/last
|
# calculate a simple growth based on last - first / years - only 1 consecutive year I guess, so can't use it, use real first/last
|
||||||
if bill_info[bill_type]['first_bill_year'] != bill_info[bill_type]['last_real_bill_year']:
|
if bill_info[bill_type]['first_bill_year'] != bill_info[bill_type]['last_real_bill_year'] and bill_info[bill_type]['first_bill_year'] in total and bill_info[bill_type]['last_real_bill_year'] in total:
|
||||||
simple_growth=( ((total[bill_info[bill_type]['last_real_bill_year']]-total[bill_info[bill_type]['first_bill_year']])/(bill_info[bill_type]['last_real_bill_year']-bill_info[bill_type]['first_bill_year'])) / total[bill_info[bill_type]['first_bill_year']] )*100.0
|
simple_growth=( ((total[bill_info[bill_type]['last_real_bill_year']]-total[bill_info[bill_type]['first_bill_year']])/(bill_info[bill_type]['last_real_bill_year']-bill_info[bill_type]['first_bill_year'])) / total[bill_info[bill_type]['first_bill_year']] )*100.0
|
||||||
set_bill_type_growth( bill_type, min_growth, avg_growth/count, max_growth, simple_growth )
|
set_bill_type_growth( bill_type, min_growth, avg_growth/count, max_growth, simple_growth )
|
||||||
else:
|
else:
|
||||||
# okay use last - first / years to get a simple_growth, just need bills from different years
|
# okay use last - first / years to get a simple_growth, just need bills from different years
|
||||||
if bill_info[bill_type]['first_bill_year'] != bill_info[bill_type]['last_real_bill_year']:
|
# if there are totals for them (may not be set with monthly and < 12 bills in 1st year)
|
||||||
|
if bill_info[bill_type]['first_bill_year'] != bill_info[bill_type]['last_real_bill_year'] and bill_info[bill_type]['first_bill_year'] in total and bill_info[bill_type]['last_real_bill_year'] in total:
|
||||||
simple_growth=( ((total[bill_info[bill_type]['last_real_bill_year']]-total[bill_info[bill_type]['first_bill_year']])/(bill_info[bill_type]['last_real_bill_year']-bill_info[bill_type]['first_bill_year'])) / total[bill_info[bill_type]['first_bill_year']] )*100.0
|
simple_growth=( ((total[bill_info[bill_type]['last_real_bill_year']]-total[bill_info[bill_type]['first_bill_year']])/(bill_info[bill_type]['last_real_bill_year']-bill_info[bill_type]['first_bill_year'])) / total[bill_info[bill_type]['first_bill_year']] )*100.0
|
||||||
set_bill_type_growth( bill_type, 0, 0, 0, simple_growth )
|
set_bill_type_growth( bill_type, 0, 0, 0, simple_growth )
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -88,7 +88,6 @@
|
|||||||
<button id="bill-type-canc-{{bt.id}}" class="px-0 col-1 btn btn-danger bg-danger-subtle text-danger d-none" onClick="CancelUpdateBillType({{bt.id}}, '{{bt.name}}')"><span class="bi bi-x"> Cancel</button>
|
<button id="bill-type-canc-{{bt.id}}" class="px-0 col-1 btn btn-danger bg-danger-subtle text-danger d-none" onClick="CancelUpdateBillType({{bt.id}}, '{{bt.name}}')"><span class="bi bi-x"> Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{ total[2][2025] }}
|
|
||||||
{% for yr in range( this_year, END_YEAR) %}
|
{% for yr in range( this_year, END_YEAR) %}
|
||||||
{% set tot=namespace( sum=0 ) %}
|
{% set tot=namespace( sum=0 ) %}
|
||||||
{% for bt in bill_types %}
|
{% for bt in bill_types %}
|
||||||
|
|||||||
Reference in New Issue
Block a user