feat(accounts): enable print format selection in Process Statement of Accounts

This commit is contained in:
diptanilsaha
2025-09-17 11:18:58 +05:30
parent f1eda7c4ec
commit 2e7c3207c4
3 changed files with 38 additions and 1 deletions

View File

@@ -83,6 +83,16 @@ frappe.ui.form.on("Process Statement Of Accounts", {
},
};
});
frm.set_query("print_format", function () {
return {
filters: {
print_format_for: "Report",
report: frm.doc.report,
disabled: 0,
print_format_type: "Jinja",
},
};
});
if (frm.doc.__islocal) {
frm.set_value("from_date", frappe.datetime.add_months(frappe.datetime.get_today(), -1));
frm.set_value("to_date", frappe.datetime.get_today());
@@ -106,6 +116,16 @@ frappe.ui.form.on("Process Statement Of Accounts", {
filters: filters,
};
});
frm.set_query("print_format", function () {
return {
filters: {
print_format_for: "Report",
report: frm.doc.report,
disabled: 0,
print_format_type: "Jinja",
},
};
});
},
customer_collection: function (frm) {
frm.set_value("collection_name", "");

View File

@@ -38,6 +38,7 @@
"column_break_17",
"customers",
"preferences",
"print_format",
"orientation",
"include_break",
"include_ageing",
@@ -406,10 +407,16 @@
"fieldname": "show_future_payments",
"fieldtype": "Check",
"label": "Show Future Payments"
},
{
"fieldname": "print_format",
"fieldtype": "Link",
"label": "Print Format",
"options": "Print Format"
}
],
"links": [],
"modified": "2025-08-29 00:20:08.088189",
"modified": "2025-09-03 14:24:43.608565",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Process Statement Of Accounts",

View File

@@ -67,6 +67,7 @@ class ProcessStatementOfAccounts(Document):
pdf_name: DF.Data | None
posting_date: DF.Date | None
primary_mandatory: DF.Check
print_format: DF.Link | None
project: DF.TableMultiSelect[PSOAProject]
report: DF.Literal["General Ledger", "Accounts Receivable"]
sales_partner: DF.Link | None
@@ -109,6 +110,11 @@ class ProcessStatementOfAccounts(Document):
self.to_date = self.start_date
self.from_date = add_months(self.to_date, -1 * self.filter_duration)
if self.print_format:
print_format_type = frappe.db.get_value("Print Format", self.print_format, "print_format_type")
if print_format_type != "Jinja":
frappe.throw(title=_("Invalid Print Format"), msg=_("Print Format Type should be Jinja."))
def validate_account(self):
if not self.account:
return
@@ -290,6 +296,10 @@ def get_html(doc, filters, entry, col, res, ageing):
if process_soa_html and process_soa_html.get(doc.report):
template_path = process_soa_html[doc.report][-1]
if doc.print_format:
custom_html, custom_css = frappe.db.get_value("Print Format", doc.print_format, ["html", "css"])
template_path = f"<style>{custom_css}</style> {custom_html}"
if doc.letter_head:
from frappe.www.printview import get_letter_head