Skip to content

Commit

Permalink
Merge branch 'master' into GT_0901
Browse files Browse the repository at this point in the history
  • Loading branch information
adityabaravkar authored Sep 4, 2023
2 parents 565b2ba + 4a96d96 commit 05a4ec6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
22 changes: 17 additions & 5 deletions maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import json
from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta
import calendar


from werkzeug.exceptions import BadRequest


# MAINTENANCE BY STATUS
Expand Down Expand Up @@ -108,7 +106,9 @@ def get(self, property_id):
-- MAINTENANCE PROJECTS BY PROPERTY
SELECT -- *
property_uid, property_address, property_unit, property_city, property_state, property_zip, property_type, property_num_beds, property_num_baths, property_area
, maintenance_request_uid, maintenance_property_id, maintenance_request_status, maintenance_title, maintenance_desc, maintenance_images, maintenance_request_type, maintenance_request_created_by, maintenance_priority, maintenance_can_reschedule, maintenance_assigned_business, maintenance_assigned_worker, maintenance_scheduled_date, maintenance_scheduled_time, maintenance_frequency, maintenance_notes, maintenance_request_created_date, maintenance_request_closed_date, maintenance_request_adjustment_date
, maintenance_request_uid, maintenance_property_id, maintenance_request_status, maintenance_title, maintenance_desc, maintenance_images, maintenance_request_type, maintenance_request_created_by
, maintenance_priority, maintenance_can_reschedule, maintenance_assigned_business, maintenance_assigned_worker, maintenance_scheduled_date, maintenance_scheduled_time, maintenance_frequency
, maintenance_notes, maintenance_request_created_date, maintenance_request_closed_date, maintenance_request_adjustment_date, maintenance_callback_number, maintenance_estimated_cost
FROM space.properties
LEFT JOIN space.maintenanceRequests ON maintenance_property_id = property_uid
WHERE property_uid = \'""" + property_id + """\';
Expand Down Expand Up @@ -187,7 +187,7 @@ def get(self, owner_id):
SELECT -- *
maintenance_request_uid, maintenance_property_id, maintenance_title, maintenance_desc, maintenance_images, maintenance_request_type, maintenance_request_created_by, user_type, user_name, user_phone, user_email
, maintenance_priority, maintenance_can_reschedule, maintenance_assigned_business, maintenance_assigned_worker, maintenance_scheduled_date, maintenance_scheduled_time, maintenance_frequency, maintenance_notes, maintenance_request_status
, maintenance_request_created_date, maintenance_request_closed_date, maintenance_request_adjustment_date
, maintenance_request_created_date, maintenance_request_closed_date, maintenance_request_adjustment_date, maintenance_callback_number, maintenance_estimated_cost
, maintenance_quote_uid, quote_maintenance_request_id, quote_business_id, quote_services_expenses, quote_earliest_availability, quote_event_type, quote_event_duration, quote_notes, quote_status, quote_created_date, quote_total_estimate, quote_maintenance_images, quote_adjustment_date
, property_uid, property_address, property_unit, property_city, property_state, property_zip, property_type
, o_details.*
Expand Down Expand Up @@ -228,6 +228,8 @@ def post(self):
, 'maintenance_request_created_date'
, 'maintenance_request_closed_date'
, 'maintenance_request_adjustment_date'
, 'maintenance_callback_number'
, 'maintenance_estimated_cost'
]

newRequest = {}
Expand Down Expand Up @@ -274,3 +276,13 @@ def post(self):
response['images'] = newRequest['maintenance_images']

return response

def put(self):
response = {}
payload = request.get_json()
if payload.get('maintenance_request_uid') is None:
raise BadRequest("Request failed, no UID in payload.")
key = {'maintenance_request_uid': payload.pop('maintenance_request_uid')}
with connect() as db:
response = db.update('maintenanceRequests', key, payload)
return response
12 changes: 8 additions & 4 deletions myspace_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,15 @@ def get(self, tenant_id):
response = {}
with connect() as db:
property = db.execute("""
SELECT p.property_uid, p.property_address, p.property_unit
SELECT SUM(pur_amount_due) AS balance,
CAST(MIN(STR_TO_DATE(pur_due_date, '%Y-%m-%d')) AS CHAR) as earliest_due_date,
p.property_uid, p.property_address, p.property_unit
FROM space.properties p
INNER JOIN space.leases l ON l.lease_property_id = p.property_uid
INNER JOIN space.lease_tenant lt ON lt.lt_lease_id = l.lease_uid
WHERE lt.lt_tenant_id = \'""" + tenant_id + """\';
LEFT JOIN space.leases l ON l.lease_property_id = p.property_uid
LEFT JOIN space.lease_tenant lt ON lt.lt_lease_id = l.lease_uid
LEFT JOIN space.purchases pur ON p.property_uid = pur.pur_property_id
WHERE pur.purchase_status = 'UNPAID' AND lt.lt_tenant_id = \'""" + tenant_id + """\'
GROUP BY property_uid;
""")
response["property"] = property
maintenance = db.execute("""
Expand Down
13 changes: 12 additions & 1 deletion properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import json
from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta
import calendar
from werkzeug.exceptions import BadRequest


# MAINTENANCE BY STATUS
Expand Down Expand Up @@ -178,6 +178,17 @@ def post(self):
response['images'] = newProperty['property_images']

return response


def put(self):
response = {}
payload = request.get_json()
if payload.get('property_uid') is None:
raise BadRequest("Request failed, no UID in payload.")
key = {'property_uid': payload.pop('property_uid')}
with connect() as db:
response = db.update('properties', key, payload)
return response


def delete(self):
Expand Down

0 comments on commit 05a4ec6

Please sign in to comment.