Added Client Type column to the CRM table. Removed unwanted Status Buttons.
This commit is contained in:
parent
1a837ffcfc
commit
e508f265a1
@ -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(),
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<H2>Client Contact List</H2>
|
||||
|
||||
<!-- Status Chart Section -->
|
||||
<div class="widgets-grid">
|
||||
<!-- Incomplete Bids Widget -->
|
||||
@ -213,6 +212,12 @@ const columns = [
|
||||
filterable: true,
|
||||
filterInputId: "customerSearchInput",
|
||||
},
|
||||
{
|
||||
label: "Type",
|
||||
fieldName: "clientType",
|
||||
type: "text",
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
label: "Property",
|
||||
fieldName: "address",
|
||||
@ -221,42 +226,42 @@ const columns = [
|
||||
filterable: true,
|
||||
filterInputId: "propertySearchInput",
|
||||
},
|
||||
{
|
||||
label: "Appt. Scheduled",
|
||||
fieldName: "appointmentScheduledStatus",
|
||||
type: "status-button",
|
||||
sortable: true,
|
||||
buttonVariant: "outlined",
|
||||
onStatusClick: (status, rowData) => handleAppointmentClick(status, rowData),
|
||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
},
|
||||
{
|
||||
label: "Estimate Sent",
|
||||
fieldName: "estimateSentStatus",
|
||||
type: "status-button",
|
||||
sortable: true,
|
||||
buttonVariant: "outlined",
|
||||
onStatusClick: (status, rowData) => handleEstimateClick(status, rowData),
|
||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
},
|
||||
{
|
||||
label: "Payment Received",
|
||||
fieldName: "paymentReceivedStatus",
|
||||
type: "status-button",
|
||||
sortable: true,
|
||||
buttonVariant: "outlined",
|
||||
onStatusClick: (status, rowData) => handlePaymentClick(status, rowData),
|
||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
},
|
||||
{
|
||||
label: "Job Status",
|
||||
fieldName: "jobStatus",
|
||||
type: "status-button",
|
||||
sortable: true,
|
||||
buttonVariant: "outlined",
|
||||
onStatusClick: (status, rowData) => handleJobClick(status, rowData),
|
||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
},
|
||||
//{
|
||||
// label: "Appt. Scheduled",
|
||||
// fieldName: "appointmentScheduledStatus",
|
||||
// type: "status-button",
|
||||
// sortable: true,
|
||||
// buttonVariant: "outlined",
|
||||
// onStatusClick: (status, rowData) => handleAppointmentClick(status, rowData),
|
||||
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
//},
|
||||
//{
|
||||
// label: "Estimate Sent",
|
||||
// fieldName: "estimateSentStatus",
|
||||
// type: "status-button",
|
||||
// sortable: true,
|
||||
// buttonVariant: "outlined",
|
||||
// onStatusClick: (status, rowData) => handleEstimateClick(status, rowData),
|
||||
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
//},
|
||||
//{
|
||||
// label: "Payment Received",
|
||||
// fieldName: "paymentReceivedStatus",
|
||||
// type: "status-button",
|
||||
// sortable: true,
|
||||
// buttonVariant: "outlined",
|
||||
// onStatusClick: (status, rowData) => handlePaymentClick(status, rowData),
|
||||
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
//},
|
||||
//{
|
||||
// label: "Job Status",
|
||||
// fieldName: "jobStatus",
|
||||
// type: "status-button",
|
||||
// sortable: true,
|
||||
// buttonVariant: "outlined",
|
||||
// onStatusClick: (status, rowData) => handleJobClick(status, rowData),
|
||||
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||
//},
|
||||
];
|
||||
|
||||
const tableActions = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user