add templates, update styles
This commit is contained in:
parent
8542a9bf37
commit
8452f57787
6 changed files with 362 additions and 153 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import frappe
|
||||
import json
|
||||
from custom_ui.db_utils import build_error_response, build_success_response
|
||||
from custom_ui.services import ClientService, AddressService
|
||||
from custom_ui.services import ClientService, AddressService, ContactService
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_address_by_full_address(full_address):
|
||||
|
|
@ -35,6 +35,33 @@ def get_address(address_name):
|
|||
# except Exception as e:
|
||||
# return build_error_response(str(e), 500)
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_address(address_data, company, customer_name):
|
||||
"""Create a new address."""
|
||||
print(f"DEBUG: create_address called with address_data: {address_data}, company: {company}, customer_name: {customer_name}")
|
||||
if isinstance(address_data, str):
|
||||
address_data = json.loads(address_data)
|
||||
customer_doctype = ClientService.get_client_doctype(customer_name)
|
||||
address_data["customer_name"] = customer_name
|
||||
address_data["customer_type"] = customer_doctype
|
||||
address_data["address_title"] = AddressService.build_address_title(customer_name, address_data)
|
||||
address_data["address_type"] = "Service"
|
||||
address_data["custom_billing_address"] = 0
|
||||
address_data["is_service_address"] = 1
|
||||
address_data["country"] = "United States"
|
||||
address_data["companies"] = [{ "company": company }]
|
||||
print(f"DEBUG: Final address_data before creation: {address_data}")
|
||||
try:
|
||||
address_doc = AddressService.create_address(address_data)
|
||||
for contact in address_data.get("contacts", []):
|
||||
AddressService.link_address_to_contact(address_doc, contact)
|
||||
contact_doc = ContactService.get_or_throw(contact)
|
||||
ContactService.link_contact_to_address(contact_doc, address_doc)
|
||||
ClientService.append_link_v2(customer_name, "properties", {"address": address_doc.name})
|
||||
return build_success_response(address_doc.as_dict())
|
||||
except Exception as e:
|
||||
return build_error_response(str(e), 500)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_addresses(fields=["*"], filters={}):
|
||||
"""Get addresses with optional filtering."""
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ def get_service_appointments(companies, filters={}):
|
|||
ServiceAppointmentService.get_full_dict(name)
|
||||
for name in service_appointment_names
|
||||
]
|
||||
|
||||
"is_half_down_paid"
|
||||
|
||||
return build_success_response(service_appointments)
|
||||
except Exception as e:
|
||||
return build_error_response(str(e), 500)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue