Open gurveenbagga opened 2 years ago
@gurveenbagga This spec of mine can achieve the effect you want, I hope it can help you. In addition, there is a jolt tutorial project, welcome to communicate and discuss jolt-universe.
[
{
"operation": "shift",
"spec": {
"*": {
"returnId": "[#2].returnId",
"returnItemAdjustments": {
"*": {
"amount": "[#4].returnTax[]"
}
}
}
}
}, {
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"returnTax": "=doubleSum(@(1,returnTax))"
}
}
}
]
This spec can also help you get the desired result
[
{
"operation": "shift",
"spec": {
"*": {
"returnItemAdjustments": {
"*": {
"returnAdjustmentTypeId": {
"RET_SALES_TAX_ADJ": {
"@(2,amount)": "[&5].returnSalesTaxAmount[]"
}
}
}
},
"@": "[&]"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"returnSalesTaxTotalAmount": "=doubleSum(@(1,returnSalesTaxAmount))"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"returnId": "[&1].returnId",
"returnSalesTaxTotalAmount": "[&1].returnTax"
}
}
}
]
We have a requirement to find the sum of a particular key type from a list. The type may repeat in the list i.e it can have multiple values in the list.
Here, we want to get the sum of amount field values from the returnItemAdjustments list with returnAdjustmentTypeId = 'RET_SALES_TAX_ADJ'.
Sample Input:
Expected output:
Can some one help to identify the possible Jolt Spec for this problem statement?