mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 20:35:09 +00:00
Merge pull request #49584 from diptanilsaha/custom-print-format-psoa
feat(accounts): enable print format selection in Process Statement of Accounts
This commit is contained in:
@@ -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", "");
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,25 @@ 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:
|
||||
pf = frappe.db.get_value(
|
||||
"Print Format",
|
||||
self.print_format,
|
||||
["print_format_type", "print_format_for", "report", "disabled"],
|
||||
as_dict=True,
|
||||
)
|
||||
if not pf:
|
||||
frappe.throw(title=_("Invalid Print Format"), msg=_("Selected Print Format does not exist."))
|
||||
if pf.print_format_type != "Jinja":
|
||||
frappe.throw(title=_("Invalid Print Format"), msg=_("Print Format Type should be Jinja."))
|
||||
if pf.print_format_for != "Report" or pf.report != self.report or pf.disabled:
|
||||
frappe.throw(
|
||||
title=_("Invalid Print Format"),
|
||||
msg=_(
|
||||
"Print Format must be an enabled Report Print Format matching the selected Report."
|
||||
),
|
||||
)
|
||||
|
||||
def validate_account(self):
|
||||
if not self.account:
|
||||
return
|
||||
@@ -290,6 +310,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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user