Skip to content

Commit

Permalink
[REF] l10n_it_fatturapa_out: Extract discounted price computation
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTakobi authored and GSLabIt committed Apr 11, 2023
1 parent dbad815 commit c87162f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion l10n_it_fatturapa_out/data/invoice_it_template.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Copyright 2022 Simone Rubino - TAKOBI
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->

<odoo>
<data>
<!--
Expand Down Expand Up @@ -119,7 +124,7 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
</template>

<template id="account_invoice_line_it_sconto_maggiorazione">
<t t-set="importo" t-value="get_importo(line.price_unit, line.discount)" />
<t t-set="importo" t-value="get_importo(line)" />
<ScontoMaggiorazione t-if="line.discount != 0 or importo != 0">
<!-- [2.2.1.10] -->
<t t-if="importo">
Expand Down
3 changes: 3 additions & 0 deletions l10n_it_fatturapa_out/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
* `TAKOBI <https://takobi.online>`_:

* Simone Rubino <sir@takobi.online>
8 changes: 5 additions & 3 deletions l10n_it_fatturapa_out/wizard/efattura.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2020 Giuseppe Borruso
# Copyright 2020 Marco Colombo
# Copyright 2022 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
import os
from datetime import datetime
Expand Down Expand Up @@ -174,12 +176,12 @@ def get_all_taxes(record):
wiz = self.env["wizard.export.fatturapa"]
return wiz.getAllTaxes(record)

def get_importo(price_unit, discount):
str_number = str(discount)
def get_importo(line, discount_field='discount'):
str_number = str(line[discount_field])
number = str_number[::-1].find(".")
if number <= 2:
return False
return price_unit * discount / 100
return line.price_unit * line.discount / 100

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

0 comments on commit c87162f

Please sign in to comment.