diff --git a/modules/invoiceOut/front/index/global-invoicing/index.js b/modules/invoiceOut/front/index/global-invoicing/index.js index ffd5484e4..1390f52e8 100644 --- a/modules/invoiceOut/front/index/global-invoicing/index.js +++ b/modules/invoiceOut/front/index/global-invoicing/index.js @@ -51,7 +51,7 @@ class Controller extends Dialog { } invoiceOut(invoice, clientsAndAddresses) { - const clientAndAddress = clientsAndAddresses[this.pos]; + const [clientAndAddress] = clientsAndAddresses; if (!clientAndAddress) return; this.currentClientId = clientAndAddress.clientId; const params = { @@ -70,7 +70,7 @@ class Controller extends Dialog { return this.$http.post(`InvoiceOuts/invoiceClient`, params, options) .then(() => { - this.pos++; + clientsAndAddresses.shift(); return this.invoiceOut(invoice, clientsAndAddresses); }); } @@ -100,7 +100,6 @@ class Controller extends Dialog { const clientsAndAddresses = res.data.clientsAndAddresses; if (!clientsAndAddresses.length) return super.responseHandler(response); this.lastClientId = clientsAndAddresses[clientsAndAddresses.length - 1].clientId; - this.pos = 0; return this.invoiceOut(invoice, clientsAndAddresses); }) .then(() => super.responseHandler(response))