Merge pull request '2700 - Closure by multiple agencies' (#498) from 2700-closure_by_agency into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #498
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2021-01-04 10:58:26 +00:00
commit 11de5743b7
1 changed files with 5 additions and 4 deletions

View File

@ -73,7 +73,7 @@ module.exports = app => {
}
});
app.get('/api/closure/by-agency', async function(req, res) {
app.get('/api/closure/by-agency', async function(req, res, next) {
try {
const reqArgs = req.args;
if (!reqArgs.agencyModeId)
@ -89,6 +89,7 @@ module.exports = app => {
message: 'Task executed successfully'
});
const agenciesId = reqArgs.agencyModeId.split(',');
const tickets = await db.rawSql(`
SELECT
t.id
@ -97,12 +98,12 @@ module.exports = app => {
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
WHERE al.code = 'PACKED'
AND t.agencyModeFk = :agencyModeId
AND t.agencyModeFk IN(:agencyModeId)
AND t.warehouseFk = :warehouseId
AND DATE(t.shipped) BETWEEN DATE_ADD(:to, INTERVAL -2 DAY) AND :to
AND t.refFk IS NULL
GROUP BY e.ticketFk`, {
agencyModeId: reqArgs.agencyModeId,
agencyModeId: agenciesId,
warehouseId: reqArgs.warehouseId,
to: reqArgs.to
});
@ -114,7 +115,7 @@ module.exports = app => {
}
});
app.get('/api/closure/by-route', async function(req, res) {
app.get('/api/closure/by-route', async function(req, res, next) {
try {
const reqArgs = req.args;
if (!reqArgs.routeId)