2021-02-10 14:03:11 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Descriptor from 'salix/components/descriptor';
|
|
|
|
|
|
|
|
class Controller extends Descriptor {
|
2021-02-12 11:19:42 +00:00
|
|
|
get invoiceIn() {
|
2021-02-10 14:03:11 +00:00
|
|
|
return this.entity;
|
|
|
|
}
|
|
|
|
|
2021-02-12 11:19:42 +00:00
|
|
|
set invoiceIn(value) {
|
2021-02-10 14:03:11 +00:00
|
|
|
this.entity = value;
|
|
|
|
}
|
|
|
|
|
2021-04-12 10:43:17 +00:00
|
|
|
get entryFilter() {
|
|
|
|
if (this.invoiceIn)
|
|
|
|
return JSON.stringify({invoiceInFk: this.invoiceIn.id});
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
get invoiceInFilter() {
|
|
|
|
if (this.invoiceIn)
|
|
|
|
return JSON.stringify({supplierFk: this.invoiceIn.supplierFk});
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteInvoiceIn() {
|
|
|
|
return this.$http.delete(`InvoiceIns/${this.id}`)
|
|
|
|
.then(() => this.$state.go('invoiceIn.index'))
|
|
|
|
.then(() => this.vnApp.showSuccess(this.$t('InvoiceIn deleted')));
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:06:48 +00:00
|
|
|
cloneInvoiceIn() {
|
|
|
|
return this.$http.post(`InvoiceIns/${this.id}/clone`)
|
|
|
|
.then(res => this.$state.go('invoiceIn.card.summary', {id: res.data.id}))
|
|
|
|
.then(() => this.vnApp.showSuccess(this.$t('InvoiceIn cloned')));
|
|
|
|
}
|
|
|
|
|
2021-02-10 14:03:11 +00:00
|
|
|
loadData() {
|
|
|
|
const filter = {
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'company',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'code']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2021-02-12 11:19:42 +00:00
|
|
|
return this.getData(`InvoiceIns/${this.id}`, {filter})
|
2021-02-10 14:03:11 +00:00
|
|
|
.then(res => this.entity = res.data);
|
|
|
|
}
|
2021-09-24 06:24:34 +00:00
|
|
|
toBook() {
|
|
|
|
return this.$http.post(`InvoiceIns/${this.id}/toBook`)
|
|
|
|
.then(() => this.vnApp.showSuccess(this.$t('InvoiceIn booked')));
|
|
|
|
}
|
2021-02-10 14:03:11 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 11:19:42 +00:00
|
|
|
ngModule.vnComponent('vnInvoiceInDescriptor', {
|
2021-02-10 14:03:11 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2021-02-12 11:19:42 +00:00
|
|
|
invoiceIn: '<'
|
2021-02-10 14:03:11 +00:00
|
|
|
}
|
|
|
|
});
|