Skip to content

Commit

Permalink
Merge branch '12.0-l10n_it_fatturapa_out-discount-amount-percent-abil…
Browse files Browse the repository at this point in the history
…ity' of git+ssh://github.com/efatto/l10n-italy into 12.0
  • Loading branch information
Pretecno committed Sep 27, 2024
2 parents 6b21176 + 397ec53 commit 8f37065
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from odoo.tools.translate import _
from odoo.exceptions import UserError
from odoo.addons.l10n_it_account.tools.account_tools import encode_for_export
from odoo.tools.float_utils import float_round
from odoo.tools.float_utils import float_round, float_repr

from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import (
FatturaElettronica,
Expand Down Expand Up @@ -769,10 +769,35 @@ def setDettaglioLinea(
def setScontoMaggiorazione(self, line):
res = []
if line.discount:
res.append(ScontoMaggiorazioneType(
Tipo='SC',
Percentuale='%.2f' % float_round(line.discount, 8)
))
str_number = str(line.discount)
number = str_number[::-1].find(".")
if number <= 2:
net_discount = False
else:
net_discount = line.price_unit * line.discount / 100
if net_discount:
price_precision = self.env['decimal.precision'].precision_get(
'Product Price for XML e-invoices')
if net_discount >= 0:
tipo = 'SC'
else:
tipo = 'MG'
res.append(ScontoMaggiorazioneType(
Tipo=tipo,
Importo=float_repr(
float_round(net_discount, price_precision),
price_precision,
)
))
else:
if line.discount >= 0:
tipo = 'SC'
else:
tipo = 'MG'
res.append(ScontoMaggiorazioneType(
Tipo=tipo,
Percentuale='%.2f' % float_round(line.discount, 8)
))
return res

def setDatiRiepilogo(self, invoice, body):
Expand Down

0 comments on commit 8f37065

Please sign in to comment.