diff --git a/db/routines/cache/procedures/available_refresh.sql b/db/routines/cache/procedures/available_refresh.sql index 87c003648..0e42a62cd 100644 --- a/db/routines/cache/procedures/available_refresh.sql +++ b/db/routines/cache/procedures/available_refresh.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refres OUT `vCalc` INT, `vRefresh` INT, `vWarehouse` INT, - `vDated` DATE + `vAvailabled` DATETIME ) proc: BEGIN DECLARE vStartDate DATE; @@ -12,6 +12,7 @@ proc: BEGIN DECLARE vInventoryDate DATE; DECLARE vLifeScope DATE; DECLARE vWarehouseFkInventory INT; + DECLARE vDated DATE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -19,13 +20,17 @@ proc: BEGIN RESIGNAL; END; - IF vDated < util.VN_CURDATE() THEN + IF vAvailabled < util.VN_CURDATE() THEN LEAVE proc; END IF; + SET vDated = DATE(vAvailabled); + + SET vAvailabled = vDated + INTERVAL HOUR(vAvailabled) HOUR; + CALL vn.item_getStock(vWarehouse, vDated, NULL); - SET vParams = CONCAT_WS('/', vWarehouse, vDated); + SET vParams = CONCAT_WS('/', vWarehouse, vAvailabled); CALL cache_calc_start (vCalc, vRefresh, 'available', vParams); IF !vRefresh THEN @@ -87,11 +92,10 @@ proc: BEGIN SELECT i.itemFk, i.landed, i.quantity FROM vn.itemEntryIn i JOIN itemRange ir ON ir.itemFk = i.itemFk - LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk WHERE i.landed >= vStartDate + AND IFNULL(i.availabled, i.landed) <= vAvailabled AND (ir.ended IS NULL OR i.landed <= ir.ended) AND i.warehouseInFk = vWarehouse - AND ISNULL(wf.entryFk) UNION ALL SELECT i.itemFk, i.shipped, i.quantity FROM vn.itemEntryOut i diff --git a/db/routines/vn/procedures/item_getStock.sql b/db/routines/vn/procedures/item_getStock.sql index 8c0eea251..cd5bc4bdc 100644 --- a/db/routines/vn/procedures/item_getStock.sql +++ b/db/routines/vn/procedures/item_getStock.sql @@ -15,8 +15,6 @@ BEGIN * * @return tmp.itemList(itemFk, stock, visible, available) */ - DECLARE vIsLogifloraDay BOOL DEFAULT vn.isLogifloraDay(vDated, vWarehouseFk); - SET vDated = TIMESTAMP(vDated, '00:00:00'); CREATE OR REPLACE TEMPORARY TABLE tmp.itemList @@ -36,14 +34,11 @@ BEGIN UNION ALL SELECT iei.itemFk, iei.quantity FROM itemEntryIn iei - LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = iei.entryFk JOIN item i ON i.id = iei.itemFk WHERE iei.landed >= util.VN_CURDATE() AND iei.landed < vDated AND iei.warehouseInFk = vWarehouseFk AND (vItemFk IS NULL OR iei.itemFk = vItemFk) - AND (wf.entryFk IS NULL OR vIsLogifloraDay) - AND NOT (iei.landed > util.VN_CURDATE() AND i.isFloramondo) UNION ALL SELECT ieo.itemFk, ieo.quantity FROM itemEntryOut ieo @@ -52,7 +47,6 @@ BEGIN AND ieo.shipped < vDated AND ieo.warehouseOutFk = vWarehouseFk AND (vItemFk IS NULL OR ieo.itemFk = vItemFk) - AND NOT (ieo.shipped > util.VN_CURDATE() AND i.isFloramondo) ) sub GROUP BY itemFk HAVING stock; diff --git a/db/routines/vn/views/itemEntryIn.sql b/db/routines/vn/views/itemEntryIn.sql index 60af585f2..5be558a43 100644 --- a/db/routines/vn/views/itemEntryIn.sql +++ b/db/routines/vn/views/itemEntryIn.sql @@ -7,7 +7,8 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`, `b`.`quantity` AS `quantity`, `t`.`isReceived` AS `isReceived`, `t`.`isRaid` AS `isVirtualStock`, - `e`.`id` AS `entryFk` + `e`.`id` AS `entryFk`, + `t`.`availabled` FROM ( ( `vn`.`buy` `b` diff --git a/db/versions/11411-turquoiseEucalyptus/00-agencyIncomingForeign.sql b/db/versions/11411-turquoiseEucalyptus/00-agencyIncomingForeign.sql index 829236a2a..7d8f44040 100644 --- a/db/versions/11411-turquoiseEucalyptus/00-agencyIncomingForeign.sql +++ b/db/versions/11411-turquoiseEucalyptus/00-agencyIncomingForeign.sql @@ -1,3 +1,5 @@ +USE vn; + DELETE ai from `vn`.`agencyIncoming` ai LEFT JOIN `vn`.`agencyMode` am ON @@ -7,6 +9,6 @@ DELETE ai from ALTER TABLE `vn`.`agencyIncoming` ADD CONSTRAINT `fk_agencyIncoming_agencyMode` FOREIGN KEY (`agencyModeFk`) - REFERENCES `agencyMode`(`id`) + REFERENCES `vn`.`agencyMode`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11424-navyRose/00-travel.sql b/db/versions/11424-navyRose/00-travel.sql new file mode 100644 index 000000000..eabd83d5e --- /dev/null +++ b/db/versions/11424-navyRose/00-travel.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.travel ADD IF NOT EXISTS availabled DATETIME NULL +COMMENT 'Indicates the moment in time when the goods become available for picking';