From e508f265a1a722568511769920aa0fb7ca5d28d7 Mon Sep 17 00:00:00 2001 From: rocketdebris Date: Tue, 16 Dec 2025 09:08:13 -0500 Subject: [PATCH] Added Client Type column to the CRM table. Removed unwanted Status Buttons. --- custom_ui/api/db/clients.py | 17 ++--- frontend/src/components/pages/Clients.vue | 79 ++++++++++++----------- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/custom_ui/api/db/clients.py b/custom_ui/api/db/clients.py index 4a28f51..760d998 100644 --- a/custom_ui/api/db/clients.py +++ b/custom_ui/api/db/clients.py @@ -208,6 +208,7 @@ def get_clients_table_data(filters={}, sortings=[], page=1, page_size=10): f"{' ' + address['address_line2'] if address['address_line2'] else ''} " f"{address['city']}, {address['state']} {address['pincode']}" ) + tableRow["client_type"] = "Lead" if is_lead else "Customer" tableRow["appointment_scheduled_status"] = address.custom_onsite_meeting_scheduled tableRow["estimate_sent_status"] = address.custom_estimate_sent_status tableRow["job_status"] = address.custom_job_status @@ -229,7 +230,7 @@ def upsert_client(data): # Handle customer creation/update print("#####DEBUG: Upsert client data received:", data) - + print("#####DEBUG: Checking for existing customer with name:", data.get("customer_name")) customer = frappe.db.exists("Customer", {"customer_name": data.get("customer_name")}) @@ -238,18 +239,18 @@ def upsert_client(data): customer = frappe.db.exists("Lead", {"lead_name": data.get("customer_name")}) else: print("#####DEBUG: Existing customer found:", customer) - + if not customer: print("#####DEBUG: No existing lead found. Creating new lead.") is_individual = data.get("customer_type") == "Individual" - + primary_contact = next((c for c in data.get("contacts", []) if c.get("is_primary")), None) if not primary_contact: return build_error_response("Primary contact information is required to create a new customer.", 400) print("#####DEBUG: Primary contact found:", primary_contact) - + new_lead_data = { - "doctype": "Lead", + "doctype": "Lead", "lead_name": data.get("customer_name"), "first_name": primary_contact.get("first_name"), "last_name": primary_contact.get("last_name"), @@ -355,7 +356,7 @@ def upsert_client(data): "link_doctype": new_client_doc.doctype, "link_name": new_client_doc.name }) - + # Address -> Contact print("#####DEBUG: Linking address to contacts.") @@ -367,7 +368,7 @@ def upsert_client(data): "phone": contact_doc.phone, "role": contact_doc.role }) - + address_doc.save(ignore_permissions=True) # Contact -> Customer/Lead & Address @@ -384,7 +385,7 @@ def upsert_client(data): }) contact_doc.custom_customer = new_client_doc.name contact_doc.save(ignore_permissions=True) - + frappe.local.message_log = [] return build_success_response({ "customer": new_client_doc.as_dict(), diff --git a/frontend/src/components/pages/Clients.vue b/frontend/src/components/pages/Clients.vue index eee6d2b..291bcef 100644 --- a/frontend/src/components/pages/Clients.vue +++ b/frontend/src/components/pages/Clients.vue @@ -1,7 +1,6 @@