diff --git a/orchestration/abri_orchestrator.py b/orchestration/abri_orchestrator.py index bf833ac42..74900336a 100644 --- a/orchestration/abri_orchestrator.py +++ b/orchestration/abri_orchestrator.py @@ -11,6 +11,7 @@ from domain.abri.models import ( AppointmentAmended, JobAbandoned, LogJobRequest, + NoTenancyFound, PlaceRef, Tenant, ) @@ -24,6 +25,11 @@ from infrastructure.hubspot.errors import HubspotRequestError # property ID is fixed externally, the domain and database call it job_no. JOB_NO_DEAL_PROPERTY = "client_booking_reference" +# The note left on a deal whose place Abri reports as having no live tenancy. +# Worded as what Abri said rather than as a conclusion about the property: the +# same signal would arrive for a place_ref the deal should never have carried. +VOID_PROPERTY_NOTE = "Abri reports no live tenancy for this property." + def _vulnerability_description(tenant: Tenant) -> Optional[str]: """The tenant's distinct vulnerabilities, verbatim and newline-joined. @@ -259,6 +265,10 @@ class AbriOrchestrator: if isinstance(tenancy, AbriRequestRejected): return tenancy + if isinstance(tenancy, NoTenancyFound): + self._note_property_void(deal_id=deal_id, place_ref=place_ref) + return PropertyReportedVoid(place_ref=place_ref) + contact_ids: List[str] = [] associated_ids: List[str] = [] for tenant_index, tenant in enumerate(tenancy.tenants): @@ -290,6 +300,16 @@ class AbriOrchestrator: ), ) + def _note_property_void(self, deal_id: str, place_ref: PlaceRef) -> None: + """Record the void property in the deal's extra booking information. + + Deliberately unimplemented: the extra-booking-information property is + not yet scraped onto the deal, so there is nothing to append to. The + write lands in the follow-up that adds the property; until then the + flow completes so a void property never dead-letters. Filling this in + is a single write_deal_property call with VOID_PROPERTY_NOTE. + """ + def amend_job(self, change: AppointmentChange) -> AmendJobOrchestrationResult: job_no = self._deal_database.job_no_for_deal(change.deal_id) if job_no is None: