Merge branch 'master' into test
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2025-03-06 09:40:50 +01:00
commit 15c9873f61
12 changed files with 80 additions and 43 deletions

View File

@ -130,7 +130,7 @@ proc: BEGIN
AND i.warehouseOutFk = vWarehouse AND i.warehouseOutFk = vWarehouse
UNION ALL UNION ALL
SELECT r.item_id, SELECT r.item_id,
r.shipment, util.dayEnd(r.shipment),
-r.amount -r.amount
FROM hedera.order_row r FROM hedera.order_row r
JOIN hedera.`order` o ON o.id = r.order_id JOIN hedera.`order` o ON o.id = r.order_id

View File

@ -155,7 +155,7 @@ BEGIN
orders AS ( orders AS (
SELECT 'order' originType, SELECT 'order' originType,
o.id originId, o.id originId,
r.shipment, util.dayEnd(r.shipment),
NULL 'in', NULL 'in',
r.amount, r.amount,
NULL alertLevel, NULL alertLevel,
@ -190,15 +190,14 @@ BEGIN
SELECT * FROM sales SELECT * FROM sales
UNION ALL UNION ALL
SELECT * FROM orders SELECT * FROM orders
ORDER BY DATE(shipped), ORDER BY (inventorySupplierFk = entityId) DESC,
(inventorySupplierFk = entityId) DESC, shipped,
alertLevel DESC,
isTicket, isTicket,
alertLevel DESC,
`order` DESC, `order` DESC,
isPicked DESC, isPicked DESC,
`in` DESC, `in` DESC,
`out` DESC, `out` DESC;
shipped;
IF vDated IS NULL THEN IF vDated IS NULL THEN
SET @a := 0; SET @a := 0;

View File

@ -14,13 +14,13 @@ BEGIN
DECLARE vCacheAvailableFk INT; DECLARE vCacheAvailableFk INT;
DECLARE vVisibleItemShelving INT; DECLARE vVisibleItemShelving INT;
DECLARE vItemFk 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.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk);
CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated); CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vAvailabled);
CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); CALL buy_getUltimate(vItemFk, vWarehouseFk, DATE(vAvailabled));
SELECT SUM(visible) INTO vVisibleItemShelving SELECT SUM(visible) INTO vVisibleItemShelving
FROM itemShelvingStock FROM itemShelvingStock

View File

