diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 1f85aeebe..480a88f35 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -128,8 +128,9 @@ BEGIN SELECT TRUE FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode + WHERE (s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode) + OR s.code = 'LAST_CALL' ) INTO vHasAssignedTickets; -- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados @@ -138,8 +139,9 @@ BEGIN DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state - WHERE s.code <> 'PICKER_DESIGNED' - OR pb.workerCode <> vWorkerCode; + WHERE (s.code <> 'PICKER_DESIGNED' + OR pb.workerCode <> vWorkerCode) + AND s.code <> 'LAST_CALL'; ELSE DELETE pb FROM tmp.productionBuffer pb