From 67127554f9eac14714589c841f8ce7cb94774d6d Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 26 Jan 2023 13:12:53 +0100 Subject: [PATCH] feat: solo muestra los clientes con error y muestra los datos de manera distinta --- .../front/global-invoicing/index.html | 5 ++-- .../front/global-invoicing/index.js | 27 +++++++------------ .../front/global-invoicing/locale/es.yml | 1 + 3 files changed, 13 insertions(+), 20 deletions(-) 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