diff --git a/modules/invoiceOut/front/global-invoicing/index.html b/modules/invoiceOut/front/global-invoicing/index.html index 1b14a72f6..ed772cf9c 100644 --- a/modules/invoiceOut/front/global-invoicing/index.html +++ b/modules/invoiceOut/front/global-invoicing/index.html @@ -1,46 +1,46 @@ -
- - - - - - Id - Status - - - - - - - {{::client.id}} - - - - - - - - - - - - - - - -
+

{{'Calculating packages to invoice...'}}

+ + + + + Id + Address + Status + + + + + + + {{::client.id}} + + + + {{::client.address}} + + + + + + + + + + + + + + - + diff --git a/modules/invoiceOut/front/global-invoicing/index.js b/modules/invoiceOut/front/global-invoicing/index.js index 0750d8d6c..07d76626d 100644 --- a/modules/invoiceOut/front/global-invoicing/index.js +++ b/modules/invoiceOut/front/global-invoicing/index.js @@ -40,7 +40,6 @@ class Controller extends Section { } restartValues() { - this.lastClientId = null; this.$.invoiceButton.disabled = false; } @@ -52,7 +51,6 @@ class Controller extends Section { invoiceOut(invoice, clientsAndAddresses) { const [clientAndAddress] = clientsAndAddresses; if (!clientAndAddress) return; - this.currentClientId = clientAndAddress.clientId; const params = { clientId: clientAndAddress.clientId, addressId: clientAndAddress.addressId, @@ -63,7 +61,14 @@ class Controller extends Section { }; - const index = this.$.data.findIndex(element => element.id == clientAndAddress.clientId); + this.$.data.push({ + id: clientAndAddress.clientId, + address: clientAndAddress.addressId, + status: 'waiting' + }); + const index = this.$.data.findIndex( + client => client.id == clientAndAddress.clientId && client.address == clientAndAddress.addressId + ); return this.$http.post(`InvoiceOuts/invoiceClient`, params) .then(() => { this.$.data[index].status = 'ok'; @@ -84,26 +89,13 @@ class Controller extends Section { throw new Error('Choose a valid clients range'); this.$.invoiceButton.disabled = true; + this.$.data = []; this.packageInvoicing = true; this.$http.post(`InvoiceOuts/clientsToInvoice`, this.invoice) .then(res => { this.packageInvoicing = false; const invoice = res.data.invoice; - - const clientsIds = []; - for (const clientAndAddress of res.data.clientsAndAddresses) - clientsIds.push(clientAndAddress.clientId); - const dataArr = new Set(clientsIds); - const clientsIdsNoRepeat = [...dataArr]; - const clients = clientsIdsNoRepeat.map(clientId => { - return { - id: clientId, - status: 'waiting' - }; - }); - this.$.data = clients; - const clientsAndAddresses = res.data.clientsAndAddresses; if (!clientsAndAddresses.length) throw new UserError(`There aren't clients to invoice`); 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 5c556fa39..3a0176845 100644 --- a/modules/invoiceOut/front/global-invoicing/locale/es.yml +++ b/modules/invoiceOut/front/global-invoicing/locale/es.yml @@ -4,4 +4,6 @@ Invoice date: Fecha de factura Invoice date and the max date should be filled: La fecha de factura y la fecha límite deben rellenarse Choose a valid clients range: Selecciona un rango válido de clientes Clients range: Rango de clientes +All clients: Todos los clientes Calculating packages to invoice...: Calculando paquetes a factura... +Clean: Limpiar