54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import ngModule from '../module';
|
|
import Descriptor from 'salix/components/descriptor';
|
|
|
|
class Controller extends Descriptor {
|
|
get invoiceOut() {
|
|
return this.entity;
|
|
}
|
|
|
|
set invoiceOut(value) {
|
|
this.entity = value;
|
|
}
|
|
|
|
deleteInvoiceOut() {
|
|
return this.$http.post(`InvoiceOuts/${this.id}/delete`)
|
|
.then(() => this.$state.go('invoiceOut.index'))
|
|
.then(() => this.vnApp.showSuccess(this.$t('InvoiceOut deleted')));
|
|
}
|
|
|
|
bookInvoiceOut() {
|
|
return this.$http.post(`InvoiceOuts/${this.invoiceOut.ref}/book`)
|
|
.then(() => this.$state.reload())
|
|
.then(() => this.vnApp.showSuccess(this.$t('InvoiceOut booked')));
|
|
}
|
|
|
|
loadData() {
|
|
const filter = {
|
|
include: [
|
|
{
|
|
relation: 'company',
|
|
scope: {
|
|
fields: ['id', 'code']
|
|
}
|
|
}, {
|
|
relation: 'client',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
return this.getData(`InvoiceOuts/${this.id}`, {filter})
|
|
.then(res => this.entity = res.data);
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnInvoiceOutDescriptor', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
invoiceOut: '<'
|
|
}
|
|
});
|