fix: fix to fetch customers and billing email in PSOA (#27363)

(cherry picked from commit a58e309297)

# Conflicts:
#	erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json
#	erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
This commit is contained in:
Anuja Pawar
2021-09-09 19:37:52 +05:30
committed by Mergify
parent f5160dc83d
commit 3918951cb1
2 changed files with 25 additions and 0 deletions

View File

@@ -294,10 +294,15 @@
} }
], ],
"links": [], "links": [],
<<<<<<< HEAD
"modified": "2022-10-17 17:47:08.662475", "modified": "2022-10-17 17:47:08.662475",
=======
"modified": "2021-09-06 21:00:45.732505",
>>>>>>> a58e309297 (fix: fix to fetch customers and billing email in PSOA (#27363))
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Process Statement Of Accounts", "name": "Process Statement Of Accounts",
"naming_rule": "Set by user",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {

View File

@@ -241,8 +241,15 @@ def fetch_customers(customer_collection, collection_name, primary_mandatory):
billing_email = get_customer_emails(customer.name, 1, billing_and_primary=False) billing_email = get_customer_emails(customer.name, 1, billing_and_primary=False)
if int(primary_mandatory): if int(primary_mandatory):
<<<<<<< HEAD
if primary_email == "": if primary_email == "":
continue continue
=======
if (primary_email == ''):
continue
elif (billing_email == '') and (primary_email == ''):
continue
>>>>>>> a58e309297 (fix: fix to fetch customers and billing email in PSOA (#27363))
customer_list.append( customer_list.append(
{ {
@@ -257,12 +264,20 @@ def fetch_customers(customer_collection, collection_name, primary_mandatory):
@frappe.whitelist() @frappe.whitelist()
def get_customer_emails(customer_name, primary_mandatory, billing_and_primary=True): def get_customer_emails(customer_name, primary_mandatory, billing_and_primary=True):
<<<<<<< HEAD
"""Returns first email from Contact Email table as a Billing email """Returns first email from Contact Email table as a Billing email
when Is Billing Contact checked when Is Billing Contact checked
and Primary email- email with Is Primary checked""" and Primary email- email with Is Primary checked"""
billing_email = frappe.db.sql( billing_email = frappe.db.sql(
""" """
=======
""" Returns first email from Contact Email table as a Billing email
when Is Billing Contact checked
and Primary email- email with Is Primary checked """
billing_email = frappe.db.sql("""
>>>>>>> a58e309297 (fix: fix to fetch customers and billing email in PSOA (#27363))
SELECT SELECT
email.email_id email.email_id
FROM FROM
@@ -279,6 +294,7 @@ def get_customer_emails(customer_name, primary_mandatory, billing_and_primary=Tr
link.link_doctype='Customer' link.link_doctype='Customer'
and link.link_name=%s and link.link_name=%s
and contact.is_billing_contact=1 and contact.is_billing_contact=1
<<<<<<< HEAD
{mcond} {mcond}
ORDER BY ORDER BY
contact.creation desc contact.creation desc
@@ -287,6 +303,10 @@ def get_customer_emails(customer_name, primary_mandatory, billing_and_primary=Tr
), ),
customer_name, customer_name,
) )
=======
ORDER BY
contact.creation desc""", customer_name)
>>>>>>> a58e309297 (fix: fix to fetch customers and billing email in PSOA (#27363))
if len(billing_email) == 0 or (billing_email[0][0] is None): if len(billing_email) == 0 or (billing_email[0][0] is None):
if billing_and_primary: if billing_and_primary: