division of two fields using jolt spec
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"
}
}
}
}
}
}
}
}]

