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

41 lines
972 B
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 {
2021-08-09 12:06:23 +00:00
taxRate(invoiceInTax, taxRateSelection) {
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
2021-06-29 06:59:55 +00:00
2021-06-25 05:47:53 +00:00
if (taxTypeSage && taxableBase)
2021-08-09 12:06:23 +00:00
return (taxTypeSage / 100) * taxableBase;
return 0;
2021-06-25 05:47:53 +00:00
}
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: '<'
}
});