Merge branch 'dev' into 3467-travelThermograph
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
6216d6fa9b
|
@ -30,8 +30,13 @@ module.exports = Self => {
|
|||
const sender = await models.Account.findById(accessToken.userId);
|
||||
const recipient = to.replace('@', '');
|
||||
|
||||
if (sender.name != recipient)
|
||||
return sendMessage(sender, to, message);
|
||||
if (sender.name != recipient) {
|
||||
const request = await sendMessage(sender, to, message);
|
||||
|
||||
return request ? request : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
async function sendMessage(sender, channel, message) {
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
DELETE FROM salix.ACL
|
||||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model = 'ClaimEnd' AND property = 'importTicketSales';
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
INSERT INTO salix.ACL
|
||||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Collection', 'setSaleQuantity', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +1,3 @@
|
|||
INSERT INTO salix.ACL
|
||||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Docuware', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +1,3 @@
|
|||
UPDATE salix.defaultViewConfig
|
||||
UPDATE `salix`.`defaultViewConfig`
|
||||
SET `columns`='{"intrastat":false,"stemMultiplier":false,"landed":false,"producer":false}'
|
||||
WHERE tableCode ='itemsIndex';
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
INSERT INTO salix.ACL (model,property,accessType,principalId)
|
||||
INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
|
||||
VALUES ('AgencyTerm','*','*','administrative');
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
UPDATE `account`.`user`
|
||||
SET `role` = 57
|
||||
WHERE id IN (2294, 4365, 7294);
|
||||
UPDATE `account`.`user` SET `role` = 57 WHERE id IN (2294, 4365, 7294);
|
|
@ -0,0 +1,64 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('checkDuplicatedData', {
|
||||
description: 'Checks if a client has same email, mobile or phone than other client and send an email',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The client id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
verb: 'GET',
|
||||
path: '/:id/checkDuplicatedData'
|
||||
}
|
||||
});
|
||||
|
||||
Self.checkDuplicatedData = async function(id, options) {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const client = await Self.app.models.Client.findById(id, myOptions);
|
||||
|
||||
const emails = client.email ? client.email.split(',') : null;
|
||||
|
||||
const findParams = [];
|
||||
if (emails.length) {
|
||||
for (let email of emails)
|
||||
findParams.push({email: email});
|
||||
}
|
||||
|
||||
if (client.phone)
|
||||
findParams.push({phone: client.phone});
|
||||
|
||||
if (client.mobile)
|
||||
findParams.push({mobile: client.mobile});
|
||||
|
||||
const filterObj = {
|
||||
where: {
|
||||
and: [
|
||||
{or: findParams},
|
||||
{id: {neq: client.id}}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
const clientSameData = await Self.findOne(filterObj, myOptions);
|
||||
|
||||
if (clientSameData) {
|
||||
await Self.app.models.Mail.create({
|
||||
receiver: 'direccioncomercial@verdnatura.es',
|
||||
subject: `Cliente con email/teléfono/móvil duplicados`,
|
||||
body: 'El cliente ' + client.id + ' comparte alguno de estos datos con el cliente ' + clientSameData.id +
|
||||
'\n- Email: ' + client.email +
|
||||
'\n- Teléfono: ' + client.phone +
|
||||
'\n- Móvil: ' + client.mobile
|
||||
}, myOptions);
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client checkDuplicated()', () => {
|
||||
it('should send an mail if mobile/phone/email is duplicated', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const id = 1110;
|
||||
const mailModel = models.Mail;
|
||||
spyOn(mailModel, 'create');
|
||||
|
||||
await models.Client.checkDuplicatedData(id, options);
|
||||
|
||||
expect(mailModel.create).toHaveBeenCalled();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,9 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const soap = require('soap');
|
||||
|
||||
describe('client sendSms()', () => {
|
||||
it('should now send a message and log it', async() => {
|
||||
spyOn(soap, 'createClientAsync').and.returnValue('a so fake client');
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
|
|
@ -26,10 +26,9 @@ describe('Client updatePortfolio', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => {
|
||||
// task 3817
|
||||
xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => {
|
||||
const salesPersonId = 19;
|
||||
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
|
|
@ -80,6 +80,7 @@ module.exports = Self => {
|
|||
stmt.merge(conn.makeWhere(filter.where));
|
||||
stmt.merge(`GROUP BY d.clientFk`);
|
||||
stmt.merge(conn.makeOrderBy(filter.order));
|
||||
stmt.merge(conn.makeLimit(filter));
|
||||
|
||||
const itemsIndex = stmts.push(stmt) - 1;
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
|
|
|
@ -30,6 +30,7 @@ module.exports = Self => {
|
|||
require('../methods/client/consumption')(Self);
|
||||
require('../methods/client/createReceipt')(Self);
|
||||
require('../methods/client/updatePortfolio')(Self);
|
||||
require('../methods/client/checkDuplicated')(Self);
|
||||
|
||||
// Validations
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ export default class Controller extends Section {
|
|||
return this.$.watcher.submit().then(() => {
|
||||
const query = `Clients/updatePortfolio`;
|
||||
this.$http.get(query);
|
||||
this.$http.get(`Clients/${this.$params.id}/checkDuplicatedData`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,10 @@ export default class Controller extends Section {
|
|||
}
|
||||
|
||||
onSubmit() {
|
||||
return this.$.watcher.submit().then(
|
||||
json => this.$state.go('client.card.basicData', {id: json.data.id})
|
||||
);
|
||||
return this.$.watcher.submit().then(json => {
|
||||
this.$state.go('client.card.basicData', {id: json.data.id});
|
||||
this.$http.get(`Clients/${this.client.id}/checkDuplicatedData`);
|
||||
});
|
||||
}
|
||||
|
||||
get province() {
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
</td>
|
||||
<td>
|
||||
<span
|
||||
vn-click-stop="itemDescriptor.show($event, item.id)"
|
||||
vn-click-stop="clientDescriptor.show($event, client.id)"
|
||||
class="link">
|
||||
{{::client.id}}
|
||||
</span>
|
||||
|
@ -83,7 +83,9 @@
|
|||
</smart-table>
|
||||
</vn-card>
|
||||
|
||||
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
||||
<vn-popover vn-id="filters">
|
||||
<div class="vn-pa-lg">
|
||||
<form ng-submit="$ctrl.onSendClientConsumption()">
|
||||
|
@ -153,3 +155,6 @@
|
|||
</vn-item>
|
||||
</slot-menu>
|
||||
</vn-contextmenu>
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const soap = require('soap');
|
||||
|
||||
describe('ticket sendSms()', () => {
|
||||
it('should send a message and log it', async() => {
|
||||
|
@ -8,7 +7,6 @@ describe('ticket sendSms()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
spyOn(soap, 'createClientAsync').and.returnValue('a so fake client');
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const id = 11;
|
||||
const destination = 222222222;
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
class="clickable search-result">
|
||||
<vn-td number>{{::zone.id}}</vn-td>
|
||||
<vn-td expand>{{::zone.name}}</vn-td>
|
||||
<vn-td>{{::zone.agencyMode.name}}</vn-td>
|
||||
<vn-td>{{::zone.agencyModeName}}</vn-td>
|
||||
<vn-td shrink>{{::zone.hour | date: 'HH:mm'}}</vn-td>
|
||||
<vn-td number>{{::zone.price | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td shrink>
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
"test": "jest --watch",
|
||||
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
|
||||
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
|
||||
"docker": "docker build -t salix-db ./db"
|
||||
"docker": "docker build --progress=plain -t salix-db ./db"
|
||||
},
|
||||
"jest": {
|
||||
"projects": [
|
||||
|
|
Loading…
Reference in New Issue