Compare commits

...

3 Commits

Author SHA1 Message Date
Sergio De la torre 05e503ad48 refs #6028 add:email
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-07 07:50:53 +01:00
Sergio De la torre 2d594a3a20 Merge branch 'dev' into 6028_route_getRouteByWorker 2023-12-05 11:28:27 +01:00
Sergio De la torre 3e3c7ea977 refs #6028 test(route): add getRoutesByWorker 2023-07-18 09:26:01 +02:00
2 changed files with 38 additions and 2 deletions

View File

@ -130,13 +130,15 @@ module.exports = Self => {
am.name agencyName, am.name agencyName,
u.name AS workerUserName, u.name AS workerUserName,
v.numberPlate AS vehiclePlateNumber, v.numberPlate AS vehiclePlateNumber,
Date_format(r.time, '%H:%i') hour Date_format(r.time, '%H:%i') hour,
eu.email
FROM route r FROM route r
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN agency a ON a.id = am.agencyFk LEFT JOIN agency a ON a.id = am.agencyFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.id` LEFT JOIN account.user u ON u.id = w.id
LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk`
); );
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeSuffix(filter));

View File

@ -0,0 +1,34 @@
const {models} = require('vn-loopback/server/server');
describe('getRoutesByWorker', () => {
it('should return the routes of the worker can view all routes', async() => {
const tx = await models.UserConfig.beginTransaction({});
const deliveryBossId = 57;
const options = {transaction: tx};
let result;
try {
const ctx = {req: {accessToken: {userId: deliveryBossId}}};
await models.UserConfig.create({
userFk: 57,
warehouseFk: 1
}, options);
result = await models.Route.getRoutesByWorker(ctx, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(result.length).toEqual(7);
});
it('should return the routes of the worker can not view all routes', async() => {
const deliveryId = 56;
const ctx = {req: {accessToken: {userId: deliveryId}}};
const result = await models.Route.getRoutesByWorker(ctx);
expect(result.length).toEqual(5);
});
});