mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added handling of archetype checks and corrected gbis calculations
This commit is contained in:
parent
b46da0f6c0
commit
a7e593ecd9
1 changed files with 47 additions and 18 deletions
|
|
@ -4154,19 +4154,25 @@ def forecast_remaining_sales(loader):
|
|||
else:
|
||||
ha_gbis_sale_conversion = median_gbis_to_install
|
||||
|
||||
gbis_total = eligiblity_counts[
|
||||
gbis_total_pre_cancellations = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"] == "gbis"
|
||||
]["count"].sum()
|
||||
gbis_total = int(np.round(gbis_total * ha_gbis_sale_conversion))
|
||||
gbis_total_revenue = int(gbis_total * gbis_rate)
|
||||
|
||||
gbis_remaining = eligiblity_counts_remaining[
|
||||
gbis_total_pre_cancellations_revenue = gbis_total_pre_cancellations * gbis_rate
|
||||
# gbis_total = int(np.round(gbis_total_pre_cancellations * ha_gbis_sale_conversion))
|
||||
# gbis_total_revenue = int(gbis_total * gbis_rate)
|
||||
|
||||
gbis_remaining_pre_cancellations = eligiblity_counts_remaining[
|
||||
eligiblity_counts_remaining["ECO Eligibility"] == "gbis"
|
||||
]["count"].sum()
|
||||
gbis_remaining = int(np.round(gbis_remaining * ha_gbis_sale_conversion))
|
||||
gbis_remaining_pre_cancellations_revenue = (
|
||||
gbis_remaining_pre_cancellations * gbis_rate
|
||||
)
|
||||
# This is the gbis jobs we expect to sell
|
||||
gbis_remaining = int(np.round(gbis_remaining_pre_cancellations * ha_gbis_sale_conversion))
|
||||
gbis_remaining_revenue = int(gbis_remaining * gbis_rate)
|
||||
|
||||
survey_list["installation_status"].value_counts()
|
||||
# This is the number we expect to cancel
|
||||
gbis_remaining_expected_cancellations = int(gbis_remaining_pre_cancellations - gbis_remaining) * gbis_rate
|
||||
|
||||
# GBIS delta
|
||||
if original_warmfront_remaining_gbis == 0:
|
||||
|
|
@ -4179,9 +4185,10 @@ def forecast_remaining_sales(loader):
|
|||
# Current sales figures
|
||||
# For any sales surveys that are complete, that could still cancel, we apply a conversion rate
|
||||
eco4_actually_sold = 0
|
||||
gbis_actually_sold = 0
|
||||
eco4_confirmed_cancellations = 0
|
||||
eco4_expected_cancellations = 0
|
||||
|
||||
gbis_actually_sold = 0
|
||||
gbis_confirmed_cancellations = 0
|
||||
gbis_expected_cancellations = 0
|
||||
if not survey_list.empty:
|
||||
|
|
@ -4284,17 +4291,30 @@ def forecast_remaining_sales(loader):
|
|||
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
|
||||
# The total before cancellations should equal:
|
||||
# The number of sold +
|
||||
# The number of confirmed cancelled +
|
||||
# The number of expected cancelled +
|
||||
# The number of remaining
|
||||
gbis_variance = gbis_total_pre_cancellations - (
|
||||
gbis_actually_sold / gbis_rate +
|
||||
gbis_confirmed_cancellations +
|
||||
gbis_expected_cancellations +
|
||||
gbis_remaining_pre_cancellations
|
||||
)
|
||||
|
||||
if gbis_variance != 0:
|
||||
raise ValueError("Something went wrong in gbis_variance")
|
||||
|
||||
# We expect the remaining to equal expected sales + expected cancellations
|
||||
gbis_variance_2 = gbis_remaining_pre_cancellations - (
|
||||
gbis_remaining +
|
||||
gbis_remaining_expected_cancellations
|
||||
)
|
||||
|
||||
if gbis_variance_2 != 0:
|
||||
raise ValueError("Something went wrong in gbis_variance")
|
||||
|
||||
to_append = {
|
||||
("", "", "", "HA Name"): ha_name,
|
||||
# ECO4 - original warmfront figures
|
||||
|
|
@ -4375,17 +4395,26 @@ def forecast_remaining_sales(loader):
|
|||
"Estimated CIGA failures - £"
|
||||
],
|
||||
# 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", "Total - #", "GBIS total"): gbis_total_pre_cancellations,
|
||||
("GBIS Postcode list", "Warmfront post code list", "Total - £", "GBIS total"):
|
||||
gbis_total_pre_cancellations_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
|
||||
("GBIS Postcode list", "", "Unconfirmed cancellations - £", ""): gbis_expected_cancellations * gbis_rate,
|
||||
("GBIS Postcode list", "Warmfront post code list", "Remaining - #", "GBIS total"): gbis_remaining,
|
||||
("GBIS Postcode list", "Warmfront post code list", "Remaining - £", "GBIS total"): gbis_remaining_revenue,
|
||||
("GBIS Postcode list", "Warmfront post code list", "Remaining - #", "GBIS total"):
|
||||
gbis_remaining_pre_cancellations,
|
||||
("GBIS Postcode list", "Warmfront post code list", "Remaining - £", "GBIS total"):
|
||||
gbis_remaining_pre_cancellations_revenue,
|
||||
("GBIS Postcode list", "", "Delta vs original estimate, remaining - %", ""):
|
||||
gbis_delta_vs_original_estimate_remaining,
|
||||
# Expected cancellations
|
||||
(
|
||||
"GBIS Postcode list", "Of which expected sales - £", "Remaining - £",
|
||||
"GBIS total"): gbis_remaining_revenue,
|
||||
("GBIS Postcode list", "Of which expected cancellations -£", "Remaining - £", "GBIS total"):
|
||||
gbis_remaining_expected_cancellations
|
||||
}
|
||||
|
||||
# Make sure nothing is forgotten due to duplicate multi-index keys
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue