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') {
|
||||
when { anyOf {
|
||||
branch 'test'
|
||||
branch 'master'
|
||||
}}
|
||||
steps {
|
||||
configFileProvider([
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn2008`.`Greuges` CHANGE COLUMN `Fecha` `Fecha` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ;
|
|
@ -30,7 +30,7 @@
|
|||
vn-one
|
||||
label="Responsability"
|
||||
value="$ctrl.claim.responsibility"
|
||||
max="5"
|
||||
max="$ctrl.maxResponsibility"
|
||||
min="1"
|
||||
step="1"
|
||||
vn-acl="salesAssistant"
|
||||
|
@ -192,3 +192,9 @@
|
|||
<vn-ticket-descriptor-popover
|
||||
vn-id="ticketDescriptor">
|
||||
</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.maxResponsibility = 5;
|
||||
}
|
||||
|
||||
openAddSalesDialog() {
|
||||
|
@ -135,9 +136,29 @@ class Controller {
|
|||
this.$http.post(query, data).then(() => {
|
||||
this.card.reload();
|
||||
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
|
||||
showDescriptor(event, itemFk) {
|
||||
this.quicklinks = {
|
||||
|
|
|
@ -158,5 +158,37 @@ describe('claim', () => {
|
|||
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
|
||||
Imports ticket lines: Importa las lineas de un ticket
|
||||
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', {
|
||||
description: 'Sends SMS to a destination phone',
|
||||
accepts: [{
|
||||
arg: 'recipientFk',
|
||||
arg: 'destinationFk',
|
||||
type: 'Integer'
|
||||
},
|
||||
{
|
||||
arg: 'recipient',
|
||||
arg: 'destination',
|
||||
type: 'String',
|
||||
required: true,
|
||||
},
|
||||
|
@ -20,7 +20,7 @@ module.exports = Self => {
|
|||
required: true,
|
||||
}],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
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 smsConfig = await Self.app.models.SmsConfig.findOne();
|
||||
const soapClient = await soap.createClientAsync(smsConfig.uri);
|
||||
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
|||
user: smsConfig.user,
|
||||
pass: smsConfig.password,
|
||||
src: smsConfig.title,
|
||||
dst: recipient,
|
||||
dst: destination,
|
||||
msg: message
|
||||
};
|
||||
|
||||
|
@ -61,18 +61,21 @@ module.exports = Self => {
|
|||
console.error(e);
|
||||
}
|
||||
|
||||
const statusCode = status.codigo[0];
|
||||
const statusDescription = status.descripcion[0];
|
||||
|
||||
const newSms = {
|
||||
senderFk: userId,
|
||||
destinationFk: recipientFk || null,
|
||||
destination: recipient,
|
||||
destinationFk: destinationFk || null,
|
||||
destination: destination,
|
||||
message: message,
|
||||
statusCode: status.codigo,
|
||||
status: status.descripcion
|
||||
statusCode: statusCode,
|
||||
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`);
|
||||
|
||||
return sms;
|
||||
|
|
|
@ -8,7 +8,7 @@ const app = require('vn-loopback/server/server');
|
|||
describe('sms send()', () => {
|
||||
it('should should return the expected message and status code', async() => {
|
||||
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.status).toEqual('Envio en procesamiento');
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
{
|
||||
"name": "Sms",
|
||||
"description": "Sms sent to client",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model":"ClientLog",
|
||||
"relation": "recipient"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "sms"
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<h5 pad-small-v translate>Send SMS</h5>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one
|
||||
label="Recipient"
|
||||
model="$ctrl.sms.recipient">
|
||||
label="Destination"
|
||||
model="$ctrl.sms.destination">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal >
|
||||
|
|
|
@ -18,11 +18,7 @@ class Controller extends Component {
|
|||
|
||||
onResponse(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
let params = {
|
||||
recipient: this.sms.recipient,
|
||||
message: this.sms.message
|
||||
};
|
||||
this.$http.post(`/client/api/Sms/send`, params).then(res => {
|
||||
this.$http.post(`/client/api/Sms/send`, this.sms).then(res => {
|
||||
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||||
|
||||
if (res.data) this.emit('send', {response: res.data});
|
||||
|
|
|
@ -17,8 +17,8 @@ describe('Client', () => {
|
|||
|
||||
describe('onResponse()', () => {
|
||||
it('should perform a POST query and show a success snackbar', () => {
|
||||
let params = {recipient: 111111111, message: 'My SMS'};
|
||||
controller.sms = {recipient: 111111111, message: 'My SMS'};
|
||||
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||
|
||||
spyOn(controller.vnApp, 'showMessage');
|
||||
$httpBackend.when('POST', `/client/api/Sms/send`, params).respond(200, params);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Send SMS: Enviar SMS
|
||||
Recipient: Destinatario
|
||||
Destination: Destinatario
|
||||
Message: Mensaje
|
||||
SMS sent!: ¡SMS enviado!
|
|
@ -182,7 +182,8 @@ class Controller {
|
|||
showSMSDialog() {
|
||||
const address = this.ticket.address;
|
||||
this.newSMS = {
|
||||
recipient: address.mobile || null,
|
||||
destinationFk: this.ticket.clientFk,
|
||||
destination: address.mobile || null,
|
||||
message: this.$translate.instant('SMSPayment')
|
||||
};
|
||||
this.$scope.sms.open();
|
||||
|
|
|
@ -331,7 +331,8 @@ class Controller {
|
|||
notAvailables
|
||||
};
|
||||
this.newSMS = {
|
||||
recipient: address.mobile || null,
|
||||
destinationFk: this.ticket.clientFk,
|
||||
destination: address.mobile || null,
|
||||
message: this.$translate.instant('SMSAvailability', params)
|
||||
};
|
||||
this.$scope.sms.open();
|
||||
|
|
|
@ -180,7 +180,7 @@ describe('Ticket', () => {
|
|||
controller.showSMSDialog();
|
||||
|
||||
expect(controller.$scope.sms.open).toHaveBeenCalledWith();
|
||||
expect(controller.newSMS.recipient).toEqual(111111111);
|
||||
expect(controller.newSMS.destination).toEqual(111111111);
|
||||
expect(controller.newSMS.message).not.toEqual('');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue