Merge branch 'dev' into 7404-roundDetailVolume
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
f019214002
|
@ -21,9 +21,8 @@ BEGIN
|
||||||
SELECT tob.ticketFk, tob.description
|
SELECT tob.ticketFk, tob.description
|
||||||
FROM vn.ticketObservation tob
|
FROM vn.ticketObservation tob
|
||||||
JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk
|
JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk
|
||||||
LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk
|
JOIN vn.observationType ot ON ot.id = tob.observationTypeFk AND ot.`code` = 'itemPicker'
|
||||||
WHERE ot.`code` = 'itemPicker'
|
WHERE tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk
|
||||||
AND tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk
|
|
||||||
)
|
)
|
||||||
SELECT t.id ticketFk,
|
SELECT t.id ticketFk,
|
||||||
IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
||||||
|
|
|
@ -18,9 +18,11 @@ BEGIN
|
||||||
* @param vDaysInForward Días de alcance para las ventas
|
* @param vDaysInForward Días de alcance para las ventas
|
||||||
*/
|
*/
|
||||||
DECLARE vAvailableCalcFk INT;
|
DECLARE vAvailableCalcFk INT;
|
||||||
|
DECLARE vVisibleCalcFk INT;
|
||||||
DECLARE vPriority INT DEFAULT 1;
|
DECLARE vPriority INT DEFAULT 1;
|
||||||
|
|
||||||
CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated);
|
CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated);
|
||||||
|
CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk);
|
||||||
|
|
||||||
WITH itemTags AS (
|
WITH itemTags AS (
|
||||||
SELECT i.id,
|
SELECT i.id,
|
||||||
|
@ -41,12 +43,6 @@ BEGIN
|
||||||
LEFT JOIN vn.tag t ON t.id = it.tagFk
|
LEFT JOIN vn.tag t ON t.id = it.tagFk
|
||||||
WHERE i.id = vSelf
|
WHERE i.id = vSelf
|
||||||
),
|
),
|
||||||
stock AS (
|
|
||||||
SELECT itemFk, SUM(visible) stock
|
|
||||||
FROM vn.itemShelvingStock
|
|
||||||
WHERE warehouseFk = vWarehouseFk
|
|
||||||
GROUP BY itemFk
|
|
||||||
),
|
|
||||||
sold AS (
|
sold AS (
|
||||||
SELECT SUM(s.quantity) quantity, s.itemFk
|
SELECT SUM(s.quantity) quantity, s.itemFk
|
||||||
FROM vn.sale s
|
FROM vn.sale s
|
||||||
|
@ -58,7 +54,7 @@ BEGIN
|
||||||
GROUP BY s.itemFk
|
GROUP BY s.itemFk
|
||||||
)
|
)
|
||||||
SELECT i.id itemFk,
|
SELECT i.id itemFk,
|
||||||
LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable,
|
LEAST(CAST(sd.quantity AS INT), v.visible) advanceable,
|
||||||
i.longName,
|
i.longName,
|
||||||
i.subName,
|
i.subName,
|
||||||
i.tag5,
|
i.tag5,
|
||||||
|
@ -80,13 +76,14 @@ BEGIN
|
||||||
WHEN b.groupingMode = 'packing' THEN b.packing
|
WHEN b.groupingMode = 'packing' THEN b.packing
|
||||||
ELSE 1
|
ELSE 1
|
||||||
END minQuantity,
|
END minQuantity,
|
||||||
sk.stock located,
|
v.visible located,
|
||||||
b.price2
|
b.price2
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
LEFT JOIN sold sd ON sd.itemFk = i.id
|
LEFT JOIN sold sd ON sd.itemFk = i.id
|
||||||
JOIN cache.available a ON a.item_id = i.id
|
JOIN cache.available a ON a.item_id = i.id
|
||||||
AND a.calc_id = vAvailableCalcFk
|
AND a.calc_id = vAvailableCalcFk
|
||||||
LEFT JOIN stock sk ON sk.itemFk = i.id
|
LEFT JOIN cache.visible v ON v.item_id = i.id
|
||||||
|
AND v.calc_id = vVisibleCalcFk
|
||||||
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id
|
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id
|
||||||
AND lb.warehouse_id = vWarehouseFk
|
AND lb.warehouse_id = vWarehouseFk
|
||||||
LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id
|
LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id
|
||||||
|
@ -96,7 +93,7 @@ BEGIN
|
||||||
LEFT JOIN vn.tag t ON t.id = it.tagFk
|
LEFT JOIN vn.tag t ON t.id = it.tagFk
|
||||||
LEFT JOIN vn.buy b ON b.id = lb.buy_id
|
LEFT JOIN vn.buy b ON b.id = lb.buy_id
|
||||||
JOIN itemTags its
|
JOIN itemTags its
|
||||||
WHERE (a.available > 0 OR sd.quantity < sk.stock)
|
WHERE (a.available > 0 OR sd.quantity < v.visible)
|
||||||
AND (i.typeFk = its.typeFk OR NOT vShowType)
|
AND (i.typeFk = its.typeFk OR NOT vShowType)
|
||||||
AND i.id <> vSelf
|
AND i.id <> vSelf
|
||||||
ORDER BY (a.available > 0) DESC,
|
ORDER BY (a.available > 0) DESC,
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS `vn`.`itemStateTag` (
|
||||||
|
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(50) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `name_UNIQUE` (`name`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT
|
||||||
|
CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Artificial');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Inactivo');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Preservado');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Seco');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Seco y preservado');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Estabilizada');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Natural y seco');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Preservado y artificial');
|
||||||
|
INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Usado');
|
||||||
|
|
||||||
|
UPDATE vn.tag
|
||||||
|
SET isFree=0,
|
||||||
|
sourceTable='itemStateTag'
|
||||||
|
WHERE name= 'Estado';
|
Loading…
Reference in New Issue