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

41 lines
972 B
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
taxRate(invoiceInTax, taxRateSelection) {
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
if (taxTypeSage && taxableBase)
return (taxTypeSage / 100) * taxableBase;
return 0;
}
add() {
this.$.model.insert({
invoiceIn: this.$params.id
});
}
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: '<'
}
});