feat: refs #8342 deprecate sorter and splitLine tables #3377

Merged
ivanm merged 2 commits from 8342-deprecateSorterAndSplitLineTables into dev 2025-01-23 11:40:56 +00:00
15 changed files with 316 additions and 123 deletions
Showing only changes of commit d98a867e12 - Show all commits

View File

@ -19,6 +19,7 @@ BEGIN
sub2.iptd futureIpt,
sub2.state futureState,
t.clientFk,
cl.salespersonFk,
t.warehouseFk,
ts.alertLevel,
sub2.alertLevel futureAlertLevel,
@ -38,6 +39,7 @@ BEGIN
JOIN vn.province p ON p.id = a.provinceFk
JOIN vn.country c ON c.id = p.countryFk
JOIN vn.ticketState ts ON ts.ticketFk = t.id
JOIN vn.client cl ON cl.id = t.clientFk
JOIN vn.state st ON st.id = ts.stateFk
JOIN vn.alertLevel al ON al.id = ts.alertLevel
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeDelete`
BEFORE DELETE ON `itemTaxCountry`
FOR EACH ROW
BEGIN
CALL util.throw('Records in this table cannot be deleted');
END$$
DELIMITER ;

View File

@ -4,5 +4,9 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeUp
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
IF NOT(NEW.`countryFk` <=> OLD.`countryFk`) OR NOT(NEW.`itemFk` <=> OLD.`itemFk`) THEN
CALL util.throw('Only the VAT can be modified');
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,130 @@
-- Place your SQL code here
CREATE TABLE IF NOT EXISTS `vn`.`itemSoldOutTag` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT
CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Ultimas unidades');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Temporalmente');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Descatalogado');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta mayo');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta febrero');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta diciembre');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta enero');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta marzo');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta nueva temporada');
INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta septiembre');
UPDATE vn.tag
SET isFree=FALSE,
sourceTable='itemSoldOutTag'
WHERE name= 'Agotado';
CREATE TABLE IF NOT EXISTS `vn`.`itemDurationTag` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT
CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('10 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('11 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('12 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('13 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('14 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('15 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('17 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('7 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('9 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('16-20 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('17-21 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('19-23 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('3-4 semanas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('13-17 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('14-16 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('15-19 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('18-25 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('20 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('6 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('9 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('10-13 días');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('6 meses');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('5 años');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('10 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('20 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('35 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('6 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('11 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('12 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('14 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('15 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('18 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('19 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('24 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('25 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('30 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('32 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('4 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('40 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('45 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('50 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('55 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('70 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('8 horas');
INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('9 horas');
UPDATE vn.tag
SET isFree=FALSE,
sourceTable='itemDurationTag'
WHERE name= 'Duracion';
CREATE TABLE IF NOT EXISTS `vn`.`itemGrowingTag` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT
CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-05');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-06');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-12');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('02-06');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-05');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-07');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-08');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-11');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('04-06');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('04-09');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('04-11');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-07');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-08');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-10');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-11');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('06-09');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('06-10');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('06-11');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-09');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-10');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-11');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-12');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('09-12');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-04 / 10-12');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-04 / 9-12');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-05 / 10-12');
INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-05 / 11-12');
UPDATE vn.tag
SET isFree=FALSE,
sourceTable='itemGrowingTag'
WHERE name= 'Recolecta';
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemSoldOutTag TO logisticAssist;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemDurationTag TO logisticAssist;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemGrowingTag TO logisticAssist;

View File

@ -109,6 +109,7 @@ module.exports = Self => {
const args = ctx.args;
const myOptions = {};
let to;
let myTeamIds = [];
if (typeof options == 'object')
Object.assign(myOptions, options);
@ -133,21 +134,8 @@ module.exports = Self => {
claimIdsByClaimResponsibleFk = claims.map(claim => claim.claimFk);
}
// Apply filter by team
const teamMembersId = [];
if (args.myTeam != null) {
const worker = await models.Worker.findById(userId, {
include: {
relation: 'collegues'
}
}, myOptions);
const collegues = worker.collegues() || [];
for (let collegue of collegues)
teamMembersId.push(collegue.collegueFk);
if (teamMembersId.length == 0)
teamMembersId.push(userId);
}
if (args.myTeam != null)
myTeamIds = await models.Worker.myTeam(userId);
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
@ -184,9 +172,9 @@ module.exports = Self => {
return {'t.zoneFk': value};
case 'myTeam':
if (value)
return {'cl.workerFk': {inq: teamMembersId}};
return {'cl.workerFk': {inq: myTeamIds}};
else
return {'cl.workerFk': {nin: teamMembersId}};
return {'cl.workerFk': {nin: myTeamIds}};
}
});

View File

@ -123,25 +123,13 @@ module.exports = Self => {
date.setHours(0, 0, 0, 0);
const args = ctx.args;
const myOptions = {};
let myTeamIds = [];
if (typeof options == 'object')
Object.assign(myOptions, options);
// Apply filter by team
const teamMembersId = [];
if (args.myTeam != null) {
const worker = await models.Worker.findById(userId, {
include: {
relation: 'collegues'
}
}, myOptions);
const collegues = worker.collegues() || [];
for (let collegue of collegues)
teamMembersId.push(collegue.collegueFk);
if (teamMembersId.length == 0)
teamMembersId.push(userId);
}
if (args.myTeam != null)
myTeamIds = await models.Worker.myTeam(userId);
if (ctx.args && args.to) {
const dateTo = args.to;
@ -163,9 +151,9 @@ module.exports = Self => {
case 'mine':
case 'myTeam':
if (value)
return {'c.salesPersonFk': {inq: teamMembersId}};
return {'c.salesPersonFk': {inq: myTeamIds}};
else
return {'c.salesPersonFk': {nin: teamMembersId}};
return {'c.salesPersonFk': {nin: myTeamIds}};
case 'id':
case 'clientFk':
param = `t.${param}`;

View File

@ -80,29 +80,15 @@ module.exports = Self => {
const conn = Self.dataSource.connector;
const myOptions = {};
const userId = ctx.req.accessToken.userId;
let myTeamIds = [];
if (typeof options == 'object')
Object.assign(myOptions, options);
const args = ctx.args;
// Apply filter by team
const teamMembersId = [];
if (args.myTeam != null) {
const worker = await models.Worker.findById(userId, {
include: {
relation: 'collegues'
}
}, myOptions);
const collegues = worker.collegues() || [];
for (let collegue of collegues)
teamMembersId.push(collegue.collegueFk);
if (teamMembersId.length == 0)
teamMembersId.push(userId);
}
if (args?.myTeam)
args.teamIds = teamIds;
if (args.myTeam != null)
myTeamIds = await models.Worker.myTeam(userId);
if (args?.to)
args.to.setHours(23, 59, 0, 0);
@ -133,9 +119,9 @@ module.exports = Self => {
return {'o.confirmed': value ? 1 : 0};
case 'myTeam':
if (value)
return {'c.salesPersonFk': {inq: teamMembersId}};
return {'c.salesPersonFk': {inq: myTeamIds}};
else
return {'c.salesPersonFk': {nin: teamMembersId}};
return {'c.salesPersonFk': {nin: myTeamIds}};
case 'showEmpty':
return {'o.total': {neq: value}};
case 'id':

View File

@ -87,6 +87,7 @@ module.exports = Self => {
const myOptions = {};
const models = Self.app.models;
const args = ctx.args;
let myTeamIds = [];
if (typeof options == 'object')
Object.assign(myOptions, options);
@ -94,20 +95,8 @@ module.exports = Self => {
if (ctx.args.mine)
ctx.args.attenderFk = userId;
const teamMembersId = [];
if (args.myTeam != null) {
const worker = await models.Worker.findById(userId, {
include: {
relation: 'collegues'
}
}, myOptions);
const collegues = worker.collegues() || [];
for (let collegue of collegues)
teamMembersId.push(collegue.collegueFk);
if (teamMembersId.length == 0)
teamMembersId.push(userId);
}
if (args.myTeam != null)
myTeamIds = await models.Worker.myTeam(userId);
const today = Date.vnNew();
const future = Date.vnNew();
@ -145,9 +134,9 @@ module.exports = Self => {
return {'c.salesPersonFk': value};
case 'myTeam':
if (value)
return {'tr.requesterFk': {inq: teamMembersId}};
return {'tr.requesterFk': {inq: myTeamIds}};
else
return {'tr.requesterFk': {nin: teamMembersId}};
return {'tr.requesterFk': {nin: myTeamIds}};
case 'daysOnward':
today.setHours(0, 0, 0, 0);
future.setDate(today.getDate() + value);

View File

@ -142,28 +142,14 @@ module.exports = Self => {
date.setHours(0, 0, 0, 0);
const models = Self.app.models;
const args = ctx.args;
let myTeamIds = [];
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
// Apply filter by team
const teamMembersId = [];
if (args.myTeam != null) {
const worker = await models.Worker.findById(userId, {
include: {
relation: 'collegues'
}
}, myOptions);
const collegues = worker.collegues() || [];
for (let collegue of collegues)
teamMembersId.push(collegue.collegueFk);
if (teamMembersId.length == 0)
teamMembersId.push(userId);
}
if (args.myTeam != null)
myTeamIds = await models.Worker.myTeam(userId);
if (ctx.args && args.to) {
const dateTo = args.to;
@ -195,9 +181,9 @@ module.exports = Self => {
case 'mine':
case 'myTeam':
if (value)
return {'c.salesPersonFk': {inq: teamMembersId}};
return {'c.salesPersonFk': {inq: myTeamIds}};
else
return {'c.salesPersonFk': {nin: teamMembersId}};
return {'c.salesPersonFk': {nin: myTeamIds}};
case 'alertLevel':
return {'ts.alertLevel': value};

View File

@ -40,21 +40,23 @@ module.exports = Self => {
try {
for (let ticket of tickets) {
const originFullPath = `${url}ticket/${ticket.originId}/summary`;
const destinationFullPath = `${url}ticket/${ticket.destinationId}/summary`;
const message = $t('Ticket merged', {
originDated: dateUtil.toString(new Date(ticket.originShipped)),
destinationDated: dateUtil.toString(new Date(ticket.destinationShipped)),
originId: ticket.originId,
destinationId: ticket.destinationId,
originFullPath,
destinationFullPath
});
if (!ticket.originId || !ticket.destinationId) continue;
await models.Sale.updateAll({ticketFk: ticket.originId}, {ticketFk: ticket.destinationId}, myOptions);
if (await models.Ticket.setDeleted(ctx, ticket.originId, myOptions))
await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message);
if (await models.Ticket.setDeleted(ctx, ticket.originId, myOptions)) {
if (!ticket.salesPersonFk) continue;
const originFullPath = `${url}ticket/${ticket.originId}/summary`;
const destinationFullPath = `${url}ticket/${ticket.destinationId}/summary`;
const message = $t('Ticket merged', {
originDated: dateUtil.toString(new Date(ticket.originShipped)),
destinationDated: dateUtil.toString(new Date(ticket.destinationShipped)),
originId: ticket.originId,
destinationId: ticket.destinationId,
originFullPath,
destinationFullPath
});
await models.Chat.sendCheckingPresence(ctx, ticket.salesPersonFk, message);
}
}
if (tx)
await tx.commit();

View File

@ -7,7 +7,7 @@ describe('ticket merge()', () => {
destinationId: 12,
originShipped: Date.vnNew(),
destinationShipped: Date.vnNew(),
workerFk: 1
salesPersonFk: 1
};
it('should merge two tickets', async() => {

View File

@ -73,6 +73,11 @@ module.exports = Self => {
type: 'String',
description: 'The user email',
http: {source: 'query'}
},
{
arg: 'myTeam',
type: 'boolean',
description: 'Whether to show only tickets for the current logged user team (currently user tickets)'
}
],
returns: {
@ -85,10 +90,21 @@ module.exports = Self => {
}
});
Self.filter = async(ctx, filter) => {
let conn = Self.dataSource.connector;
Self.filter = async(ctx, filter, options) => {
const userId = ctx.req.accessToken.userId;
const conn = Self.dataSource.connector;
const models = Self.app.models;
const args = ctx.args;
let myTeamIds = [];
const myOptions = {};
let where = buildFilter(ctx.args, (param, value) => {
if (typeof options == 'object')
Object.assign(myOptions, options);
if (args.myTeam != null)
myTeamIds = await models.Worker.myTeam(userId);
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
@ -117,12 +133,17 @@ module.exports = Self => {
return {'u.name': {like: `%${value}%`}};
case 'email':
return {'eu.email': {like: `%${value}%`}};
case 'myTeam':
if (value)
return {'c.salesPersonFk': {inq: myTeamIds}};
else
return {'c.salesPersonFk': {nin: myTeamIds}};
}
});
filter = mergeFilters(ctx.args.filter, {where});
filter = mergeFilters(filter, {where});
let stmts = [];
const stmts = [];
let stmt;
stmt = new ParameterizedSQL(
@ -145,11 +166,12 @@ module.exports = Self => {
LEFT JOIN account.emailUser eu ON eu.userFk = u.id`
);
stmt.merge(conn.makeSuffix(filter));
let itemsIndex = stmts.push(stmt) - 1;
stmt.merge(conn.makeWhere(filter.where));
stmts.push(stmt);
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql);
return itemsIndex === 0 ? result : result[itemsIndex];
const itemsIndex = stmts.push(stmt) - 1;
const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql, myOptions);
return result[itemsIndex];
};
};

