Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
97f3761e0c
|
@ -131,6 +131,7 @@ pipeline {
|
||||||
stage('Database') {
|
stage('Database') {
|
||||||
when { anyOf {
|
when { anyOf {
|
||||||
branch 'test'
|
branch 'test'
|
||||||
|
branch 'master'
|
||||||
}}
|
}}
|
||||||
steps {
|
steps {
|
||||||
configFileProvider([
|
configFileProvider([
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `vn2008`.`Greuges` CHANGE COLUMN `Fecha` `Fecha` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ;
|
|
@ -30,7 +30,7 @@
|
||||||
vn-one
|
vn-one
|
||||||
label="Responsability"
|
label="Responsability"
|
||||||
value="$ctrl.claim.responsibility"
|
value="$ctrl.claim.responsibility"
|
||||||
max="5"
|
max="$ctrl.maxResponsibility"
|
||||||
min="1"
|
min="1"
|
||||||
step="1"
|
step="1"
|
||||||
vn-acl="salesAssistant"
|
vn-acl="salesAssistant"
|
||||||
|
@ -192,3 +192,9 @@
|
||||||
<vn-ticket-descriptor-popover
|
<vn-ticket-descriptor-popover
|
||||||
vn-id="ticketDescriptor">
|
vn-id="ticketDescriptor">
|
||||||
</vn-ticket-descriptor-popover>
|
</vn-ticket-descriptor-popover>
|
||||||
|
<vn-confirm
|
||||||
|
vn-id="update-greuge"
|
||||||
|
question="Insert greuges on client card"
|
||||||
|
message="Do you want to insert greuges?"
|
||||||
|
on-response="$ctrl.onUpdateGreugeResponse(response)">
|
||||||
|
</vn-confirm>
|
|
@ -23,6 +23,7 @@ class Controller {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
this.resolvedState = 3;
|
this.resolvedState = 3;
|
||||||
|
this.maxResponsibility = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
openAddSalesDialog() {
|
openAddSalesDialog() {
|
||||||
|
@ -135,9 +136,29 @@ class Controller {
|
||||||
this.$http.post(query, data).then(() => {
|
this.$http.post(query, data).then(() => {
|
||||||
this.card.reload();
|
this.card.reload();
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2)
|
||||||
|
this.$.updateGreuge.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUpdateGreugeResponse(response) {
|
||||||
|
if (response !== 'ACCEPT')
|
||||||
|
return;
|
||||||
|
let greugeTypeFreight = 7;
|
||||||
|
let query = `claim/api/Greuges/`;
|
||||||
|
let data = {
|
||||||
|
clientFk: this.claim.clientFk,
|
||||||
|
description: `claim: ${this.claim.id}`,
|
||||||
|
amount: 11,
|
||||||
|
greugeTypeFk: greugeTypeFreight,
|
||||||
|
ticketFk: this.claim.ticketFk
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$http.post(query, data).then(() => {
|
||||||
|
this.card.reload();
|
||||||
|
this.vnApp.showSuccess(this.$translate.instant('Greuge inserted!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
// Item Descriptor
|
// Item Descriptor
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, itemFk) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
|
|
|
@ -158,5 +158,37 @@ describe('claim', () => {
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('onUpdateGreugeResponse()', () => {
|
||||||
|
it('should do nothing', () => {
|
||||||
|
spyOn(controller.card, 'reload');
|
||||||
|
spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
|
controller.onUpdateGreugeResponse('CANCEL');
|
||||||
|
|
||||||
|
expect(controller.card.reload).not.toHaveBeenCalledWith();
|
||||||
|
expect(controller.vnApp.showSuccess).not.toHaveBeenCalledWith('Greuge inserted!');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should perform a insert into greuges', () => {
|
||||||
|
spyOn(controller.card, 'reload');
|
||||||
|
spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
controller.claim.clientFk = 101;
|
||||||
|
controller.claim.id = 11;
|
||||||
|
let data = {
|
||||||
|
clientFk: 101,
|
||||||
|
description: `claim: ${controller.claim.id}`,
|
||||||
|
amount: 11,
|
||||||
|
greugeTypeFk: 7,
|
||||||
|
ticketFk: controller.claim.ticketFk
|
||||||
|
};
|
||||||
|
$httpBackend.expect('POST', `claim/api/Greuges/`, data).respond();
|
||||||
|
controller.onUpdateGreugeResponse('ACCEPT');
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Greuge inserted!');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,3 +6,6 @@ Imports claim details: Importa detalles de la reclamacion
|
||||||
Import ticket: Importar ticket
|
Import ticket: Importar ticket
|
||||||
Imports ticket lines: Importa las lineas de un ticket
|
Imports ticket lines: Importa las lineas de un ticket
|
||||||
Regularize: Regularizar
|
Regularize: Regularizar
|
||||||
|
Do you want to insert greuges?: Desea insertar greuges?
|
||||||
|
Insert greuges on client card: Insertar greuges en la ficha del cliente
|
||||||
|
Greuge inserted: Greuge insertado
|
|
@ -6,11 +6,11 @@ module.exports = Self => {
|
||||||
Self.remoteMethodCtx('send', {
|
Self.remoteMethodCtx('send', {
|
||||||
description: 'Sends SMS to a destination phone',
|
description: 'Sends SMS to a destination phone',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'recipientFk',
|
arg: 'destinationFk',
|
||||||
type: 'Integer'
|
type: 'Integer'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'recipient',
|
arg: 'destination',
|
||||||
type: 'String',
|
type: 'String',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
@ -20,7 +20,7 @@ module.exports = Self => {
|
||||||
required: true,
|
required: true,
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'boolean',
|
type: 'Object',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.send = async(ctx, recipientFk, recipient, message) => {
|
Self.send = async(ctx, destinationFk, destination, message) => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const smsConfig = await Self.app.models.SmsConfig.findOne();
|
const smsConfig = await Self.app.models.SmsConfig.findOne();
|
||||||
const soapClient = await soap.createClientAsync(smsConfig.uri);
|
const soapClient = await soap.createClientAsync(smsConfig.uri);
|
||||||
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
||||||
user: smsConfig.user,
|
user: smsConfig.user,
|
||||||
pass: smsConfig.password,
|
pass: smsConfig.password,
|
||||||
src: smsConfig.title,
|
src: smsConfig.title,
|
||||||
dst: recipient,
|
dst: destination,
|
||||||
msg: message
|
msg: message
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,18 +61,21 @@ module.exports = Self => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const statusCode = status.codigo[0];
|
||||||
|
const statusDescription = status.descripcion[0];
|
||||||
|
|
||||||
const newSms = {
|
const newSms = {
|
||||||
senderFk: userId,
|
senderFk: userId,
|
||||||
destinationFk: recipientFk || null,
|
destinationFk: destinationFk || null,
|
||||||
destination: recipient,
|
destination: destination,
|
||||||
message: message,
|
message: message,
|
||||||
statusCode: status.codigo,
|
statusCode: statusCode,
|
||||||
status: status.descripcion
|
status: statusDescription
|
||||||
};
|
};
|
||||||
|
|
||||||
const sms = Self.create(newSms);
|
const sms = await Self.create(newSms);
|
||||||
|
|
||||||
if (status.codigo != 200)
|
if (statusCode != 200)
|
||||||
throw new UserError(`We weren't able to send this SMS`);
|
throw new UserError(`We weren't able to send this SMS`);
|
||||||
|
|
||||||
return sms;
|
return sms;
|
||||||
|
|
|
@ -8,7 +8,7 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('sms send()', () => {
|
describe('sms send()', () => {
|
||||||
it('should should return the expected message and status code', async() => {
|
it('should should return the expected message and status code', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 1}}};
|
let ctx = {req: {accessToken: {userId: 1}}};
|
||||||
let result = await app.models.Sms.send(ctx, null, 'Invalid', 'My SMS Body');
|
let result = await app.models.Sms.send(ctx, 101, 'Invalid', 'My SMS Body');
|
||||||
|
|
||||||
expect(result.statusCode).toEqual(200);
|
expect(result.statusCode).toEqual(200);
|
||||||
expect(result.status).toEqual('Envio en procesamiento');
|
expect(result.status).toEqual('Envio en procesamiento');
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "Sms",
|
"name": "Sms",
|
||||||
"description": "Sms sent to client",
|
"description": "Sms sent to client",
|
||||||
"base": "VnModel",
|
"base": "Loggable",
|
||||||
|
"log": {
|
||||||
|
"model":"ClientLog",
|
||||||
|
"relation": "recipient"
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "sms"
|
"table": "sms"
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<h5 pad-small-v translate>Send SMS</h5>
|
<h5 pad-small-v translate>Send SMS</h5>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-one
|
<vn-textfield vn-one
|
||||||
label="Recipient"
|
label="Destination"
|
||||||
model="$ctrl.sms.recipient">
|
model="$ctrl.sms.destination">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal >
|
<vn-horizontal >
|
||||||
|
|
|
@ -18,11 +18,7 @@ class Controller extends Component {
|
||||||
|
|
||||||
onResponse(response) {
|
onResponse(response) {
|
||||||
if (response === 'ACCEPT') {
|
if (response === 'ACCEPT') {
|
||||||
let params = {
|
this.$http.post(`/client/api/Sms/send`, this.sms).then(res => {
|
||||||
recipient: this.sms.recipient,
|
|
||||||
message: this.sms.message
|
|
||||||
};
|
|
||||||
this.$http.post(`/client/api/Sms/send`, params).then(res => {
|
|
||||||
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||||||
|
|
||||||
if (res.data) this.emit('send', {response: res.data});
|
if (res.data) this.emit('send', {response: res.data});
|
||||||
|
|
|
@ -17,8 +17,8 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('onResponse()', () => {
|
describe('onResponse()', () => {
|
||||||
it('should perform a POST query and show a success snackbar', () => {
|
it('should perform a POST query and show a success snackbar', () => {
|
||||||
let params = {recipient: 111111111, message: 'My SMS'};
|
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||||
controller.sms = {recipient: 111111111, message: 'My SMS'};
|
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showMessage');
|
spyOn(controller.vnApp, 'showMessage');
|
||||||
$httpBackend.when('POST', `/client/api/Sms/send`, params).respond(200, params);
|
$httpBackend.when('POST', `/client/api/Sms/send`, params).respond(200, params);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Send SMS: Enviar SMS
|
Send SMS: Enviar SMS
|
||||||
Recipient: Destinatario
|
Destination: Destinatario
|
||||||
Message: Mensaje
|
Message: Mensaje
|
||||||
SMS sent!: ¡SMS enviado!
|
SMS sent!: ¡SMS enviado!
|
|
@ -182,7 +182,8 @@ class Controller {
|
||||||
showSMSDialog() {
|
showSMSDialog() {
|
||||||
const address = this.ticket.address;
|
const address = this.ticket.address;
|
||||||
this.newSMS = {
|
this.newSMS = {
|
||||||
recipient: address.mobile || null,
|
destinationFk: this.ticket.clientFk,
|
||||||
|
destination: address.mobile || null,
|
||||||
message: this.$translate.instant('SMSPayment')
|
message: this.$translate.instant('SMSPayment')
|
||||||
};
|
};
|
||||||
this.$scope.sms.open();
|
this.$scope.sms.open();
|
||||||
|
|
|
@ -331,7 +331,8 @@ class Controller {
|
||||||
notAvailables
|
notAvailables
|
||||||
};
|
};
|
||||||
this.newSMS = {
|
this.newSMS = {
|
||||||
recipient: address.mobile || null,
|
destinationFk: this.ticket.clientFk,
|
||||||
|
destination: address.mobile || null,
|
||||||
message: this.$translate.instant('SMSAvailability', params)
|
message: this.$translate.instant('SMSAvailability', params)
|
||||||
};
|
};
|
||||||
this.$scope.sms.open();
|
this.$scope.sms.open();
|
||||||
|
|
|
@ -180,7 +180,7 @@ describe('Ticket', () => {
|
||||||
controller.showSMSDialog();
|
controller.showSMSDialog();
|
||||||
|
|
||||||
expect(controller.$scope.sms.open).toHaveBeenCalledWith();
|
expect(controller.$scope.sms.open).toHaveBeenCalledWith();
|
||||||
expect(controller.newSMS.recipient).toEqual(111111111);
|
expect(controller.newSMS.destination).toEqual(111111111);
|
||||||
expect(controller.newSMS.message).not.toEqual('');
|
expect(controller.newSMS.message).not.toEqual('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue