import ngModule from '../../module'; import Dialog from 'core/components/dialog'; import './style.scss'; class Controller extends Dialog { constructor($element, $, $transclude) { super($element, $, $transclude); this.isInvoicing = false; this.invoice = { maxShipped: new Date() }; } responseHandler(response) { try { if (response !== 'accept') return super.responseHandler(response); if (this.invoice.clientFk && !this.invoice.maxShipped) throw new Error('Client and the max shipped should be filled'); if (!this.invoice.serial || !this.invoice.taxArea) throw new Error('Some fields are required'); this.isInvoicing = true; return this.$http.post(`InvoiceOuts/createManualInvoice`, this.invoice) .then(res => { this.$state.go('invoiceOut.card.summary', {id: res.data.id}); super.responseHandler(response); }) .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) .finally(() => this.isInvoicing = false); } catch (e) { this.vnApp.showError(this.$t(e.message)); this.isInvoicing = false; return false; } } } Controller.$inject = ['$element', '$scope', '$transclude']; ngModule.vnComponent('vnInvoiceOutManual', { slotTemplate: require('./index.html'), controller: Controller, bindings: { ticketFk: '