I am looking to calculate the running balance by subtracting AmountApplied
from Amort
. Here is the desired output:
Line Amort Total Payment Running Balance
1 30250 10000 20250.00
30250 20250 0.00
2 30250 30250 0.00
In my Vue component:
<table>
//...
<tbody v-for="(fetch,count,idx) in soaData">
<tr>
// code
</tr>
<template v-for="(subFetch,count) in fetch.subPayments" >
<tr>
<td class="text-right">{{subFetch.AmountApplied | formatNum}}</td>
<td class="text-right">{{getRunningBal(fetch.subPayments,fetch.amortId)}}</td>
</tr>
</template>
</tbody>
</table>
Inside my methods:
getRunningBal(subPayments,amortId){
let subpayCount = Object.values(this.soaData[amortId].subPayments).length
let data = Object.values(this.soaData[amortId].subPayments)
var total = 0;
for(let i=0; i < subpayCount; i++){
return total += data[i].AmountApplied)
}
Sample data structure:
{
"267": {
"Ndays": 9,
...
},
"270": {
"Ndays": 12,
...
}
}