mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 16:38:41 +00:00
fix: update round off account functions to accept document context for regional overrides (#55758)
(cherry picked from commit 08129ff71c)
# Conflicts:
# erpnext/controllers/taxes_and_totals.py
# erpnext/controllers/tests/test_taxes_and_totals.py
# erpnext/public/js/controllers/taxes_and_totals.js
This commit is contained in:
@@ -26,9 +26,14 @@ from erpnext.utilities.regional import temporary_flag
|
|||||||
class calculate_taxes_and_totals:
|
class calculate_taxes_and_totals:
|
||||||
def __init__(self, doc: Document):
|
def __init__(self, doc: Document):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
|
<<<<<<< HEAD
|
||||||
frappe.flags.round_off_applicable_accounts = []
|
frappe.flags.round_off_applicable_accounts = []
|
||||||
frappe.flags.round_row_wise_tax = frappe.db.get_single_value(
|
frappe.flags.round_row_wise_tax = frappe.db.get_single_value(
|
||||||
"Accounts Settings", "round_row_wise_tax"
|
"Accounts Settings", "round_row_wise_tax"
|
||||||
|
=======
|
||||||
|
frappe.flags.round_off_applicable_accounts = (
|
||||||
|
get_round_off_applicable_accounts(self.doc.company, [], self.doc) or []
|
||||||
|
>>>>>>> 08129ff71c (fix: update round off account functions to accept document context for regional overrides (#55758))
|
||||||
)
|
)
|
||||||
|
|
||||||
if doc.get("round_off_applicable_accounts_for_tax_withholding"):
|
if doc.get("round_off_applicable_accounts_for_tax_withholding"):
|
||||||
@@ -1128,14 +1133,20 @@ def get_itemised_tax_breakup_html(doc):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
<<<<<<< HEAD
|
||||||
def get_round_off_applicable_accounts(company, account_list):
|
def get_round_off_applicable_accounts(company, account_list):
|
||||||
|
=======
|
||||||
|
def get_round_off_applicable_accounts(
|
||||||
|
company: str, account_list: list | str, doc: str | dict | Document | None = None
|
||||||
|
):
|
||||||
|
>>>>>>> 08129ff71c (fix: update round off account functions to accept document context for regional overrides (#55758))
|
||||||
# required to set correct region
|
# required to set correct region
|
||||||
with temporary_flag("company", company):
|
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
|
@erpnext.allow_regional
|
||||||
def get_regional_round_off_accounts(company, account_list):
|
def get_regional_round_off_accounts(company, account_list, doc=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,33 @@ from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
|
|||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
class TestTaxesAndTotals(FrappeTestCase):
|
class TestTaxesAndTotals(FrappeTestCase):
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
|
||||||
|
>>>>>>> 08129ff71c (fix: update round off account functions to accept document context for regional overrides (#55758))
|
||||||
def test_disabling_rounded_total_resets_base_fields(self):
|
def test_disabling_rounded_total_resets_base_fields(self):
|
||||||
"""Disabling rounded total should also clear base rounded values."""
|
"""Disabling rounded total should also clear base rounded values."""
|
||||||
so = make_sales_order(do_not_save=True)
|
so = make_sales_order(do_not_save=True)
|
||||||
|
|||||||
@@ -204,10 +204,19 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
|
|
||||||
if (me.frm.doc.company) {
|
if (me.frm.doc.company) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
|
<<<<<<< HEAD
|
||||||
"method": "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts",
|
"method": "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts",
|
||||||
"args": {
|
"args": {
|
||||||
"company": me.frm.doc.company,
|
"company": me.frm.doc.company,
|
||||||
"account_list": frappe.flags.round_off_applicable_accounts
|
"account_list": frappe.flags.round_off_applicable_accounts
|
||||||
|
=======
|
||||||
|
method: "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts",
|
||||||
|
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,
|
||||||
|
>>>>>>> 08129ff71c (fix: update round off account functions to accept document context for regional overrides (#55758))
|
||||||
},
|
},
|
||||||
callback(r) {
|
callback(r) {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
|
|||||||
Reference in New Issue
Block a user