Skip to content

Commit c87162f

Browse files
SirTakobiGSLabIt
authored andcommitted
[REF] l10n_it_fatturapa_out: Extract discounted price computation
1 parent dbad815 commit c87162f

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

l10n_it_fatturapa_out/data/invoice_it_template.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
~ Copyright 2022 Simone Rubino - TAKOBI
4+
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5+
-->
6+
27
<odoo>
38
<data>
49
<!--
@@ -119,7 +124,7 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
119124
</template>
120125

121126
<template id="account_invoice_line_it_sconto_maggiorazione">
122-
<t t-set="importo" t-value="get_importo(line.price_unit, line.discount)" />
127+
<t t-set="importo" t-value="get_importo(line)" />
123128
<ScontoMaggiorazione t-if="line.discount != 0 or importo != 0">
124129
<!-- [2.2.1.10] -->
125130
<t t-if="importo">

l10n_it_fatturapa_out/readme/CONTRIBUTORS.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
* `Tecnativa <https://www.tecnativa.com>`_:
1010

1111
* Víctor Martínez
12+
* `TAKOBI <https://takobi.online>`_:
13+
14+
* Simone Rubino <sir@takobi.online>

l10n_it_fatturapa_out/wizard/efattura.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Copyright 2020 Giuseppe Borruso
22
# Copyright 2020 Marco Colombo
3+
# Copyright 2022 Simone Rubino - TAKOBI
4+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
35
import logging
46
import os
57
from datetime import datetime
@@ -174,12 +176,12 @@ def get_all_taxes(record):
174176
wiz = self.env["wizard.export.fatturapa"]
175177
return wiz.getAllTaxes(record)
176178

177-
def get_importo(price_unit, discount):
178-
str_number = str(discount)
179+
def get_importo(line, discount_field='discount'):
180+
str_number = str(line[discount_field])
179181
number = str_number[::-1].find(".")
180182
if number <= 2:
181183
return False
182-
return price_unit * discount / 100
184+
return line.price_unit * line.discount / 100
183185

184186
def get_importo_totale(invoice):
185187
# wrapper to a method in wizard (for better overriding)

0 commit comments

Comments
 (0)