mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
save workload
This commit is contained in:
parent
fc67f0c1e4
commit
9b34dc58d2
4 changed files with 66 additions and 14 deletions
|
|
@ -1,6 +0,0 @@
|
|||
|
||||
|
||||
|
||||
class InvoiceCalculator():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
|
@ -1,14 +1,71 @@
|
|||
from etl.hubSpotClient.hubspot import HubSpotClient, DealStage
|
||||
import pandas as pd
|
||||
from etl.jjc_old_lewis_manual_way_ import get_jjc_price_matrix, work_out_total_floor_area, type_of_work, get_band
|
||||
from etl.scraper.scraper import SharePointScraper, SharePointInstaller, WEEK_COMMENCING
|
||||
from etl.surveyedData.surveryedData import surveyedDataProcessor
|
||||
import os
|
||||
os.environ["SHAREPOINT_CLIENT_ID"] = "895e3b77-b1d7-43ec-b18f-dcfe07cdfeaf"
|
||||
os.environ["SHAREPOINT_CLIENT_SECRET"] = "SOf8Q~-is4wdQiqvEEm9FlJQRAY9ELGaj5Qz-a6E"
|
||||
os.environ["SHAREPOINT_TENANT_ID"] = "c3f7519c-2719-4547-af04-6da6cbfd8f8f"
|
||||
os.environ["JJC_SERVICE_SHAREPOINT_ID"] = "7fdd0485-bbf3-4b29-b30f-98c81c2a6284"
|
||||
|
||||
|
||||
hubSpotClient = HubSpotClient()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
deals = hubSpotClient.get_deals_from_deal_stage(DealStage.SURVEYED_COMPLETE_NEEDS_SIGN_OFF)
|
||||
|
||||
|
||||
csv_list = []
|
||||
|
||||
for deal in deals:
|
||||
print(deal)
|
||||
csv_list.append({
|
||||
"hubspot_work_type": deal.work_type,
|
||||
"Address": deal.deal_name,
|
||||
"Trickle Vent": 1 if deal.needs_trickle_ventilation else 0,
|
||||
"wetrooms": deal.no_of_wet_rooms,
|
||||
"hubspot_wall_insulation_info": deal.existing_wall_insulation,
|
||||
"POST INSTALL SAP SCORE": deal.post_sap_score,
|
||||
})
|
||||
|
||||
|
||||
hubspot_submissions = pd.DataFrame(csv_list)
|
||||
price_empty = get_jjc_price_matrix()
|
||||
price_foam = get_jjc_price_matrix("foam.csv")
|
||||
price_general = get_jjc_price_matrix("general.csv")
|
||||
total_price = []
|
||||
|
||||
|
||||
jjc = SharePointScraper(SharePointInstaller.JJC, development=True)
|
||||
file_paths = jjc.download_file_for_each_address()
|
||||
list_of_surveys = []
|
||||
|
||||
for eachAddress in file_paths:
|
||||
for address, files in eachAddress.items():
|
||||
list_of_surveys.append(surveyedDataProcessor(address, files))
|
||||
for survey in list_of_surveys:
|
||||
if survey.pre_site_note:
|
||||
floor_banding, total_floor_area = work_out_total_floor_area(survey.pre_site_note)
|
||||
letter, number = survey.pre_site_note.survey_information.current_sap.split(" ")
|
||||
pre_sap_score = number+letter
|
||||
|
||||
address = survey.pre_site_note.survey_information.address.split(",")
|
||||
address = [item.strip() for item in address][0]
|
||||
filtered_df = hubspot_submissions[hubspot_submissions["Address"].apply(lambda x: address.upper() == x.split(",")[0].upper())]
|
||||
if len(filtered_df) == 1:
|
||||
funding_type = type_of_work(letter.upper(), get_band(filtered_df["POST INSTALL SAP SCORE"].values[0])[-1])
|
||||
data = {
|
||||
"Address": survey.pre_site_note.survey_information.address,
|
||||
"HubSpot Address": filtered_df["Address"].values[0],
|
||||
"Surveyor's Name": survey.pre_site_note.assessor_information.name,
|
||||
"floor_area_group" : floor_banding,
|
||||
"wetrooms" : filtered_df["wetrooms"].values[0],
|
||||
"Trickle Vent" : filtered_df["Ventilation Requirements"].values[0],
|
||||
}
|
||||
|
||||
insulation = None
|
||||
merged_df = pd.DataFrame()
|
||||
if survey.csr:
|
||||
if survey.csr.insulation_info:
|
||||
insultation = survey.csr.insulation_info.type.upper()
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ from datetime import datetime, timedelta
|
|||
def previous_monday():
|
||||
today = datetime.today()
|
||||
last_monday = today - timedelta(days=today.weekday() + 7) # Go back to last week's Monday
|
||||
# return f"W.C. 17.03.2025"
|
||||
return f"W.C. 31.03.2025"
|
||||
return f"W.C. {last_monday.strftime('%d.%m.%Y')}"
|
||||
|
||||
WEEK_COMMENCING = os.getenv("WEEK_COMMENCING", previous_monday())
|
||||
|
|
@ -57,7 +57,8 @@ class SharePointScraper():
|
|||
|
||||
# Delete me for production
|
||||
if development:
|
||||
self.surveyor_names = ['Abdul Koddus','Carl Fitzgerald']
|
||||
self.surveyor_names = ['Jun-te Kim (JJ Crump)']
|
||||
self.surveyor_to_dates_folder = {'Jun-te Kim (JJ Crump)': 'W.C. 31.03.2025'}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
# Example of how to run python code in this environment
|
||||
poetry run python etl/jjc_invoice.py
|
||||
poetry run python etl/jjc_old_lewis_manual_way.py
|
||||
Loading…
Add table
Reference in a new issue