From 3ead28906cb849d50b53e2402704121acdfb5b9d Mon Sep 17 00:00:00 2001 From: Dany Robert Date: Tue, 22 Aug 2023 14:41:07 +0000 Subject: [PATCH] feat: item(row) wise tax amount rounding --- .../doctype/accounts_settings/accounts_settings.json | 10 +++++----- .../accounts/doctype/payment_entry/payment_entry.py | 5 +++++ erpnext/controllers/taxes_and_totals.py | 5 +++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 6857ba343e..570be095ab 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -32,6 +32,7 @@ "column_break_19", "add_taxes_from_item_tax_template", "book_tax_discount_loss", + "round_row_wise_tax", "print_settings", "show_inclusive_tax_in_print", "show_taxes_as_table_in_print", @@ -58,7 +59,6 @@ "closing_settings_tab", "period_closing_settings_section", "acc_frozen_upto", - "ignore_account_closing_balance", "column_break_25", "frozen_accounts_modifier", "tab_break_dpet", @@ -410,10 +410,10 @@ }, { "default": "0", - "description": "Financial reports will be generated using GL Entry doctypes (should be enabled if Period Closing Voucher is not posted for all years sequentially or missing) ", - "fieldname": "ignore_account_closing_balance", + "description": "Tax Amount will be rounded on a row(items) level", + "fieldname": "round_row_wise_tax", "fieldtype": "Check", - "label": "Ignore Account Closing Balance" + "label": "Round Tax Amount Row-wise" } ], "icon": "icon-cog", @@ -421,7 +421,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-07-27 15:05:34.000264", + "modified": "2023-08-22 20:11:00.042840", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index ac31e8a1db..39ee497fda 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1387,6 +1387,9 @@ class PaymentEntry(AccountsController): def calculate_taxes(self): self.total_taxes_and_charges = 0.0 self.base_total_taxes_and_charges = 0.0 + frappe.flags.round_row_wise_tax = ( + frappe.db.get_single_value("Accounts Settings", "round_row_wise_tax") + ) actual_tax_dict = dict( [ @@ -1398,6 +1401,8 @@ class PaymentEntry(AccountsController): for i, tax in enumerate(self.get("taxes")): current_tax_amount = self.get_current_tax_amount(tax) + if frappe.flags.round_row_wise_tax: + current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount")) if tax.charge_type == "Actual": actual_tax_dict[tax.idx] -= current_tax_amount diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 62d4c53868..1cf1788f43 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -25,6 +25,9 @@ class calculate_taxes_and_totals(object): def __init__(self, doc: Document): self.doc = doc frappe.flags.round_off_applicable_accounts = [] + frappe.flags.round_row_wise_tax = ( + frappe.db.get_single_value("Accounts Settings", "round_row_wise_tax") + ) self._items = self.filter_rows() if self.doc.doctype == "Quotation" else self.doc.get("items") @@ -368,6 +371,8 @@ class calculate_taxes_and_totals(object): for i, tax in enumerate(self.doc.get("taxes")): # tax_amount represents the amount of tax for the current step current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map) + if frappe.flags.round_row_wise_tax: + current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount")) # Adjust divisional loss to the last item if tax.charge_type == "Actual":