From 491a50a02766d833eec0b2cad8650ef495206a8e Mon Sep 17 00:00:00 2001 From: Anand Baburajan Date: Tue, 13 Jun 2023 19:42:56 +0530 Subject: [PATCH] fix: make showing taxes as table in print configurable (#35672) --- .../doctype/accounts_settings/accounts_settings.json | 9 ++++++++- erpnext/controllers/accounts_controller.py | 3 +++ erpnext/controllers/print_settings.py | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index c59d90dfab..09482d7d30 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -34,6 +34,7 @@ "book_tax_discount_loss", "print_settings", "show_inclusive_tax_in_print", + "show_taxes_as_table_in_print", "column_break_12", "show_payment_schedule_in_print", "currency_exchange_section", @@ -376,6 +377,12 @@ "fieldname": "auto_reconcile_payments", "fieldtype": "Check", "label": "Auto Reconcile Payments" + }, + { + "default": "0", + "fieldname": "show_taxes_as_table_in_print", + "fieldtype": "Check", + "label": "Show Taxes as Table in Print" } ], "icon": "icon-cog", @@ -383,7 +390,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-06-01 15:42:44.912316", + "modified": "2023-06-13 18:47:46.430291", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 2e290e30ca..c83e28d78f 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -917,6 +917,9 @@ class AccountsController(TransactionBase): return is_inclusive + def should_show_taxes_as_table_in_print(self): + return cint(frappe.db.get_single_value("Accounts Settings", "show_taxes_as_table_in_print")) + def validate_advance_entries(self): order_field = "sales_order" if self.doctype == "Sales Invoice" else "purchase_order" order_list = list(set(d.get(order_field) for d in self.get("items") if d.get(order_field))) diff --git a/erpnext/controllers/print_settings.py b/erpnext/controllers/print_settings.py index d2c80961a3..c951154a9e 100644 --- a/erpnext/controllers/print_settings.py +++ b/erpnext/controllers/print_settings.py @@ -30,10 +30,16 @@ def set_print_templates_for_taxes(doc, settings): doc.print_templates.update( { "total": "templates/print_formats/includes/total.html", - "taxes": "templates/print_formats/includes/taxes.html", } ) + if not doc.should_show_taxes_as_table_in_print(): + doc.print_templates.update( + { + "taxes": "templates/print_formats/includes/taxes.html", + } + ) + def format_columns(display_columns, compact_fields): compact_fields = compact_fields + ["image", "item_code", "item_name"]