Added in remaining breakdowns into forecast and confirmed

This commit is contained in:
Khalim Conn-Kowlessar 2024-03-01 18:13:11 +00:00
parent 5c686f5ec4
commit c47af474b9

View file

@ -2555,24 +2555,40 @@ def calculate_eco4_post_ciga(eligiblity_counts, input_data, ha_ciga_conversion_r
has_ciga_check = not input_data["ciga_list"].empty
if has_ciga_check:
eco4_post_ciga = eligiblity_counts[
eco4_confirmed = eligiblity_counts[
eligiblity_counts["ECO Eligibility"].isin(
["eco4", "eco4 - passed ciga", "failed ciga"]
["eco4", "eco4 - passed ciga"]
)
]["count"].sum()
if remaining_needing_ciga_check > 0:
# We update the eco4 post ciga with the converted remaining
eco4_post_ciga += np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
eco4_remaining_forecast = np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
eco4_post_ciga = eco4_confirmed + eco4_remaining_forecast
else:
eco4_remaining_forecast = 0
eco4_post_ciga = eco4_confirmed
else:
eco4_confirmed = 0
eco4_remaining_forecast = np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
eco4_post_ciga = (
eligiblity_counts[eligiblity_counts["ECO Eligibility"] == "eco4"]["count"].sum() +
np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
eligiblity_counts[eligiblity_counts["ECO Eligibility"] == "eco4"]["count"].sum() + eco4_remaining_forecast
)
eco4_post_ciga = int(eco4_post_ciga)
eco4_post_ciga_revenue = eco4_post_ciga * eco4_rate
eco4_remaining_forecast = int(eco4_remaining_forecast)
return eco4_post_ciga, eco4_post_ciga_revenue
results = {
# Counts
"ECO4 - post CIGA - #": eco4_post_ciga,
"Of which confirmed - #": eco4_confirmed,
"Of which forecast - #": eco4_remaining_forecast,
# Revenue
"ECO4 - post CIGA - £": eco4_post_ciga * eco4_rate,
"Of which confirmed - £": eco4_confirmed * eco4_rate,
"Of which forecast - £": eco4_remaining_forecast * eco4_rate,
}
return results
def forecast_remaining_sales(loader):
@ -2837,14 +2853,16 @@ def forecast_remaining_sales(loader):
median_ciga_success_rate
)
eco4_post_ciga, eco4_post_ciga_revenue = calculate_eco4_post_ciga(
eco4_post_ciga_total_results = calculate_eco4_post_ciga(
eligiblity_counts, input_data, ha_ciga_conversion_rate, eco4_rate
)
# Calculate the delta compared to Warmfront's original estimate
eco4_delta_vs_original_estimate = 200 * (eco4_post_ciga - original_warmfront_eco4) / original_warmfront_eco4
eco4_delta_vs_original_estimate = 100 * (
eco4_post_ciga_total_results["ECO4 - post CIGA - #"] - original_warmfront_eco4
) / original_warmfront_eco4
eco4_post_ciga_remaining, eco4_post_ciga_remaining_revenue = calculate_eco4_post_ciga(
eco4_post_ciga_remaining_results = calculate_eco4_post_ciga(
eligiblity_counts_remaining, input_data, ha_ciga_conversion_rate, eco4_rate
)
@ -2866,12 +2884,25 @@ def forecast_remaining_sales(loader):
("ECO4 pre-ciga", "", "Total - £", ""): eco4_pre_ciga_revenue,
("ECO4 pre-ciga", "", "Remaining - £", ""): eco4_pre_ciga_remaining_revenue,
# ECO4 - asset list, post ciga, total
("ECO4 post-ciga", "", "Estimated total eligible - #", ""): eco4_post_ciga,
("ECO4 post-ciga", "", "Estimated total eligible - £", ""): eco4_post_ciga_revenue,
("ECO4 post-ciga", "", "Estimated total eligible - #", ""): eco4_post_ciga_total_results[
"ECO4 - post CIGA - #"],
("ECO4 post-ciga", "", "Estimated total eligible - £", ""): eco4_post_ciga_total_results[
"ECO4 - post CIGA - £"],
("ECO4 post-ciga", "", "Delta vs original estimate", ""): eco4_delta_vs_original_estimate,
# ECO4 - asset list, post ciga, remaining
("ECO4 post-ciga", "", "Estimated remaining eligible - #", ""): eco4_post_ciga_remaining,
("ECO4 post-ciga", "", "Estimated remaining total eligible - £", ""): eco4_post_ciga_remaining_revenue,
("ECO4 post-ciga", "", "Estimated remaining eligible - #", ""): eco4_post_ciga_remaining_results[
"ECO4 - post CIGA - #"],
("ECO4 post-ciga", "", "Estimated remaining total eligible - £", ""): eco4_post_ciga_remaining_results[
"ECO4 - post CIGA - £"],
("ECO4 post-ciga", "", "Of which - confirmed (post CIGA or no CIGA required) - #", ""):
eco4_post_ciga_remaining_results["Of which confirmed - #"],
("ECO4 post-ciga", "", "Of which - confirmed (post CIGA or no CIGA required) - £", ""):
eco4_post_ciga_remaining_results["Of which confirmed - £"],
("ECO4 post-ciga", "", "Of which forecast - #", ""):
eco4_post_ciga_remaining_results["Of which forecast - #"],
("ECO4 post-ciga", "", "Of which forecast - £", ""):
eco4_post_ciga_remaining_results["Of which forecast - £"],
# CIGA failures
}
# Make sure nothing is forgotten due to duplicate multi-index keys