fix address map
This commit is contained in:
parent
3c75ba975e
commit
73f4b3b97a
@ -109,13 +109,8 @@ def get_client(client_name):
|
||||
clientData.update(map_lead_client(clientData))
|
||||
links = []
|
||||
if customer.doctype == "Customer":
|
||||
links = (
|
||||
[{"link_doctype": "Contact", "link_name": row.contact}
|
||||
for row in customer.get("custom_add_contacts", [])]
|
||||
+
|
||||
[{"link_doctype": "Address", "link_name": row.address}
|
||||
for row in customer.get("custom_select_address", [])]
|
||||
)
|
||||
clientData["addresses"] = customer.custom_select_address or []
|
||||
clientData["contacts"] = customer.custom_add_contacts or []
|
||||
|
||||
else:
|
||||
links = frappe.get_all(
|
||||
@ -130,16 +125,16 @@ def get_client(client_name):
|
||||
"parent as link_name",
|
||||
]
|
||||
)
|
||||
|
||||
print("DEBUG: Retrieved links from lead:", links)
|
||||
for link in links:
|
||||
print("DEBUG: Processing link:", link)
|
||||
linked_doc = frappe.get_doc(link["link_doctype"], link["link_name"])
|
||||
if link["link_doctype"] == "Contact":
|
||||
clientData["contacts"].append(linked_doc.as_dict())
|
||||
elif link["link_doctype"] == "Address":
|
||||
clientData["addresses"].append(linked_doc.as_dict())
|
||||
print("DEBUG: Retrieved links from lead:", links)
|
||||
for link in links:
|
||||
print("DEBUG: Processing link:", link)
|
||||
linked_doc = frappe.get_doc(link["link_doctype"], link["link_name"])
|
||||
if link["link_doctype"] == "Contact":
|
||||
clientData["contacts"].append(linked_doc.as_dict())
|
||||
elif link["link_doctype"] == "Address":
|
||||
clientData["addresses"].append(linked_doc.as_dict())
|
||||
# TODO: Continue getting other linked docs like jobs, invoices, etc.
|
||||
print("DEBUG: Final client data prepared:", clientData)
|
||||
return build_success_response(clientData)
|
||||
except frappe.ValidationError as ve:
|
||||
return build_error_response(str(ve), 400)
|
||||
|
||||
@ -32,7 +32,7 @@ class ApiUtils {
|
||||
|
||||
static toCamelCaseObject(obj) {
|
||||
const newObj = Object.entries(obj).reduce((acc, [key, value]) => {
|
||||
const camelKey = key.replace(/_([a-z])/g, (match, p1) => p1.toUpperCase());
|
||||
const camelKey = key.replace(/_([a-zA-Z0-9])/g, (match, p1) => p1.toUpperCase());
|
||||
// check if value is an array
|
||||
if (Array.isArray(value)) {
|
||||
value = value.map((item) => {
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
/>
|
||||
</template>
|
||||
<div class="status-cards">
|
||||
<template v-if="isNew || editMode">
|
||||
<template v-if="isNew || editMode">
|
||||
<ClientInformationForm
|
||||
ref="clientInfoRef"
|
||||
@ -160,7 +159,7 @@
|
||||
|
||||
<!-- Edit Confirmation Dialog -->
|
||||
<Dialog
|
||||
v-model:visible="showEditConfirmDialog"
|
||||
:visible="showEditConfirmDialog"
|
||||
header="Confirm Edit"
|
||||
:modal="true"
|
||||
:closable="false"
|
||||
@ -318,10 +317,10 @@ const fullAddress = computed(() => {
|
||||
|
||||
// Get contacts linked to the selected address
|
||||
const contactsForAddress = computed(() => {
|
||||
if (!selectedAddressData.value?.customLinkedContacts || !props.clientData?.contacts) return [];
|
||||
return selectedAddressData.value.customLinkedContacts
|
||||
.map((link) => props.clientData.contacts.find((c) => c.name === link.contact))
|
||||
.filter(Boolean);
|
||||
console.log("DEBUG: props.clientData:", props.clientData);
|
||||
console.log("DEBUG: Calculating contacts for address:", props.selectedAddress);
|
||||
if (!selectedAddressData.value?.customLinkedContacts && !props.clientData?.contacts) return [];
|
||||
return props.clientData.contacts
|
||||
});
|
||||
|
||||
// Selected contact index for display
|
||||
|
||||
@ -121,11 +121,11 @@ const getClient = async (name) => {
|
||||
selectedAddressObject.value?.customLatitude
|
||||
) {
|
||||
geocode.value = {
|
||||
longitude: selectedAddressObject.value.customLongitude,
|
||||
latitude: selectedAddressObject.value.customLatitude,
|
||||
longitude: selectedAddressObject.value.customLongitude || selectedAddressObject.value.longitude,
|
||||
latitude: selectedAddressObject.value.customLatitude || selectedAddressObject.value.latitude,
|
||||
};
|
||||
} else if (selectedAddress.value) {
|
||||
geocode.value = await Api.getGeocode(selectedAddress.value);
|
||||
// geocode.value = await Api.getGeocode(selectedAddress.value);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching client data in Client.vue: ", error.message || error);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user