Created 10-31-2023 11:56 AM
Hi
when i'm performing calculations for "Importo" attribute, it computing correctly , but since it is an array i'm getting repetitive of "Importo" : "." for each item level. Can you help in get rid of this unwanted "Importo" : "." values.
INPUT:
{
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiGeneraliDocumento": {
"Numero": "130889",
"Data": "31.10.2023",
"Causale": "22122013260655367-000180 DEL 20/12/2022",
"Divisa": "EUR",
"ImportoTotaleDocumento": "25369.31",
"TipoDocumento": "${TipoDocumento}"
},
"DatiDDT": [
{
"NumeroDDT": "287421-30.10.2023"
},
{
"NumeroDDT": " 287419-30.10.2023"
},
{
"NumeroDDT": " 287423-30.10.2023"
},
{
"NumeroDDT": " 287422-30.10.2023"
},
{
"NumeroDDT": " 287420-30.10.2023"
}
]
},
"DatiBeniServizi": {
"DettaglioLinee": {
"AltriDatiGestionali": {
"RiferimentoTesto": "22122013260655367-000180 DEL 20/12/2022",
"RiferimentoData": "22122013260655367-000180 DEL 20/12/2022",
"TipoDato": "INTENTO"
},
"NumeroLinea": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
"addnewline_1"
],
"Quantita": [
"12.00000000",
"2.00000000",
"8.00000000",
"5.00000000",
"3.00000000",
"12.00000000",
"1.00000000",
"3.00000000",
"1.00000000",
"6.00000000",
"7.00000000",
"1.00000000",
"7.00000000",
"6.00000000",
"9.00000000",
"4.00000000",
"1.00"
],
"PrezzoUnitario": [
"8.40000000",
"209.04000000",
"254.93000000",
"2136.93000000",
"2136.93000000",
"8.40000000",
"209.04000000",
"254.93000000",
"209.04000000",
"253.45000000",
"134.22000000",
"134.22000000",
"253.45000000",
"2136.93000000",
"254.93000000",
"253.45000000",
"169.20"
],
"AliquotaIVA": [
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00",
"0.00"
],
"ScontoMaggiorazione": {
"Tipo": [
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC",
"SC"
],
"Percentuale": [
"40.00",
"42.00",
"42.00",
"42.00",
"42.00",
"40.00",
"42.00",
"42.00",
"42.00",
"15.00",
"42.00",
"42.00",
"15.00",
"42.00",
"42.00",
"15.00"
],
"Importo": [
"40.32",
"175.60",
"856.56",
"4487.55",
"2692.53",
"40.32",
"87.80",
"321.21",
"87.80",
"228.12",
"394.59",
"56.37",
"266.14",
"5385.06",
"963.63",
"152.08"
]
},
"Descrizione": [
"A1661800209 KIT PZ. CARTUCCIA FILTRO",
"A6510108918 COPERCHIO TESTATA CIL.",
"A4634230112 DISCO DEL FRENO",
"A2751500680 BOBINA DI ACCENSIONE",
"A2751500680 BOBINA DI ACCENSIONE",
"A1661800209 KIT PZ. CARTUCCIA FILTRO",
"A6510108918 COPERCHIO TESTATA CIL.",
"A4634230112 DISCO DEL FRENO",
"A6510108918 COPERCHIO TESTATA CIL.",
"A0009704902 SEGGIOLINO",
"A6390100513 COPPA DELL'OLIO",
"A6390100513 COPPA DELL'OLIO",
"A0009704902 SEGGIOLINO",
"A2751500680 BOBINA DI ACCENSIONE",
"A4634230112 DISCO DEL FRENO",
"A0009704902 SEGGIOLINO",
"dettaglio 1"
],
"PrezzoTotale": [
"60.48000000",
"242.48000000",
"1182.88000000",
"6197.10000000",
"3718.26000000",
"60.48000000",
"121.24000000",
"443.58000000",
"121.24000000",
"1292.58000000",
"544.95000000",
"77.85000000",
"1508.01000000",
"7436.52000000",
"1330.74000000",
"861.72000000",
"169.20"
],
"Natura": "N3.5"
},
"DatiRiepilogo": {
"Natura": "N3.5",
"EsigibilitaIVA": "I",
"AliquotaIVA": "0.00",
"ImponibileImporto": "25369.31",
"Imposta": "0.00"
}
},
"Allegati": {
"NomeAttachment": "${filename_pdf}",
"Attachment": "${payload}"
}
}
}
SPEC:
[
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"NumeroLinea": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].NumeroLinea"
}
},
"Quantita": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].Quantita"
}
},
"ScontoMaggiorazione": {
"Tipo": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[&1].Tipo"
}
},
"Percentuale": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[&1].Percentuale"
}
},
"Importo": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[&1].Importo"
}
}
}
}
}
}
}
}
,
{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"ScontoMaggiorazione": {
"*": {
// "decImporto": "=divide(@(1,Importo),@(3,Quantita))",
"decImporto": "=divideAndRound(2,@(1,Importo),@(3,Quantita))",
"strImporto": "=toString(@(1,decImporto))",
"array_importo": "=split('[.]',@(1,strImporto))",
"pad_importo": "=rightPad(@(1,array_importo[1]), 8, '0')",
"Importo": "=concat(@(1,array_importo[0]),'.',@(1,pad_importo))"
}
}
}
}
}
}
}
},
{
"operation": "remove",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"ScontoMaggiorazione": {
"*": {
// "decImporto": "=divide(@(1,Importo),@(3,Quantita))",
"decImporto": "",
"strImporto": "",
"array_importo": "",
"pad_importo": ""
}
}
}
}
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"ScontoMaggiorazione": {
"*": {
"Importo": {
"*": {
"*": "=lastElement(@(1,&))"
}
}
}
}
}
}
}
}
}
},
{ "operation": "modify-overwrite-beta", "spec": { "*": "=recursivelySquashNulls" } }
]
Created 10-31-2023 12:47 PM
There is a lot to take here. It would be better if you always can simplify the problem by removing redundancy and isolating it where you can only re create the scenario you are trying to resolve. You dont have to use the exact data specially when its not worded in English as you can spend sometime trying to create a dummy data that resemble your structure which is easy to understand and readable by others. Keep in mind the more time you spend simplifying and articulating your problem the higher the chances it will get attention and the it will get resolved. Please keep that in mind when submitting other posts.
As far as your problem goes, it was hard for me to follow everything but something that might be causing the issue is the spec for moving Tipo, Percentuale & Importo under the "ScontoMaggiorazione" object in the first transformation as in the following:
...
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[&1].Tipo"
...
If you are trying to group those values under an array then use # instead of &1 , as follows:
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[#].Tipo"
Using &1 ended up creating null object which probably caused the generation of "Importo" : "." in later transformation.
If that helps please accept solution.
Created 10-31-2023 11:59 AM
Created 10-31-2023 12:47 PM
There is a lot to take here. It would be better if you always can simplify the problem by removing redundancy and isolating it where you can only re create the scenario you are trying to resolve. You dont have to use the exact data specially when its not worded in English as you can spend sometime trying to create a dummy data that resemble your structure which is easy to understand and readable by others. Keep in mind the more time you spend simplifying and articulating your problem the higher the chances it will get attention and the it will get resolved. Please keep that in mind when submitting other posts.
As far as your problem goes, it was hard for me to follow everything but something that might be causing the issue is the spec for moving Tipo, Percentuale & Importo under the "ScontoMaggiorazione" object in the first transformation as in the following:
...
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[&1].Tipo"
...
If you are trying to group those values under an array then use # instead of &1 , as follows:
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[#].Tipo"
Using &1 ended up creating null object which probably caused the generation of "Importo" : "." in later transformation.
If that helps please accept solution.
Created on 10-31-2023 11:43 PM - edited 10-31-2023 11:54 PM
Thanks A lot as Always @SAMSAL for answering all my Jolt Doubts and sharing the knowledge with detailed explanation. I've huge jolt this is one part of it, whenever i'm posting for only one specific issue always. Yeah i know this is hardest part to understand italian chars, the input is english and we are converting to italian whatever i've posted above is second jolt which i'm using. i would have given less input instead of all line items. sorry for that
one doubt it is why modify-overwrite-beta logic is not working if i place this above Shift,