invoice calculator

This commit is contained in:
Jun-te Kim 2025-04-09 10:18:33 +00:00
parent a42ea8670a
commit fc67f0c1e4
5 changed files with 40 additions and 13 deletions

View file

@ -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

View file

@ -0,0 +1,6 @@
class InvoiceCalculator():
def __init__(self):
pass

View file

@ -10,6 +10,11 @@ class BaseModel(SQLModel):
)
class Deal(BaseModel):
id: str
name: str
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

View file

@ -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"]
))