mirror of
https://github.com/mokuappio/serverless-invoices.git
synced 2026-02-07 08:31:42 -05:00
Fix invoice totals in list. Don't store full client in invoices.
This commit is contained in:
@@ -177,14 +177,5 @@ export default {
|
||||
.orderBy('number', 'desc')
|
||||
.get();
|
||||
},
|
||||
subTotal(state, getters) {
|
||||
return getters.invoice.rows.reduce((carr, row) => (row.quantity * row.price) + carr, 0);
|
||||
},
|
||||
total(state, getters) {
|
||||
return getters.subTotal + getters.totalVat;
|
||||
},
|
||||
totalVat(state, getters) {
|
||||
return (getters.invoice.vat_rate / 100) * getters.subTotal;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -48,4 +48,25 @@ export default class Invoice extends Model {
|
||||
total: this.attr(null), // Only used in lists.
|
||||
};
|
||||
}
|
||||
|
||||
get subTotal() {
|
||||
return this.rows.reduce((carr, row) => (row.quantity * row.price) + carr, 0);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-empty-function
|
||||
set subTotal(val) {}
|
||||
|
||||
get total() {
|
||||
return this.subTotal + this.totalVat;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-empty-function
|
||||
set total(val) {}
|
||||
|
||||
get totalVat() {
|
||||
return (this.vat_rate / 100) * this.subTotal;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-empty-function
|
||||
set totalVat(val) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user