Skip to content

Commit

Permalink
[IMP] l10n_it_fatturapa_out_rc: supporto per la conversione degli imp…
Browse files Browse the repository at this point in the history
…orti in EUR per fatture in valuta estera
  • Loading branch information
TheMule71 committed Apr 15, 2022
1 parent 1e862c3 commit 07f73ce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
18 changes: 8 additions & 10 deletions l10n_it_fatturapa_out_rc/views/invoice_it_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,20 @@
t-esc="record.fiscal_document_type_id.code"
/>
</xpath>
<xpath
expr="//DatiGeneraliDocumento/ImportoTotaleDocumento"
position="replace"
>
<ImportoTotaleDocumento
t-esc="format_numbers_two(get_sign(record) * record.amount_total)"
/>
</xpath>
<xpath expr="//DettaglioPagamento/ImportoPagamento" position="replace" />
<xpath expr="//DettaglioPagamento/ImportoPagamento" position="replace">
<ImportoPagamento
t-if="record.company_id.xml_divisa_value == 'keep_orig'"
t-esc="format_numbers_two(get_sign(record) * (move_line.amount_currency or move_line.debit))"
/>
<ImportoPagamento
t-if="not record.company_id.xml_divisa_value == 'keep_orig'"
t-esc="format_numbers_two(fpa_to_eur(get_sign(record) * (move_line.amount_currency or move_line.debit), record))"
/>
</xpath>
<xpath expr="//DatiRiepilogo/ImponibileImporto" position="replace">
<ImponibileImporto
t-esc="format_monetary(get_sign(record) * tax_data['ImponibileImporto'], currency)"
t-esc="format_monetary(fpa_to_eur(get_sign(record) * tax_data['ImponibileImporto'], record), euro)"
/>
</xpath>
<xpath expr="//DatiRiepilogo/Imposta" position="replace">
Expand All @@ -86,7 +84,7 @@
</xpath>
<xpath expr="//PrezzoTotale" position="replace">
<PrezzoTotale
t-esc="format_monetary(get_sign(line.move_id) * line.price_subtotal, currency)"
t-esc="format_monetary(fpa_to_eur(get_sign(line.move_id) * line.price_subtotal, record), euro)"
/>
</xpath>
</template>
Expand Down
11 changes: 2 additions & 9 deletions l10n_it_fatturapa_out_rc/wizard/efattura.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@
)


# extend the EFatturaOut class to add a new helper function
class EFatturaOut(_EFatturaOut):
def get_template_values(self):
def get_sign(invoice):
sign = 1
if invoice.move_type in [
"out_refund",
"in_refund",
] and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]:
sign = -1
return sign

get_sign = self.env["wizard.export.fatturapa"].getSign
template_values = super().get_template_values()
template_values.update({"get_sign": get_sign})
return template_values
19 changes: 18 additions & 1 deletion l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
# Copyright 2021 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models
from odoo import api, models

from .efattura import EFatturaOut


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

@api.model
def _get_efattura_class(self):
return EFatturaOut

@api.model
def getSign(self, invoice):
sign = 1
if invoice.move_type in [
"out_refund",
"in_refund",
] and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]:
sign = -1
return sign

@api.model
def getImportoTotale(self, invoice):
amount_total = super().getImportoTotale(invoice)
amount_total *= self.getSign(invoice)
return amount_total

0 comments on commit 07f73ce

Please sign in to comment.