fix: update round off account functions to accept document context for regional overrides (backport #55758) (#55771)

Co-authored-by: Lakshit Jain <ljain112@gmail.com>
fix: update round off account functions to accept document context for regional overrides (#55758)
This commit is contained in:
mergify[bot]
2026-06-22 12:30:09 +00:00
committed by GitHub
parent b4f2b6cab2
commit f5d05b969b
3 changed files with 34 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
from unittest.mock import patch
import frappe
from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
@@ -6,6 +8,28 @@ from erpnext.tests.utils import ERPNextTestSuite
class TestTaxesAndTotals(ERPNextTestSuite):
def test_regional_round_off_accounts(self):
"""
Regional overrides cannot extend the list in-place — the return
value must be assigned back to frappe.flags.round_off_applicable_accounts.
"""
test_account = "_Test Round Off Account"
def mock_regional(company, account_list: list, doc=None) -> list:
# Simulates a regional override
account_list.extend([test_account])
return account_list
so = make_sales_order(do_not_save=True)
with patch(
"erpnext.controllers.taxes_and_totals.get_regional_round_off_accounts",
mock_regional,
):
calculate_taxes_and_totals(so)
self.assertIn(test_account, frappe.flags.round_off_applicable_accounts)
def test_disabling_rounded_total_resets_base_fields(self):
"""Disabling rounded total should also clear base rounded values."""
so = make_sales_order(do_not_save=True)