Skip to content

Commit

Permalink
[IMP][l10n_it_fatturapa_out] the data invoice relative line and total…
Browse files Browse the repository at this point in the history
… amount it is converted with the currency of invoice

[FIX][l10n_it_fatturapa_out] fix field ImportoPagamento not assign

[FIX][l10n_it_fatturapa_out] fix missing field
  • Loading branch information
matteoopenf committed Apr 8, 2022
1 parent d0341c7 commit 0c30bea
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,14 @@ def setDatiGeneraliDocumento(self, invoice, body):
_('Invoice %s does not have a number.' % invoice.display_name))

TipoDocumento = invoice.fiscal_document_type_id.code
ImportoTotaleDocumento = invoice.amount_total
ImportoTotaleDocumento = self._to_EUR(
invoice.currency_id, invoice.amount_total, invoice=invoice)
if invoice.split_payment:
ImportoTotaleDocumento += invoice.amount_sp
ImportoTotaleDocumento += self._to_EUR(
invoice.currency_id, invoice.amount_sp, invoice=invoice)
body.DatiGenerali.DatiGeneraliDocumento = DatiGeneraliDocumentoType(
TipoDocumento=TipoDocumento,
Divisa=invoice.currency_id.name,
Divisa=self.env.ref('base.EUR').name,
Data=invoice.date_invoice,
Numero=invoice.number,
ImportoTotaleDocumento='%.2f' % float_round(ImportoTotaleDocumento, 2))
Expand Down Expand Up @@ -680,7 +682,9 @@ def setDettaglioLinea(
aliquota = line.invoice_line_tax_ids[0].amount
AliquotaIVA = '%.2f' % float_round(aliquota, 2)
line.ftpa_line_number = line_no
prezzo_unitario = self._get_prezzo_unitario(line)
prezzo_unitario = self._to_EUR(
line.currency_id, self._get_prezzo_unitario(line),
invoice=line.invoice_id)
DettaglioLinea = DettaglioLineeType(
NumeroLinea=str(line_no),
Descrizione=encode_for_export(line.name, 1000),
Expand All @@ -690,8 +694,21 @@ def setDettaglioLinea(
qta=line.quantity, precision=uom_precision),
UnitaMisura=line.uom_id and (
unidecode(line.uom_id.name)) or None,
PrezzoTotale='%.2f' % float_round(line.price_subtotal, 2),
PrezzoTotale='%.2f' % float_round(
self._to_EUR(line.currency_id, line.price_subtotal,
invoice=line.invoice_id), 2),
AliquotaIVA=AliquotaIVA)
if line.currency_id != self.env.ref('base.EUR'):
prezzo_unitario = DettaglioLinea.PrezzoTotale / DettaglioLinea.Quantita
DettaglioLinea.PrezzoUnitario = '{prezzo:.{precision}f}'.format(
prezzo=prezzo_unitario, precision=price_precision)
AltriDatiGestionali = AltriDatiGestionaliType(
TipoDato="Valuta",
RiferimentoTesto=line.currency_id.name,
RiferimentoNumero=self._get_prezzo_unitario(line),
RiferimentoData=fields.Date.today()
)
DettaglioLinea.AltriDatiGestionali.append(AltriDatiGestionali)
DettaglioLinea.ScontoMaggiorazione.extend(
self.setScontoMaggiorazione(line))
if aliquota == 0.0:
Expand Down Expand Up @@ -752,8 +769,11 @@ def setDatiRiepilogo(self, invoice, body):
tax = tax_line.tax_id
riepilogo = DatiRiepilogoType(
AliquotaIVA='%.2f' % float_round(tax.amount, 2),
ImponibileImporto='%.2f' % float_round(tax_line.base, 2),
Imposta='%.2f' % float_round(tax_line.amount, 2)
ImponibileImporto='%.2f' % float_round(self._to_EUR(
invoice.currency_id, tax_line.base, invoice=invoice), 2),
Imposta='%.2f' % float_round(
self._to_EUR(invoice.currency_id, tax_line.amount,
invoice=invoice), 2)
)
if tax.amount == 0.0:
if not tax.kind_id:
Expand Down Expand Up @@ -796,7 +816,10 @@ def setDatiPagamento(self, invoice, body):
for move_line_id in payment_line_ids:
move_line = move_line_pool.browse(move_line_id)
ImportoPagamento = '%.2f' % float_round(
move_line.amount_currency or move_line.debit, 2)
self._to_EUR(invoice.currency_id,
move_line.amount_currency or
move_line.debit, invoice),
2)
# Create with only mandatory fields
DettaglioPagamento = DettaglioPagamentoType(
ModalitaPagamento=(
Expand Down

0 comments on commit 0c30bea

Please sign in to comment.