8355-testToMaster #3336

Merged
alexm merged 241 commits from 8355-testToMaster into master 2025-01-07 06:44:57 +00:00
5 changed files with 94 additions and 10 deletions
Showing only changes of commit 7a3339b623 - Show all commits

View File

@ -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

View File

@ -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));

View File

@ -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,

View File

@ -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};
}
});

View File

@ -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;
}
});
});