import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); } /* 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); } }*/ 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; } add() { const defaultExpenseFk = 6000000001; this.$.model.insert({ invoiceIn: this.$params.id, expenseFk: defaultExpenseFk }); } 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: '<' } });