Skip to content

Commit

Permalink
[12.0][FIX] fatturapa withholding tax invoice received e-invoice 1.6 (O…
Browse files Browse the repository at this point in the history
…CA#1878)

* [12.0][FIX] fatturapa withholding tax invoice received - e-invoice 1.6

* [FIX] l10n_it_fatturapa_out_wt pep8 fixes

This reverts commit 421ef9e51634383263638e9b52ea4038829f62ec.

* [IMP] migration script

* [FIX] l10n_it_fatturapa_out_wt: Fixed ordering in DatiRitenuta generation, according to XML test file.
Otherwise:
2020-09-17 07:34:14,789 7808 ERROR openerp_test odoo.addons.l10n_it_fatturapa_out_wt.tests.test_fatturapa_wt: ` AssertionError: b'<ns[1677 chars]a>RT02</TipoRitenuta><ImportoRitenuta>2.00</Im[1155 chars]ica>' != b'<ns[1677 chars]a>RT04</TipoRitenuta><ImportoRitenuta>0.83</Im[1155 chars]ica>'

Co-authored-by: SimoRubi <[email protected]>
  • Loading branch information
2 people authored and TheMule71 committed Apr 21, 2023
1 parent 27343e8 commit 769aa11
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_out_wt/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'name': 'ITA - Fattura elettronica - Integrazione '
'ritenuta',
'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.',
'version': '12.0.1.1.3',
'version': '12.0.2.0.0',
'development_status': 'Beta',
'category': 'Hidden',
'website': 'https://github.com/OCA/l10n-italy',
Expand Down
8 changes: 1 addition & 7 deletions l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ msgid "Export E-invoice"
msgstr ""

#. module: l10n_it_fatturapa_out_wt
#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:27
#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:47
#, python-format
msgid "Missing payment reason for withholding tax %s!"
msgstr ""

#. module: l10n_it_fatturapa_out_wt
#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:24
#, python-format
msgid "More than one withholding tax in invoice!"
msgstr ""

22 changes: 12 additions & 10 deletions l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def setUp(self):
'causale_pagamento_id': self.env.ref(
'l10n_it_causali_pagamento.a').id,
'rate_ids': [(0, 0, {
'tax': 8.25,
'base': 1,
})]
'tax': 8.25,
'base': 1,
})]
}
self.enasarco = self.env['withholding.tax'].create(wt_vals)
wt_vals = {
Expand All @@ -74,9 +74,9 @@ def setUp(self):
'causale_pagamento_id': self.env.ref(
'l10n_it_causali_pagamento.a').id,
'rate_ids': [(0, 0, {
'tax': 5.25,
'base': 1,
})]
'tax': 5.25,
'base': 1,
})]
}
self.inps = self.env['withholding.tax'].create(wt_vals)

Expand Down Expand Up @@ -243,7 +243,8 @@ def test_e_invoice_wt_enas_2(self):
self.check_content(
xml_content, 'IT06363391001_00016.xml',
module_name='l10n_it_fatturapa_out_wt')



def test_e_invoice_wt_inps_0(self):
self.set_sequences(17, '2019-01-07')
invoice = self.invoice_model.create({
Expand Down Expand Up @@ -282,7 +283,8 @@ def test_e_invoice_wt_inps_0(self):
self.check_content(
xml_content, 'IT06363391001_00017.xml',
module_name='l10n_it_fatturapa_out_wt')



def test_e_invoice_wt_inps_1(self):
"""
Fill DatiCassaPrevidenziale with INPS data
Expand Down Expand Up @@ -326,7 +328,8 @@ def test_e_invoice_wt_inps_1(self):
self.check_content(
xml_content, 'IT06363391001_00018.xml',
module_name='l10n_it_fatturapa_out_wt')



def test_e_invoice_wt_inps_2(self):
"""
Fill DatiCassaPrevidenziale with INPS data,
Expand Down Expand Up @@ -371,4 +374,3 @@ def test_e_invoice_wt_inps_2(self):
self.check_content(
xml_content, 'IT06363391001_00019.xml',
module_name='l10n_it_fatturapa_out_wt')

17 changes: 8 additions & 9 deletions l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from odoo.tools.float_utils import float_round
from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import (
DatiRitenutaType,
AltriDatiGestionaliType,
DatiCassaPrevidenzialeType,
DatiRiepilogoType
)
Expand All @@ -23,9 +22,10 @@
'enpam': 'TC09',
}


class WizardExportFatturapa(models.TransientModel):
_inherit = "wizard.export.fatturapa"

def getTipoRitenuta(self, wt_types, partner):
if wt_types == 'ritenuta':
if partner.is_company:
Expand All @@ -35,14 +35,13 @@ def getTipoRitenuta(self, wt_types, partner):
else:
tipoRitenuta = WT_TAX_CODE[wt_types]
return tipoRitenuta

def setDatiGeneraliDocumento(self, invoice, body):
res = super(WizardExportFatturapa, self).setDatiGeneraliDocumento(
invoice, body)
ritenuta_lines = invoice.withholding_tax_line_ids
# if len(ritenuta_lines) > 1:
# raise UserError(
# _("More than one withholding tax in invoice!"))
# Get consistent ordering for file generation for compare with test XML
ritenuta_lines = invoice.withholding_tax_line_ids.sorted(
key=lambda l: l.withholding_tax_id.code)
for wt_line in ritenuta_lines:
if not wt_line.withholding_tax_id.causale_pagamento_id.code:
raise UserError(_('Missing payment reason for '
Expand Down Expand Up @@ -81,14 +80,14 @@ def setDatiGeneraliDocumento(self, invoice, body):
def get_tax_riepilogo(self, body, tax_id):
for riepilogo in body.DatiBeniServizi.DatiRiepilogo:
if float(riepilogo.AliquotaIVA) == 0.0 \
and riepilogo.Natura == tax_id.kind_id.code:
and riepilogo.Natura == tax_id.kind_id.code:
return riepilogo

def setDatiRiepilogo(self, invoice, body):
res = super(WizardExportFatturapa, self).setDatiRiepilogo(
invoice, body)
wt_lines_to_write = invoice.withholding_tax_line_ids.filtered(
lambda x: x.withholding_tax_id.wt_types not in ('ritenuta', 'other')
lambda x: x.withholding_tax_id.wt_types not in ('ritenuta', 'other')
and x.withholding_tax_id.use_daticassaprev
)
for wt_line in wt_lines_to_write:
Expand Down

0 comments on commit 769aa11

Please sign in to comment.