diff --git a/custom_ui/api/db/addresses.py b/custom_ui/api/db/addresses.py
index 3d3fe96..bb99ff7 100644
--- a/custom_ui/api/db/addresses.py
+++ b/custom_ui/api/db/addresses.py
@@ -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."""
diff --git a/custom_ui/api/db/service_appointments.py b/custom_ui/api/db/service_appointments.py
index 6cb864c..2ac4b63 100644
--- a/custom_ui/api/db/service_appointments.py
+++ b/custom_ui/api/db/service_appointments.py
@@ -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)
diff --git a/frontend/src/components/clientView/GeneralClientInfo.vue b/frontend/src/components/clientView/GeneralClientInfo.vue
index 2505590..2b27689 100644
--- a/frontend/src/components/clientView/GeneralClientInfo.vue
+++ b/frontend/src/components/clientView/GeneralClientInfo.vue
@@ -4,6 +4,26 @@
+
+
+ mdi-map-marker-plus
+ Add Address
+
+
+ mdi-account-plus
+ Add Contact
+
+
@@ -145,35 +165,56 @@ const formattedCreationDate = computed(() => {
day: "numeric",
});
});
+
+// Placeholder methods for adding address and contact
+const addAddress = () => {
+ console.log("Add Address modal would open here");
+ // TODO: Open add address modal
+};
+
+const addContact = () => {
+ console.log("Add Contact modal would open here");
+ // TODO: Open add contact modal
+};
diff --git a/frontend/src/components/clientView/PropertyDetails.vue b/frontend/src/components/clientView/PropertyDetails.vue
index b9c06af..b0c4cfa 100644
--- a/frontend/src/components/clientView/PropertyDetails.vue
+++ b/frontend/src/components/clientView/PropertyDetails.vue
@@ -4,7 +4,7 @@
-
+
-
-
+
+
+
+
+
+
+
No companies associated
+
+
+
+
+
+
+
+