diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index ed1569935..36ef85834 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -131,7 +131,8 @@ BEGIN DELETE e FROM entry e - JOIN tEntryToDelete tmp ON tmp.id = e.id; + JOIN tEntryToDelete tmp ON tmp.id = e.id + WHERE NOT e.isBooked; -- borrar de route registros menores a 4 aƱos CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete diff --git a/db/routines/vn/procedures/collection_addItem.sql b/db/routines/vn/procedures/collection_addItem.sql index c19d88684..b5bc91c67 100644 --- a/db/routines/vn/procedures/collection_addItem.sql +++ b/db/routines/vn/procedures/collection_addItem.sql @@ -52,6 +52,10 @@ BEGIN SELECT LAST_INSERT_ID() INTO vSaleFk; + UPDATE sale + SET originalQuantity = 0 + WHERE id = vSaleFk; + CALL sale_calculateComponent(vSaleFk, NULL); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/workerTimeControl_direction.sql b/db/routines/vn/procedures/workerTimeControl_direction.sql index ce44b9703..f7a68e1e4 100644 --- a/db/routines/vn/procedures/workerTimeControl_direction.sql +++ b/db/routines/vn/procedures/workerTimeControl_direction.sql @@ -26,7 +26,7 @@ BEGIN FROM workerTimeControl WHERE userFk = vWorkerFk AND direction = 'middle' - AND timed BETWEEN vLastIn AND util.VN_NOW(); + AND timed BETWEEN vLastIn AND vTimed; DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection; CREATE TEMPORARY TABLE tmp.workerTimeControlDirection diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index d4e2d0f74..207f8020f 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -27,8 +27,11 @@ module.exports = Self => { const where = filter.where; const query = 'CALL vn.item_getBalance(?, ?, ?)'; + if (where?.date) { + where.date = new Date(where.date); + where.date.setHours(0, 0, 0, 0); + } const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); - for (const entry of diary) if (entry.clientType === 'loses') entry.highlighted = true;