Openbravo Issue Tracking System - Openbravo Localizations
View Issue Details
0052768Openbravo LocalizationsLocalization Italypublic2023-06-16 12:202023-06-30 11:24
wicherr 
frank_gonzalez 
urgentmajoralways
closedfixed 
5
 
 
0052768: Italian Invoice XML : PrezzoTotale non calcolato secondo le specifiche tecniche
We have this kind of error on Norauto : PrezzoTotale non calcolato secondo le specifiche tecniche

After analysis, the problem comes from the multiple roundings we do recording any tickets.
There are multiple cases where we make roundings. The most common are :
- Roundings on unit prices regarding the quantities
- Roundings on prices without taxes

real example from a real invoice in production [extract of the XML] :
<CodiceArticolo>
          <CodiceTipo>EAN</CodiceTipo>
          <CodiceValore>0000022359346</CodiceValore>
        </CodiceArticolo>
        <Descrizione>LIQ. LHM BREMBO 500ML</Descrizione>
        <Quantita>5.00</Quantita>
        <PrezzoUnitario>7.34</PrezzoUnitario>
        <PrezzoTotale>36.68</PrezzoTotale>
        <AliquotaIVA>22.00</AliquotaIVA>
        <AltriDatiGestionali>
          <TipoDato>SCONTRINO</TipoDato>
        </AltriDatiGestionali>

All the data comes from the backend. Nothing is calculated in the extraction.
We can see that : 7.34 x 5 = 36.7 <> 36.68


I had another case where the sum of the <PrezzoTotale> was not equal to the <ImponibileImporto> which means the sum of the line without taxes was not equals to the total of the ticket without taxes because of roundings done in the BO.
We have 3 options I guess :

→ Either we add digits for more accuracy in the BO

→ Or we split the products per quantity if we need to round the amount in the BO (ex : 2 qties at 2,74 and 1 at 2,73)

→ Or we manage that only in the export XML recalculating everything which is the worst option IMO
NOR
Issue History
2023-06-16 12:20wicherrNew Issue
2023-06-16 12:20wicherrAssigned To => psanjuan
2023-06-16 12:20wicherrTag Attached: NOR
2023-06-16 12:55psanjuanAssigned Topsanjuan => Triage Omni OMS
2023-06-20 09:57aferrazAssigned ToTriage Omni OMS => frank_gonzalez
2023-06-21 14:14frank_gonzalezStatusnew => acknowledged
2023-06-22 12:51psanjuanNote Added: 0151496
2023-06-22 12:51psanjuanNote Deleted: 0151496
2023-06-22 13:02psanjuanNote Added: 0151498
2023-06-23 08:27hgbotNote Added: 0151539
2023-06-23 09:13frank_gonzalezNote Added: 0151541
2023-06-27 14:33wicherrNote Added: 0151672
2023-06-29 10:21frank_gonzalezNote Added: 0151813
2023-06-29 12:29frank_gonzalezNote Edited: 0151813bug_revision_view_page.php?bugnote_id=0151813#r26376
2023-06-29 18:30hgbotResolutionopen => fixed
2023-06-29 18:30hgbotStatusacknowledged => closed
2023-06-29 18:30hgbotNote Added: 0151892
2023-06-29 18:30hgbotNote Added: 0151893
2023-06-29 18:32aferrazNote Added: 0151895
2023-06-30 08:26hgbotNote Added: 0151922
2023-06-30 11:24hgbotNote Added: 0151948
2023-06-30 11:24hgbotNote Added: 0151949

Notes
(0151498)
psanjuan   
2023-06-22 13:02   
This "I had another case where the sum of the <PrezzoTotale> was not equal to the <ImponibileImporto> which means the sum of the line without taxes was not equals to the total of the ticket without taxes because of roundings done in the BO." needs to be managed in a separated issue with proper definition and steps to reproduce. Please open a new issue for it.
(0151539)
hgbot   
2023-06-23 08:27   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice/-/merge_requests/33 [^]
(0151541)
frank_gonzalez   
2023-06-23 09:13   
We've found a solution for the rounding problem that basically consists in following the technical spec for Sdl and allowing the unitPrice (PrezzoUnitario) to have up to 8 decimal places.

Sdl technical spec: https://www.agenziaentrate.gov.it/portale/documents/20143/2370834/Allegato+A+-+Specifiche+tecniche+vers+1.6_.pdf/a9917ec2-29a3-4f4a-a7d0-93af96fcaad5 [^]

To fix the issue:
1. Set the price precision to 4 in the Backoffice
2. Apply the changes in the MR
(0151672)
wicherr   
2023-06-27 14:33   
The solution seems promising. let's try it.
(0151813)
frank_gonzalez   
2023-06-29 10:21   
(edited on: 2023-06-29 12:29)
It appears the fix can't be applied due to differences in client price precision configuration so another fix has been implemented that should solve the problem at the time of XML generation:

Instead of getting the unit price from the API, calculate it by dividing the net total by the quantity since that's how the Italian government's exchange system expects rounding to be done.

(0151892)
hgbot   
2023-06-29 18:30   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice [^]
Changeset: e2f6a9675bf3c3fecb018c2aef0bb4a2eba3cc97
Author: Frank González <frank.gonzalez@openbravo.com>
Date: 29-06-2023 16:30:40
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice/-/commit/e2f6a9675bf3c3fecb018c2aef0bb4a2eba3cc97 [^]

Fixes ISSUE-52768: Italy E-Invoice PrezzoTotale non calcolato secondo le specifiche tecniche

---
M src-test/org/openbravo/localization/italy/einvoice/TestItalyXMLCreationFromJson.java
M src/org/openbravo/localization/italy/einvoice/xmlengine/document/ItalyDatiRiepilogo.java
M src/org/openbravo/localization/italy/einvoice/xmlengine/document/ItalyDettaglioLinee.java
---
(0151893)
hgbot   
2023-06-29 18:30   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice/-/merge_requests/33 [^]
(0151895)
aferraz   
2023-06-29 18:32   
With the fix we finally implemented, it is not needed to change the price precision in OB backoffice.
(0151922)
hgbot   
2023-06-30 08:26   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice/-/merge_requests/34 [^]
(0151948)
hgbot   
2023-06-30 11:24   
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice [^]
Changeset: 6c4331f5bd9ca4b0e6d28ef69397f15b6ecfcf2d
Author: Frank González <frank.gonzalez@openbravo.com>
Date: 30-06-2023 09:24:06
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice/-/commit/6c4331f5bd9ca4b0e6d28ef69397f15b6ecfcf2d [^]

Related to ISSUE-52768: Fix test

---
M src-test/org/openbravo/localization/italy/einvoice/TestItalyXMLCreationFromJson.java
---
(0151949)
hgbot   
2023-06-30 11:24   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.localization.italy.einvoice/-/merge_requests/34 [^]