refactor code
This commit is contained in:
parent
2d1b48280c
commit
86d24ffede
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue