Added Client Type column to the CRM table. Removed unwanted Status Buttons.
This commit is contained in:
parent
1a837ffcfc
commit
e508f265a1
2 changed files with 51 additions and 45 deletions
|
|
@ -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['address_line2'] if address['address_line2'] else ''} "
|
||||||
f"{address['city']}, {address['state']} {address['pincode']}"
|
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["appointment_scheduled_status"] = address.custom_onsite_meeting_scheduled
|
||||||
tableRow["estimate_sent_status"] = address.custom_estimate_sent_status
|
tableRow["estimate_sent_status"] = address.custom_estimate_sent_status
|
||||||
tableRow["job_status"] = address.custom_job_status
|
tableRow["job_status"] = address.custom_job_status
|
||||||
|
|
@ -229,7 +230,7 @@ def upsert_client(data):
|
||||||
|
|
||||||
# Handle customer creation/update
|
# Handle customer creation/update
|
||||||
print("#####DEBUG: Upsert client data received:", data)
|
print("#####DEBUG: Upsert client data received:", data)
|
||||||
|
|
||||||
print("#####DEBUG: Checking for existing customer with name:", data.get("customer_name"))
|
print("#####DEBUG: Checking for existing customer with name:", data.get("customer_name"))
|
||||||
customer = frappe.db.exists("Customer", {"customer_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")})
|
customer = frappe.db.exists("Lead", {"lead_name": data.get("customer_name")})
|
||||||
else:
|
else:
|
||||||
print("#####DEBUG: Existing customer found:", customer)
|
print("#####DEBUG: Existing customer found:", customer)
|
||||||
|
|
||||||
if not customer:
|
if not customer:
|
||||||
print("#####DEBUG: No existing lead found. Creating new lead.")
|
print("#####DEBUG: No existing lead found. Creating new lead.")
|
||||||
is_individual = data.get("customer_type") == "Individual"
|
is_individual = data.get("customer_type") == "Individual"
|
||||||
|
|
||||||
primary_contact = next((c for c in data.get("contacts", []) if c.get("is_primary")), None)
|
primary_contact = next((c for c in data.get("contacts", []) if c.get("is_primary")), None)
|
||||||
if not primary_contact:
|
if not primary_contact:
|
||||||
return build_error_response("Primary contact information is required to create a new customer.", 400)
|
return build_error_response("Primary contact information is required to create a new customer.", 400)
|
||||||
print("#####DEBUG: Primary contact found:", primary_contact)
|
print("#####DEBUG: Primary contact found:", primary_contact)
|
||||||
|
|
||||||
new_lead_data = {
|
new_lead_data = {
|
||||||
"doctype": "Lead",
|
"doctype": "Lead",
|
||||||
"lead_name": data.get("customer_name"),
|
"lead_name": data.get("customer_name"),
|
||||||
"first_name": primary_contact.get("first_name"),
|
"first_name": primary_contact.get("first_name"),
|
||||||
"last_name": primary_contact.get("last_name"),
|
"last_name": primary_contact.get("last_name"),
|
||||||
|
|
@ -355,7 +356,7 @@ def upsert_client(data):
|
||||||
"link_doctype": new_client_doc.doctype,
|
"link_doctype": new_client_doc.doctype,
|
||||||
"link_name": new_client_doc.name
|
"link_name": new_client_doc.name
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
# Address -> Contact
|
# Address -> Contact
|
||||||
print("#####DEBUG: Linking address to contacts.")
|
print("#####DEBUG: Linking address to contacts.")
|
||||||
|
|
@ -367,7 +368,7 @@ def upsert_client(data):
|
||||||
"phone": contact_doc.phone,
|
"phone": contact_doc.phone,
|
||||||
"role": contact_doc.role
|
"role": contact_doc.role
|
||||||
})
|
})
|
||||||
|
|
||||||
address_doc.save(ignore_permissions=True)
|
address_doc.save(ignore_permissions=True)
|
||||||
|
|
||||||
# Contact -> Customer/Lead & Address
|
# Contact -> Customer/Lead & Address
|
||||||
|
|
@ -384,7 +385,7 @@ def upsert_client(data):
|
||||||
})
|
})
|
||||||
contact_doc.custom_customer = new_client_doc.name
|
contact_doc.custom_customer = new_client_doc.name
|
||||||
contact_doc.save(ignore_permissions=True)
|
contact_doc.save(ignore_permissions=True)
|
||||||
|
|
||||||
frappe.local.message_log = []
|
frappe.local.message_log = []
|
||||||
return build_success_response({
|
return build_success_response({
|
||||||
"customer": new_client_doc.as_dict(),
|
"customer": new_client_doc.as_dict(),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
<H2>Client Contact List</H2>
|
<H2>Client Contact List</H2>
|
||||||
|
|
||||||
<!-- Status Chart Section -->
|
<!-- Status Chart Section -->
|
||||||
<div class="widgets-grid">
|
<div class="widgets-grid">
|
||||||
<!-- Incomplete Bids Widget -->
|
<!-- Incomplete Bids Widget -->
|
||||||
|
|
@ -213,6 +212,12 @@ const columns = [
|
||||||
filterable: true,
|
filterable: true,
|
||||||
filterInputId: "customerSearchInput",
|
filterInputId: "customerSearchInput",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Type",
|
||||||
|
fieldName: "clientType",
|
||||||
|
type: "text",
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Property",
|
label: "Property",
|
||||||
fieldName: "address",
|
fieldName: "address",
|
||||||
|
|
@ -221,42 +226,42 @@ const columns = [
|
||||||
filterable: true,
|
filterable: true,
|
||||||
filterInputId: "propertySearchInput",
|
filterInputId: "propertySearchInput",
|
||||||
},
|
},
|
||||||
{
|
//{
|
||||||
label: "Appt. Scheduled",
|
// label: "Appt. Scheduled",
|
||||||
fieldName: "appointmentScheduledStatus",
|
// fieldName: "appointmentScheduledStatus",
|
||||||
type: "status-button",
|
// type: "status-button",
|
||||||
sortable: true,
|
// sortable: true,
|
||||||
buttonVariant: "outlined",
|
// buttonVariant: "outlined",
|
||||||
onStatusClick: (status, rowData) => handleAppointmentClick(status, rowData),
|
// onStatusClick: (status, rowData) => handleAppointmentClick(status, rowData),
|
||||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||||
},
|
//},
|
||||||
{
|
//{
|
||||||
label: "Estimate Sent",
|
// label: "Estimate Sent",
|
||||||
fieldName: "estimateSentStatus",
|
// fieldName: "estimateSentStatus",
|
||||||
type: "status-button",
|
// type: "status-button",
|
||||||
sortable: true,
|
// sortable: true,
|
||||||
buttonVariant: "outlined",
|
// buttonVariant: "outlined",
|
||||||
onStatusClick: (status, rowData) => handleEstimateClick(status, rowData),
|
// onStatusClick: (status, rowData) => handleEstimateClick(status, rowData),
|
||||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||||
},
|
//},
|
||||||
{
|
//{
|
||||||
label: "Payment Received",
|
// label: "Payment Received",
|
||||||
fieldName: "paymentReceivedStatus",
|
// fieldName: "paymentReceivedStatus",
|
||||||
type: "status-button",
|
// type: "status-button",
|
||||||
sortable: true,
|
// sortable: true,
|
||||||
buttonVariant: "outlined",
|
// buttonVariant: "outlined",
|
||||||
onStatusClick: (status, rowData) => handlePaymentClick(status, rowData),
|
// onStatusClick: (status, rowData) => handlePaymentClick(status, rowData),
|
||||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||||
},
|
//},
|
||||||
{
|
//{
|
||||||
label: "Job Status",
|
// label: "Job Status",
|
||||||
fieldName: "jobStatus",
|
// fieldName: "jobStatus",
|
||||||
type: "status-button",
|
// type: "status-button",
|
||||||
sortable: true,
|
// sortable: true,
|
||||||
buttonVariant: "outlined",
|
// buttonVariant: "outlined",
|
||||||
onStatusClick: (status, rowData) => handleJobClick(status, rowData),
|
// onStatusClick: (status, rowData) => handleJobClick(status, rowData),
|
||||||
// disableCondition: (status) => status?.toLowerCase() !== "not started",
|
// // disableCondition: (status) => status?.toLowerCase() !== "not started",
|
||||||
},
|
//},
|
||||||
];
|
];
|
||||||
|
|
||||||
const tableActions = [
|
const tableActions = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue