Seeking guidance on calculating a total for a vue.js list that contains invoice items. To illustrate, let's consider a scenario where a table of invoice items is being rendered. Here is the code snippet:
<table>
<template v-for="(invoice_item, index) in invoice_items" v-if="invoice_item.category === 'widgets'">
<tr>
<td>@{{ invoice_item.name }}</td>
<td><input type="number" class="inline-edit" v-model="invoice_item.rate"></td>
<td><input type="number" class="inline-edit" v-model="invoice_item.quantity"></td>
<td><input type="number" class="inline-edit" v-model="invoice_item.activation_fee"></td>
<td class="subtotal">@{{ computeSubTotal(invoice_item) }}</td>
</tr>
</template>
</table>
An individual subtotal is calculated for each row and displayed in the final column using the Vue.js JavaScript function below:
computeSubTotal: function(invoice_item) {
return(this.formatPrice((parseFloat(invoice_item.rate) * parseFloat(invoice_item.quantity) + parseFloat(invoice_item.activation_fee))));
},
The current setup works effectively. However, the objective now is to show the total sum of all subtotals from the listed invoice items:
https://i.sstatic.net/9Qjwc.png
How can this be achieved?
Appreciate any input!