refactor code

This commit is contained in:
Vicent Llopis 2022-10-17 13:02:03 +02:00
parent 2d1b48280c
commit 86d24ffede
2 changed files with 5 additions and 6 deletions

View File

@ -21,8 +21,7 @@ module.exports = Self => {
{ {
arg: 'toClientId', arg: 'toClientId',
type: 'number', type: 'number',
description: 'The maximum client id', description: 'The maximum client id'
required: false
}, },
{ {
arg: 'companyFk', arg: 'companyFk',

View File

@ -58,7 +58,7 @@ class Controller extends Dialog {
if (!this.invoice.invoiceDate || !this.invoice.maxShipped) if (!this.invoice.invoiceDate || !this.invoice.maxShipped)
throw new Error('Invoice date and the max date should be filled'); throw new Error('Invoice date and the max date should be filled');
if (!this.invoice.fromClientId) if (!this.invoice.fromClientId || !this.invoice.toClientId)
throw new Error('Choose a valid clients range'); throw new Error('Choose a valid clients range');
this.on('close', () => { this.on('close', () => {
@ -71,11 +71,11 @@ class Controller extends Dialog {
return this.$http.post(`InvoiceOuts/clientToInvoice`, this.invoice) return this.$http.post(`InvoiceOuts/clientToInvoice`, this.invoice)
.then(async res => { .then(async res => {
const clientsAndAddresses = res.data.clientsAndAddresses;
const invoice = res.data.invoice; const invoice = res.data.invoice;
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;
for (let clientAndAddress of clientsAndAddresses) { for (let clientAndAddress of clientsAndAddresses) {
this.currentClientId = clientAndAddress.clientId; this.currentClientId = clientAndAddress.clientId;
const params = { const params = {
@ -98,8 +98,8 @@ class Controller extends Dialog {
.then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) .then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
.finally(() => this.restartValues()); .finally(() => this.restartValues());
} catch (e) { } catch (e) {
this.restartValues();
this.vnApp.showError(this.$t(e.message)); this.vnApp.showError(this.$t(e.message));
this.restartValues();
return false; return false;
} }
} }