View File

@ -0,0 +1,43 @@
module.exports = Self => {
Self.remoteMethod('myTeam', {
description: 'Return the members of the user team',
accessType: 'READ',
accepts: [{
arg: 'userId',
type: 'string',
required: true
}],
returns: {
type: 'string',
root: true
},
http: {
path: `/myTeam`,
verb: 'GET'
}
});
Self.myTeam = async(userId, options) => {
const models = Self.app.models;
const myOptions = {};
const teamMembersId = [];
if (typeof options == 'object')
Object.assign(myOptions, options);
const worker = await models.Worker.findById(userId, {
include: {
relation: 'collegues'
}
}, myOptions);
const collegues = worker.collegues() || [];
for (let collegue of collegues)
teamMembersId.push(collegue.collegueFk);
if (teamMembersId.length == 0)
teamMembersId.push(userId);
return teamMembersId;
};
};

View File

@ -1,25 +1,69 @@
const models = require('vn-loopback/server/server').models;
const app = require('vn-loopback/server/server');
describe('worker filter()', () => {
it('should return 1 result filtering by id', async() => {
let result = await app.models.Worker.filter({args: {filter: {}, search: 1}});
const ctx = beforeAll.getCtx();
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(1);
it('should return 1 result filtering by id', async() => {
const tx = await models.Worker.beginTransaction({});
try {
const options = {transaction: tx};
const filter = {};
const args = {search: 1};
ctx.args = args;
let result = await app.models.Worker.filter(ctx, filter, options);
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return 1 result filtering by string', async() => {
let result = await app.models.Worker.filter({args: {filter: {}, search: 'administrativeNick'}});
const tx = await models.Worker.beginTransaction({});
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(5);
try {
const options = {transaction: tx};
const filter = {};
const args = {search: 'administrativeNick'};
ctx.args = args;
let result = await app.models.Worker.filter(ctx, filter, options);
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return 2 results filtering by name', async() => {
let result = await app.models.Worker.filter({args: {filter: {}, firstName: 'agency'}});
it('should return 2 result filtering by name', async() => {
const tx = await models.Worker.beginTransaction({});
expect(result.length).toEqual(2);
expect(result[0].nickname).toEqual('agencyNick');
expect(result[1].nickname).toEqual('agencyBossNick');
try {
const options = {transaction: tx};
const filter = {};
const args = {firstName: 'agency'};
ctx.args = args;
let result = await app.models.Worker.filter(ctx, filter, options);
expect(result[0].nickname).toEqual('agencyNick');
expect(result[1].nickname).toEqual('agencyBossNick');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -21,6 +21,7 @@ module.exports = Self => {
require('../methods/worker/isAuthorized')(Self);
require('../methods/worker/setPassword')(Self);
require('../methods/worker/getAvailablePda')(Self);
require('../methods/worker/myTeam')(Self);
Self.validateAsync('fi', tinIsValid, {
message: 'Invalid TIN'