refs #3074 taxableBase
This commit is contained in:
parent
998f00da49
commit
bed85c7ddb
modules/invoiceIn/front/tax
|
@ -11,7 +11,6 @@
|
|||
'transactionTypeSageFk']"
|
||||
link="{invoiceInFk: $ctrl.$params.id}"
|
||||
data="$ctrl.taxes"
|
||||
on-data-change="$ctrl.calculateTotals()"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
|
@ -28,7 +27,7 @@
|
|||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-auto class="totalBox">
|
||||
<span td class="chip"><vn-label translate>Taxable base</vn-label> {{$ctrl.totalTaxableBase | currency: 'EUR':2 | dashIfEmpty}}</span>
|
||||
<span td class="chip"><vn-label translate>Taxable base</vn-label> {{$ctrl.taxableBase | currency: 'EUR':2 | dashIfEmpty}}</span>
|
||||
<p><vn-label translate>Total</vn-label> {{$ctrl.totalVat | currency: 'EUR':2 | dashIfEmpty}}</p>
|
||||
</vn-auto>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -11,31 +11,21 @@ class Controller extends Section {
|
|||
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
|
||||
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
|
||||
|
||||
if (taxTypeSage && taxableBase) {
|
||||
invoiceInTax.rate = (taxTypeSage / 100) * taxableBase;
|
||||
return invoiceInTax.rate;
|
||||
}
|
||||
this.calculateTotals();
|
||||
return 0;
|
||||
}
|
||||
set taxes(value) {
|
||||
this._taxes = value;
|
||||
|
||||
if (value) this.calculateTotals();
|
||||
invoiceInTax.rate = taxTypeSage && taxableBase ? (taxTypeSage / 100) * taxableBase : 0;
|
||||
return invoiceInTax.rate;
|
||||
}
|
||||
|
||||
get taxes() {
|
||||
return this._taxes;
|
||||
get taxableBase() {
|
||||
if (!this.taxes) return;
|
||||
return this.taxes.reduce(
|
||||
(a, tax) => a + (tax.taxableBase || 0), 0);
|
||||
}
|
||||
|
||||
calculateTotals() {
|
||||
if (!this._taxes) return;
|
||||
this.totalTaxableBase = 0;
|
||||
this.totalVat = 0;
|
||||
for (let tax of this._taxes) {
|
||||
this.totalTaxableBase += tax.taxableBase;
|
||||
this.totalVat += tax.rate || 0;
|
||||
}
|
||||
get totalVat() {
|
||||
if (!this.taxes) return;
|
||||
const tax = this.taxes.reduce(
|
||||
(a, tax) => a + tax.rate, 0);
|
||||
return this.taxableBase + tax;
|
||||
}
|
||||
|
||||
add() {
|
||||
|
|
Loading…
Reference in New Issue