From fc67f0c1e4aeb2346e774f0690ca3555a450855b Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Wed, 9 Apr 2025 10:18:33 +0000 Subject: [PATCH] invoice calculator --- etl/hubSpotClient/hubspot.py | 23 +++++++++++++++++-- etl/hubSpotClient/invoice.py | 6 +++++ etl/hubSpotClient/types.py | 11 ++++++--- etl/hubspot_to_deemed_calculator.py | 13 ++++------- ...nvoice.py => jjc_old_lewis_manual_way_.py} | 0 5 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 etl/hubSpotClient/invoice.py rename etl/{jjc_invoice.py => jjc_old_lewis_manual_way_.py} (100%) diff --git a/etl/hubSpotClient/hubspot.py b/etl/hubSpotClient/hubspot.py index ff04f85..49d2199 100644 --- a/etl/hubSpotClient/hubspot.py +++ b/etl/hubSpotClient/hubspot.py @@ -1,6 +1,7 @@ import hubspot from enum import Enum from hubspot.crm.deals import PublicObjectSearchRequest +from etl.hubSpotClient.types import SubmissionInfoFromDeal class DealStage(Enum): SURVEYED_COMPLETE_NEEDS_SIGN_OFF = "1617223914" @@ -24,11 +25,29 @@ class HubSpotClient(): "value": deal_stage.value, }] }], - properties=["dealname"], + properties=[ + "dealname", + "number_of_wet_rooms_needing_ventilation", + "work_type", + "property_needs_trickle_vents", + "domna_survey_post_sap", + "existing_wall_insulation" + ], ) found_deals = self.client.crm.deals.search_api.do_search(search_request) + all_deals = [] if hasattr(found_deals, "results"): - return found_deals.results + for deal in found_deals.results: + all_deals.append(SubmissionInfoFromDeal( + deal_id= deal.properties["hs_object_id"], + deal_name=deal.properties["dealname"], + work_type=deal.properties["work_type"], + needs_trickle_ventilation=True if deal.properties["property_needs_trickle_vents"].upper() == "YES" else False, + post_sap_score=int(deal.properties["domna_survey_post_sap"]), + existing_wall_insulation=deal.properties["existing_wall_insulation"], + no_of_wet_rooms=int(deal.properties["number_of_wet_rooms_needing_ventilation"]) + )) + return all_deals else: return None diff --git a/etl/hubSpotClient/invoice.py b/etl/hubSpotClient/invoice.py new file mode 100644 index 0000000..ec1a8f9 --- /dev/null +++ b/etl/hubSpotClient/invoice.py @@ -0,0 +1,6 @@ + + + +class InvoiceCalculator(): + def __init__(self): + pass \ No newline at end of file diff --git a/etl/hubSpotClient/types.py b/etl/hubSpotClient/types.py index 8a2a8cb..c109f53 100644 --- a/etl/hubSpotClient/types.py +++ b/etl/hubSpotClient/types.py @@ -10,6 +10,11 @@ class BaseModel(SQLModel): ) -class Deal(BaseModel): - id: str - name: str \ No newline at end of file +class SubmissionInfoFromDeal(BaseModel): + deal_id: str + deal_name: str + work_type: str + needs_trickle_ventilation: bool + post_sap_score: int + existing_wall_insulation: str + no_of_wet_rooms: int \ No newline at end of file diff --git a/etl/hubspot_to_deemed_calculator.py b/etl/hubspot_to_deemed_calculator.py index 09c8d61..96b8fd6 100644 --- a/etl/hubspot_to_deemed_calculator.py +++ b/etl/hubspot_to_deemed_calculator.py @@ -1,17 +1,14 @@ from etl.hubSpotClient.hubspot import HubSpotClient, DealStage -from etl.hubSpotClient.types import Deal hubSpotClient = HubSpotClient() + + deals = hubSpotClient.get_deals_from_deal_stage(DealStage.SURVEYED_COMPLETE_NEEDS_SIGN_OFF) -all_deals = [] +for deal in deals: + print(deal) + -if deals: - for deal in deals: - all_deals.append(Deal( - id= deal.properties["hs_object_id"], - name=deal.properties["dealname"] - )) \ No newline at end of file diff --git a/etl/jjc_invoice.py b/etl/jjc_old_lewis_manual_way_.py similarity index 100% rename from etl/jjc_invoice.py rename to etl/jjc_old_lewis_manual_way_.py