diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json
index 45373741f39..e711ae0de2b 100644
--- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json
+++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json
@@ -49,6 +49,7 @@
"column_break_21",
"start_date",
"section_break_33",
+ "pdf_name",
"subject",
"column_break_28",
"cc_to",
@@ -273,7 +274,7 @@
"fieldname": "help_text",
"fieldtype": "HTML",
"label": "Help Text",
- "options": "
\n
Note
\n\n- \nYou can use Jinja tags in Subject and Body fields for dynamic values.\n
- \n All fields in this doctype are available under the doc object and all fields for the customer to whom the mail will go to is available under the customer object.\n
\n Examples
\n\n\n - Subject:
Statement Of Accounts for {{ customer.name }}
\n - Body:
\nHello {{ customer.name }},
PFA your Statement Of Accounts from {{ doc.from_date }} to {{ doc.to_date }}.
\n
\n"
+ "options": "
\nNote
\n\n- \nYou can use Jinja tags in Subject and Body fields for dynamic values.\n
- \n All fields in this doctype are available under the doc object and all fields for the customer to whom the mail will go to is available under the customer object.\n
\n Examples
\n\n\n - Subject:
Statement Of Accounts for {{ customer.customer_name }}
\n - Body:
\nHello {{ customer.customer_name }},
PFA your Statement Of Accounts from {{ doc.from_date }} to {{ doc.to_date }}.
\n
\n"
},
{
"fieldname": "subject",
@@ -368,10 +369,15 @@
"fieldname": "based_on_payment_terms",
"fieldtype": "Check",
"label": "Based On Payment Terms"
+ },
+ {
+ "fieldname": "pdf_name",
+ "fieldtype": "Data",
+ "label": "PDF Name"
}
],
"links": [],
- "modified": "2023-06-23 10:13:15.051950",
+ "modified": "2023-08-28 12:59:53.071334",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Process Statement Of Accounts",
diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
index 6cd601f663d..b9ea2142958 100644
--- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
+++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
@@ -26,7 +26,13 @@ class ProcessStatementOfAccounts(Document):
if not self.subject:
self.subject = "Statement Of Accounts for {{ customer.customer_name }}"
if not self.body:
- self.body = "Hello {{ customer.name }},
PFA your Statement Of Accounts from {{ doc.from_date }} to {{ doc.to_date }}."
+ if self.report == "General Ledger":
+ body_str = " from {{ doc.from_date }} to {{ doc.to_date }}."
+ else:
+ body_str = " until {{ doc.posting_date }}."
+ self.body = "Hello {{ customer.customer_name }},
PFA your Statement Of Accounts" + body_str
+ if not self.pdf_name:
+ self.pdf_name = "{{ customer.customer_name }}"
validate_template(self.subject)
validate_template(self.body)
@@ -139,6 +145,7 @@ def get_ar_filters(doc, entry):
return {
"report_date": doc.posting_date if doc.posting_date else None,
"customer": entry.customer,
+ "customer_name": entry.customer_name if entry.customer_name else None,
"payment_terms_template": doc.payment_terms_template if doc.payment_terms_template else None,
"sales_partner": doc.sales_partner if doc.sales_partner else None,
"sales_person": doc.sales_person if doc.sales_person else None,
@@ -368,10 +375,18 @@ def send_emails(document_name, from_scheduler=False):
if report:
for customer, report_pdf in report.items():
- attachments = [{"fname": customer + ".pdf", "fcontent": report_pdf}]
+ context = get_context(customer, doc)
+ filename = frappe.render_template(doc.pdf_name, context)
+ attachments = [{"fname": filename + ".pdf", "fcontent": report_pdf}]
recipients, cc = get_recipients_and_cc(customer, doc)
+<<<<<<< HEAD
context = get_context(customer, doc)
+=======
+ if not recipients:
+ continue
+
+>>>>>>> 5c2a949593 (feat: add field for specifying pdf name)
subject = frappe.render_template(doc.subject, context)
message = frappe.render_template(doc.body, context)