falta selection
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javi Gallego 2022-11-14 17:58:44 +01:00
parent bed85c7ddb
commit 3c1f86f171
2 changed files with 10 additions and 9 deletions

View File

@ -9,6 +9,10 @@
'foreignValue',
'taxTypeSageFk',
'transactionTypeSageFk']"
include="{
relation: 'taxTypeSage',
scope: {fields: ['id', 'rate']}
}"
link="{invoiceInFk: $ctrl.$params.id}"
data="$ctrl.taxes"
auto-load="true">
@ -61,7 +65,6 @@
show-field="vat"
fields="['id', 'vat', 'rate']"
search-function="{or: [{id: $search}, {vat: {like: '%'+ $search +'%'}}]}"
selection="taxRateSelection"
rule>
<tpl-item>{{id}}: {{vat}}</tpl-item>
</vn-autocomplete>
@ -77,7 +80,7 @@
<vn-textfield
disabled="true"
label="Rate"
field="$ctrl.taxRate(invoiceInTax, taxRateSelection) | currency:'EUR':2">
field="$ctrl.taxRate(invoiceInTax) | currency:'EUR':2">
</vn-textfield>
<vn-input-number
disabled="$ctrl.invoiceIn.currency.code == 'EUR'"

View File

@ -3,16 +3,14 @@ import Section from 'salix/components/section';
import UserError from 'core/lib/user-error';
class Controller extends Section {
constructor($element, $, vnWeekDays) {
constructor($element, $) {
super($element, $);
this.expense = {};
}
taxRate(invoiceInTax, taxRateSelection) {
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
invoiceInTax.rate = taxTypeSage && taxableBase ? (taxTypeSage / 100) * taxableBase : 0;
return invoiceInTax.rate;
taxRate(tax) {
if (!tax || !tax.taxTypeSage) return 0;
return (tax.taxTypeSage.rate / 100) * tax.taxableBase;
}
get taxableBase() {
@ -24,7 +22,7 @@ class Controller extends Section {
get totalVat() {
if (!this.taxes) return;
const tax = this.taxes.reduce(
(a, tax) => a + tax.rate, 0);
(a, tax) => a + this.taxRate(tax), 0);
return this.taxableBase + tax;
}