salix/modules/invoiceOut/front/descriptor/index.js

71 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-03-26 13:27:08 +00:00
import ngModule from '../module';
2020-04-25 09:50:04 +00:00
import Descriptor from 'salix/components/descriptor';
2019-03-26 13:27:08 +00:00
2020-04-25 09:50:04 +00:00
class Controller extends Descriptor {
2019-03-26 13:27:08 +00:00
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')));
}
2021-03-15 12:43:22 +00:00
createInvoicePdf() {
const invoiceId = this.invoiceOut.id;
return this.$http.post(`InvoiceOuts/${invoiceId}/createPdf`)
.then(() => {
const snackbarMessage = this.$t(
`The invoice PDF document has been regenerated`);
this.vnApp.showSuccess(snackbarMessage);
});
}
2020-05-29 09:10:58 +00:00
get filter() {
if (this.invoiceOut)
return JSON.stringify({refFk: this.invoiceOut.ref});
return null;
}
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);
}
2019-03-26 13:27:08 +00:00
}
2020-04-25 09:50:04 +00:00
ngModule.vnComponent('vnInvoiceOutDescriptor', {
2019-03-26 13:27:08 +00:00
template: require('./index.html'),
2020-04-25 09:50:04 +00:00
controller: Controller,
2019-03-26 13:27:08 +00:00
bindings: {
2020-04-25 09:50:04 +00:00
invoiceOut: '<'
}
2019-03-26 13:27:08 +00:00
});