Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on 05-11-2023 11:16 AM - edited 05-11-2023 11:18 AM
i'm trying to perform Importo= importo/Quantita for each line item value.
but unable get the division even though i've used =divide function. Could you please help me
input:
{
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": [
{
"NumeroLinea": 1,
"Quantita": "3.0",
"PrezzoUnitario": "311.55000000",
"AliquotaIVA": "22.00",
"ScontoMaggiorazione": [
{
"Tipo": "SC",
"Percentuale": "28.00",
"Importo": "261.69"
}
],
"Descrizione": "B66450458 SACCA DA GOLF",
"PrezzoTotale": "672.96000000"
},
{
"NumeroLinea": 2,
"Quantita": "1.00000000",
"PrezzoUnitario": "311.55000000",
"AliquotaIVA": "22.00",
"ScontoMaggiorazione": [
{
"Tipo": "SC",
"Percentuale": "28.00",
"Importo": "87.23000000"
}
],
"Descrizione": "B66450458 SACCA DA GOLF",
"PrezzoTotale": "224.32000000"
},
{
"NumeroLinea": 3,
"Quantita": "1.00000000",
"PrezzoUnitario": "311.55000000",
"AliquotaIVA": "22.00",
"ScontoMaggiorazione": [
{
"Tipo": "SC",
"Percentuale": "28.00",
"Importo": "87.23000000"
}
],
"Descrizione": "B66450458 SACCA DA GOLF",
"PrezzoTotale": "224.32000000"
},
{
"NumeroLinea": 4,
"Quantita": "3.00000000",
"PrezzoUnitario": "2150.00000000",
"AliquotaIVA": "22.00",
"ScontoMaggiorazione": [
{
"Tipo": "SC",
"Percentuale": "16.00",
"Importo": "1032.00000000"
}
],
"Descrizione": "A205330410780 INGRANAGGI E DIFFER. ANT.",
"PrezzoTotale": "5418.00000000"
},
{
"NumeroLinea": 5,
"Quantita": "7.00000000",
"PrezzoUnitario": "202.96000000",
"AliquotaIVA": "22.00",
"ScontoMaggiorazione": [
{
"Tipo": "SC",
"Percentuale": "19.00",
"Importo": "269.92000000"
}
],
"Descrizione": "A6510108918 COPERCHIO TESTATA CIL.",
"PrezzoTotale": "1150.80000000"
}
]
}
}
}
Jolt Spec:
[{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"ScontoMaggiorazione": {
"*": {
"Importo": "=divide(@(1,Importo),@(1,Quantita))"
}
}
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"NumeroLinea": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].NumeroLinea",
"Descrizione": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].Descrizione",
"Quantita": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].Quantita",
"PrezzoUnitario": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].PrezzoUnitario",
"ScontoMaggiorazione": {
"*": {
"Importo": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].ScontoMaggiorazione[&3].Importo"
}
}
}
}
}
}
}
}]
Created 05-11-2023 11:43 AM
Hi,
Please see the modified spec below. The comments indicate what I had to do to make your modify-overwrite-beta spec works based on the input json. I hope it works.
[{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
// The DatiGenerali level is not found in the input JSON
// "DatiGenerali": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
//level3
"ScontoMaggiorazione": {
// level2
"*": {
// Quantita is located level 3 and not level 1
"Importo": "=divide(@(1,Importo),@(3,Quantita))"
}
}
}
}
}
//}
}
}
}]
Created on 05-11-2023 03:50 PM - edited 05-11-2023 03:51 PM
I think you had it right but you need to convert the division value into string before applying split on it. Here are the steps:
"decImporto": "=divide(@(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))"
Created 05-11-2023 11:43 AM
Hi,
Please see the modified spec below. The comments indicate what I had to do to make your modify-overwrite-beta spec works based on the input json. I hope it works.
[{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
// The DatiGenerali level is not found in the input JSON
// "DatiGenerali": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
//level3
"ScontoMaggiorazione": {
// level2
"*": {
// Quantita is located level 3 and not level 1
"Importo": "=divide(@(1,Importo),@(3,Quantita))"
}
}
}
}
}
//}
}
}
}]
Created 05-11-2023 12:15 PM
Thanks @SAMSAL for the quick help. division got worked
but after this division the value coming with 2 decimal values , where as i needed 8 decimal points after the dot. so far that i've used below logic in the same spec. but its giving empty value.
"ScontoMaggiorazione": {
"*": {
"first_Importo": "=divide(@(1,Importo),@(3,Quantita))",
"array_importo": "=split('.',@(1,first_Importo))",
"pad_importo": "=rightPad(@(1,array_importo[1]), 8, '0')",
"Importo": "=concat(@(1,array_importo[0]),'.',@(1,pad_importo))"
}
any idea on this too?
Created on 05-11-2023 03:50 PM - edited 05-11-2023 03:51 PM
I think you had it right but you need to convert the division value into string before applying split on it. Here are the steps:
"decImporto": "=divide(@(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))"