Skip to content

Commit

Permalink
[IMP] l10n_it_fatturapa_in_rc: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMule71 authored and SirAionTech committed Sep 27, 2023
1 parent 67347f7 commit 935dd68
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 171 deletions.
8 changes: 3 additions & 5 deletions l10n_it_fatturapa_in_rc/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Copyright 2018 Sergio Corato (https://efatto.it)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'ITA - Fattura elettronica - Inversione contabile',
"summary": "Modulo ponte tra e-fattura in acquisto e inversione"
" contabile",
"name": "ITA - Fattura elettronica - Inversione contabile",
"summary": "Modulo ponte tra e-fattura in acquisto e inversione" " contabile",
"version": "12.0.1.1.4",
"development_status": "Beta",
"category": "Hidden",
'website': 'https://github.com/OCA/l10n-italy/tree/10.0/'
'l10n_it_fatturapa_in_rc',
"website": "https://github.com/OCA/l10n-italy" "l10n_it_fatturapa_in_rc",
"author": "Efatto.it di Sergio Corato, Odoo Community Association (OCA)",
"maintainers": ["sergiocorato"],
"license": "AGPL-3",
Expand Down
80 changes: 40 additions & 40 deletions l10n_it_fatturapa_in_rc/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
from odoo import models, api, _
from odoo import _, api, models
from odoo.tools import float_compare


class InvoiceLine(models.Model):
_inherit = 'account.invoice.line'
_inherit = "account.invoice.line"

@api.multi
def _set_rc_flag(self, invoice):
self.ensure_one()
if 'fatturapa.attachment.in' in self.env.context.get(
'active_model', []
):
if "fatturapa.attachment.in" in self.env.context.get("active_model", []):
# this means we are importing an e-invoice,
# so RC flag is already set, where needed
return
return super(InvoiceLine, self)._set_rc_flag(invoice)


class Invoice(models.Model):
_inherit = 'account.invoice'
_inherit = "account.invoice"

def e_inv_check_amount_tax(self):
if (
any(self.invoice_line_ids.mapped('rc')) and
self.e_invoice_amount_tax
):
error_message = ''
if any(self.invoice_line_ids.mapped("rc")) and self.e_invoice_amount_tax:
error_message = ""
amount_added_for_rc = self.get_tax_amount_added_for_rc()
amount_tax = self.amount_tax - amount_added_for_rc
if float_compare(
amount_tax, self.e_invoice_amount_tax,
precision_rounding=self.currency_id.rounding
) != 0:
error_message = (
_("Taxed amount ({bill_amount_tax}) "
"does not match with "
"e-bill taxed amount ({e_bill_amount_tax})")
.format(
bill_amount_tax=amount_tax or 0,
e_bill_amount_tax=self.e_invoice_amount_tax
))
if (
float_compare(
amount_tax,
self.e_invoice_amount_tax,
precision_rounding=self.currency_id.rounding,
)
!= 0
):
error_message = _(
"Taxed amount ({bill_amount_tax}) "
"does not match with "
"e-bill taxed amount ({e_bill_amount_tax})"
).format(
bill_amount_tax=amount_tax or 0,
e_bill_amount_tax=self.e_invoice_amount_tax,
)
return error_message
else:
return super(Invoice, self).e_inv_check_amount_tax()

def e_inv_check_amount_total(self):
if (
any(self.invoice_line_ids.mapped('rc')) and
self.e_invoice_amount_total
):
error_message = ''
if any(self.invoice_line_ids.mapped("rc")) and self.e_invoice_amount_total:
error_message = ""
amount_added_for_rc = self.get_tax_amount_added_for_rc()
amount_total = self.amount_total - amount_added_for_rc
if float_compare(
amount_total, self.e_invoice_amount_total,
precision_rounding=self.currency_id.rounding
) != 0:
error_message = (
_("Total amount ({bill_amount_total}) "
"does not match with "
"e-bill total amount ({e_bill_amount_total})")
.format(
bill_amount_total=amount_total or 0,
e_bill_amount_total=self.e_invoice_amount_total
))
if (
float_compare(
amount_total,
self.e_invoice_amount_total,
precision_rounding=self.currency_id.rounding,
)
!= 0
):
error_message = _(
"Total amount ({bill_amount_total}) "
"does not match with "
"e-bill total amount ({e_bill_amount_total})"
).format(
bill_amount_total=amount_total or 0,
e_bill_amount_total=self.e_invoice_amount_total,
)
return error_message
else:
return super(Invoice, self).e_inv_check_amount_total()
8 changes: 4 additions & 4 deletions l10n_it_fatturapa_in_rc/models/account_rc_type.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from odoo import models, fields
from odoo import fields, models


class RCType(models.Model):
_inherit = 'account.rc.type'
_inherit = "account.rc.type"

e_invoice_suppliers = fields.Boolean(
"E-invoice suppliers",
help="Automatically used when importing e-invoices from Italian "
"suppliers")
help="Automatically used when importing e-invoices from Italian " "suppliers",
)
15 changes: 11 additions & 4 deletions l10n_it_fatturapa_in_rc/tests/data/IT01234567890_FPR04.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:FatturaElettronica versione="FPR12" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd">
<?xml version="1.0" encoding="UTF-8" ?>
<p:FatturaElettronica
versione="FPR12"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd"
>
<FatturaElettronicaHeader>
<DatiTrasmissione>
<IdTrasmittente>
Expand All @@ -9,7 +15,7 @@
<ProgressivoInvio>00001</ProgressivoInvio>
<FormatoTrasmissione>FPR12</FormatoTrasmissione>
<CodiceDestinatario>0000000</CodiceDestinatario>
<ContattiTrasmittente/>
<ContattiTrasmittente />
</DatiTrasmissione>
<CedentePrestatore>
<DatiAnagrafici>
Expand Down Expand Up @@ -85,7 +91,8 @@
<ImponibileImporto>20.00</ImponibileImporto>
<Imposta>0.00</Imposta>
<EsigibilitaIVA>I</EsigibilitaIVA>
<RiferimentoNormativo>ex art.74 commi 7 e 8 art.17.commi 2e 6 DPR 633/72</RiferimentoNormativo>
<RiferimentoNormativo
>ex art.74 commi 7 e 8 art.17.commi 2e 6 DPR 633/72</RiferimentoNormativo>
</DatiRiepilogo>
</DatiBeniServizi>
</FatturaElettronicaBody>
Expand Down
Loading

0 comments on commit 935dd68

Please sign in to comment.