Fixed merge conflict.
This commit is contained in:
parent
c35689aaf8
commit
3fa8b1ce99
@ -132,6 +132,7 @@ def get_client(client_name):
|
||||
except Exception as e:
|
||||
return build_error_response(str(e), 500)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_clients_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||
"""Get paginated client table data with filtering and sorting support."""
|
||||
@ -202,6 +203,10 @@ def get_clients_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||
def upsert_client(data):
|
||||
"""Create or update a client (customer and address)."""
|
||||
try:
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> 8f44d90 (Fixed an API error when searching for a non existent client name.)
|
||||
data = json.loads(data)
|
||||
|
||||
# Handle customer creation/update
|
||||
@ -216,6 +221,7 @@ def upsert_client(data):
|
||||
}).insert(ignore_permissions=True)
|
||||
else:
|
||||
customer_doc = frappe.get_doc("Customer", data.get("customer_name"))
|
||||
<<<<<<< HEAD
|
||||
print("Customer:", customer_doc.as_dict())
|
||||
|
||||
# Handle address creation
|
||||
@ -230,6 +236,23 @@ def upsert_client(data):
|
||||
print("Existing address check:", existing_address)
|
||||
if existing_address:
|
||||
frappe.throw(f"Address already exists for customer {data.get('customer_name')}.", frappe.ValidationError)
|
||||
=======
|
||||
|
||||
print("Customer:", customer_doc.as_dict())
|
||||
|
||||
# Check for existing address
|
||||
filters = {
|
||||
"address_line1": data.get("address_line1"),
|
||||
"city": data.get("city"),
|
||||
"state": data.get("state"),
|
||||
}
|
||||
existing_address = frappe.db.exists("Address", filters)
|
||||
print("Existing address check:", existing_address)
|
||||
if existing_address:
|
||||
frappe.throw(f"Address already exists for customer {data.get('customer_name')}.", frappe.ValidationError)
|
||||
|
||||
# Create address
|
||||
>>>>>>> 8f44d90 (Fixed an API error when searching for a non existent client name.)
|
||||
address_doc = frappe.get_doc({
|
||||
"doctype": "Address",
|
||||
"address_title": data.get("address_title"),
|
||||
@ -241,6 +264,7 @@ def upsert_client(data):
|
||||
"pincode": data.get("pincode"),
|
||||
"custom_customer_to_bill": customer_doc.name
|
||||
}).insert(ignore_permissions=True)
|
||||
<<<<<<< HEAD
|
||||
print("Address:", address_doc.as_dict())
|
||||
|
||||
#Handle contact creation
|
||||
@ -296,6 +320,11 @@ def upsert_client(data):
|
||||
# Address -> Customer
|
||||
print("#####DEBUG: Linking address to customer.")
|
||||
address_doc.append("links", {
|
||||
=======
|
||||
|
||||
# Link address to customer
|
||||
link = {
|
||||
>>>>>>> 8f44d90 (Fixed an API error when searching for a non existent client name.)
|
||||
"link_doctype": "Customer",
|
||||
"link_name": customer_doc.name
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user