salix/modules/invoiceIn/front/tax/index.js

62 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-06-09 08:20:18 +00:00
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
}
2021-06-16 16:36:42 +00:00
/*
get invoiceIn() {
return this._invoiceIn;
}
set invoiceIn(value) {
this._invoiceIn = value;
if (value) {
const filter = {
currency: this.invoiceIn.currency
}
this.$http.get(`ReferenceRates`, {filter})
.then(res => this.referenceRate = res.data);
}
}*/
2021-06-25 05:47:53 +00:00
get setTaxRate() {
return this._setTaxRate;
}
set setTaxRate(selection) {
this._setTaxRate = selection;
const taxTypeSage = this.$.taxTypeSage.selection;
const taxableBase = this.$.taxableBase.value;
if (taxTypeSage && taxableBase)
this.taxRate = (taxTypeSage.rate / 100) * taxableBase;
}
2021-06-09 08:20:18 +00:00
add() {
2021-06-16 16:36:42 +00:00
const defaultExpenseFk = 6000000001;
2021-06-09 08:20:18 +00:00
this.$.model.insert({
invoiceIn: this.$params.id,
2021-06-16 16:36:42 +00:00
expenseFk: defaultExpenseFk
2021-06-09 08:20:18 +00:00
});
}
onSubmit() {
this.$.watcher.check();
this.$.model.save().then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
this.card.reload();
});
}
}
ngModule.vnComponent('vnInvoiceInTax', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnInvoiceInCard'
},
bindings: {
invoiceIn: '<'
}
});