refactor: separate function for statement dict

(cherry picked from commit 67f878ff8c)

# Conflicts:
#	erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
This commit is contained in:
Gursheen Anand
2023-09-29 14:34:43 +05:30
committed by Mergify
parent 15d2024b8e
commit c29eab12df

View File

@@ -47,6 +47,20 @@ class ProcessStatementOfAccounts(Document):
def get_report_pdf(doc, consolidated=True):
statement_dict = get_statement_dict(doc)
if not bool(statement_dict):
return False
elif consolidated:
delimiter = '<div style="page-break-before: always;"></div>' if doc.include_break else ""
result = delimiter.join(list(statement_dict.values()))
return get_pdf(result, {"orientation": doc.orientation})
else:
for customer, statement_html in statement_dict.items():
statement_dict[customer] = get_pdf(statement_html, {"orientation": doc.orientation})
return statement_dict
def get_statement_dict(doc, get_statement_dict=False):
statement_dict = {}
ageing = ""
@@ -77,8 +91,11 @@ def get_report_pdf(doc, consolidated=True):
if not res:
continue
statement_dict[entry.customer] = get_html(doc, filters, entry, col, res, ageing)
statement_dict[entry.customer] = (
[res, ageing] if get_statement_dict else get_html(doc, filters, entry, col, res, ageing)
)
<<<<<<< HEAD
if not bool(statement_dict):
return False
elif consolidated:
@@ -88,6 +105,9 @@ def get_report_pdf(doc, consolidated=True):
for customer, statement_html in statement_dict.items():
statement_dict[customer] = get_pdf(statement_html, {"orientation": doc.orientation})
return statement_dict
=======
return statement_dict
>>>>>>> 67f878ff8c (refactor: separate function for statement dict)
def set_ageing(doc, entry):
@@ -101,7 +121,7 @@ def set_ageing(doc, entry):
"range3": 90,
"range4": 120,
"party_type": "Customer",
"party": entry.customer,
"party": [entry.customer],
}
)
col1, ageing = get_ageing(ageing_filters)