mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 16:08:39 +00:00
fix: update round off account functions to accept document context for regional overrides (#55758)
This commit is contained in:
@@ -32,7 +32,7 @@ class calculate_taxes_and_totals:
|
||||
def __init__(self, doc: Document):
|
||||
self.doc = doc
|
||||
frappe.flags.round_off_applicable_accounts = (
|
||||
get_round_off_applicable_accounts(self.doc.company, []) or []
|
||||
get_round_off_applicable_accounts(self.doc.company, [], self.doc) or []
|
||||
)
|
||||
frappe.flags.round_row_wise_tax = frappe.get_single_value("Accounts Settings", "round_row_wise_tax")
|
||||
|
||||
@@ -1240,14 +1240,16 @@ def get_itemised_tax_breakup_html(doc):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_round_off_applicable_accounts(company: str, account_list: list | str):
|
||||
def get_round_off_applicable_accounts(
|
||||
company: str, account_list: list | str, doc: str | dict | Document | None = None
|
||||
):
|
||||
# required to set correct region
|
||||
with temporary_flag("company", company):
|
||||
return get_regional_round_off_accounts(company, account_list)
|
||||
return get_regional_round_off_accounts(company, account_list, doc)
|
||||
|
||||
|
||||
@erpnext.allow_regional
|
||||
def get_regional_round_off_accounts(company, account_list):
|
||||
def get_regional_round_off_accounts(company, account_list, doc=None):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class TestTaxesAndTotals(ERPNextTestSuite):
|
||||
"""
|
||||
test_account = "_Test Round Off Account"
|
||||
|
||||
def mock_regional(company, account_list: list) -> list:
|
||||
def mock_regional(company, account_list: list, doc=None) -> list:
|
||||
# Simulates a regional override
|
||||
account_list.extend([test_account])
|
||||
return account_list
|
||||
|
||||
@@ -231,6 +231,8 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
args: {
|
||||
company: me.frm.doc.company,
|
||||
account_list: frappe.flags.round_off_applicable_accounts,
|
||||
// pass the doc so regional overrides can inspect it
|
||||
doc: me.frm.doc,
|
||||
},
|
||||
callback(r) {
|
||||
if (r.message) {
|
||||
|
||||
Reference in New Issue
Block a user