feat: salesPersonFk to saleDepartmentFk refs #6802
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
3b5f88fd33
commit
d8086c7776
|
@ -34,8 +34,6 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const stmt = new ParameterizedSQL(`
|
||||
SELECT v.id,
|
||||
d.name salesDepartment,
|
||||
|
@ -48,10 +46,7 @@ module.exports = Self => {
|
|||
FROM hedera.visitUser v
|
||||
JOIN client c ON c.id = v.userFk
|
||||
LEFT JOIN department d ON d.id = c.salesDepartmentFk
|
||||
LEFT JOIN workerDepartment wd ON wd.departmentFk = d.id
|
||||
LEFT JOIN sharingCart sc ON sc.workerFk = wd.workerFk
|
||||
AND ? BETWEEN sc.started AND sc.ended`,
|
||||
[date]);
|
||||
LEFT JOIN workerDepartment wd ON wd.departmentFk = d.id`);
|
||||
|
||||
if (!filter.where) filter.where = {};
|
||||
|
||||
|
@ -62,7 +57,6 @@ module.exports = Self => {
|
|||
stmt.merge(`GROUP BY clientFk, v.stamp`);
|
||||
stmt.merge(conn.makePagination(filter));
|
||||
|
||||
console.log('stmt: ', stmt);
|
||||
return conn.executeStmt(stmt, myOptions);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('SalesMonitor clientsFilter()', () => {
|
||||
fit('should return the clients web activity', async() => {
|
||||
it('should return the clients web activity', async() => {
|
||||
const tx = await models.SalesMonitor.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
@ -19,10 +19,8 @@ describe('SalesMonitor clientsFilter()', () => {
|
|||
}
|
||||
};
|
||||
const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
|
||||
console.log('result: ', result);
|
||||
console.log('filter: ', from, to);
|
||||
|
||||
expect(result.length).toEqual(3);
|
||||
expect(result.length).toEqual(1);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -52,7 +50,7 @@ describe('SalesMonitor clientsFilter()', () => {
|
|||
|
||||
const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
expect(result.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -180,25 +180,6 @@ describe('SalesMonitor salesFilter()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should now return the tickets that are not from the worker team', async() => {
|
||||
const tx = await models.SalesMonitor.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: false}};
|
||||
const filter = {};
|
||||
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(4);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the tickets sorted by problems descendant', async() => {
|
||||
const tx = await models.SalesMonitor.beginTransaction({});
|
||||
|
||||
|
|
|
@ -186,13 +186,6 @@ module.exports = Self => {
|
|||
return {'ts.stateFk': value};
|
||||
case 'collectionFk':
|
||||
return {'cll.id': value};
|
||||
case 'mine':
|
||||
case 'myTeam':
|
||||
if (value)
|
||||
return {'c.salesDepartmentFk': {inq: teamMembersId}};
|
||||
else
|
||||
return {'c.salesDepartmentFk': {nin: teamMembersId}};
|
||||
|
||||
case 'alertLevel':
|
||||
return {'ts.alertLevel': value};
|
||||
case 'hasRoute':
|
||||
|
@ -205,9 +198,6 @@ module.exports = Self => {
|
|||
return {'t.refFk': null};
|
||||
case 'pending':
|
||||
return {'st.isNotValidated': value};
|
||||
case 'id':
|
||||
case 'clientFk':
|
||||
case 'agencyModeFk':
|
||||
case 'warehouseFk':
|
||||
param = `t.${param}`;
|
||||
return {[param]: value};
|
||||
|
|
|
@ -165,13 +165,13 @@ describe('ticket filter()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should return the tickets from the worker team', async() => {
|
||||
it('should return the tickets from the salesDeparment', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: true}};
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {salesDepartmentFk: 80}};
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -184,13 +184,13 @@ describe('ticket filter()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should return the tickets that are not from the worker team', async() => {
|
||||
it('should return the tickets that are not from the salesDeparment', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: false}};
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {salesDepartmentFk: 80}};
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
|
Loading…
Reference in New Issue