diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index e3cbc83e2..35b9b1e37 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -138,9 +138,12 @@ module.exports = Self => { JOIN alertLevel al ON al.id = ts.alertLevel JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id SET t.routeFk = NULL WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) AND al.code NOT IN ('DELIVERED', 'PACKED') + AND NOT t.packages + AND tob.id IS NULL AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); return {