fix: net_amount calculation (#44231)

fix: tax_item_rate calculation
This commit is contained in:
David Arnold
2024-11-23 23:10:33 +01:00
committed by GitHub
parent e9ea9ee57b
commit 2e04eeb661
13 changed files with 85 additions and 41 deletions

View File

@@ -961,6 +961,7 @@ class AccountsController(TransactionBase):
"account_head": account_head,
"rate": 0,
"description": account_head,
"set_by_item_tax_template": 1,
},
)
@@ -3176,10 +3177,11 @@ def set_child_tax_template_and_map(item, child_item, parent_doc):
)
child_item.item_tax_template = _get_item_tax_template(ctx, item.taxes)
if child_item.get("item_tax_template"):
child_item.item_tax_rate = get_item_tax_map(
parent_doc.get("company"), child_item.item_tax_template, as_json=True
)
child_item.item_tax_rate = get_item_tax_map(
doc=parent_doc,
tax_template=child_item.item_tax_template,
as_json=True,
)
def add_taxes_from_tax_template(child_item, parent_doc, db_insert=True):
@@ -3202,6 +3204,7 @@ def add_taxes_from_tax_template(child_item, parent_doc, db_insert=True):
"charge_type": "On Net Total",
"account_head": tax_type,
"rate": tax_rate,
"set_by_item_tax_template": 1,
}
)
if parent_doc.doctype == "Purchase Order":

View File

@@ -501,9 +501,7 @@ class calculate_taxes_and_totals:
)
elif tax.charge_type == "On Net Total":
if not item_tax_map:
current_net_amount = item.net_amount
elif tax.account_head in item_tax_map:
if tax.account_head in item_tax_map:
current_net_amount = item.net_amount
current_tax_amount = (tax_rate / 100.0) * item.net_amount
elif tax.charge_type == "On Previous Row Amount":

View File

@@ -79,7 +79,7 @@ class TestTaxesAndTotals(FrappeTestCase):
"rate": 50,
},
)
self.doc.set_missing_item_details()
calculate_taxes_and_totals(self.doc)
expected_values = {