fix: cannot save customer email & phone (#23797)

diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index 135e892..a690050 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -229,13 +229,31 @@
 		frappe.db.set_value('Customer', customer, 'loyalty_program', value)
 
 	contact = frappe.get_cached_value('Customer', customer, 'customer_primary_contact')
+	if not contact:
+		contact = frappe.db.sql("""
+			SELECT parent FROM `tabDynamic Link`
+			WHERE
+				parenttype = 'Contact' AND
+				parentfield = 'links' AND
+				link_doctype = 'Customer' AND
+				link_name = %s
+			""", (customer), as_dict=1)
+		contact = contact[0].get('parent') if contact else None
 
-	if contact:
-		contact_doc = frappe.get_doc('Contact', contact)
-		if fieldname == 'email_id':
-			contact_doc.set('email_ids', [{ 'email_id': value, 'is_primary': 1}])
-			frappe.db.set_value('Customer', customer, 'email_id', value)
-		elif fieldname == 'mobile_no':
-			contact_doc.set('phone_nos', [{ 'phone': value, 'is_primary_mobile_no': 1}])
-			frappe.db.set_value('Customer', customer, 'mobile_no', value)
-		contact_doc.save()
\ No newline at end of file
+	if not contact:
+		new_contact = frappe.new_doc('Contact')
+		new_contact.is_primary_contact = 1
+		new_contact.first_name = customer
+		new_contact.set('links', [{'link_doctype': 'Customer', 'link_name': customer}])
+		new_contact.save()
+		contact = new_contact.name
+		frappe.db.set_value('Customer', customer, 'customer_primary_contact', contact)
+
+	contact_doc = frappe.get_doc('Contact', contact)
+	if fieldname == 'email_id':
+		contact_doc.set('email_ids', [{ 'email_id': value, 'is_primary': 1}])
+		frappe.db.set_value('Customer', customer, 'email_id', value)
+	elif fieldname == 'mobile_no':
+		contact_doc.set('phone_nos', [{ 'phone': value, 'is_primary_mobile_no': 1}])
+		frappe.db.set_value('Customer', customer, 'mobile_no', value)
+	contact_doc.save()
\ No newline at end of file