4090-global_invoincing #1135

Merged
vicent merged 46 commits from 4090-global_invoincing into dev 2022-11-15 08:48:25 +00:00
1 changed files with 26 additions and 28 deletions
Showing only changes of commit 9d53360d50 - Show all commits

View File

@ -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.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
};
return this.$http.post(`InvoiceOuts/globalInvoicing`, params, options)
.then(() => {
this.pos++; this.pos++;
this.invoice(); 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!')))