From 2f089681df8b64698c3d3508604f2bda82ae7ffc Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Feb 2020 12:52:05 +0100 Subject: [PATCH 1/3] Don't throw error if no salesPerson is assigned --- modules/ticket/back/methods/ticket/updateDiscount.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 66b4d6f95..8777a60fc 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -108,8 +108,10 @@ module.exports = Self => { await Promise.all(promises); - query = `call vn.manaSpellersRequery(?)`; - await Self.rawSql(query, [salesPersonId], options); + if (salesPersonId) { + const query = `call vn.manaSpellersRequery(?)`; + await Self.rawSql(query, [salesPersonId], options); + } await tx.commit(); } catch (error) { From bf4e0d09c5c3a52f870586776610b883d335f1e4 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Feb 2020 08:37:37 +0100 Subject: [PATCH 2/3] Get phone from address and client --- .../back/methods/client/createAddress.js | 26 +++++++------- .../back/methods/client/updateAddress.js | 24 ++++++------- .../back/methods/client/updateFiscalData.js | 36 +++++++++---------- modules/client/front/descriptor/index.js | 5 +-- modules/ticket/front/card/index.js | 4 ++- modules/ticket/front/descriptor/index.js | 4 ++- modules/ticket/front/sale/index.js | 5 ++- 7 files changed, 56 insertions(+), 48 deletions(-) diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index 0319fc386..1a086b124 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -5,60 +5,60 @@ module.exports = function(Self) { description: 'Creates client address updating default address', accepts: [{ arg: 'id', - type: 'Number', + type: 'number', description: 'The client id', http: {source: 'path'} }, { arg: 'nickname', - type: 'String', + type: 'string', required: true }, { arg: 'city', - type: 'String', + type: 'string', required: true }, { arg: 'street', - type: 'String', + type: 'string', required: true }, { arg: 'phone', - type: 'String' + type: 'string' }, { arg: 'mobile', - type: 'String' + type: 'string' }, { arg: 'postalCode', - type: 'String' + type: 'string' }, { arg: 'provinceId', - type: 'Number' + type: 'number' }, { arg: 'agencyModeId', - type: 'Number' + type: 'number' }, { arg: 'incotermsId', - type: 'String' + type: 'string' }, { arg: 'customsAgentId', - type: 'Number' + type: 'number' }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isDefaultAddress', - type: 'Boolean' + type: 'boolean' }], returns: { root: true, diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index b9270600f..aa0a7d178 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -10,55 +10,55 @@ module.exports = function(Self) { }, { arg: 'clientId', - type: 'Number', + type: ['number', 'null'], description: 'The client id', http: {source: 'path'} }, { arg: 'addressId', - type: 'Number', + type: ['number', 'null'], description: 'The address id', http: {source: 'path'} }, { arg: 'nickname', - type: 'String' + type: ['string'] }, { arg: 'city', - type: 'String' + type: ['string'] }, { arg: 'street', - type: 'String' + type: ['string'] }, { arg: 'phone', - type: 'String' + type: 'any' }, { arg: 'mobile', - type: 'String' + type: 'any' }, { arg: 'postalCode', - type: 'String' + type: 'any' }, { arg: 'provinceFk', - type: 'Number' + type: 'any' }, { arg: 'agencyModeFk', - type: 'Number' + type: 'any' }, { arg: 'incotermsFk', - type: 'String' + type: 'any' }, { arg: 'customsAgentFk', - type: 'Number' + type: 'any' }, { arg: 'isActive', diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 4bc6fda9b..f16b0ef2b 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -17,75 +17,75 @@ module.exports = Self => { }, { arg: 'socialName', - type: 'String' + type: 'string' }, { arg: 'fi', - type: 'String' + type: 'string' }, { arg: 'street', - type: 'String' + type: 'string' }, { arg: 'postcode', - type: 'String' + type: 'string' }, { arg: 'city', - type: 'String' + type: 'string' }, { arg: 'countryFk', - type: 'Number' + type: 'number' }, { arg: 'provinceFk', - type: 'Number' + type: 'number' }, { arg: 'hasToInvoiceByAddress', - type: 'Boolean' + type: 'boolean' }, { arg: 'hasToInvoice', - type: 'Boolean' + type: 'boolean' }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isFreezed', - type: 'Boolean' + type: 'boolean' }, { arg: 'isVies', - type: 'Boolean' + type: 'boolean' }, { arg: 'isToBeMailed', - type: 'Boolean' + type: 'boolean' }, { arg: 'isEqualizated', - type: 'Boolean' + type: 'boolean' }, { arg: 'isTaxDataVerified', - type: 'Boolean' + type: 'boolean' }, { arg: 'isTaxDataChecked', - type: 'Boolean' + type: 'boolean' }, { arg: 'despiteOfClient', - type: 'Number' + type: 'number' }], returns: { arg: 'res', - type: 'String', + type: 'string', root: true }, http: { diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 3ef1e7616..95754b4df 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -55,10 +55,11 @@ class Controller extends Component { } showSMSDialog() { - const phone = this.$params.phone || this.client.phone; + const client = this.client; + const phone = this.$params.phone || client.mobile || client.phone; const message = this.$params.message || ''; this.newSMS = { - destinationFk: this.client.id, + destinationFk: client.id, destination: phone, message: message }; diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 131968d65..3872259a9 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -27,7 +27,9 @@ class Controller extends ModuleCard { 'isFreezed', 'isTaxDataChecked', 'credit', - 'email' + 'email', + 'phone', + 'mobile' ], include: { relation: 'salesPerson', diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index 10da4cca9..d804a2eb2 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -241,7 +241,9 @@ class Controller extends Component { showSMSDialog() { const address = this.ticket.address; - const phone = this.$params.phone || address.mobile; + const client = this.ticket.client; + const phone = this.$params.phone || address.mobile || address.phone || + client.mobile || client.phone; const message = this.$params.message || this.$translate.instant('SMSPayment'); this.newSMS = { destinationFk: this.ticket.clientFk, diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index d0854c996..1ecb6fe41 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -431,6 +431,9 @@ class Controller { showSMSDialog() { const address = this.ticket.address; + const client = this.ticket.client; + const phone = address.mobile || address.phone || + client.mobile || client.phone; const sales = this.checkedLines(); const items = sales.map(sale => { return `${sale.quantity} ${sale.concept}`; @@ -443,7 +446,7 @@ class Controller { }; this.newSMS = { destinationFk: this.ticket.clientFk, - destination: address.mobile || null, + destination: phone, message: this.$translate.instant('SMSAvailability', params) }; this.$scope.sms.open(); From 2dbde24a990a5fffed4f449debc2004dce6393ad Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Feb 2020 09:00:13 +0100 Subject: [PATCH 3/3] Requested changes --- .../client/back/methods/client/updateAddress.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index aa0a7d178..db8ed38d6 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -10,27 +10,27 @@ module.exports = function(Self) { }, { arg: 'clientId', - type: ['number', 'null'], + type: 'number', description: 'The client id', http: {source: 'path'} }, { arg: 'addressId', - type: ['number', 'null'], + type: 'number', description: 'The address id', http: {source: 'path'} }, { arg: 'nickname', - type: ['string'] + type: 'string' }, { arg: 'city', - type: ['string'] + type: 'string' }, { arg: 'street', - type: ['string'] + type: 'string' }, { arg: 'phone', @@ -62,11 +62,11 @@ module.exports = function(Self) { }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isEqualizated', - type: 'Boolean' + type: 'boolean' }], returns: { root: true,