Skip to content

Commit

Permalink
[14.0][MIG] l10n_it_fatturapa_out_triple_discount
Browse files Browse the repository at this point in the history
  • Loading branch information
GSLabIt committed Apr 13, 2022
1 parent c47219d commit 85306ed
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 84 deletions.
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_out/data/invoice_it_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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)" />
<t t-set="importo" t-value="get_importo(line.price_unit, line.discount)" />
<ScontoMaggiorazione t-if="line.discount != 0 or importo != 0">
<!-- [2.2.1.10] -->
<t t-if="importo">
Expand Down
6 changes: 3 additions & 3 deletions l10n_it_fatturapa_out/wizard/efattura.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ def _key(tax_id):
out.update(out_computed)
return out

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

if self.partner_id.commercial_partner_id.is_pa:
# check value code
Expand Down
2 changes: 0 additions & 2 deletions l10n_it_fatturapa_out_triple_discount/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@

from . import wizards
14 changes: 7 additions & 7 deletions l10n_it_fatturapa_out_triple_discount/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': 'ITA - Fattura elettronica - Integrazione sconto triplo',
"summary": "Modulo ponte tra emissione "
"fatture elettroniche e sconto triplo",
"version": "12.0.2.0.1",
"name": "ITA - Fattura elettronica - Integrazione sconto triplo",
"summary": "Modulo ponte tra emissione " "fatture elettroniche e sconto triplo",
"version": "14.0.1.0.0",
"development_status": "Beta",
"category": "Hidden",
'website': 'https://github.com/OCA/l10n-italy/tree/12.0/'
'l10n_it_fatturapa_out_triple_discount',
"website": "https://github.com/OCA/l10n-italy"
"l10n_it_fatturapa_out_triple_discount",
"author": "Agile Business Group, Odoo Community Association (OCA)",
"license": "AGPL-3",
"auto_install": True,
"depends": [
"l10n_it_fatturapa_out",
"account_invoice_triple_discount",
]
],
"data": ["data/invoice_it_template.xml"],
}
46 changes: 46 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/data/invoice_it_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<template
id="account_invoice_line_it_triple_discount"
inherit_id="l10n_it_fatturapa_out.account_invoice_line_it_sconto_maggiorazione"
>
<xpath expr="//ScontoMaggiorazione" position="after">
<t
t-set="importo2"
t-value="get_importo(line.price_unit, line.discount2)"
/>
<t
t-set="importo3"
t-value="get_importo(line.price_unit, line.discount3)"
/>
<ScontoMaggiorazione t-if="line.discount2 != 0 or importo2 != 0">
<!-- [2.2.1.10] -->
<t t-if="importo">
<Tipo t-if="importo2 &gt; 0">SC</Tipo>
<Tipo t-if="importo2 &lt;= 0">MG</Tipo>
<Importo t-esc="format_numbers(abs(importo2))" />
</t>
<t t-else="">
<Tipo t-if="line.discount2 &gt; 0">SC</Tipo>
<Tipo t-if="line.discount2 &lt;= 0">MG</Tipo>
<Percentuale t-esc="format_numbers_two(abs(line.discount2))" />
</t>
</ScontoMaggiorazione>
<ScontoMaggiorazione t-if="line.discount3 != 0 or importo3 != 0">
<!-- [2.2.1.10] -->
<t t-if="importo">
<Tipo t-if="importo3 &gt; 0">SC</Tipo>
<Tipo t-if="importo3 &lt;= 0">MG</Tipo>
<Importo t-esc="format_numbers(abs(importo3))" />
</t>
<t t-else="">
<Tipo t-if="line.discount3 &gt; 0">SC</Tipo>
<Tipo t-if="line.discount3 &lt;= 0">MG</Tipo>
<Percentuale t-esc="format_numbers_two(abs(line.discount3))" />
</t>
</ScontoMaggiorazione>
</xpath>
</template>
</data>
</odoo>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Simone Rubino
* Alex Comba <alex.comba@agilebg.com>
* Giovanni Serra <giovanni@gslab.it>
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_out_triple_discount/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# tests disabled because unstable
# TODO https://github.com/OCA/l10n-italy/issues/1588
#from . import test_fatturapa_triple_discount
# from . import test_fatturapa_triple_discount
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<ns1:FatturaElettronica
xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"
versione="FPA12">
xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"
versione="FPA12"
>
<FatturaElettronicaHeader>
<DatiTrasmissione>
<IdTrasmittente>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,57 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import codecs
from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import (
FatturaPACommon)

from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon

class TestInvoiceTripleDiscount(FatturaPACommon):

class TestInvoiceTripleDiscount(FatturaPACommon):
def setUp(self):
super(TestInvoiceTripleDiscount, self).setUp()

def test_xml_export_triple_discount(self):
self.set_sequences(13, '2016-01-07')
invoice = self.invoice_model.create({
'date_invoice': '2016-01-07',
'partner_id': self.res_partner_fatturapa_0.id,
'journal_id': self.sales_journal.id,
'account_id': self.a_recv.id,
'payment_term_id': self.account_payment_term.id,
'user_id': self.user_demo.id,
'type': 'out_invoice',
'currency_id': self.EUR.id,
'invoice_line_ids': [
(0, 0, {
'account_id': self.a_sale.id,
'product_id': self.product_product_10.id,
'name': 'Mouse\nOptical',
'quantity': 1,
'uom_id': self.product_uom_unit.id,
'price_unit': 10,
'discount': 50,
'discount2': 50,
'discount3': 50,
'invoice_line_tax_ids': [(6, 0, {
self.tax_22.id})]
})],
})
self.set_sequences(13, "2016-01-07")
invoice = self.invoice_model.create(
{
"date_invoice": "2016-01-07",
"partner_id": self.res_partner_fatturapa_0.id,
"journal_id": self.sales_journal.id,
"account_id": self.a_recv.id,
"payment_term_id": self.account_payment_term.id,
"user_id": self.user_demo.id,
"type": "out_invoice",
"currency_id": self.EUR.id,
"invoice_line_ids": [
(
0,
0,
{
"account_id": self.a_sale.id,
"product_id": self.product_product_10.id,
"name": "Mouse\nOptical",
"quantity": 1,
"uom_id": self.product_uom_unit.id,
"price_unit": 10,
"discount": 50,
"discount2": 50,
"discount3": 50,
"invoice_line_tax_ids": [(6, 0, {self.tax_22.id})],
},
)
],
}
)
invoice.action_invoice_open()
res = self.run_wizard(invoice.id)

self.assertTrue(res)
attachment = self.attach_model.browse(res['res_id'])
self.set_e_invoice_file_id(attachment, 'IT06363391001_00001.xml')
attachment = self.attach_model.browse(res["res_id"])
self.set_e_invoice_file_id(attachment, "IT06363391001_00001.xml")

# XML doc to be validated
xml_content = codecs.decode(attachment.datas, 'base64')
self.check_content(xml_content, 'IT06363391001_00001.xml',
module_name='l10n_it_fatturapa_out_triple_discount')
xml_content = codecs.decode(attachment.datas, "base64")
self.check_content(
xml_content,
"IT06363391001_00001.xml",
module_name="l10n_it_fatturapa_out_triple_discount",
)
2 changes: 0 additions & 2 deletions l10n_it_fatturapa_out_triple_discount/wizards/__init__.py

This file was deleted.

This file was deleted.

6 changes: 6 additions & 0 deletions setup/l10n_it_fatturapa_out_triple_discount/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 85306ed

Please sign in to comment.