From aba0d971063386e646dfc36ea8d915d5210503a8 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 31 Jan 2024 09:00:43 +0100 Subject: [PATCH 1/7] feat: refs#5167 Update --- db/routines/vn/procedures/fustControl.sql | 79 ------------------- .../vn/procedures/fustControlDetail.sql | 36 --------- 2 files changed, 115 deletions(-) delete mode 100644 db/routines/vn/procedures/fustControl.sql delete mode 100644 db/routines/vn/procedures/fustControlDetail.sql diff --git a/db/routines/vn/procedures/fustControl.sql b/db/routines/vn/procedures/fustControl.sql deleted file mode 100644 index 506354b20..000000000 --- a/db/routines/vn/procedures/fustControl.sql +++ /dev/null @@ -1,79 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`fustControl`(vFromDated DATE, vToDated DATE) -BEGIN - - DECLARE vSijsnerClientFk INT DEFAULT 19752; - - DECLARE vDateStart DATETIME; - DECLARE vDateEnd DATETIME; - - SET vDateStart = vFromDated; - SET vDateEnd = util.Dayend(vToDated); - - SELECT p.id FustCode, - CAST(sent.stucks AS DECIMAL(10,0)) FH, - CAST(tp.stucks AS DECIMAL(10,0)) Tickets, - CAST(-sj.stucks AS DECIMAL(10,0)) Sijsner, - CAST(IFNULL(sent.stucks,0) - IFNULL(tp.stucks,0) + IFNULL(sj.stucks,0) AS DECIMAL(10,0)) saldo - FROM vn.packaging p - LEFT JOIN ( - SELECT FustCode, sum(fustQuantity) stucks - FROM ( - SELECT IFNULL(pe.equivalentFk ,b.packagingFk) FustCode, s.quantity / b.packing AS fustQuantity - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = t.warehouseFk - JOIN vn.buy b ON b.id = lb.buy_id - JOIN vn.packaging p ON p.id = b.packagingFk - LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p2 ON p2.id = a.provinceFk - JOIN vn.country c ON c.id = p2.countryFk - WHERE t.shipped BETWEEN vDateStart AND vDateEnd - AND wa.name = 'VNH' - AND p.isPackageReturnable - AND c.country = 'FRANCIA') sub - GROUP BY FustCode) sent ON sent.FustCode = p.id - LEFT JOIN ( - SELECT FustCode, sum(quantity) stucks - FROM ( - SELECT IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, tp.quantity - FROM vn.ticketPackaging tp - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN vn.packaging p ON p.id = tp.packagingFk - LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p2 ON p2.id = a.provinceFk - JOIN vn.country c ON c.id = p2.countryFk - WHERE t.shipped BETWEEN vDateStart AND vDateEnd - AND wa.name = 'VNH' - AND p.isPackageReturnable - AND c.country = 'FRANCIA' - AND t.clientFk != vSijsnerClientFk - AND tp.quantity > 0) sub - GROUP BY FustCode) tp ON tp.FustCode = p.id - LEFT JOIN ( - SELECT FustCode, sum(quantity) stucks - FROM ( - SELECT IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, tp.quantity - FROM vn.ticketPackaging tp - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN vn.packaging p ON p.id = tp.packagingFk - LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id - WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, 1, vDateStart ) AND TIMESTAMPADD(DAY, 1, vDateEnd ) - AND wa.name = 'VNH' - AND p.isPackageReturnable - AND t.clientFk = vSijsnerClientFk) sub - GROUP BY FustCode) sj ON sj.FustCode = p.id - WHERE sent.stucks - OR tp.stucks - OR sj.stucks; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/fustControlDetail.sql b/db/routines/vn/procedures/fustControlDetail.sql deleted file mode 100644 index a48a3531b..000000000 --- a/db/routines/vn/procedures/fustControlDetail.sql +++ /dev/null @@ -1,36 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`fustControlDetail`(vFromDated DATE, vToDated DATE) -BEGIN - - DECLARE vSijsnerClientFk INT DEFAULT 19752; - - DECLARE vDateStart DATETIME; - DECLARE vDateEnd DATETIME; - - SET vDateStart = vFromDated; - SET vDateEnd = util.Dayend(vToDated); - - SELECT a.nickname shopName, - a.city , - IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, - tp.quantity, - tp.ticketFk, - CONCAT('From ', vFromDated,' to ', vToDated) AS dateRange - FROM vn.ticketPackaging tp - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN vn.packaging p ON p.id = tp.packagingFk - LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p2 ON p2.id = a.provinceFk - JOIN vn.country c ON c.id = p2.countryFk - WHERE t.shipped BETWEEN vFromDated AND util.dayend(vToDated) - AND wa.name = 'VNH' - AND p.isPackageReturnable - AND c.country = 'FRANCIA' - AND t.clientFk != vSijsnerClientFk - AND tp.quantity > 0; - -END$$ -DELIMITER ; From 18772c04f6efd189efadadc2115178c6e16ed1ad Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 31 Jan 2024 09:38:57 +0100 Subject: [PATCH 2/7] feat: refs #5167 update --- db/dump/fixtures.after.sql | 7 +- db/dump/fixtures.before.sql | 43 +++++----- .../itemPlacementSupplyStockGetTargetList.sql | 21 ++--- .../vn/triggers/warehouse_afterUpdate.sql | 12 --- db/routines/vn/views/warehouseJoined.sql | 6 -- .../vn/views/zoneEstimatedDelivery.sql | 25 ------ .../vn2008/procedures/desglose_volume.sql | 82 ------------------- db/routines/vn2008/views/agency.sql | 1 - db/routines/vn2008/views/v_price_fixed.sql | 35 -------- db/routines/vn2008/views/v_warehouse.sql | 10 --- db/routines/vn2008/views/warehouse_alias.sql | 6 -- .../10857-navyArborvitae/00-firstScript.sql | 6 ++ 12 files changed, 36 insertions(+), 218 deletions(-) delete mode 100644 db/routines/vn/triggers/warehouse_afterUpdate.sql delete mode 100644 db/routines/vn/views/warehouseJoined.sql delete mode 100644 db/routines/vn/views/zoneEstimatedDelivery.sql delete mode 100644 db/routines/vn2008/procedures/desglose_volume.sql delete mode 100644 db/routines/vn2008/views/v_price_fixed.sql delete mode 100644 db/routines/vn2008/views/v_warehouse.sql delete mode 100644 db/routines/vn2008/views/warehouse_alias.sql create mode 100644 db/versions/10857-navyArborvitae/00-firstScript.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 57ccb8626..4d8f1b9b5 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -73,9 +73,10 @@ INSERT INTO vn.cmr (id, truckPlate, observations, senderInstruccions, paymentIns UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101'); -INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `warehouseAliasFk`, `isOwn`, `isAnyVolumeAllowed`) VALUES - ('Agencia', '1', '1', '1', '1'), - ('Otra agencia ', '1', '2', '0', '0'); +INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`) + VALUES + ('Agencia', '1', '1', '1'), + ('Otra agencia ', '1', '0', '0'); INSERT INTO `vn`.`expedition` (`agencyModeFk`, `ticketFk`, `isBox`, `counter`, `workerFk`, `externalId`, `packagingFk`, `hostFk`, `itemPackingTypeFk`, `hasNewRoute`) VALUES ('1', '1', 1, '1', '1', '1', '1', 'pc00', 'F', 0), diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 0f608d19d..42049a782 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -174,20 +174,15 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, (19,'Francia', 1, 'FR', 1, 27, 4, 0, 1), (30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2); -INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) +INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`) VALUES - (1, 'Main Warehouse'), - (2, 'Gotham'); - -INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`) - VALUES - (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1), - (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1), - (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), - (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), - (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), - (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0), - (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0); + (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), + (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0), + (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0), + (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1), + (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), + (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0), + (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0); INSERT INTO `vn`.`sectorType` (id,description) VALUES (1,'First type'); @@ -271,18 +266,18 @@ INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`) (3, 'PICKUP', 'Recogida'), (4, 'OTHER', 'Otros'); -INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `warehouseAliasFk`) +INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`) VALUES - (1, 'inhouse pickup' , 1, 1), - (2, 'Super-Man delivery' , 1, 1), - (3, 'Teleportation device' , 1, 1), - (4, 'Entanglement' , 1, 1), - (5, 'Quantum break device' , 1, 1), - (6, 'Walking' , 1, 1), - (7, 'Gotham247' , 1, 1), - (8, 'Gotham247Expensive' , 1, 1), - (9, 'Refund' , 1, 1), - (10, 'Other agency' , 1, 1); + (1, 'inhouse pickup' , 1), + (2, 'Super-Man delivery' , 1), + (3, 'Teleportation device' , 1), + (4, 'Entanglement' , 1), + (5, 'Quantum break device' , 1), + (6, 'Walking' , 1), + (7, 'Gotham247' , 1), + (8, 'Gotham247Expensive' , 1), + (9, 'Refund' , 1), + (10, 'Other agency' , 1); UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup'; UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery'; diff --git a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql index 424e3438d..e77d88b70 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql @@ -8,27 +8,20 @@ BEGIN * @param vItemFk Identificador de vn.item * @param vSectorFk Identificador de vn.sector */ - DECLARE vWarehouseAliasFk INT; - - SELECT w.aliasFk INTO vWarehouseAliasFk - FROM vn.sector s - JOIN vn.warehouse w ON w.id = s.warehouseFk - WHERE s.id = vSectorFk; - SELECT ish.shelvingFk shelving, - p.code parking, - sum(ish.visible) as stockTotal, - ish.created, - p.pickingOrder + p.code parking, + SUM(ish.visible) as stockTotal, + ish.created, + p.pickingOrder FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.warehouse w ON w.id = sc.warehouseFk - WHERE w.aliasFk = vWarehouseAliasFk + WHERE sc.id = vSectorFk AND ish.visible > 0 AND ish.itemFk = vItemFk GROUP BY ish.id - ORDER BY (sc.id = vSectorFk) DESC, sh.priority DESC, ish.created, p.pickingOrder; + ORDER BY sh.priority DESC, ish.created, p.pickingOrder; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/warehouse_afterUpdate.sql b/db/routines/vn/triggers/warehouse_afterUpdate.sql deleted file mode 100644 index 93f424429..000000000 --- a/db/routines/vn/triggers/warehouse_afterUpdate.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`warehouse_afterUpdate` - AFTER UPDATE ON `warehouse` - FOR EACH ROW -BEGIN - IF NEW.isFeedStock IS TRUE AND OLD.isFeedStock IS FALSE THEN - INSERT IGNORE INTO warehouseAlias(`name`) VALUES(NEW.`name`); - INSERT IGNORE INTO warehouseJoined(warehouseFk, warehouseAliasFk) - VALUES(NEW.id,LAST_INSERT_ID()); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/views/warehouseJoined.sql b/db/routines/vn/views/warehouseJoined.sql deleted file mode 100644 index dbbb40b1a..000000000 --- a/db/routines/vn/views/warehouseJoined.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`warehouseJoined` -AS SELECT `wj`.`warehouse_id` AS `warehouseFk`, - `wj`.`warehouse_alias_id` AS `warehouseAliasFk` -FROM `vn2008`.`warehouse_joined` `wj` diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql deleted file mode 100644 index e52d5487e..000000000 --- a/db/routines/vn/views/zoneEstimatedDelivery.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`zoneEstimatedDelivery` - AS SELECT t.zoneFk, - zc.`hour` zoneClosureHour, - z.`hour` zoneHour, - sv.volume volume, - al.hasToRecalcPrice, - lhp.m3, - dl.minSpeed - FROM ticket t - JOIN ticketStateToday tst ON tst.ticket = t.id - JOIN state s ON s.id = tst.state - JOIN saleVolume sv ON sv.ticketFk = t.id - LEFT JOIN lastHourProduction lhp ON lhp.warehouseFk = t.warehouseFk - JOIN warehouse w ON w.id = t.warehouseFk - JOIN warehouseAlias wa ON wa.id = w.aliasFk - STRAIGHT_JOIN `zone` z ON z.id = t.zoneFk - LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - AND zc.dated = util.VN_CURDATE() - LEFT JOIN cache.departure_limit dl ON dl.warehouse_id = t.warehouseFk - AND dl.fecha = util.VN_CURDATE() - JOIN alertLevel al ON al.id = s.alertLevel - WHERE w.hasProduction - AND DATE(t.shipped) = util.VN_CURDATE() diff --git a/db/routines/vn2008/procedures/desglose_volume.sql b/db/routines/vn2008/procedures/desglose_volume.sql deleted file mode 100644 index 3fcad4b71..000000000 --- a/db/routines/vn2008/procedures/desglose_volume.sql +++ /dev/null @@ -1,82 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`desglose_volume`(IN vAgencyFk INT) -BEGIN - - DECLARE vStarted DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE()); - DECLARE vEnded DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE(), '23:59:59'); - DECLARE vIsHolland BOOL; - - SELECT (wa.name = 'Holanda') INTO vIsHolland - FROM vn.agency a - JOIN vn.warehouseAlias wa ON wa.id = a.warehouseAliasFk - WHERE a.id = vAgencyFk; - - IF vIsHolland THEN - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated; - CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated - ( - ticketFk INT PRIMARY KEY - ,carros DECIMAL(5,1) DEFAULT 0 - ); - - INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, carros) - SELECT sv.ticketFk, ROUND(vc.dutchCompressionRate * sum(sv.volume) / vc.trolleyM3,0) - FROM vn.ticket t - JOIN vn.saleVolume sv ON sv.ticketFk = t.id - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.volumeConfig vc - WHERE t.shipped BETWEEN vStarted AND vEnded - AND am.agencyFk = vAgencyFk - GROUP BY t.id; - - SELECT a.nickname Provincia, - count(*) expediciones, - 0 Bultos, - sum(tpe.carros) Prevision - FROM vn.ticket t - JOIN vn.address a ON a.id = t.addressFk - JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id - GROUP BY a.nickname; - - ELSE - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated; - CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated - ( - ticketFk INT PRIMARY KEY - ,boxes INT DEFAULT 0 - ); - - INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, boxes) - SELECT sv.ticketFk, CEIL(1000 * sum(sv.volume) / vc.standardFlowerBox) - FROM vn.ticket t - JOIN vn.saleVolume sv ON sv.ticketFk = t.id - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.volumeConfig vc - WHERE t.shipped BETWEEN vStarted AND vEnded - AND IFNULL(t.packages,0) = 0 - AND am.agencyFk = vAgencyFk - GROUP BY t.id; - - - SELECT p.name Provincia, - count(*) expediciones, - sum(t.packages) Bultos, - sum(tpe.boxes) Prevision - FROM vn.ticket t - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p ON a.provinceFk = p.id - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id - WHERE t.warehouseFk = 60 - AND t.shipped BETWEEN vStarted AND vEnded - AND am.agencyFk = vAgencyFk - GROUP BY p.name; - - END IF; - SELECT * FROM tmp.ticket_PackagingEstimated; - DROP TEMPORARY TABLE tmp.ticket_PackagingEstimated; - -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/views/agency.sql b/db/routines/vn2008/views/agency.sql index 819fbd009..637bb0910 100644 --- a/db/routines/vn2008/views/agency.sql +++ b/db/routines/vn2008/views/agency.sql @@ -4,7 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` AS SELECT `a`.`id` AS `agency_id`, `a`.`name` AS `name`, `a`.`warehouseFk` AS `warehouse_id`, - `a`.`warehouseAliasFk` AS `warehouse_alias_id`, `a`.`isOwn` AS `propios`, `a`.`workCenterFk` AS `workCenterFk` FROM `vn`.`agency` `a` diff --git a/db/routines/vn2008/views/v_price_fixed.sql b/db/routines/vn2008/views/v_price_fixed.sql deleted file mode 100644 index db48e5a46..000000000 --- a/db/routines/vn2008/views/v_price_fixed.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`v_price_fixed` -AS SELECT `pf`.`warehouse_id` AS `warehouse_id`, - `pf`.`item_id` AS `item_id`, - `pf`.`rate_0` AS `rate_0`, - `pf`.`rate_1` AS `rate_1`, - `pf`.`rate_2` AS `rate_2`, - `pf`.`rate_3` AS `rate_3`, - `pf`.`date_start` AS `date_start`, - `pf`.`date_end` AS `date_end`, - `pf`.`bonus` AS `bonus`, - `pf`.`grouping` AS `grouping`, - `pf`.`Packing` AS `Packing`, - `pf`.`caja` AS `caja` -FROM `vn2008`.`price_fixed` `pf` -WHERE `pf`.`warehouse_id` < 1000 -UNION ALL -SELECT `wg`.`warehouse_id` AS `warehouse_id`, - `pf`.`item_id` AS `item_id`, - `pf`.`rate_0` AS `rate_0`, - `pf`.`rate_1` AS `rate_1`, - `pf`.`rate_2` AS `rate_2`, - `pf`.`rate_3` AS `rate_3`, - `pf`.`date_start` AS `date_start`, - `pf`.`date_end` AS `date_end`, - `pf`.`bonus` AS `bonus`, - `pf`.`grouping` AS `grouping`, - `pf`.`Packing` AS `Packing`, - `pf`.`caja` AS `caja` -FROM ( - `vn2008`.`price_fixed` `pf` - JOIN `vn2008`.`warehouse_group` `wg` - ) -WHERE `wg`.`warehouse_alias_id` + 1000 = `pf`.`warehouse_id` diff --git a/db/routines/vn2008/views/v_warehouse.sql b/db/routines/vn2008/views/v_warehouse.sql deleted file mode 100644 index fd17b6a06..000000000 --- a/db/routines/vn2008/views/v_warehouse.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`v_warehouse` -AS SELECT `warehouse`.`id` AS `id`, - `warehouse`.`name` AS `almacen` -FROM `vn2008`.`warehouse` -UNION ALL -SELECT 1000 + `warehouse_alias`.`warehouse_alias_id` AS `warehouse_alias_id`, - concat(`warehouse_alias`.`alias`, '(G)') AS `concat(alias, '(G)')` -FROM `vn2008`.`warehouse_alias` diff --git a/db/routines/vn2008/views/warehouse_alias.sql b/db/routines/vn2008/views/warehouse_alias.sql deleted file mode 100644 index 9a151c9d5..000000000 --- a/db/routines/vn2008/views/warehouse_alias.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`warehouse_alias` -AS SELECT `wa`.`id` AS `warehouse_alias_id`, - `wa`.`name` AS `alias` -FROM `vn`.`warehouseAlias` `wa` diff --git a/db/versions/10857-navyArborvitae/00-firstScript.sql b/db/versions/10857-navyArborvitae/00-firstScript.sql new file mode 100644 index 000000000..f379f54cd --- /dev/null +++ b/db/versions/10857-navyArborvitae/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.agency CHANGE warehouseAliasFk warehouseAliasFk__ smallint(5) unsigned DEFAULT NULL NULL COMMENT 'Refs #5167 Deprecated 2024-01-23'; + +ALTER TABLE vn.warehouse CHANGE aliasFk aliasFk__ smallint(5) unsigned DEFAULT NULL NULL COMMENT 'Refs #5167 Deprecated 2024-01-23'; + +RENAME TABLE vn.warehouseAlias TO vn.warehouseAlias__; +ALTER TABLE vn.warehouseAlias__ COMMENT='Refs #5167 Deprecated 2024-01-23'; \ No newline at end of file From f4591aae85b6d73df9a6f9f3514df3db3204917a Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 5 Feb 2024 08:07:12 +0100 Subject: [PATCH 3/7] feat: refs #5167 Restaurar zoneEstimatedDelivery --- .../vn/views/zoneEstimatedDelivery.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 db/routines/vn/views/zoneEstimatedDelivery.sql diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql new file mode 100644 index 000000000..a58286efc --- /dev/null +++ b/db/routines/vn/views/zoneEstimatedDelivery.sql @@ -0,0 +1,24 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn`.`zoneEstimatedDelivery` + AS SELECT t.zoneFk, + zc.`hour` zoneClosureHour, + z.`hour` zoneHour, + sv.volume volume, + al.hasToRecalcPrice, + lhp.m3, + dl.minSpeed + FROM ticket t + JOIN ticketStateToday tst ON tst.ticket = t.id + JOIN state s ON s.id = tst.state + JOIN saleVolume sv ON sv.ticketFk = t.id + LEFT JOIN lastHourProduction lhp ON lhp.warehouseFk = t.warehouseFk + JOIN warehouse w ON w.id = t.warehouseFk + STRAIGHT_JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + AND zc.dated = util.VN_CURDATE() + LEFT JOIN cache.departure_limit dl ON dl.warehouse_id = t.warehouseFk + AND dl.fecha = util.VN_CURDATE() + JOIN alertLevel al ON al.id = s.alertLevel + WHERE w.hasProduction + AND DATE(t.shipped) = util.VN_CURDATE() From 9f6807204d80705139b01557a0875266476a40d9 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 6 Feb 2024 08:05:30 +0100 Subject: [PATCH 4/7] feat: refs #5167 changes required --- .../itemPlacementSupplyStockGetTargetList.sql | 12 +++++++----- db/versions/10857-navyArborvitae/00-firstScript.sql | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql index e77d88b70..bdc13ae9d 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql @@ -10,7 +10,7 @@ BEGIN */ SELECT ish.shelvingFk shelving, p.code parking, - SUM(ish.visible) as stockTotal, + SUM(ish.visible) stockTotal, ish.created, p.pickingOrder FROM vn.itemShelving ish @@ -18,10 +18,12 @@ BEGIN JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.warehouse w ON w.id = sc.warehouseFk - WHERE sc.id = vSectorFk - AND ish.visible > 0 - AND ish.itemFk = vItemFk + WHERE sc.id = vSectorFk + AND ish.visible > 0 + AND ish.itemFk = vItemFk GROUP BY ish.id - ORDER BY sh.priority DESC, ish.created, p.pickingOrder; + ORDER BY sh.priority DESC, + ish.created, + p.pickingOrder; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10857-navyArborvitae/00-firstScript.sql b/db/versions/10857-navyArborvitae/00-firstScript.sql index f379f54cd..78b0f8c8c 100644 --- a/db/versions/10857-navyArborvitae/00-firstScript.sql +++ b/db/versions/10857-navyArborvitae/00-firstScript.sql @@ -3,4 +3,4 @@ ALTER TABLE vn.agency CHANGE warehouseAliasFk warehouseAliasFk__ smallint(5) uns ALTER TABLE vn.warehouse CHANGE aliasFk aliasFk__ smallint(5) unsigned DEFAULT NULL NULL COMMENT 'Refs #5167 Deprecated 2024-01-23'; RENAME TABLE vn.warehouseAlias TO vn.warehouseAlias__; -ALTER TABLE vn.warehouseAlias__ COMMENT='Refs #5167 Deprecated 2024-01-23'; \ No newline at end of file +ALTER TABLE vn.warehouseAlias__ COMMENT='@Deprecated 2024-01-23 Refs #5167'; \ No newline at end of file From 7ebb9cb429aa2f4717bc5d59f4cb60b2281e81e2 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 6 Feb 2024 09:55:47 +0100 Subject: [PATCH 5/7] feat: refs #5167 change required --- db/versions/10857-navyArborvitae/00-firstScript.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/versions/10857-navyArborvitae/00-firstScript.sql b/db/versions/10857-navyArborvitae/00-firstScript.sql index 78b0f8c8c..507ddcfaa 100644 --- a/db/versions/10857-navyArborvitae/00-firstScript.sql +++ b/db/versions/10857-navyArborvitae/00-firstScript.sql @@ -1,6 +1,8 @@ -ALTER TABLE vn.agency CHANGE warehouseAliasFk warehouseAliasFk__ smallint(5) unsigned DEFAULT NULL NULL COMMENT 'Refs #5167 Deprecated 2024-01-23'; +ALTER TABLE vn.agency + CHANGE warehouseAliasFk warehouseAliasFk__ SMALLINT(5) unsigned DEFAULT NULL NULL COMMENT '@Deprecated 2024-01-23 Refs #5167'; -ALTER TABLE vn.warehouse CHANGE aliasFk aliasFk__ smallint(5) unsigned DEFAULT NULL NULL COMMENT 'Refs #5167 Deprecated 2024-01-23'; +ALTER TABLE vn.warehouse + CHANGE aliasFk aliasFk__ SMALLINT(5) UNSIGNED DEFAULT NULL NULL COMMENT '@Deprecated 2024-01-23 Refs #5167'; RENAME TABLE vn.warehouseAlias TO vn.warehouseAlias__; ALTER TABLE vn.warehouseAlias__ COMMENT='@Deprecated 2024-01-23 Refs #5167'; \ No newline at end of file From a949c25860aad740d350b7f9b025668338e5e13f Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 6 Feb 2024 10:09:39 +0100 Subject: [PATCH 6/7] feat refs #5167 changes required --- db/versions/10857-navyArborvitae/00-firstScript.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/versions/10857-navyArborvitae/00-firstScript.sql b/db/versions/10857-navyArborvitae/00-firstScript.sql index 507ddcfaa..64e4d5282 100644 --- a/db/versions/10857-navyArborvitae/00-firstScript.sql +++ b/db/versions/10857-navyArborvitae/00-firstScript.sql @@ -1,8 +1,8 @@ ALTER TABLE vn.agency - CHANGE warehouseAliasFk warehouseAliasFk__ SMALLINT(5) unsigned DEFAULT NULL NULL COMMENT '@Deprecated 2024-01-23 Refs #5167'; + CHANGE warehouseAliasFk warehouseAliasFk__ SMALLINT(5) UNSIGNED DEFAULT NULL NULL COMMENT '@deprecated 2024-01-23 refs #5167'; ALTER TABLE vn.warehouse - CHANGE aliasFk aliasFk__ SMALLINT(5) UNSIGNED DEFAULT NULL NULL COMMENT '@Deprecated 2024-01-23 Refs #5167'; + CHANGE aliasFk aliasFk__ SMALLINT(5) UNSIGNED DEFAULT NULL NULL COMMENT '@deprecated 2024-01-23 refs #5167'; RENAME TABLE vn.warehouseAlias TO vn.warehouseAlias__; -ALTER TABLE vn.warehouseAlias__ COMMENT='@Deprecated 2024-01-23 Refs #5167'; \ No newline at end of file +ALTER TABLE vn.warehouseAlias__ COMMENT='@deprecated 2024-01-23 refs #5167'; \ No newline at end of file From b3e658f9aabb6a18a5bc7058ad98f7c46a29b3ce Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 6 Feb 2024 10:20:04 +0100 Subject: [PATCH 7/7] ci: refs#6706 Jenkinsfile fixes --- Jenkinsfile | 106 +++++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 47 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bd19e8e15..28c5e4775 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,34 +5,36 @@ def FROM_GIT def RUN_TESTS def RUN_BUILD -pre: { - switch (env.BRANCH_NAME) { - case 'test': - env.NODE_ENV = 'test' - env.BACK_REPLICAS = 2 - break - case 'master': - env.NODE_ENV = 'production' - env.BACK_REPLICAS = 4 - break - default: - env.NODE_ENV = 'dev' - env.BACK_REPLICAS = 1 +node { + stage('Setup') { + switch (env.BRANCH_NAME) { + case 'test': + env.NODE_ENV = 'test' + env.BACK_REPLICAS = 2 + break + case 'master': + env.NODE_ENV = 'production' + env.BACK_REPLICAS = 4 + break + default: + env.NODE_ENV = 'dev' + env.BACK_REPLICAS = 1 + } + + PROTECTED_BRANCH = [ + 'dev', + 'test', + 'master' + ].contains(env.BRANCH_NAME) + + FROM_GIT = env.JOB_NAME.startsWith('gitea/') + RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT + RUN_BUILD = PROTECTED_BRANCH && FROM_GIT + + // Uncomment to enable debugging + // https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference + //env.DEBUG = 'strong-remoting:shared-method' } - - PROTECTED_BRANCH = [ - 'dev', - 'test', - 'master' - ].contains(env.BRANCH_NAME) - - FROM_GIT = env.JOB_NAME.startsWith('gitea/') - RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT - RUN_BUILD = PROTECTED_BRANCH && FROM_GIT - - // Uncomment to enable debugging - // https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference - //env.DEBUG = 'strong-remoting:shared-method' } pipeline { agent any @@ -47,29 +49,47 @@ pipeline { STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" } stages { + stage('Install') { + environment { + NODE_ENV = '' + } + parallel { + stage('Back') { + steps { + sh 'pnpm install --prefer-offline' + } + } + stage('Print') { + when { + expression { FROM_GIT } + } + steps { + sh 'pnpm install --prefer-offline --prefix=print' + } + } + stage('Front') { + when { + expression { FROM_GIT } + } + steps { + sh 'pnpm install --prefer-offline --prefix=front' + } + } + } + } stage('Stack') { environment { - NODE_ENV = "" TZ = 'Europe/Madrid' } parallel { stage('Back') { stages { - stage('Install') { - environment { - NODE_ENV = "" - } - steps { - sh 'pnpm install --prefer-offline' - sh 'pnpm install --prefer-offline --prefix=print' - } - } stage('Test') { when { expression { RUN_TESTS } } environment { - NODE_ENV = "" + NODE_ENV = '' } steps { sh 'npm run test:back:ci' @@ -106,20 +126,12 @@ pipeline { expression { FROM_GIT } } stages { - stage('Install') { - environment { - NODE_ENV = "" - } - steps { - sh 'pnpm install --prefer-offline --prefix=front' - } - } stage('Test') { when { expression { RUN_TESTS } } environment { - NODE_ENV = "" + NODE_ENV = '' } steps { sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=10'