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