Skip to content

Commit

Permalink
[FIX] account_financial_report: take multiple account tags per tax in…
Browse files Browse the repository at this point in the history
…to account

- When there are multiple repartition lines having different tax tags the VAT report
  will take all the tax lines for all tags into consideration leading to wrong
  results (e.g.: l10n_at.account_tax_template_sales_rev_charge_0_code021_1e)
- This patch will fix this by only using the balance of account move lines for
  the linked tax tags.
- As this change leads to the account move line balance being only taken into
  account for the tags being explicitly set in the repartition line the net
  sum will not be affected when the tag is not associated to the base repartition
  line (leading to changes in the expected behaviour in test_01_compute).
  • Loading branch information
dhx committed Jan 5, 2025
1 parent 8e6d9de commit 518f420
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
4 changes: 0 additions & 4 deletions account_financial_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ you can set default interval configuration per company in:
Known issues / Roadmap
======================

* 'VAT Report' is valid only for cases where it's met that for each
Tax defined: all the "Account tags" of all the
'Repartition for Invoices' or 'Repartition for Credit Notes'
are different.
* It would be nice to have in reports a column indicating the
state of the entries when the option "All Entries" is selected
in "Target Moves" field in a wizard
Expand Down
4 changes: 0 additions & 4 deletions account_financial_report/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
* 'VAT Report' is valid only for cases where it's met that for each
Tax defined: all the "Account tags" of all the
'Repartition for Invoices' or 'Repartition for Credit Notes'
are different.
* It would be nice to have in reports a column indicating the
state of the entries when the option "All Entries" is selected
in "Target Moves" field in a wizard
8 changes: 5 additions & 3 deletions account_financial_report/report/vat_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _get_vat_report_data(self, company_id, date_from, date_to, only_posted_moves
"net": 0.0,
"tax": tax_move_line["balance"],
"tax_line_id": tax_move_line["tax_line_id"][0],
"tax_tag_ids": tax_move_line["tax_tag_ids"],
}
)
for taxed_move_line in taxed_move_lines:
Expand All @@ -89,6 +90,7 @@ def _get_vat_report_data(self, company_id, date_from, date_to, only_posted_moves
"net": taxed_move_line["balance"],
"tax": 0.0,
"tax_line_id": tax_id,
"tax_tag_ids": taxed_move_line["tax_tag_ids"],
}
)
tax_ids = list(map(operator.itemgetter("tax_line_id"), vat_data))
Expand Down Expand Up @@ -161,12 +163,11 @@ def _get_vat_report_tag_data(self, vat_report_data, tax_data, tax_detail):
vat_report = {}
for tax_move_line in vat_report_data:
tax_id = tax_move_line["tax_line_id"]
tags_ids = tax_data[tax_id]["tags_ids"]
if tax_data[tax_id]["amount_type"] == "group":
continue
else:
if tags_ids:
for tag_id in tags_ids:
if tax_move_line["tax_tag_ids"]:
for tag_id in tax_move_line["tax_tag_ids"]:
if tag_id not in vat_report.keys():
vat_report[tag_id] = {}
vat_report[tag_id]["net"] = 0.0
Expand Down Expand Up @@ -240,4 +241,5 @@ def _get_ml_fields_vat_report(self):
"balance",
"tax_line_id",
"tax_ids",
"tax_tag_ids",
]
10 changes: 5 additions & 5 deletions account_financial_report/tests/test_vat_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,15 @@ def test_01_compute(self):
tax_10_net, tax_10_tax = self._get_tax_line(self.tax_10.name, vat_report)
tax_20_net, tax_20_tax = self._get_tax_line(self.tax_20.name, vat_report)

self.assertEqual(tag_01_net, -100)
self.assertEqual(tag_01_net, 0)
self.assertEqual(tag_01_tax, -10)
self.assertEqual(tag_02_net, -350)
self.assertEqual(tag_02_net, 0)
self.assertEqual(tag_02_tax, -60)
self.assertEqual(tag_03_net, -250)
self.assertEqual(tag_03_net, 0)
self.assertEqual(tag_03_tax, -50)
self.assertEqual(tax_10_net, -100)
self.assertEqual(tax_10_net, 0)
self.assertEqual(tax_10_tax, -10)
self.assertEqual(tax_20_net, -250)
self.assertEqual(tax_20_net, 0)
self.assertEqual(tax_20_tax, -50)

# Check report based on taxgroups
Expand Down

0 comments on commit 518f420

Please sign in to comment.