mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Adding cancellations to output
This commit is contained in:
parent
680f38963a
commit
e966dfdf6e
1 changed files with 49 additions and 19 deletions
|
|
@ -3301,6 +3301,10 @@ def forecast_remaining_sales(loader):
|
||||||
# For any sales surveys that are complete, that could still cancel, we apply a conversion rate
|
# For any sales surveys that are complete, that could still cancel, we apply a conversion rate
|
||||||
eco4_actually_sold = 0
|
eco4_actually_sold = 0
|
||||||
gbis_actually_sold = 0
|
gbis_actually_sold = 0
|
||||||
|
eco4_confirmed_cancellations = 0
|
||||||
|
eco4_expected_cancellations = 0
|
||||||
|
gbis_confirmed_cancellations = 0
|
||||||
|
gbis_expected_cancellations = 0
|
||||||
if not survey_list.empty:
|
if not survey_list.empty:
|
||||||
surveys_with_eligibility = survey_list.merge(
|
surveys_with_eligibility = survey_list.merge(
|
||||||
asset_list[["asset_list_row_id", "ECO Eligibility"]],
|
asset_list[["asset_list_row_id", "ECO Eligibility"]],
|
||||||
|
|
@ -3308,34 +3312,54 @@ def forecast_remaining_sales(loader):
|
||||||
)
|
)
|
||||||
completed_eco4_sales = surveys_with_eligibility[
|
completed_eco4_sales = surveys_with_eligibility[
|
||||||
surveys_with_eligibility["installation_status"] == "ECO4 - installed"
|
surveys_with_eligibility["installation_status"] == "ECO4 - installed"
|
||||||
]
|
].shape[0]
|
||||||
incomplete_eco4_sales = surveys_with_eligibility[
|
incomplete_eco4_sales = surveys_with_eligibility[
|
||||||
(surveys_with_eligibility["installation_status"] == "ECO4 - in progress") &
|
(surveys_with_eligibility["installation_status"] == "ECO4 - in progress") &
|
||||||
(~surveys_with_eligibility["ECO Eligibility"].isin(
|
(~surveys_with_eligibility["ECO Eligibility"].isin(
|
||||||
["eco4 - passed ciga"])
|
["eco4 - passed ciga"])
|
||||||
)
|
)
|
||||||
]
|
].shape[0]
|
||||||
incomplete_eco4_sales_ciga = surveys_with_eligibility[
|
incomplete_eco4_sales_ciga = surveys_with_eligibility[
|
||||||
(surveys_with_eligibility["installation_status"] == "ECO4 - in progress") &
|
(surveys_with_eligibility["installation_status"] == "ECO4 - in progress") &
|
||||||
(surveys_with_eligibility["ECO Eligibility"].isin(
|
(surveys_with_eligibility["ECO Eligibility"].isin(
|
||||||
["eco4 - passed ciga"])
|
["eco4 - passed ciga"])
|
||||||
)
|
)
|
||||||
]
|
].shape[0]
|
||||||
|
|
||||||
eco4_actually_sold = (completed_eco4_sales.shape[0] * eco4_rate) + (
|
eco4_confirmed_cancellations = surveys_with_eligibility[
|
||||||
incomplete_eco4_sales.shape[0] * ha_eco4_to_sale_rate +
|
surveys_with_eligibility["installation_status"] == "ECO4 - cancelled"
|
||||||
incomplete_eco4_sales_ciga.shape[0] * ha_ciga_pass_to_sale_rate
|
].shape[0]
|
||||||
) * eco4_rate
|
|
||||||
|
expected_eco4_sales_no_ciga = np.round(incomplete_eco4_sales * ha_eco4_to_sale_rate)
|
||||||
|
expected_eco4_sales_ciga = np.round(incomplete_eco4_sales_ciga * ha_ciga_pass_to_sale_rate)
|
||||||
|
|
||||||
|
eco4_expected_cancellations = (incomplete_eco4_sales + incomplete_eco4_sales_ciga) - (
|
||||||
|
expected_eco4_sales_no_ciga + expected_eco4_sales_ciga
|
||||||
|
)
|
||||||
|
eco4_expected_cancellations = int(np.round(eco4_expected_cancellations))
|
||||||
|
|
||||||
|
eco4_actually_sold = eco4_rate * (
|
||||||
|
completed_eco4_sales + expected_eco4_sales_no_ciga + expected_eco4_sales_ciga
|
||||||
|
)
|
||||||
|
|
||||||
completed_gbis_sales = surveys_with_eligibility[
|
completed_gbis_sales = surveys_with_eligibility[
|
||||||
surveys_with_eligibility["installation_status"] == "GBIS - installed"
|
surveys_with_eligibility["installation_status"] == "GBIS - installed"
|
||||||
]
|
].shape[0]
|
||||||
incomplete_gbis_sales = surveys_with_eligibility[
|
incomplete_gbis_sales = surveys_with_eligibility[
|
||||||
(surveys_with_eligibility["installation_status"] == "GBIS - in progress")
|
(surveys_with_eligibility["installation_status"] == "GBIS - in progress")
|
||||||
]
|
].shape[0]
|
||||||
|
|
||||||
gbis_actually_sold = completed_gbis_sales.shape[0] * gbis_rate + (
|
# Get confirmed cancellations
|
||||||
incomplete_gbis_sales.shape[0] * ha_gbis_sale_conversion * gbis_rate
|
gbis_confirmed_cancellations = surveys_with_eligibility[
|
||||||
|
surveys_with_eligibility["installation_status"] == "GBIS - cancelled"
|
||||||
|
].shape[0]
|
||||||
|
|
||||||
|
expected_gbis_unconfirmed_sales = incomplete_gbis_sales * ha_gbis_sale_conversion
|
||||||
|
|
||||||
|
gbis_expected_cancellations = int(incomplete_gbis_sales - expected_gbis_unconfirmed_sales)
|
||||||
|
|
||||||
|
gbis_actually_sold = completed_gbis_sales * gbis_rate + (
|
||||||
|
expected_gbis_unconfirmed_sales * gbis_rate
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add in the variance:
|
# Add in the variance:
|
||||||
|
|
@ -3381,6 +3405,9 @@ def forecast_remaining_sales(loader):
|
||||||
("ECO4 pre-ciga", "", "VARIANCE - TOTAL", ""): variance_total,
|
("ECO4 pre-ciga", "", "VARIANCE - TOTAL", ""): variance_total,
|
||||||
("ECO4 pre-ciga", "", "VARIANCE - REMAINING", ""): variance_remaining,
|
("ECO4 pre-ciga", "", "VARIANCE - REMAINING", ""): variance_remaining,
|
||||||
("ECO4 pre-ciga", "", "Sold - £", ""): eco4_actually_sold,
|
("ECO4 pre-ciga", "", "Sold - £", ""): eco4_actually_sold,
|
||||||
|
("ECO4 pre-ciga", "", "Confirmed cancellations - £", ""): eco4_confirmed_cancellations,
|
||||||
|
# This is for jobs that are in-progress and could still cancel
|
||||||
|
("ECO4 pre-ciga", "", "Unconfirmed cancellations - £", ""): eco4_expected_cancellations,
|
||||||
("ECO4 pre-ciga", "", "Remaining - £", ""): eco4_pre_ciga_remaining_revenue,
|
("ECO4 pre-ciga", "", "Remaining - £", ""): eco4_pre_ciga_remaining_revenue,
|
||||||
# ECO4 - asset list, post ciga, total
|
# ECO4 - asset list, post ciga, total
|
||||||
("ECO4 post-ciga", "", "Estimated total eligible - #", "ECO4 total"):
|
("ECO4 post-ciga", "", "Estimated total eligible - #", "ECO4 total"):
|
||||||
|
|
@ -3403,6 +3430,13 @@ def forecast_remaining_sales(loader):
|
||||||
eco4_post_ciga_remaining_results["Of which forecast - #"],
|
eco4_post_ciga_remaining_results["Of which forecast - #"],
|
||||||
("ECO4 post-ciga", "", "Of which forecast - £", ""):
|
("ECO4 post-ciga", "", "Of which forecast - £", ""):
|
||||||
eco4_post_ciga_remaining_results["Of which forecast - £"],
|
eco4_post_ciga_remaining_results["Of which forecast - £"],
|
||||||
|
# Expected ECO4 cancellations
|
||||||
|
("ECO4 Cancellations", "", "Of which expected cancellations - #", ""): eco4_post_ciga_remaining_results[
|
||||||
|
"Expected cancellations - #"
|
||||||
|
],
|
||||||
|
("ECO4 Cancellations", "", "Of which expected cancellations - £", ""): eco4_post_ciga_remaining_results[
|
||||||
|
"Expected cancellations - £"
|
||||||
|
],
|
||||||
# CIGA failures
|
# CIGA failures
|
||||||
("ECO4 CIGA failures", "", "Estimated total - failed CIGA - #", ""): eco4_post_ciga_remaining_results[
|
("ECO4 CIGA failures", "", "Estimated total - failed CIGA - #", ""): eco4_post_ciga_remaining_results[
|
||||||
'Estimated total - failed CIGA'
|
'Estimated total - failed CIGA'
|
||||||
|
|
@ -3422,17 +3456,13 @@ def forecast_remaining_sales(loader):
|
||||||
("ECO4 CIGA failures", "", "Estimated failures - £", ""): eco4_post_ciga_remaining_results[
|
("ECO4 CIGA failures", "", "Estimated failures - £", ""): eco4_post_ciga_remaining_results[
|
||||||
"Estimated CIGA failures - £"
|
"Estimated CIGA failures - £"
|
||||||
],
|
],
|
||||||
# Expected ECO4 cancellations
|
|
||||||
("ECO4 Cancellations", "", "Expected cancellations - #", ""): eco4_post_ciga_remaining_results[
|
|
||||||
"Expected cancellations - #"
|
|
||||||
],
|
|
||||||
("ECO4 Cancellations", "", "Expected cancellations - £", ""): eco4_post_ciga_remaining_results[
|
|
||||||
"Expected cancellations - £"
|
|
||||||
],
|
|
||||||
# GBIS postcode list
|
# 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,
|
||||||
("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_revenue,
|
||||||
("GBIS Postcode list", "Warmfront post code list", "Sold - £", "GBIS total"): gbis_actually_sold,
|
("GBIS Postcode list", "Warmfront post code list", "Sold - £", "GBIS total"): gbis_actually_sold,
|
||||||
|
("GBIS Postcode list", "", "Confirmed cancellations - £", ""): gbis_confirmed_cancellations,
|
||||||
|
# This is for jobs that are in-progress and could still cancel
|
||||||
|
("GBIS Postcode list", "", "Unconfirmed cancellations - £", ""): gbis_expected_cancellations,
|
||||||
("GBIS Postcode list", "Warmfront post code list", "Remaining - #", "GBIS total"): gbis_remaining,
|
("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_revenue,
|
||||||
("GBIS Postcode list", "", "Delta vs original estimate, remaining - %", ""):
|
("GBIS Postcode list", "", "Delta vs original estimate, remaining - %", ""):
|
||||||
|
|
@ -3440,7 +3470,7 @@ def forecast_remaining_sales(loader):
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make sure nothing is forgotten due to duplicate multi-index keys
|
# Make sure nothing is forgotten due to duplicate multi-index keys
|
||||||
if len(to_append) != 41:
|
if len(to_append) != 45:
|
||||||
raise ValueError("Something went wrong")
|
raise ValueError("Something went wrong")
|
||||||
|
|
||||||
results.append(to_append)
|
results.append(to_append)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue