-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by TheMule71
- Loading branch information
Showing
8 changed files
with
236 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import fields | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2024 Simone Rubino - Aion Tech | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.fields import Float | ||
|
||
orig_convert_to_cache = Float.convert_to_cache | ||
orig_get_digits = Float.get_digits | ||
|
||
E_INVOICE_PRECISION_TO_FIELD = { | ||
"Discount": "discount_decimal_digits", | ||
"Product Price": "price_decimal_digits", | ||
"Product Unit of Measure": "quantity_decimal_digits", | ||
} | ||
# Map a `decimal.precision` to the name of the field in `fatturapa.attachment` | ||
# that stores the value used during import | ||
|
||
|
||
def get_digits(self, env): | ||
digits = orig_get_digits(self, env) | ||
if e_invoice_precision := env.context.get("l10n_it_fatturapa_in_precision"): | ||
digits = digits[0], e_invoice_precision | ||
return digits | ||
|
||
|
||
def convert_to_cache(self, value, record, validate=True): | ||
if record._name in ("account.move", "account.move.line"): | ||
e_invoice = record.fatturapa_attachment_in_id | ||
if e_invoice: | ||
# The invoice [line] has been created by importing an e-invoice. | ||
# If a different precision has been used, | ||
# keep using that precision to read values that have it. | ||
field_precision = self._digits | ||
if isinstance(field_precision, str): | ||
e_invoice_precision_field = E_INVOICE_PRECISION_TO_FIELD.get( | ||
field_precision | ||
) | ||
if e_invoice_precision_field: | ||
if e_invoice_precision := e_invoice[e_invoice_precision_field]: | ||
record = record.with_context( | ||
l10n_it_fatturapa_in_precision=e_invoice_precision | ||
) | ||
|
||
return orig_convert_to_cache(self, value, record, validate=validate) | ||
|
||
|
||
Float.convert_to_cache = convert_to_cache | ||
Float.get_digits = get_digits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<q1:FatturaElettronica xmlns:q1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" versione="FPR12"> | ||
<FatturaElettronicaHeader> | ||
<DatiTrasmissione> | ||
<IdTrasmittente> | ||
<IdPaese>IT</IdPaese> | ||
<IdCodice>02780790107</IdCodice> | ||
</IdTrasmittente> | ||
<ProgressivoInvio>FPR14</ProgressivoInvio> | ||
<FormatoTrasmissione>FPR12</FormatoTrasmissione> | ||
<CodiceDestinatario>0000000</CodiceDestinatario> | ||
<ContattiTrasmittente> | ||
<Telefono>06543534343</Telefono> | ||
<Email>[email protected]</Email> | ||
</ContattiTrasmittente> | ||
<PECDestinatario>[email protected]</PECDestinatario> | ||
</DatiTrasmissione> | ||
<CedentePrestatore> | ||
<DatiAnagrafici> | ||
<IdFiscaleIVA> | ||
<IdPaese>IT</IdPaese> | ||
<IdCodice>02780790107</IdCodice> | ||
</IdFiscaleIVA> | ||
<Anagrafica> | ||
<Denominazione>YourCompany</Denominazione> | ||
</Anagrafica> | ||
<RegimeFiscale>RF01</RegimeFiscale> | ||
</DatiAnagrafici> | ||
<Sede> | ||
<Indirizzo>Via Milano, 1</Indirizzo> | ||
<CAP>00100</CAP> | ||
<Comune>Roma</Comune> | ||
<Provincia>AK</Provincia> | ||
<Nazione>IT</Nazione> | ||
</Sede> | ||
<Contatti> | ||
<Telefono>06543534343</Telefono> | ||
<Email>[email protected]</Email> | ||
</Contatti> | ||
</CedentePrestatore> | ||
<CessionarioCommittente> | ||
<DatiAnagrafici> | ||
<IdFiscaleIVA> | ||
<IdPaese>IT</IdPaese> | ||
<IdCodice>07973780013</IdCodice> | ||
</IdFiscaleIVA> | ||
<CodiceFiscale>07973780013</CodiceFiscale> | ||
<Anagrafica> | ||
<Denominazione>B2B Customer</Denominazione> | ||
</Anagrafica> | ||
</DatiAnagrafici> | ||
<Sede> | ||
<Indirizzo>Via Roma, 1</Indirizzo> | ||
<CAP>16100</CAP> | ||
<Comune>Genova</Comune> | ||
<Provincia>AK</Provincia> | ||
<Nazione>IT</Nazione> | ||
</Sede> | ||
</CessionarioCommittente> | ||
</FatturaElettronicaHeader> | ||
<FatturaElettronicaBody> | ||
<DatiGenerali> | ||
<DatiGeneraliDocumento> | ||
<TipoDocumento>TD01</TipoDocumento> | ||
<Divisa>EUR</Divisa> | ||
<Data>2020-09-30</Data> | ||
<Numero>14481</Numero> | ||
<ImportoTotaleDocumento>81.49</ImportoTotaleDocumento> | ||
</DatiGeneraliDocumento> | ||
</DatiGenerali> | ||
<DatiBeniServizi> | ||
<DettaglioLinee> | ||
<NumeroLinea>1</NumeroLinea> | ||
<Descrizione>Test precisione decimale</Descrizione> | ||
<Quantita>69.00</Quantita> | ||
<PrezzoUnitario>0.968</PrezzoUnitario> | ||
<PrezzoTotale>66.792</PrezzoTotale> | ||
<AliquotaIVA>22.00</AliquotaIVA> | ||
</DettaglioLinee> | ||
<DatiRiepilogo> | ||
<AliquotaIVA>22.00</AliquotaIVA> | ||
<ImponibileImporto>66.79</ImponibileImporto> | ||
<Imposta>14.69</Imposta> | ||
</DatiRiepilogo> | ||
</DatiBeniServizi> | ||
</FatturaElettronicaBody> | ||
</q1:FatturaElettronica> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters