Skip to content

Commit

Permalink
FIX VAT registries and VAT statement when invoices with negative lines (
Browse files Browse the repository at this point in the history
OCA#452)

Bug solved:
 - Create an invoice with a positive line and a negative line
 - Print VAT register
Get wrong totals
  • Loading branch information
eLBati authored and TonyMasciI committed Jan 16, 2023
1 parent d8afbc2 commit e072e13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion l10n_it_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
'name': 'Italian Localization - Account',
'version': '10.0.1.1.1',
'version': '10.0.1.1.2',
'category': 'Hidden',
'author': "Agile Business Group,Abstract,Odoo Community Association (OCA)",
'website': 'http://www.odoo-italia.net',
Expand Down
19 changes: 14 additions & 5 deletions l10n_it_account/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@ def _compute_totals_tax(self, data):
'from_date': data['from_date'],
'to_date': data['to_date'],
}
registry_type = data.get('registry_type', 'customer')
if data.get('journal_ids'):
context['vat_registry_journal_ids'] = data['journal_ids']

tax = self.env['account.tax'].with_context(context).browse(self.id)
tax_name = tax._get_tax_name()
if not tax.children_tax_ids:
base_balance = tax.base_balance
balance = tax.balance
if registry_type == 'supplier':
base_balance = -base_balance
balance = -balance
return (
tax_name, abs(tax.base_balance), abs(tax.balance),
abs(tax.balance), 0
tax_name, base_balance, balance, balance, 0
)
else:
base_balance = tax.base_balance
Expand All @@ -69,7 +74,7 @@ def _compute_totals_tax(self, data):
):
# Prendo la parte di competenza di ogni registro e lo
# sommo sempre
child_balance = abs(child_balance)
child_balance = child_balance

elif child.cee_type:
continue
Expand All @@ -79,7 +84,11 @@ def _compute_totals_tax(self, data):
deductible += child_balance
else:
undeductible += child_balance
if registry_type == 'supplier':
base_balance = -base_balance
tax_balance = -tax_balance
deductible = -deductible
undeductible = -undeductible
return (
tax_name, abs(base_balance), abs(tax_balance), abs(deductible),
abs(undeductible)
tax_name, base_balance, tax_balance, deductible, undeductible
)

0 comments on commit e072e13

Please sign in to comment.