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

47 lines
1.1 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
2021-06-30 06:26:03 +00:00
get taxRateSelection() {
return this._taxRateSelection;
2021-06-25 05:47:53 +00:00
}
2021-06-29 06:59:55 +00:00
2021-06-30 06:26:03 +00:00
set taxRateSelection(selection) {
this._taxRateSelection = selection;
2021-06-25 05:47:53 +00:00
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() {
this.$.model.insert({
2021-06-29 06:59:55 +00:00
invoiceIn: this.$params.id
2021-06-09 08:20:18 +00:00
});
}
2021-06-29 06:59:55 +00:00
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: '<'
}
});