big update

This commit is contained in:
Casey 2026-01-15 17:31:53 -06:00
parent 73d235b7bc
commit 0380dd10d8
18 changed files with 951 additions and 490 deletions

View file

@ -205,19 +205,20 @@ def get_clients_table_data(filters={}, sortings=[], page=1, page_size=10):
addresses = [frappe.get_doc("Address", addr["name"]).as_dict() for addr in address_names]
tableRows = []
for address in addresses:
is_lead = False
is_lead = address.customer_type == "Lead"
print("##########IS LEAD:", is_lead)
tableRow = {}
links = address.links
customer_links = [link for link in links if link.link_doctype == "Customer"] if links else None
customer_name = address.get("custom_customer_to_bill", None)
if not customer_links:
customer_links = [link for link in links if link.link_doctype == "Lead"] if links else None
is_lead = True if customer_links else False
if not customer_name and not customer_links:
# customer_links = [link for link in links if link.link_doctype == "Customer"] if links else None
customer_name = address.get("customer_name")
# if not customer_links:
# customer_links = [link for link in links if link.link_doctype == "Lead"] if links else None
# is_lead = True if customer_links else False
# if not customer_name and not customer_links:
# customer_name = frappe.get_value("Lead", address.get("customer_name"), "custom_customer_name")
if is_lead:
# print("DEBUG: No customer to bill. Customer links found:", customer_links)
customer_name = frappe.get_value("Lead", address.get("customer_name"), "custom_customer_name")
elif not customer_name and customer_links:
print("DEBUG: No customer to bill. Customer links found:", customer_links)
customer_name = frappe.get_value("Lead", customer_links[0].link_name, "custom_customer_name") if is_lead else customer_links[0].link_name
tableRow["id"] = address["name"]
tableRow["customer_name"] = customer_name
tableRow["address"] = (
@ -225,6 +226,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']}"
)
print("########IS LEAD @TABLE ROW:", is_lead)
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
@ -308,6 +310,7 @@ def upsert_client(data):
"phone": primary_contact.get("phone_number"),
"custom_customer_name": customer_name,
"customer_type": customer_type,
"address_type": "Billing",
"companies": [{ "company": data.get("company_name")
}]
}