-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from UKGovernmentBEIS/staging
Deploy staging to main
- Loading branch information
Showing
22 changed files
with
1,469 additions
and
562 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ CONTACT_EMAIL="[email protected]" | |
FROM_EMAIL="[email protected]" | ||
EMAIL_BACKEND_TYPE=CONSOLE | ||
BASE_URL=http://localhost:8012/ | ||
OS_API_KEY=["f4k3k3y"] | ||
OS_API_KEY=["api_key_1","api_key_2","api_key_3","api_key_4","api_key_5"] | ||
EPC_API_BASE_URL="https://api.epb.digital.communities.gov.uk" | ||
EPC_API_CLIENT_ID="client_id" | ||
EPC_API_CLIENT_SECRET="client_secret" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,52 @@ | ||
import logging | ||
gbis = "GBIS" | ||
eco4 = "ECO4" | ||
|
||
logger = logging.getLogger(__name__) | ||
not_eligible = () | ||
eligible_for_gbis = (gbis,) | ||
eligible_for_gbis_and_eco4 = (gbis, eco4) | ||
|
||
country_council_tax_bands = { | ||
"England": { | ||
"eligible": ("A", "B", "C", "D"), | ||
"ineligible": ("E", "F", "G", "H"), | ||
}, | ||
"Scotland": { | ||
"eligible": ("A", "B", "C", "D", "E"), | ||
"ineligible": ("F", "G", "H"), | ||
}, | ||
"Wales": { | ||
"eligible": ("A", "B", "C", "D", "E"), | ||
"ineligible": ("F", "G", "H", "I"), | ||
}, | ||
} | ||
|
||
def _is_eligible_council_tax_band(country, council_tax_band): | ||
if country == "England": | ||
return council_tax_band in ("A", "B", "C", "D") | ||
if country in ("Scotland", "Wales"): | ||
return council_tax_band in ("A", "B", "C", "D", "E") | ||
return False | ||
|
||
|
||
def calculate_eligibility(session_data): | ||
""" | ||
:param session_data: | ||
:return: A tuple of which schemes the person is eligible for, if any | ||
""" | ||
epc_rating = session_data.get("epc_rating", "Not found") | ||
council_tax_band = session_data.get("council_tax_band") | ||
country = session_data.get("country") | ||
benefits = session_data.get("benefits") | ||
property_type = session_data.get("property_type") | ||
own_property = session_data.get("own_property") | ||
property_type = session_data.get("property_type") | ||
park_home_main_residence = session_data.get("park_home_main_residence", "No") | ||
council_tax_band = session_data.get("council_tax_band") | ||
epc_rating = session_data.get("epc_rating", "Not found") | ||
accept_suggested_epc = session_data.get("accept_suggested_epc") | ||
benefits = session_data.get("benefits") | ||
household_income = session_data.get("household_income") | ||
|
||
# "Scenario 0" | ||
if property_type == "Park home": | ||
return ("GBIS",) | ||
|
||
# ECO4 and GBIS scenario 1 - home owner | ||
if country in country_council_tax_bands: | ||
if own_property in ("Yes, I own my property and live in it",): | ||
if epc_rating in ("D", "E", "F", "G", "Not found"): | ||
if benefits in ("Yes",): | ||
return ("GBIS", "ECO4") | ||
if country not in ("England", "Scotland", "Wales"): | ||
return not_eligible | ||
|
||
# ECO4 and GBIS scenario 2 - private rented (tenant or landlord) | ||
if country in country_council_tax_bands: | ||
if own_property in ( | ||
"No, I am a tenant", | ||
"Yes, I am the property owner but I lease the property to one or more tenants", | ||
): | ||
if epc_rating in ("E", "F", "G", "Not found"): | ||
if benefits in ("Yes",): | ||
return ("GBIS", "ECO4") | ||
if epc_rating in ("A", "B", "C") and accept_suggested_epc == "Yes": | ||
return not_eligible | ||
|
||
# ECO4 and GBIS scenario 3 - social housing tenant | ||
if country in country_council_tax_bands: | ||
if own_property in ("No, I am a social housing tenant",): | ||
if epc_rating in ("D", "E", "F", "G", "Not found"): | ||
if benefits in ("Yes",): | ||
return ("GBIS", "ECO4") | ||
if own_property == "No, I am a social housing tenant": | ||
return eligible_for_gbis_and_eco4 | ||
|
||
# Scenario 3 | ||
if country in country_council_tax_bands: | ||
if council_tax_band in country_council_tax_bands[country]["eligible"]: | ||
if epc_rating in ("D", "E", "F", "G", "Not found"): | ||
if benefits in ("No",): | ||
return ("GBIS",) | ||
if property_type == "Park home" and park_home_main_residence == "No": | ||
return not_eligible | ||
|
||
if country in country_council_tax_bands: | ||
if council_tax_band in country_council_tax_bands[country]["eligible"]: | ||
if epc_rating in ("D", "Not Found"): | ||
if benefits in ("Yes",): | ||
return ("GBIS",) | ||
if benefits == "Yes": | ||
return eligible_for_gbis_and_eco4 | ||
|
||
# Scenario 3.1 | ||
if country in country_council_tax_bands: | ||
if council_tax_band in country_council_tax_bands[country]["ineligible"]: | ||
if epc_rating in ("D", "Not Found"): | ||
if benefits in ("Yes",): | ||
return ("GBIS",) | ||
if household_income == "Less than £31,000 a year": | ||
return eligible_for_gbis_and_eco4 | ||
|
||
# Scenario 4 | ||
if country in country_council_tax_bands: | ||
if council_tax_band in country_council_tax_bands[country]["ineligible"]: | ||
if epc_rating in ("D", "E", "F", "G"): | ||
if benefits in ("No",): | ||
return () | ||
if property_type == "Park home": | ||
return eligible_for_gbis | ||
|
||
# Scenario 5 | ||
if country in country_council_tax_bands: | ||
if council_tax_band in country_council_tax_bands[country]["ineligible"]: | ||
if epc_rating in ("Not found"): | ||
if benefits in ("No",): | ||
return () | ||
if _is_eligible_council_tax_band(country, council_tax_band): | ||
return eligible_for_gbis | ||
|
||
return () | ||
return not_eligible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.