0๐
You need to make computed properties they will recompute any time a dependancy is changed, for example:
subtotal_with_ewa(){
return Number((this.subtotal_price / 100) *
this.unit.reservation.prices.ewa_parentage) + Number(this.subtotal_price);
}
You can use getters and setters with computed properties or separate them from the bound v-model on the fields.
- [Vuejs]-Can not load external script js file wtih spring
- [Vuejs]-Initialize vuex store data at startup in a Vue-Electron App using v-model
0๐
The below functions should solve the problem.
the function accepts the percentage of each tax as argument and returns a json will all the values.
function fromSubTotal(subTotal, pre, vato, tx) {
const preAmount = subTotal * pre / 100
const vatoAmount = (subTotal + pre) * vato / 100
const txAmount = subTotal * tx / 100
const total = subTotal + preAmount + vatoAmount + txAmount
return {subTotal, preAmount, vatoAmount, txAmount, total}
}
function fromTotal(total, pre, vato, tx) {
const subTotal = (total * 100) / (100 + pre + tx + (1.01 * pre * vato))
return fromSubTotal(subTotal, pre, vato, tx)
}
// eg.
console.log(fromSubTotal(100,1,1,1))
console.log(fromTotal(103.01,1,1,1))
Source:stackexchange.com