Merge pull request #36235 from resilient-tech/fix-tax-breakup-for-diff-tax-rates
fix: Correct Tax Breakup for different tax rates for same hsn code
This commit is contained in:
commit
30554301c9
@ -1900,16 +1900,22 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
si = self.create_si_to_test_tax_breakup()
|
||||
|
||||
itemised_tax, itemised_taxable_amount = get_itemised_tax_breakup_data(si)
|
||||
itemised_tax_data = get_itemised_tax_breakup_data(si)
|
||||
|
||||
expected_itemised_tax = {
|
||||
"_Test Item": {"Service Tax": {"tax_rate": 10.0, "tax_amount": 1000.0}},
|
||||
"_Test Item 2": {"Service Tax": {"tax_rate": 10.0, "tax_amount": 500.0}},
|
||||
}
|
||||
expected_itemised_taxable_amount = {"_Test Item": 10000.0, "_Test Item 2": 5000.0}
|
||||
expected_itemised_tax = [
|
||||
{
|
||||
"item": "_Test Item",
|
||||
"taxable_amount": 10000.0,
|
||||
"Service Tax": {"tax_rate": 10.0, "tax_amount": 1000.0},
|
||||
},
|
||||
{
|
||||
"item": "_Test Item 2",
|
||||
"taxable_amount": 5000.0,
|
||||
"Service Tax": {"tax_rate": 10.0, "tax_amount": 500.0},
|
||||
},
|
||||
]
|
||||
|
||||
self.assertEqual(itemised_tax, expected_itemised_tax)
|
||||
self.assertEqual(itemised_taxable_amount, expected_itemised_taxable_amount)
|
||||
self.assertEqual(itemised_tax_data, expected_itemised_tax)
|
||||
|
||||
frappe.flags.country = None
|
||||
|
||||
|
@ -954,16 +954,15 @@ def get_itemised_tax_breakup_html(doc):
|
||||
|
||||
with temporary_flag("company", doc.company):
|
||||
headers = get_itemised_tax_breakup_header(doc.doctype + " Item", tax_accounts)
|
||||
itemised_tax, itemised_taxable_amount = get_itemised_tax_breakup_data(doc)
|
||||
get_rounded_tax_amount(itemised_tax, doc.precision("tax_amount", "taxes"))
|
||||
itemised_tax_data = get_itemised_tax_breakup_data(doc)
|
||||
get_rounded_tax_amount(itemised_tax_data, doc.precision("tax_amount", "taxes"))
|
||||
update_itemised_tax_data(doc)
|
||||
|
||||
return frappe.render_template(
|
||||
"templates/includes/itemised_tax_breakup.html",
|
||||
dict(
|
||||
headers=headers,
|
||||
itemised_tax=itemised_tax,
|
||||
itemised_taxable_amount=itemised_taxable_amount,
|
||||
itemised_tax_data=itemised_tax_data,
|
||||
tax_accounts=tax_accounts,
|
||||
doc=doc,
|
||||
),
|
||||
@ -999,7 +998,15 @@ def get_itemised_tax_breakup_data(doc):
|
||||
|
||||
itemised_taxable_amount = get_itemised_taxable_amount(doc.items)
|
||||
|
||||
return itemised_tax, itemised_taxable_amount
|
||||
itemised_tax_data = []
|
||||
for item_code, taxes in itemised_tax.items():
|
||||
itemised_tax_data.append(
|
||||
frappe._dict(
|
||||
{"item": item_code, "taxable_amount": itemised_taxable_amount.get(item_code), **taxes}
|
||||
)
|
||||
)
|
||||
|
||||
return itemised_tax_data
|
||||
|
||||
|
||||
def get_itemised_tax(taxes, with_tax_account=False):
|
||||
@ -1044,9 +1051,10 @@ def get_itemised_taxable_amount(items):
|
||||
|
||||
def get_rounded_tax_amount(itemised_tax, precision):
|
||||
# Rounding based on tax_amount precision
|
||||
for taxes in itemised_tax.values():
|
||||
for tax_account in taxes:
|
||||
taxes[tax_account]["tax_amount"] = flt(taxes[tax_account]["tax_amount"], precision)
|
||||
for taxes in itemised_tax:
|
||||
for row in taxes.values():
|
||||
if isinstance(row, dict) and isinstance(row["tax_amount"], float):
|
||||
row["tax_amount"] = flt(row["tax_amount"], precision)
|
||||
|
||||
|
||||
class init_landed_taxes_and_totals(object):
|
||||
|
@ -12,14 +12,14 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item, taxes in itemised_tax.items() %}
|
||||
{% for taxes in itemised_tax_data %}
|
||||
<tr>
|
||||
<td>{{ item }}</td>
|
||||
<td>{{ taxes.item }}</td>
|
||||
<td class="text-right">
|
||||
{% if doc.get('is_return') %}
|
||||
{{ frappe.utils.fmt_money((itemised_taxable_amount.get(item, 0))|abs, None, doc.currency) }}
|
||||
{{ frappe.utils.fmt_money(taxes.taxable_amount |abs, None, doc.currency) }}
|
||||
{% else %}
|
||||
{{ frappe.utils.fmt_money(itemised_taxable_amount.get(item, 0), None, doc.currency) }}
|
||||
{{ frappe.utils.fmt_money(taxes.taxable_amount, None, doc.currency) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% for tax_account in tax_accounts %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user