build meeting notes form in install on migrate

This commit is contained in:
Casey 2026-01-27 11:40:49 -06:00
parent 6cd3d138ad
commit c024e7fd86
12 changed files with 227 additions and 124 deletions

View file

@ -445,12 +445,16 @@ def upsert_client(data):
address_docs = []
for address in addresses:
is_billing = True if address.get("is_billing_address") else False
is_service = True if address.get("is_service_address") else False
print("#####DEBUG: Creating address with data:", address)
address_doc = AddressService.create_address({
"address_title": AddressService.build_address_title(customer_name, address),
"address_line1": address.get("address_line1"),
"address_line2": address.get("address_line2"),
"address_type": "Billing" if is_billing else "Service",
"custom_billing_address": is_billing,
"is_service_address": is_service,
"is_primary_address": is_billing,
"city": address.get("city"),
"state": address.get("state"),
"country": "United States",
@ -480,13 +484,12 @@ def upsert_client(data):
"address": address_doc.name
})
client_doc.save(ignore_permissions=True)
client_dict = client_doc.as_dict()
client_dict["contacts"] = [contact.as_dict() for contact in contact_docs]
client_dict["addresses"] = [address.as_dict() for address in address_docs]
frappe.local.message_log = []
return build_success_response({
"customer": client_doc.as_dict(),
"address": [address_doc.as_dict() for address_doc in address_docs],
"contacts": [contact_doc.as_dict() for contact_doc in contact_docs]
})
return build_success_response(client_dict)
except frappe.ValidationError as ve:
return build_error_response(str(ve), 400)
except Exception as e:

View file

@ -485,7 +485,7 @@ def upsert_estimate(data):
"letter_head": data.get("company"),
"custom_project_template": data.get("project_template", None),
"custom_quotation_template": data.get("quotation_template", None),
"from_onsite_meeting": data.get("onsite_meeting", None)
"from_onsite_meeting": data.get("from_onsite_meeting", None)
})
for item in data.get("items", []):
item = json.loads(item) if isinstance(item, str) else item

View file

@ -12,7 +12,31 @@ def get_service_appointments(companies, filters={}):
filters = json.loads(filters)
filters["company"] = ["in", companies]
service_appointment_names = frappe.get_all(
"Service Appointment",
"Service Address 2",
filters=filters,
pluck="name"
)
service_appointments = [
ServiceAppointmentService.get_full_dict(name)
for name in service_appointment_names
]
return build_success_response(service_appointments)
except Exception as e:
return build_error_response(str(e), 500)
@frappe.whitelist()
def get_unscheduled_service_appointments(companies):
"""Get unscheduled Service Appointments for given companies."""
try:
if isinstance(companies, str):
companies = json.loads(companies)
filters = {
"company": ["in", companies],
"expected_start_date": None,
"status": "Open"
}
service_appointment_names = frappe.get_all(
"Service Address 2",
filters=filters,
pluck="name"
)
@ -27,9 +51,11 @@ def get_service_appointments(companies, filters={}):
@frappe.whitelist()
def update_service_appointment_scheduled_dates(service_appointment_name: str, start_date, end_date, crew_lead_name, start_time=None, end_time=None):
"""Update scheduled dates for a Service Appointment."""
print(f"DEBUG: Updating scheduled dates for Service Appointment {service_appointment_name} to start: {start_date}, end: {end_date}, crew lead: {crew_lead_name}, start time: {start_time}, end time: {end_time}")
try:
updated_service_appointment = ServiceAppointmentService.update_scheduled_dates(
service_appointment_name,
crew_lead_name,
start_date,
end_date,
start_time,