Inconsistent behavior of get_itemised_tax function

Hi everyone. I’m not 100% sure whether the following has already been reported, so it might be worth opening an issue on GitHub — but I’d like to confirm here first.

The get_itemised_tax function returns the taxes applied to each item in a Sales Invoice. It is defined in erpnext/controllers/taxes_and_totals.py and is used to display the tax breakdown per item in the “Tax Breakup” section.

Simply put, the function associates each invoice item with the taxes applied to it, based on the “Sales Taxes and Charges” table.

To distinguish between taxes, the function uses the description field, as seen in the line:

itemised_tax[item_code][tax.description].tax_account = tax.account_head

The inconsistency appears when two taxes with the same description are applied to the same invoice. The Grand Total will correctly reflect the total amount from all tax rows, regardless of their description. However, in the Tax Breakup, only one of the tax rows with the same description will prevail — the others will be overwritten.