mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added eligibility calculations
This commit is contained in:
parent
a81f1f2520
commit
6544adc6c3
1 changed files with 35 additions and 20 deletions
|
|
@ -2548,6 +2548,33 @@ def patch_cleaned(cleaned):
|
|||
return cleaned
|
||||
|
||||
|
||||
def calculate_eco4_post_ciga(eligiblity_counts, input_data, ha_ciga_conversion_rate, eco4_rate):
|
||||
remaining_needing_ciga_check = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"] == "eco4 (subject to ciga)"
|
||||
]["count"].sum()
|
||||
|
||||
has_ciga_check = not input_data["ciga_list"].empty
|
||||
if has_ciga_check:
|
||||
eco4_post_ciga = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"].isin(
|
||||
["eco4", "eco4 - passed ciga", "failed 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)
|
||||
else:
|
||||
eco4_post_ciga = (
|
||||
eligiblity_counts[eligiblity_counts["ECO Eligibility"] == "eco4"]["count"].sum() +
|
||||
np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
|
||||
)
|
||||
eco4_post_ciga = int(eco4_post_ciga)
|
||||
eco4_post_ciga_revenue = eco4_post_ciga * eco4_rate
|
||||
|
||||
return eco4_post_ciga, eco4_post_ciga_revenue
|
||||
|
||||
|
||||
def forecast_remaining_sales(loader):
|
||||
# Assumptions:
|
||||
# We cap the ciga conversion rate at 75% because I expect future HAs to have a lower CIGA conversion rate
|
||||
|
|
@ -2810,27 +2837,13 @@ def forecast_remaining_sales(loader):
|
|||
median_ciga_success_rate
|
||||
)
|
||||
|
||||
remaining_needing_ciga_check = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"] == "eco4 (subject to ciga)"
|
||||
]["count"].sum()
|
||||
eco4_post_ciga, eco4_post_ciga_revenue = calculate_eco4_post_ciga(
|
||||
eligiblity_counts, input_data, ha_ciga_conversion_rate, eco4_rate
|
||||
)
|
||||
|
||||
has_ciga_check = not input_data["ciga_list"].empty
|
||||
if has_ciga_check:
|
||||
eco4_post_ciga = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"].isin(
|
||||
["eco4", "eco4 - passed ciga", "failed 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)
|
||||
else:
|
||||
eco4_post_ciga = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"] == "eco4"
|
||||
]["count"].sum() + np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
|
||||
|
||||
eco4_post_ciga = int(eco4_post_ciga)
|
||||
eco4_post_ciga_remaining, eco4_post_ciga_remaining_revenue = calculate_eco4_post_ciga(
|
||||
eligiblity_counts_remaining, input_data, ha_ciga_conversion_rate, eco4_rate
|
||||
)
|
||||
|
||||
to_append = {
|
||||
("", "", "", "HA Name"): ha_name,
|
||||
|
|
@ -2851,6 +2864,8 @@ def forecast_remaining_sales(loader):
|
|||
("ECO4 pre-ciga", "", "Remaining - £", ""): eco4_pre_ciga_remaining_revenue,
|
||||
# ECO4 - asset list, post ciga
|
||||
("ECO4 post-ciga", "", "Estimated total eligible - #", ""): eco4_post_ciga,
|
||||
("ECO4 post-ciga", "", "Estimated remaining eligible - #", ""): eco4_post_ciga_remaining,
|
||||
("ECO4 post-ciga", "", "Estimated total eligible - £", ""): eco4_post_ciga_revenue,
|
||||
}
|
||||
|
||||
# Make sure nothing is forgotten due to duplicate multi-index keys
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue