This commit is contained in:
parent
cb4e8355ba
commit
1efe258ea0
|
@ -51,7 +51,8 @@ BEGIN
|
|||
origin.companyFk futureCompanyFk,
|
||||
IFNULL(dest.nickname, origin.nickname) nickname,
|
||||
dest.landed,
|
||||
dest.preparation
|
||||
dest.preparation,
|
||||
origin.departmentFk
|
||||
FROM (
|
||||
SELECT s.ticketFk,
|
||||
c.salesPersonFk workerFk,
|
||||
|
@ -71,9 +72,11 @@ BEGIN
|
|||
t.addressFk,
|
||||
t.warehouseFk,
|
||||
t.companyFk,
|
||||
t.agencyModeFk
|
||||
t.agencyModeFk,
|
||||
wd.departmentFk
|
||||
FROM ticket t
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
|
|
|
@ -51,9 +51,9 @@ module.exports = Self => {
|
|||
description: 'True when lines and stock of origin are equal'
|
||||
},
|
||||
{
|
||||
arg: 'myTeam',
|
||||
type: 'boolean',
|
||||
description: `Whether to show only tickets for the current logged user team (currently user tickets)`
|
||||
arg: 'departmentFk',
|
||||
type: 'number',
|
||||
description: 'Department identifier'
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
|
@ -74,27 +74,11 @@ module.exports = Self => {
|
|||
Self.getTicketsAdvance = async(ctx, options) => {
|
||||
const args = ctx.args;
|
||||
const conn = Self.dataSource.connector;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const teamMembersId = [];
|
||||
if (args.myTeam != null) {
|
||||
const worker = await Self.app.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);
|
||||
}
|
||||
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'id':
|
||||
|
@ -117,11 +101,8 @@ module.exports = Self => {
|
|||
};
|
||||
case 'isFullMovable':
|
||||
return {'f.isFullMovable': value};
|
||||
case 'myTeam':
|
||||
if (value)
|
||||
return {'workerFk': {inq: teamMembersId}};
|
||||
else
|
||||
return {'workerFk': {nin: teamMembersId}};
|
||||
case 'departmentFk':
|
||||
return {'f.departmentFk': value};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue