diff --git a/modules/invoiceOut/front/global-invoicing/index.html b/modules/invoiceOut/front/global-invoicing/index.html index cf307959a..8f1e909e1 100644 --- a/modules/invoiceOut/front/global-invoicing/index.html +++ b/modules/invoiceOut/front/global-invoicing/index.html @@ -3,11 +3,10 @@
Invoicing
- {{'Client' | translate}}: {{$ctrl.currentClient}} - {{'of' | translate}} {{::$ctrl.clients.length}} + {{'Current client id' | translate}}: {{$ctrl.currentClientId}}
- {{($ctrl.percentage / 100) | percentage: 0}} + {{($ctrl.percentage / 100) | percentage: 0}} ({{$ctrl.currentClient}} {{'of' | translate}} {{$ctrl.clients.length}})
diff --git a/modules/invoiceOut/front/global-invoicing/index.js b/modules/invoiceOut/front/global-invoicing/index.js index 9ae3b498c..4e46d7a81 100644 --- a/modules/invoiceOut/front/global-invoicing/index.js +++ b/modules/invoiceOut/front/global-invoicing/index.js @@ -51,6 +51,7 @@ class Controller extends Section { const [clientAndAddress] = clientsAndAddresses; if (!clientAndAddress) return; + this.currentClientId = clientAndAddress.clientId; this.currentClient = ++this.currentClient; this.getPercentage(); @@ -67,23 +68,14 @@ class Controller extends Section { this.$http.get(`Addresses/${clientAndAddress.addressId}`) .then(res => { this.address = res.data; - - this.$.data.unshift({ - id: clientAndAddress.clientId, - address: this.address, - status: 'waiting' - }); - - const index = this.$.data.findIndex( - client => client.id == clientAndAddress.clientId && client.address.id == clientAndAddress.addressId - ); - return this.$http.post(`InvoiceOuts/invoiceClient`, params) - .then(() => { - this.$.data.shift(); - }).catch(res => { - this.$.data[index].status = 'error'; - this.$.data[index].error = res.data.error.message; + .catch(res => { + this.$.data.unshift({ + id: clientAndAddress.clientId, + address: this.address, + status: 'error', + error: res.data.error.message + }); }).finally(() => { clientsAndAddresses.shift(); return this.invoiceOut(invoice, clientsAndAddresses); @@ -110,13 +102,14 @@ class Controller extends Section { .then(res => { this.packageInvoicing = false; const invoice = res.data.invoice; + this.currentClient = 0; + const clientsAndAddresses = res.data.clientsAndAddresses; if (!clientsAndAddresses.length) throw new UserError(`There aren't clients to invoice`); this.clients = []; for (const clientAndAddress of clientsAndAddresses) this.clients.push(clientAndAddress.clientId); - this.currentClient = 0; return this.invoiceOut(invoice, clientsAndAddresses); }) diff --git a/modules/invoiceOut/front/global-invoicing/locale/es.yml b/modules/invoiceOut/front/global-invoicing/locale/es.yml index 3c6e1d154..5a453e5b9 100644 --- a/modules/invoiceOut/front/global-invoicing/locale/es.yml +++ b/modules/invoiceOut/front/global-invoicing/locale/es.yml @@ -15,5 +15,6 @@ Address id: Id dirección Printer: Impresora of: de Client: Cliente +Current client id: Id cliente actual Invoicing: Facturando Invoice out: Facturar