Get phone from address and client

This commit is contained in:
Joan Sanchez 2020-02-21 08:37:37 +01:00
parent a86c7c9b8a
commit 893b634d33
7 changed files with 56 additions and 48 deletions

View File

@ -5,60 +5,60 @@ module.exports = function(Self) {
description: 'Creates client address updating default address', description: 'Creates client address updating default address',
accepts: [{ accepts: [{
arg: 'id', arg: 'id',
type: 'Number', type: 'number',
description: 'The client id', description: 'The client id',
http: {source: 'path'} http: {source: 'path'}
}, },
{ {
arg: 'nickname', arg: 'nickname',
type: 'String', type: 'string',
required: true required: true
}, },
{ {
arg: 'city', arg: 'city',
type: 'String', type: 'string',
required: true required: true
}, },
{ {
arg: 'street', arg: 'street',
type: 'String', type: 'string',
required: true required: true
}, },
{ {
arg: 'phone', arg: 'phone',
type: 'String' type: 'string'
}, },
{ {
arg: 'mobile', arg: 'mobile',
type: 'String' type: 'string'
}, },
{ {
arg: 'postalCode', arg: 'postalCode',
type: 'String' type: 'string'
}, },
{ {
arg: 'provinceId', arg: 'provinceId',
type: 'Number' type: 'number'
}, },
{ {
arg: 'agencyModeId', arg: 'agencyModeId',
type: 'Number' type: 'number'
}, },
{ {
arg: 'incotermsId', arg: 'incotermsId',
type: 'String' type: 'string'
}, },
{ {
arg: 'customsAgentId', arg: 'customsAgentId',
type: 'Number' type: 'number'
}, },
{ {
arg: 'isActive', arg: 'isActive',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isDefaultAddress', arg: 'isDefaultAddress',
type: 'Boolean' type: 'boolean'
}], }],
returns: { returns: {
root: true, root: true,

View File

@ -10,55 +10,55 @@ module.exports = function(Self) {
}, },
{ {
arg: 'clientId', arg: 'clientId',
type: 'Number', type: ['number', 'null'],
description: 'The client id', description: 'The client id',
http: {source: 'path'} http: {source: 'path'}
}, },
{ {
arg: 'addressId', arg: 'addressId',
type: 'Number', type: ['number', 'null'],
description: 'The address id', description: 'The address id',
http: {source: 'path'} http: {source: 'path'}
}, },
{ {
arg: 'nickname', arg: 'nickname',
type: 'String' type: ['string']
}, },
{ {
arg: 'city', arg: 'city',
type: 'String' type: ['string']
}, },
{ {
arg: 'street', arg: 'street',
type: 'String' type: ['string']
}, },
{ {
arg: 'phone', arg: 'phone',
type: 'String' type: 'any'
}, },
{ {
arg: 'mobile', arg: 'mobile',
type: 'String' type: 'any'
}, },
{ {
arg: 'postalCode', arg: 'postalCode',
type: 'String' type: 'any'
}, },
{ {
arg: 'provinceFk', arg: 'provinceFk',
type: 'Number' type: 'any'
}, },
{ {
arg: 'agencyModeFk', arg: 'agencyModeFk',
type: 'Number' type: 'any'
}, },
{ {
arg: 'incotermsFk', arg: 'incotermsFk',
type: 'String' type: 'any'
}, },
{ {
arg: 'customsAgentFk', arg: 'customsAgentFk',
type: 'Number' type: 'any'
}, },
{ {
arg: 'isActive', arg: 'isActive',

View File

@ -17,75 +17,75 @@ module.exports = Self => {
}, },
{ {
arg: 'socialName', arg: 'socialName',
type: 'String' type: 'string'
}, },
{ {
arg: 'fi', arg: 'fi',
type: 'String' type: 'string'
}, },
{ {
arg: 'street', arg: 'street',
type: 'String' type: 'string'
}, },
{ {
arg: 'postcode', arg: 'postcode',
type: 'String' type: 'string'
}, },
{ {
arg: 'city', arg: 'city',
type: 'String' type: 'string'
}, },
{ {
arg: 'countryFk', arg: 'countryFk',
type: 'Number' type: 'number'
}, },
{ {
arg: 'provinceFk', arg: 'provinceFk',
type: 'Number' type: 'number'
}, },
{ {
arg: 'hasToInvoiceByAddress', arg: 'hasToInvoiceByAddress',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'hasToInvoice', arg: 'hasToInvoice',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isActive', arg: 'isActive',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isFreezed', arg: 'isFreezed',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isVies', arg: 'isVies',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isToBeMailed', arg: 'isToBeMailed',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isEqualizated', arg: 'isEqualizated',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isTaxDataVerified', arg: 'isTaxDataVerified',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'isTaxDataChecked', arg: 'isTaxDataChecked',
type: 'Boolean' type: 'boolean'
}, },
{ {
arg: 'despiteOfClient', arg: 'despiteOfClient',
type: 'Number' type: 'number'
}], }],
returns: { returns: {
arg: 'res', arg: 'res',
type: 'String', type: 'string',
root: true root: true
}, },
http: { http: {

View File

@ -55,10 +55,11 @@ class Controller extends Component {
} }
showSMSDialog() { 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 || ''; const message = this.$params.message || '';
this.newSMS = { this.newSMS = {
destinationFk: this.client.id, destinationFk: client.id,
destination: phone, destination: phone,
message: message message: message
}; };

View File

@ -27,7 +27,9 @@ class Controller extends ModuleCard {
'isFreezed', 'isFreezed',
'isTaxDataChecked', 'isTaxDataChecked',
'credit', 'credit',
'email' 'email',
'phone',
'mobile'
], ],
include: { include: {
relation: 'salesPerson', relation: 'salesPerson',

View File

@ -241,7 +241,9 @@ class Controller extends Component {
showSMSDialog() { showSMSDialog() {
const address = this.ticket.address; 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'); const message = this.$params.message || this.$translate.instant('SMSPayment');
this.newSMS = { this.newSMS = {
destinationFk: this.ticket.clientFk, destinationFk: this.ticket.clientFk,

View File

@ -431,6 +431,9 @@ class Controller {
showSMSDialog() { showSMSDialog() {
const address = this.ticket.address; 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 sales = this.checkedLines();
const items = sales.map(sale => { const items = sales.map(sale => {
return `${sale.quantity} ${sale.concept}`; return `${sale.quantity} ${sale.concept}`;
@ -443,7 +446,7 @@ class Controller {
}; };
this.newSMS = { this.newSMS = {
destinationFk: this.ticket.clientFk, destinationFk: this.ticket.clientFk,
destination: address.mobile || null, destination: phone,
message: this.$translate.instant('SMSAvailability', params) message: this.$translate.instant('SMSAvailability', params)
}; };
this.$scope.sms.open(); this.$scope.sms.open();