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',
type: 'number',
description: 'The maximum client id',
required: false
description: 'The maximum client id'
},
{
arg: 'companyFk',

View File

@ -58,7 +58,7 @@ class Controller extends Dialog {
if (!this.invoice.invoiceDate || !this.invoice.maxShipped)
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');
this.on('close', () => {
@ -71,11 +71,11 @@ class Controller extends Dialog {
return this.$http.post(`InvoiceOuts/clientToInvoice`, this.invoice)
.then(async res => {
const clientsAndAddresses = res.data.clientsAndAddresses;
const invoice = res.data.invoice;
const clientsAndAddresses = res.data.clientsAndAddresses;
if (!clientsAndAddresses.length) return super.responseHandler(response);
this.lastClientId = clientsAndAddresses[clientsAndAddresses.length - 1].clientId;
for (let clientAndAddress of clientsAndAddresses) {
this.currentClientId = clientAndAddress.clientId;
const params = {
@ -98,8 +98,8 @@ class Controller extends Dialog {
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
.finally(() => this.restartValues());
} catch (e) {
this.restartValues();
this.vnApp.showError(this.$t(e.message));
this.restartValues();
return false;
}
}