8355-testToMaster #3336
|
@ -52,7 +52,8 @@ BEGIN
|
||||||
IFNULL(dest.nickname, origin.nickname) nickname,
|
IFNULL(dest.nickname, origin.nickname) nickname,
|
||||||
dest.landed,
|
dest.landed,
|
||||||
dest.preparation,
|
dest.preparation,
|
||||||
origin.departmentFk
|
origin.departmentFk,
|
||||||
|
origin.saleClonedFk
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.ticketFk,
|
SELECT s.ticketFk,
|
||||||
c.salesPersonFk workerFk,
|
c.salesPersonFk workerFk,
|
||||||
|
@ -73,11 +74,13 @@ BEGIN
|
||||||
t.warehouseFk,
|
t.warehouseFk,
|
||||||
t.companyFk,
|
t.companyFk,
|
||||||
t.agencyModeFk,
|
t.agencyModeFk,
|
||||||
wd.departmentFk
|
wd.departmentFk,
|
||||||
|
sc.saleClonedFk
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN client c ON c.id = t.clientFk
|
JOIN client c ON c.id = t.clientFk
|
||||||
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
|
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.id
|
||||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
|
|
|
@ -80,6 +80,12 @@ module.exports = Self => {
|
||||||
description: 'The claimResponsible id',
|
description: 'The claimResponsible id',
|
||||||
http: {source: 'query'}
|
http: {source: 'query'}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'zoneFk',
|
||||||
|
type: 'string',
|
||||||
|
description: 'The zone name',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'myTeam',
|
arg: 'myTeam',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -174,6 +180,8 @@ module.exports = Self => {
|
||||||
to.setHours(23, 59, 59, 999);
|
to.setHours(23, 59, 59, 999);
|
||||||
|
|
||||||
return {'cl.created': {between: [value, to]}};
|
return {'cl.created': {between: [value, to]}};
|
||||||
|
case 'zoneFk':
|
||||||
|
return {'t.zoneFk': value};
|
||||||
case 'myTeam':
|
case 'myTeam':
|
||||||
if (value)
|
if (value)
|
||||||
return {'cl.workerFk': {inq: teamMembersId}};
|
return {'cl.workerFk': {inq: teamMembersId}};
|
||||||
|
@ -195,11 +203,15 @@ module.exports = Self => {
|
||||||
u.name AS workerName,
|
u.name AS workerName,
|
||||||
cs.code stateCode,
|
cs.code stateCode,
|
||||||
cs.description stateDescription,
|
cs.description stateDescription,
|
||||||
cl.created
|
cl.created,
|
||||||
|
z.name zoneName,
|
||||||
|
z.id zoneId
|
||||||
FROM claim cl
|
FROM claim cl
|
||||||
LEFT JOIN client c ON c.id = cl.clientFk
|
LEFT JOIN client c ON c.id = cl.clientFk
|
||||||
LEFT JOIN account.user u ON u.id = cl.workerFk
|
LEFT JOIN account.user u ON u.id = cl.workerFk
|
||||||
LEFT JOIN claimState cs ON cs.id = cl.claimStateFk`
|
LEFT JOIN claimState cs ON cs.id = cl.claimStateFk
|
||||||
|
LEFT JOIN ticket t ON t.id = cl.ticketFk
|
||||||
|
LEFT JOIN zone z ON z.id = t.zoneFk`
|
||||||
);
|
);
|
||||||
|
|
||||||
stmt.merge(conn.makeSuffix(filter));
|
stmt.merge(conn.makeSuffix(filter));
|
||||||
|
|
|
@ -98,6 +98,11 @@ module.exports = Self => {
|
||||||
arg: 'countryFk',
|
arg: 'countryFk',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The country id filter'
|
description: 'The country id filter'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'payMethod',
|
||||||
|
type: 'string',
|
||||||
|
description: 'The payment method filter'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -165,6 +170,8 @@ module.exports = Self => {
|
||||||
case 'clientFk':
|
case 'clientFk':
|
||||||
param = `t.${param}`;
|
param = `t.${param}`;
|
||||||
return {[param]: value};
|
return {[param]: value};
|
||||||
|
case 'payMethod':
|
||||||
|
return {'c.payMethodFk': value};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -205,6 +212,8 @@ module.exports = Self => {
|
||||||
u.name userName,
|
u.name userName,
|
||||||
c.salesPersonFk,
|
c.salesPersonFk,
|
||||||
c.credit,
|
c.credit,
|
||||||
|
c.payMethodFk payMethodFk,
|
||||||
|
pm.id payMethodId,
|
||||||
pm.name payMethod,
|
pm.name payMethod,
|
||||||
z.hour zoneLanding,
|
z.hour zoneLanding,
|
||||||
z.name zoneName,
|
z.name zoneName,
|
||||||
|
|
|
@ -55,6 +55,11 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'Department identifier'
|
description: 'Department identifier'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'onlyWithDestination',
|
||||||
|
type: 'Boolean',
|
||||||
|
description: 'True when only tickets with destination are returned'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'filter',
|
arg: 'filter',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
@ -103,6 +108,8 @@ module.exports = Self => {
|
||||||
return {'f.isFullMovable': value};
|
return {'f.isFullMovable': value};
|
||||||
case 'departmentFk':
|
case 'departmentFk':
|
||||||
return {'f.departmentFk': value};
|
return {'f.departmentFk': value};
|
||||||
|
case 'onlyWithDestination':
|
||||||
|
return {'f.id': value ? {neq: null} : null};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
tomorrow.setDate(today.getDate() + 1);
|
tomorrow.setDate(today.getDate() + 1);
|
||||||
const salesDeptId = 43;
|
const salesDeptId = 43;
|
||||||
const spain1DeptId = 95;
|
const spain1DeptId = 95;
|
||||||
|
const warehouseId = 1;
|
||||||
beforeAll.mockLoopBackContext();
|
beforeAll.mockLoopBackContext();
|
||||||
|
|
||||||
it('should return the tickets passing the required data', async() => {
|
it('should return the tickets passing the required data', async() => {
|
||||||
|
@ -19,7 +20,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
const args = {
|
const args = {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: warehouseId,
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.args = args;
|
ctx.args = args;
|
||||||
|
@ -42,7 +43,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
const args = {
|
const args = {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: warehouseId,
|
||||||
isFullMovable: true
|
isFullMovable: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
const args = {
|
const args = {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: warehouseId,
|
||||||
isFullMovable: false
|
isFullMovable: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
const args = {
|
const args = {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: warehouseId,
|
||||||
ipt: 'V'
|
ipt: 'V'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
const args = {
|
const args = {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: warehouseId,
|
||||||
tfIpt: 'V'
|
tfIpt: 'V'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
ctx.args = {
|
ctx.args = {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: warehouseId,
|
||||||
};
|
};
|
||||||
|
|
||||||
await models.Ticket.updateAll({id: {inq: [12, 31]}}, {clientFk: 1}, options);
|
await models.Ticket.updateAll({id: {inq: [12, 31]}}, {clientFk: 1}, options);
|
||||||
|
@ -167,4 +168,56 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return the tickets with only destination', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dateFuture: today,
|
||||||
|
dateToAdvance: today.setHours(23, 59, 59, 999),
|
||||||
|
warehouseFk: warehouseId,
|
||||||
|
};
|
||||||
|
ctx.args = args;
|
||||||
|
|
||||||
|
const allTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
ctx.args.onlyWithDestination = true;
|
||||||
|
const withDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
|
expect(allTickets.filter(ticket => ticket.id).length).toBe(withDestinationTickets.length);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the tickets without only destination', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dateFuture: today,
|
||||||
|
dateToAdvance: today.setHours(23, 59, 59, 999),
|
||||||
|
warehouseFk: warehouseId,
|
||||||
|
};
|
||||||
|
ctx.args = args;
|
||||||
|
|
||||||
|
const allTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
ctx.args.onlyWithDestination = false;
|
||||||
|
const withoutDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
|
expect(allTickets.filter(ticket => !ticket.id).length).toBe(withoutDestinationTickets.length);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue