mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added gbis variance checks
This commit is contained in:
parent
21082d8d37
commit
af13467c2c
1 changed files with 36 additions and 47 deletions
|
|
@ -3237,6 +3237,7 @@ def forecast_remaining_sales(loader):
|
|||
|
||||
results = []
|
||||
for ha_name, input_data in loader.data.items():
|
||||
|
||||
# Original warmfront figures - ECO4
|
||||
original_warmfront_estimates = december_figures[december_figures["HA Name"] == ha_name]
|
||||
|
||||
|
|
@ -3280,50 +3281,6 @@ def forecast_remaining_sales(loader):
|
|||
asset_list_remaining = asset_list_remaining[pd.isnull(asset_list_remaining["installation_status"])]
|
||||
asset_list_remaining = asset_list_remaining.drop(columns=["installation_status"])
|
||||
|
||||
# TODO: TEMP
|
||||
# n_pre_ciga = asset_list[
|
||||
# asset_list["ECO Eligibility"].isin(
|
||||
# [
|
||||
# "eco4 - passed ciga",
|
||||
# "eco4 (subject to ciga)",
|
||||
# "failed ciga",
|
||||
# "eco4"
|
||||
# ]
|
||||
# )
|
||||
# ].shape[0]
|
||||
#
|
||||
# n_pre_ciga_remaining = asset_list_remaining[
|
||||
# asset_list_remaining["ECO Eligibility"].isin(
|
||||
# [
|
||||
# "eco4 - passed ciga",
|
||||
# "eco4 (subject to ciga)",
|
||||
# "failed ciga",
|
||||
# "eco4"
|
||||
# ]
|
||||
# )
|
||||
# ].shape[0]
|
||||
#
|
||||
# compare_to_ids = asset_list_remaining["asset_list_row_id"].values
|
||||
# assets_diff_ids = [x for x in asset_list["asset_list_row_id"].values if x not in compare_to_ids]
|
||||
# diff = asset_list[asset_list["asset_list_row_id"].isin(assets_diff_ids)]
|
||||
#
|
||||
# n_sold = survey_list[survey_list["installation_status"].str.contains("ECO4")].shape[0]
|
||||
# # cancellations = survey_list[]
|
||||
# asset_list["ECO Eligibility"].value_counts()
|
||||
#
|
||||
# # Revenenue
|
||||
# pre_ciga_revenue = n_pre_ciga * eco4_rate
|
||||
# pre_ciga_remaining_revenue = n_pre_ciga_remaining * eco4_rate
|
||||
# sold_revenue = n_sold * eco4_rate
|
||||
#
|
||||
# pre_ciga_revenue - (pre_ciga_remaining_revenue + sold_revenue)
|
||||
# # MISSING 1 SALE from sold
|
||||
# cancelled = survey_list[survey_list["installation_status"].str.contains("ECO4")].shape[0]
|
||||
# dupes = survey_list[survey_list["asset_list_row_id"].duplicated()]["asset_list_row_id"].values
|
||||
# z = survey_list[survey_list["asset_list_row_id"].isin(dupes)]
|
||||
# z[['NO.', 'Street / Block Name', 'Post Code', 'INSTALLED OR CANCELLED', 'SUBMISSION DATE']]
|
||||
# # TODO: END TEMP
|
||||
|
||||
eligiblity_counts = pd.DataFrame(asset_list["ECO Eligibility"].value_counts()).reset_index()
|
||||
eligiblity_counts_remaining = pd.DataFrame(asset_list_remaining["ECO Eligibility"].value_counts()).reset_index()
|
||||
|
||||
|
|
@ -3525,6 +3482,35 @@ def forecast_remaining_sales(loader):
|
|||
if variance_remaining != 0:
|
||||
raise ValueError("Something went wrong in variance remaining")
|
||||
|
||||
# We also check variances to make sure that the pre-CIGA ECO4 total equals
|
||||
# 1) Pre CIGA remaining +
|
||||
# 2) ECO4 sold +
|
||||
# 3) ECO4 confirmed cancellations +
|
||||
# 4) ECO4 unconfirmed cancellations
|
||||
|
||||
pre_ciga_eco4_variance = (
|
||||
eco4_pre_ciga_revenue -
|
||||
eco4_pre_ciga_remaining_revenue -
|
||||
eco4_actually_sold -
|
||||
eco4_confirmed_cancellations * eco4_rate -
|
||||
eco4_expected_cancellations * eco4_rate
|
||||
)
|
||||
|
||||
if pre_ciga_eco4_variance != 0:
|
||||
raise ValueError("Something went wrong in pre_ciga_eco4_variance")
|
||||
|
||||
# Check GBIS total variance
|
||||
gbis_variance = (
|
||||
gbis_total_revenue -
|
||||
gbis_actually_sold -
|
||||
gbis_confirmed_cancellations * gbis_rate -
|
||||
gbis_expected_cancellations * gbis_rate -
|
||||
gbis_remaining_revenue
|
||||
)
|
||||
|
||||
if gbis_variance != 0:
|
||||
raise ValueError("Something went wrong in gbis_variance")
|
||||
|
||||
to_append = {
|
||||
("", "", "", "HA Name"): ha_name,
|
||||
# ECO4 - original warmfront figures
|
||||
|
|
@ -3544,8 +3530,10 @@ def forecast_remaining_sales(loader):
|
|||
("ECO4 pre-ciga", "", "Remaining - #", ""): eco4_pre_ciga_remaining,
|
||||
("ECO4 pre-ciga", "", "Total - £", ""): eco4_pre_ciga_revenue,
|
||||
("ECO4 pre-ciga", "", "Remaining - £", ""): eco4_pre_ciga_remaining_revenue,
|
||||
("ECO4 pre-ciga", "", "VARIANCE - TOTAL", ""): variance_total,
|
||||
("ECO4 pre-ciga", "", "VARIANCE - REMAINING", ""): variance_remaining,
|
||||
("ECO4 pre-ciga", "", "VARIANCE - PRE-CIGA ECO4 TOTAL", ""): pre_ciga_eco4_variance,
|
||||
("ECO4 pre-ciga", "", "VARIANCE - PRE-CIGA ECO4 TOTAL VS ELIGIBLE & INELIGIBLE", ""): variance_total,
|
||||
("ECO4 pre-ciga", "", "VARIANCE - PRE-CIGA ECO4 REMAINING VS ELIGIBLE & INELIGIBLE", ""):
|
||||
variance_remaining,
|
||||
("ECO4 pre-ciga", "", "Sold - £", ""): eco4_actually_sold,
|
||||
("ECO4 pre-ciga", "", "Confirmed cancellations - £", ""): eco4_confirmed_cancellations * eco4_rate,
|
||||
# This is for jobs that are in-progress and could still cancel
|
||||
|
|
@ -3600,6 +3588,7 @@ def forecast_remaining_sales(loader):
|
|||
# GBIS postcode list
|
||||
("GBIS Postcode list", "Warmfront post code list", "Total - #", "GBIS total"): gbis_total,
|
||||
("GBIS Postcode list", "Warmfront post code list", "Total - £", "GBIS total"): gbis_total_revenue,
|
||||
("GBIS Postcode list", "Warmfront post code list", "GBIS VARIANCE", "GBIS total"): gbis_variance,
|
||||
("GBIS Postcode list", "Warmfront post code list", "Sold - £", "GBIS total"): gbis_actually_sold,
|
||||
("GBIS Postcode list", "", "Confirmed cancellations - £", ""): gbis_confirmed_cancellations * gbis_rate,
|
||||
# This is for jobs that are in-progress and could still cancel
|
||||
|
|
@ -3611,7 +3600,7 @@ def forecast_remaining_sales(loader):
|
|||
}
|
||||
|
||||
# Make sure nothing is forgotten due to duplicate multi-index keys
|
||||
if len(to_append) != 45:
|
||||
if len(to_append) != 47:
|
||||
raise ValueError("Something went wrong")
|
||||
|
||||
results.append(to_append)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue