diff --git a/db/routines/cache/procedures/available_refresh.sql b/db/routines/cache/procedures/available_refresh.sql index eeb85d5799..a8923381be 100644 --- a/db/routines/cache/procedures/available_refresh.sql +++ b/db/routines/cache/procedures/available_refresh.sql @@ -130,7 +130,7 @@ proc: BEGIN AND i.warehouseOutFk = vWarehouse UNION ALL SELECT r.item_id, - r.shipment, + util.dayEnd(r.shipment), -r.amount FROM hedera.order_row r JOIN hedera.`order` o ON o.id = r.order_id diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index a13d4af05c..d6dd337c95 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -155,7 +155,7 @@ BEGIN orders AS ( SELECT 'order' originType, o.id originId, - r.shipment, + util.dayEnd(r.shipment), NULL 'in', r.amount, NULL alertLevel, @@ -190,15 +190,14 @@ BEGIN SELECT * FROM sales UNION ALL SELECT * FROM orders - ORDER BY DATE(shipped), - (inventorySupplierFk = entityId) DESC, - alertLevel DESC, + ORDER BY (inventorySupplierFk = entityId) DESC, + shipped, isTicket, + alertLevel DESC, `order` DESC, isPicked DESC, `in` DESC, - `out` DESC, - shipped; + `out` DESC; IF vDated IS NULL THEN SET @a := 0; diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql index bd59728f7e..829eb3463b 100644 --- a/db/routines/vn/procedures/item_getInfo.sql +++ b/db/routines/vn/procedures/item_getInfo.sql @@ -14,13 +14,13 @@ BEGIN DECLARE vCacheAvailableFk INT; DECLARE vVisibleItemShelving INT; DECLARE vItemFk INT; - DECLARE vDated DATE; + DECLARE vAvailabled DATETIME; - SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated; + SELECT barcodeToItem(vBarcode), util.VN_NOW() INTO vItemFk, vAvailabled; CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); - CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated); - CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); + CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vAvailabled); + CALL buy_getUltimate(vItemFk, vWarehouseFk, DATE(vAvailabled)); SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql index 931964245b..1d59374ed6 100644 --- a/db/routines/vn/procedures/item_getLack.sql +++ b/db/routines/vn/procedures/item_getLack.sql @@ -1,19 +1,19 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`( vSelf INT, - vForce BOOLEAN, - vDays INT, - vTime TIME, - vLongname VARCHAR(255), - vProducerName VARCHAR(255), - vColor VARCHAR(255), - vSize INT, - vOrigen INT, - vLack INT, - vWarehouseFk INT, - vCategoryFk INT, - vTypeFk INT - ) + vForce BOOLEAN, + vDays INT, + vTime TIME, + vLongname VARCHAR(255), + vProducerName VARCHAR(255), + vColor VARCHAR(255), + vSize INT, + vOrigen INT, + vLack INT, + vWarehouseFk INT, + vCategoryFk INT, + vTypeFk INT +) BEGIN /** * Calcula una tabla con el máximo negativo visible para cada producto y almacen @@ -21,9 +21,11 @@ BEGIN * @param vForce Fuerza el recalculo del stock * @param vDays Numero de dias a considerar **/ + DECLARE vAvailabled DATETIME; + SET vAvailabled = ADDTIME(util.VN_CURDATE(), vTime); - CALL `cache`.stock_refresh(vForce); - CALL item_getMinacum(NULL, ADDTIME(util.VN_CURDATE(), vTime), vDays, NULL); + CALL item_getStock(vWarehouseFk, vAvailabled, NULL); + CALL item_getMinacum(NULL, vAvailabled, vDays, NULL); CALL item_getMinETD(); CALL item_zoneClosure(); @@ -36,24 +38,24 @@ BEGIN i.category, it.categoryFk, w.name warehouse, - SUM(IFNULL(sub.amount,0)) lack, + CAST(SUM(IFNULL(sub.visible,0)) AS SIGNED) lack, i.inkFk, IFNULL(im.timed, util.midnight()) timed, IFNULL(izc.timed, util.midnight()) minTimed, o.name originFk - FROM (SELECT item_id, - warehouse_id, - amount - FROM cache.stock - WHERE amount > 0 + FROM (SELECT itemFk, + vWarehouseFk warehouseFk, + visible + FROM tmp.itemList + WHERE visible <> 0 UNION ALL SELECT itemFk, warehouseFk, amount FROM tmp.itemMinacum ) sub - JOIN warehouse w ON w.id = sub.warehouse_id - JOIN item i ON i.id = sub.item_id + JOIN warehouse w ON w.id = sub.warehouseFk + JOIN item i ON i.id = sub.itemFk LEFT JOIN producer p ON p.id = i.producerFk JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk @@ -69,13 +71,14 @@ BEGIN AND (vColor IS NULL OR vColor = i.inkFk) AND (vSize IS NULL OR vSize = i.`size`) AND (vOrigen IS NULL OR vOrigen = w.id) - AND (vLack IS NULL OR vLack = sub.amount) + AND (vLack IS NULL OR vLack = sub.visible) AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id) AND (vCategoryFk IS NULL OR vCategoryFk = it.categoryFk) AND (vTypeFk IS NULL OR vTypeFk = i.typeFk) GROUP BY i.id, w.id HAVING lack < 0; + DROP TEMPORARY TABLE tmp.itemList; DROP TEMPORARY TABLE tmp.itemMinacum; DROP TEMPORARY TABLE tmp.itemMinETD; DROP TEMPORARY TABLE tmp.itemZoneClosure; diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index 8a07b43fc7..2b820fa622 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -1,5 +1,4 @@ DELIMITER $$ -$$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getMinacum`( vWarehouseFk TINYINT, vAvailabled DATETIME, @@ -68,7 +67,7 @@ BEGIN AND NOT t.isRaid UNION ALL SELECT r.itemFk, - r.shipment, + util.dayEnd(r.shipment), -r.amount, r.warehouseFk FROM hedera.orderRow r diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index cee706e08c..1dfaddae1c 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -115,7 +115,7 @@ BEGIN t.landed, t.agencyModeFk, SEC_TO_TIME( - COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)) * 3600 + + COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)) * 3600 + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) * 60 ) preparation FROM ticket t diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 2c78bf54eb..b3971d4892 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -45,5 +45,9 @@ BEGIN SET NEW.availabled = NEW.landed; END IF; + IF NEW.isReceived <> OLD.isReceived AND NEW.landed >= CURDATE() THEN + SET NEW.landed = CURDATE(); + SET NEW.availabled = NOW(); + END IF; END$$ DELIMITER ; diff --git a/modules/account/front/routes.json b/modules/account/front/routes.json index 9eadf2af21..11b80dd4a5 100644 --- a/modules/account/front/routes.json +++ b/modules/account/front/routes.json @@ -6,7 +6,7 @@ "dependencies": [], "menus": { "main": [ - {"state": "account.index", "icon": "face"}, + {"state": "account.index", "icon": "face"} ] }, "keybindings": [ @@ -25,6 +25,22 @@ "state": "account.index", "component": "vn-user-index", "description": "Users" + }, + { + "url": "/:id", + "state": "account.card", + "component": "vn-user-card", + "abstract": true, + "description": "Detail" + }, + { + "url": "/summary", + "state": "account.card.summary", + "component": "vn-user-summary", + "description": "Summary", + "params": { + "user": "$ctrl.user" + } } ] } diff --git a/modules/ticket/back/methods/expedition-state/filter.js b/modules/ticket/back/methods/expedition-state/filter.js index 3a4e7a87c5..2da29fc0ca 100644 --- a/modules/ticket/back/methods/expedition-state/filter.js +++ b/modules/ticket/back/methods/expedition-state/filter.js @@ -30,9 +30,9 @@ module.exports = Self => { const stmt = new ParameterizedSQL( `SELECT es.created, u.name, u.id workerFk, est.description state, es.isScanned - FROM vn.expeditionState es + FROM vn.expeditionState es JOIN vn.expeditionStateType est ON est.id = es.typeFk - JOIN account.user u ON u.id = es.userFk + LEFT JOIN account.user u ON u.id = es.userFk `); stmt.merge(Self.buildSuffix(filter, 'es')); diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 7e56ba8079..b644ec5f79 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -47,6 +47,7 @@ module.exports = Self => { { arg: 'warehouseFk', type: 'number', + required: true, description: 'The warehouse id', }, { @@ -68,6 +69,11 @@ module.exports = Self => { arg: 'days', type: 'number', description: 'The range days', + }, + { + arg: 'time', + type: 'string', + description: 'The time', } ], returns: [ @@ -90,7 +96,7 @@ module.exports = Self => { Object.assign(myOptions, options); const filterKeyOrder = [ - 'itemFk', 'force', 'days', 'longName', 'supplier', + 'itemFk', 'force', 'days', 'time', 'longName', 'supplier', 'inkFk', 'size', 'originFk', 'lack', 'warehouseFk', 'categoryFk', 'typeFk' ]; @@ -109,6 +115,8 @@ module.exports = Self => { if (!procedureParams[forceIndex])procedureParams[forceIndex] = true; const daysIndex = filterKeyOrder.indexOf('days'); if (!procedureParams[daysIndex])procedureParams[daysIndex] = 2; + const timeIndex = filterKeyOrder.indexOf('time'); + if (!procedureParams[timeIndex])procedureParams[timeIndex] = '23:59'; const procedureArgs = Array(procedureParams.length).fill('?').join(', '); let query = `CALL vn.item_getLack(${procedureArgs})`; diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index fb3a604315..858b122aed 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -3,6 +3,7 @@ const {models} = require('vn-loopback/server/server'); describe('Item Lack', () => { let options; let tx; + const warehouseId = {warehouseFk: 1, time: '23:59'}; const ctx = beforeAll.getCtx(); beforeAll.mockLoopBackContext(); @@ -17,7 +18,7 @@ describe('Item Lack', () => { }); it('should return data with NO filters', async() => { - const filter = {}; + const filter = {...warehouseId}; const result = await models.Ticket.itemLack(ctx, filter, options); expect(result.length).toEqual(2); @@ -25,6 +26,7 @@ describe('Item Lack', () => { it('should return data with filter.id', async() => { const filter = { + ...warehouseId, itemFk: 5 }; const result = await models.Ticket.itemLack(ctx, filter, options); @@ -34,6 +36,7 @@ describe('Item Lack', () => { it('should return data with filter.longname', async() => { const filter = { + ...warehouseId, longName: 'Ranged weapon pistol 9mm' }; const result = await models.Ticket.itemLack(ctx, filter, options); @@ -43,6 +46,7 @@ describe('Item Lack', () => { it('should return data with filter.color', async() => { const filter = { + ...warehouseId, inkFk: 'WHT' }; const result = await models.Ticket.itemLack(ctx, filter, options); @@ -52,6 +56,7 @@ describe('Item Lack', () => { it('should return data with filter.origen', async() => { const filter = { + ...warehouseId, originFk: 1 }; const result = await models.Ticket.itemLack(ctx, filter, options); @@ -61,6 +66,7 @@ describe('Item Lack', () => { it('should return data with filter.size', async() => { const filter = { + ...warehouseId, size: '15' }; const result = await models.Ticket.itemLack(ctx, filter, options); @@ -70,6 +76,7 @@ describe('Item Lack', () => { it('should return data with filter.lack', async() => { const filter = { + ...warehouseId, lack: '-15' }; diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 7da8a8da27..f1a960fe3a 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -9,6 +9,7 @@ module.exports = Self => { arg: 'fi', type: 'string', description: `The worker fi`, + required: true, }, { arg: 'name', type: 'string',