@ -1,19 +1,19 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`(
vSelf INT, vSelf INT,
vForce BOOLEAN, vForce BOOLEAN,
vDays INT, vDays INT,
vTime TIME, vTime TIME,
vLongname VARCHAR(255), vLongname VARCHAR(255),
vProducerName VARCHAR(255), vProducerName VARCHAR(255),
vColor VARCHAR(255), vColor VARCHAR(255),
vSize INT, vSize INT,
vOrigen INT, vOrigen INT,
vLack INT, vLack INT,
vWarehouseFk INT, vWarehouseFk INT,
vCategoryFk INT, vCategoryFk INT,
vTypeFk INT vTypeFk INT
) )
BEGIN BEGIN
/** /**
* Calcula una tabla con el máximo negativo visible para cada producto y almacen * 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 vForce Fuerza el recalculo del stock
* @param vDays Numero de dias a considerar * @param vDays Numero de dias a considerar
**/ **/
DECLARE vAvailabled DATETIME;
SET vAvailabled = ADDTIME(util.VN_CURDATE(), vTime);
CALL `cache`.stock_refresh(vForce); CALL item_getStock(vWarehouseFk, vAvailabled, NULL);
CALL item_getMinacum(NULL, ADDTIME(util.VN_CURDATE(), vTime), vDays, NULL); CALL item_getMinacum(NULL, vAvailabled, vDays, NULL);
CALL item_getMinETD(); CALL item_getMinETD();
CALL item_zoneClosure(); CALL item_zoneClosure();
@ -36,24 +38,24 @@ BEGIN
i.category, i.category,
it.categoryFk, it.categoryFk,
w.name warehouse, w.name warehouse,
SUM(IFNULL(sub.amount,0)) lack, CAST(SUM(IFNULL(sub.visible,0)) AS SIGNED) lack,
i.inkFk, i.inkFk,
IFNULL(im.timed, util.midnight()) timed, IFNULL(im.timed, util.midnight()) timed,
IFNULL(izc.timed, util.midnight()) minTimed, IFNULL(izc.timed, util.midnight()) minTimed,
o.name originFk o.name originFk
FROM (SELECT item_id, FROM (SELECT itemFk,
warehouse_id, vWarehouseFk warehouseFk,
amount visible
FROM cache.stock FROM tmp.itemList
WHERE amount > 0 WHERE visible <> 0
UNION ALL UNION ALL
SELECT itemFk, SELECT itemFk,
warehouseFk, warehouseFk,
amount amount
FROM tmp.itemMinacum FROM tmp.itemMinacum
) sub ) sub
JOIN warehouse w ON w.id = sub.warehouse_id JOIN warehouse w ON w.id = sub.warehouseFk
JOIN item i ON i.id = sub.item_id JOIN item i ON i.id = sub.itemFk
LEFT JOIN producer p ON p.id = i.producerFk LEFT JOIN producer p ON p.id = i.producerFk
JOIN itemType it ON it.id = i.typeFk JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk JOIN itemCategory ic ON ic.id = it.categoryFk
@ -69,13 +71,14 @@ BEGIN
AND (vColor IS NULL OR vColor = i.inkFk) AND (vColor IS NULL OR vColor = i.inkFk)
AND (vSize IS NULL OR vSize = i.`size`) AND (vSize IS NULL OR vSize = i.`size`)
AND (vOrigen IS NULL OR vOrigen = w.id) 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 (vWarehouseFk IS NULL OR vWarehouseFk = w.id)
AND (vCategoryFk IS NULL OR vCategoryFk = it.categoryFk) AND (vCategoryFk IS NULL OR vCategoryFk = it.categoryFk)
AND (vTypeFk IS NULL OR vTypeFk = i.typeFk) AND (vTypeFk IS NULL OR vTypeFk = i.typeFk)
GROUP BY i.id, w.id GROUP BY i.id, w.id
HAVING lack < 0; HAVING lack < 0;
DROP TEMPORARY TABLE tmp.itemList;
DROP TEMPORARY TABLE tmp.itemMinacum; DROP TEMPORARY TABLE tmp.itemMinacum;
DROP TEMPORARY TABLE tmp.itemMinETD; DROP TEMPORARY TABLE tmp.itemMinETD;
DROP TEMPORARY TABLE tmp.itemZoneClosure; DROP TEMPORARY TABLE tmp.itemZoneClosure;

View File

@ -1,5 +1,4 @@
DELIMITER $$ DELIMITER $$
$$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getMinacum`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getMinacum`(
vWarehouseFk TINYINT, vWarehouseFk TINYINT,
vAvailabled DATETIME, vAvailabled DATETIME,
@ -68,7 +67,7 @@ BEGIN
AND NOT t.isRaid AND NOT t.isRaid
UNION ALL UNION ALL
SELECT r.itemFk, SELECT r.itemFk,
r.shipment, util.dayEnd(r.shipment),
-r.amount, -r.amount,
r.warehouseFk r.warehouseFk
FROM hedera.orderRow r FROM hedera.orderRow r

View File

@ -115,7 +115,7 @@ BEGIN
t.landed, t.landed,
t.agencyModeFk, t.agencyModeFk,
SEC_TO_TIME( 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 COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) * 60
) preparation ) preparation
FROM ticket t FROM ticket t

View File

@ -45,5 +45,9 @@ BEGIN
SET NEW.availabled = NEW.landed; SET NEW.availabled = NEW.landed;
END IF; END IF;
IF NEW.isReceived <> OLD.isReceived AND NEW.landed >= CURDATE() THEN
SET NEW.landed = CURDATE();
SET NEW.availabled = NOW();
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -6,7 +6,7 @@
"dependencies": [], "dependencies": [],
"menus": { "menus": {
"main": [ "main": [
{"state": "account.index", "icon": "face"}, {"state": "account.index", "icon": "face"}
] ]
}, },
"keybindings": [ "keybindings": [
@ -25,6 +25,22 @@
"state": "account.index", "state": "account.index",
"component": "vn-user-index", "component": "vn-user-index",
"description": "Users" "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"
}
} }
] ]
} }

View File

@ -30,9 +30,9 @@ module.exports = Self => {
const stmt = new ParameterizedSQL( const stmt = new ParameterizedSQL(
`SELECT es.created, u.name, u.id workerFk, est.description state, es.isScanned `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 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')); stmt.merge(Self.buildSuffix(filter, 'es'));

View File

@ -47,6 +47,7 @@ module.exports = Self => {
{ {
arg: 'warehouseFk', arg: 'warehouseFk',
type: 'number', type: 'number',
required: true,
description: 'The warehouse id', description: 'The warehouse id',
}, },
{ {
@ -68,6 +69,11 @@ module.exports = Self => {
arg: 'days', arg: 'days',
type: 'number', type: 'number',
description: 'The range days', description: 'The range days',
},
{
arg: 'time',
type: 'string',
description: 'The time',
} }
], ],
returns: [ returns: [
@ -90,7 +96,7 @@ module.exports = Self => {
Object.assign(myOptions, options); Object.assign(myOptions, options);
const filterKeyOrder = [ const filterKeyOrder = [
'itemFk', 'force', 'days', 'longName', 'supplier', 'itemFk', 'force', 'days', 'time', 'longName', 'supplier',
'inkFk', 'size', 'originFk', 'inkFk', 'size', 'originFk',
'lack', 'warehouseFk', 'categoryFk', 'typeFk' 'lack', 'warehouseFk', 'categoryFk', 'typeFk'
]; ];
@ -109,6 +115,8 @@ module.exports = Self => {
if (!procedureParams[forceIndex])procedureParams[forceIndex] = true; if (!procedureParams[forceIndex])procedureParams[forceIndex] = true;
const daysIndex = filterKeyOrder.indexOf('days'); const daysIndex = filterKeyOrder.indexOf('days');
if (!procedureParams[daysIndex])procedureParams[daysIndex] = 2; 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(', '); const procedureArgs = Array(procedureParams.length).fill('?').join(', ');
let query = `CALL vn.item_getLack(${procedureArgs})`; let query = `CALL vn.item_getLack(${procedureArgs})`;

View File

@ -3,6 +3,7 @@ const {models} = require('vn-loopback/server/server');
describe('Item Lack', () => { describe('Item Lack', () => {
let options; let options;
let tx; let tx;
const warehouseId = {warehouseFk: 1, time: '23:59'};
const ctx = beforeAll.getCtx(); const ctx = beforeAll.getCtx();
beforeAll.mockLoopBackContext(); beforeAll.mockLoopBackContext();
@ -17,7 +18,7 @@ describe('Item Lack', () => {
}); });
it('should return data with NO filters', async() => { it('should return data with NO filters', async() => {
const filter = {}; const filter = {...warehouseId};
const result = await models.Ticket.itemLack(ctx, filter, options); const result = await models.Ticket.itemLack(ctx, filter, options);
expect(result.length).toEqual(2); expect(result.length).toEqual(2);
@ -25,6 +26,7 @@ describe('Item Lack', () => {
it('should return data with filter.id', async() => { it('should return data with filter.id', async() => {
const filter = { const filter = {
...warehouseId,
itemFk: 5 itemFk: 5
}; };
const result = await models.Ticket.itemLack(ctx, filter, options); const result = await models.Ticket.itemLack(ctx, filter, options);
@ -34,6 +36,7 @@ describe('Item Lack', () => {
it('should return data with filter.longname', async() => { it('should return data with filter.longname', async() => {
const filter = { const filter = {
...warehouseId,
longName: 'Ranged weapon pistol 9mm' longName: 'Ranged weapon pistol 9mm'
}; };
const result = await models.Ticket.itemLack(ctx, filter, options); const result = await models.Ticket.itemLack(ctx, filter, options);
@ -43,6 +46,7 @@ describe('Item Lack', () => {
it('should return data with filter.color', async() => { it('should return data with filter.color', async() => {
const filter = { const filter = {
...warehouseId,
inkFk: 'WHT' inkFk: 'WHT'
}; };
const result = await models.Ticket.itemLack(ctx, filter, options); const result = await models.Ticket.itemLack(ctx, filter, options);
@ -52,6 +56,7 @@ describe('Item Lack', () => {
it('should return data with filter.origen', async() => { it('should return data with filter.origen', async() => {
const filter = { const filter = {
...warehouseId,
originFk: 1 originFk: 1
}; };
const result = await models.Ticket.itemLack(ctx, filter, options); const result = await models.Ticket.itemLack(ctx, filter, options);
@ -61,6 +66,7 @@ describe('Item Lack', () => {
it('should return data with filter.size', async() => { it('should return data with filter.size', async() => {
const filter = { const filter = {
...warehouseId,
size: '15' size: '15'
}; };
const result = await models.Ticket.itemLack(ctx, filter, options); const result = await models.Ticket.itemLack(ctx, filter, options);
@ -70,6 +76,7 @@ describe('Item Lack', () => {
it('should return data with filter.lack', async() => { it('should return data with filter.lack', async() => {
const filter = { const filter = {
...warehouseId,
lack: '-15' lack: '-15'
}; };

View File

@ -9,6 +9,7 @@ module.exports = Self => {
arg: 'fi', arg: 'fi',
type: 'string', type: 'string',
description: `The worker fi`, description: `The worker fi`,
required: true,
}, { }, {
arg: 'name', arg: 'name',
type: 'string', type: 'string',