diff --git a/print/methods/closure.js b/print/methods/closure.js index 1df9564bd..2a7ac19fb 100644 --- a/print/methods/closure.js +++ b/print/methods/closure.js @@ -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)