4090-global_invoincing #1135
|
@ -50,15 +50,32 @@ class Controller extends Dialog {
|
||||||
this.$.invoiceButton.disabled = false;
|
this.$.invoiceButton.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice() {
|
invoiceOut(invoice, clientsAndAddresses) {
|
||||||
const clientAndAddress = clientsAndAddresses[this.pos];
|
const clientAndAddress = clientsAndAddresses[this.pos];
|
||||||
return this.post(`InvoiceOuts/globalInvoicing`, params, options).then(() => {
|
if (!clientAndAddress) return;
|
||||||
this.pos++;
|
this.currentClientId = clientAndAddress.clientId;
|
||||||
this.invoice();
|
const params = {
|
||||||
});
|
clientId: clientAndAddress.clientId,
|
||||||
|
addressId: clientAndAddress.addressId,
|
||||||
|
invoiceDate: invoice.invoiceDate,
|
||||||
|
maxShipped: invoice.maxShipped,
|
||||||
|
companyFk: invoice.companyFk,
|
||||||
|
minShipped: invoice.minShipped,
|
||||||
|
|
||||||
|
};
|
||||||
|
this.canceler = this.$q.defer();
|
||||||
|
const options = {
|
||||||
|
timeout: this.canceler.promise
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.$http.post(`InvoiceOuts/globalInvoicing`, params, options)
|
||||||
|
.then(() => {
|
||||||
|
this.pos++;
|
||||||
|
return this.invoiceOut(invoice, clientsAndAddresses);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async responseHandler(response) {
|
responseHandler(response) {
|
||||||
try {
|
try {
|
||||||
if (response !== 'accept')
|
if (response !== 'accept')
|
||||||
return super.responseHandler(response);
|
return super.responseHandler(response);
|
||||||
|
@ -77,33 +94,14 @@ class Controller extends Dialog {
|
||||||
this.$.invoiceButton.disabled = true;
|
this.$.invoiceButton.disabled = true;
|
||||||
if (this.clientsNumber == 'allClients') this.getMaxClientId();
|
if (this.clientsNumber == 'allClients') this.getMaxClientId();
|
||||||
|
|
||||||
this.pos = 0;
|
|
||||||
this.invoice();
|
|
||||||
|
|
||||||
this.$http.post(`InvoiceOuts/clientToInvoice`, this.invoice)
|
this.$http.post(`InvoiceOuts/clientToInvoice`, this.invoice)
|
||||||
.then(async res => {
|
.then(res => {
|
||||||
const invoice = res.data.invoice;
|
const invoice = res.data.invoice;
|
||||||
const clientsAndAddresses = res.data.clientsAndAddresses;
|
const clientsAndAddresses = res.data.clientsAndAddresses;
|
||||||
if (!clientsAndAddresses.length) return super.responseHandler(response);
|
if (!clientsAndAddresses.length) return super.responseHandler(response);
|
||||||
this.lastClientId = clientsAndAddresses[clientsAndAddresses.length - 1].clientId;
|
this.lastClientId = clientsAndAddresses[clientsAndAddresses.length - 1].clientId;
|
||||||
|
this.pos = 0;
|
||||||
for (let clientAndAddress of clientsAndAddresses) {
|
return this.invoiceOut(invoice, clientsAndAddresses);
|
||||||
this.currentClientId = clientAndAddress.clientId;
|
|
||||||
const params = {
|
|
||||||
clientId: clientAndAddress.clientId,
|
|
||||||
addressId: clientAndAddress.addressId,
|
|
||||||
invoiceDate: invoice.invoiceDate,
|
|
||||||
maxShipped: invoice.maxShipped,
|
|
||||||
companyFk: invoice.companyFk,
|
|
||||||
minShipped: invoice.minShipped,
|
|
||||||
|
|
||||||
};
|
|
||||||
this.canceler = this.$q.defer();
|
|
||||||
const options = {
|
|
||||||
timeout: this.canceler.promise
|
|
||||||
};
|
|
||||||
await this.$http.post(`InvoiceOuts/globalInvoicing`, params, options).then();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.then(() => super.responseHandler(response))
|
.then(() => super.responseHandler(response))
|
||||||
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
|
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
|
||||||
|
|
Loading…
Reference in New Issue