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