Untitled
unknown
plain_text
3 years ago
1.9 kB
14
Indexable
def get_sov_valutaion(self, obj_in: dict) -> ValuatedPropertySovInputDTO:
"""
Logic based off of this Excel file:
https://britgroupservices.sharepoint.com/:x:/t/PricingAssessment/EWpFk6gQRgFDsi0Rgv389LwBSQelRij3oHB6m5lCQf5Udw?e=ixfnXD
Inquire with Waqaad:
- GrossArea is the same as floor_area
- BuildingValue is tiv_building
"""
obj_out = ValuatedPropertySovInputDTO(**obj_in)
# finding matching OccupancyQuartile match:
filters = {"state_id": obj_in["state_id"], "construction_type_id": obj_in["construction_type_id"], "occupancy_type_id": obj_in["occupancy_type_id"]}
quartile_match = self.db.session.query(OccupancyQuartile).filter_by(**filters).first
if not quartile_match:
quartile_match = self.db.session.query(OccupancyQuartile).filter(and_(OccupancyQuartile.occupancy_type_id==obj_in["occupancy_type_id"], OccupancyQuartile.construction_type_id==None, OccupancyQuartile.state_id==None)).first
# calculating tiv_per_sqft_quartile:
if quartile_match:
if obj_out.tiv_per_sqft >= quartile_match.q3:
obj_out.tiv_per_sqft_quartile = "High"
elif obj_out.tiv_per_sqft >= quartile_match.q1:
obj_out.tiv_per_sqft_quartile = "Average"
else:
obj_out.tiv_per_sqft_quartile = "Low"
# calculating suggested_tiv_per_sqft:
if quartile_match:
obj_out.suggested_tiv_per_sqft = quartile_match.q2
# calculating tiv_per_sqft & suggested_tiv:
if obj_in["floor_area"] and obj_in["floor_area"] > 1:
obj_out.tiv_per_sqft = obj_in["tiv_building"] / obj_in["floor_area"]
obj_out.suggested_tiv = obj_in["floor_area"] * obj_out.suggested_tiv_per_sqft
else:
obj_out.tiv_per_sqft = None
obj_out.suggested_tiv = obj_in["tiv_building"]
return obj_outEditor is loading...