From 7a557be09a0256d95636dbfc34d9c80daecb4e6b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 11:07:57 +0200 Subject: [PATCH 1/8] feat: refs #6968 Changed groupingMode to enum --- db/dump/fixtures.before.sql | 52 +++++++++---------- db/routines/edi/procedures/ekt_load.sql | 3 +- .../procedures/floramondo_offerRefresh.sql | 10 ++-- .../procedures/catalog_componentCalculate.sql | 7 +-- .../vn/procedures/collectionPlacement_get.sql | 4 +- db/routines/vn/procedures/inventoryMake.sql | 2 +- db/routines/vn/procedures/item_getSimilar.sql | 4 +- .../vn/procedures/sale_replaceItem.sql | 8 ++- db/routines/vn/triggers/buy_beforeInsert.sql | 2 +- db/versions/10997-crimsonCyca/00-part1.sql | 2 + db/versions/10997-crimsonCyca/01-part2.sql | 7 +++ db/versions/10997-crimsonCyca/02-part3.sql | 2 + modules/entry/back/models/buy.json | 2 +- modules/entry/front/buy/index/index.html | 8 +-- modules/entry/front/buy/index/index.js | 8 +-- modules/entry/front/buy/index/index.spec.js | 27 +++------- modules/entry/front/latest-buys/index.html | 4 +- modules/entry/front/summary/index.html | 4 +- modules/item/front/last-entries/index.html | 4 +- 19 files changed, 77 insertions(+), 83 deletions(-) create mode 100644 db/versions/10997-crimsonCyca/00-part1.sql create mode 100644 db/versions/10997-crimsonCyca/01-part2.sql create mode 100644 db/versions/10997-crimsonCyca/02-part3.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c9832545f..277734eb7 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1492,21 +1492,21 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) VALUES - (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), - (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), - (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), - (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), - (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), - (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), - (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), - (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), - (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), - (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), - (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), - (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()); + (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), + (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), + (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, NULL, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), + (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, NULL, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), + (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), + (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'packing', NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), + (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), + (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES @@ -3235,7 +3235,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3273,7 +3273,7 @@ INSERT INTO vn.buy stickers = 1, packing = 40, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3311,7 +3311,7 @@ INSERT INTO vn.buy stickers = 2, packing = 10, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3357,7 +3357,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 4, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3395,7 +3395,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3434,7 +3434,7 @@ INSERT INTO vn.buy stickers = 1, packing = 200, `grouping` = 30, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3473,7 +3473,7 @@ INSERT INTO vn.buy stickers = 1, packing = 500, `grouping` = 10, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3512,7 +3512,7 @@ INSERT INTO vn.buy stickers = 2, packing = 300, `grouping` = 50, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3551,7 +3551,7 @@ INSERT INTO vn.buy stickers = 2, packing = 50, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3591,7 +3591,7 @@ INSERT vn.buy stickers = 1, packing = 5, `grouping` = 2, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, @@ -3630,7 +3630,7 @@ INSERT vn.buy stickers = 1, packing = 100, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index ccdcd1999..a72f48674 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -14,7 +14,6 @@ proc:BEGIN DECLARE vPackage INT; DECLARE vPutOrderFk INT; DECLARE vIsLot BOOLEAN; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vEntryFk INT; DECLARE vHasToChangePackagingFk BOOLEAN; DECLARE vIsFloramondoDirect BOOLEAN; @@ -150,7 +149,7 @@ proc:BEGIN @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, - vForceToPacking, + 'packing', IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk), (IFNULL(i.weightByPiece, 0) * @pac) / 1000 FROM ekt e diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql index 26e09ebaf..18d3f8b7e 100644 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ b/db/routines/edi/procedures/floramondo_offerRefresh.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() proc: BEGIN DECLARE vLanded DATETIME; DECLARE vDone INT DEFAULT FALSE; @@ -417,7 +417,7 @@ proc: BEGIN o.NumberOfUnits etiquetas, o.NumberOfItemsPerCask packing, GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, - 2, -- Obliga al Packing + 'packing', o.embalageCode, o.diId FROM edi.offer o @@ -518,5 +518,5 @@ proc: BEGIN fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 1af0ff9eb..4b860103d 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -48,7 +48,7 @@ BEGIN IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3, IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing, IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, + b.groupingMode groupingMode, tl.buyFk, i.typeFk, IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping @@ -252,14 +252,15 @@ BEGIN SELECT tcc.warehouseFk, tcc.itemFk, 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, + IF(tcc.groupingMode = 'grouping', tcc.`grouping`, 1) `grouping`, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) + AND NOT tcc.groupingMode = 'packing' + AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL) GROUP BY tcs.warehouseFk, tcs.itemFk; INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index 3641ba705..3fb3339e7 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -40,8 +40,8 @@ BEGIN ENGINE = MEMORY SELECT b.itemFk, CASE b.groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN b.packing + WHEN NULL THEN 1 + WHEN 'packing' THEN b.packing ELSE b.`grouping` END `grouping` FROM buy b diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index c50d75b05..b7ea377d2 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -116,7 +116,7 @@ BEGIN freightValue decimal(10,3) DEFAULT '0.000', packing int(11) DEFAULT '1', `grouping` smallint(5) unsigned NOT NULL DEFAULT '1', - groupingMode tinyint(4) NOT NULL DEFAULT 0 , + groupingMode enum('grouping', 'packing') DEFAULT NULL, comissionValue decimal(10,3) DEFAULT '0.000', packageValue decimal(10,3) DEFAULT '0.000', packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--', diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index f79bed375..1da60cf70 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -61,8 +61,8 @@ BEGIN a.available, IFNULL(ip.counter, 0) `counter`, CASE - WHEN b.groupingMode = 1 THEN b.grouping - WHEN b.groupingMode = 2 THEN b.packing + WHEN b.groupingMode = 'grouping' THEN b.grouping + WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END AS minQuantity, iss.visible located diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 82c5d1ec2..2514c14c7 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vWarehouseFk SMALLINT; DECLARE vDate DATE; DECLARE vGrouping INT; - DECLARE vGroupingModeFk INT; + DECLARE vGroupingModeFk VARCHAR(255); DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; DECLARE vLanded DATE; @@ -23,8 +23,6 @@ BEGIN DECLARE vOldPrice DECIMAL(10,2); DECLARE vOption VARCHAR(255); DECLARE vNewSaleFk INT; - DECLARE vForceToGrouping INT DEFAULT 1; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vFinalPrice DECIMAL(10,2); DECLARE EXIT HANDLER FOR SQLEXCEPTION @@ -63,10 +61,10 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; - IF vGroupingModeFk = vForceToPacking AND vPacking > 0 THEN + IF vGroupingModeFk = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; - IF vGroupingModeFk = vForceToGrouping AND vGrouping > 0 THEN + IF vGroupingModeFk = 'grouping' AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index bc51ac852..6ad72916b 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -6,7 +6,7 @@ trig: BEGIN DECLARE vWarehouse INT; DECLARE vLanding DATE; DECLARE vGrouping INT; - DECLARE vGroupingMode TINYINT; + DECLARE vGroupingMode VARCHAR(255); DECLARE vGenericFk INT; DECLARE vGenericInDate BOOL; DECLARE vBuyerFk INT; diff --git a/db/versions/10997-crimsonCyca/00-part1.sql b/db/versions/10997-crimsonCyca/00-part1.sql new file mode 100644 index 000000000..8811b81a7 --- /dev/null +++ b/db/versions/10997-crimsonCyca/00-part1.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; diff --git a/db/versions/10997-crimsonCyca/01-part2.sql b/db/versions/10997-crimsonCyca/01-part2.sql new file mode 100644 index 000000000..1f7a3c9f6 --- /dev/null +++ b/db/versions/10997-crimsonCyca/01-part2.sql @@ -0,0 +1,7 @@ +UPDATE vn.buy + SET groupingMode2 = 'packing' + WHERE groupingMode = 2; + +UPDATE vn.buy + SET groupingMode2 = 'grouping' + WHERE groupingMode = 1; diff --git a/db/versions/10997-crimsonCyca/02-part3.sql b/db/versions/10997-crimsonCyca/02-part3.sql new file mode 100644 index 000000000..c63560957 --- /dev/null +++ b/db/versions/10997-crimsonCyca/02-part3.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.buy DROP COLUMN groupingMode; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index fa804f4d8..35861fd81 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -34,7 +34,7 @@ "type": "number" }, "groupingMode": { - "type": "number" + "type": "string" }, "comissionValue": { "type": "number" diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html index 203d6c522..0e0c69788 100644 --- a/modules/entry/front/buy/index/index.html +++ b/modules/entry/front/buy/index/index.html @@ -119,13 +119,13 @@ @@ -140,13 +140,13 @@ diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js index c991b745b..9131c31f6 100644 --- a/modules/entry/front/buy/index/index.js +++ b/modules/entry/front/buy/index/index.js @@ -53,12 +53,8 @@ export default class Controller extends Section { } toggleGroupingMode(buy, mode) { - const grouping = 1; - const packing = 2; - const groupingMode = mode === 'grouping' ? grouping : packing; - - const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode; - + const groupingMode = mode === 'grouping' ? mode : 'packing'; + const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode; const params = { groupingMode: newGroupingMode }; diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index b9d5fab51..f5c6d1bdb 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -57,45 +57,34 @@ describe('Entry buy', () => { describe('toggleGroupingMode()', () => { it(`should toggle grouping mode from grouping to packing`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: grouping}; + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'packing'}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle grouping mode from packing to grouping`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: grouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'grouping'}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was packing to packing`, () => { - const noGrouping = 0; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was grouping to grouping`, () => { - const noGrouping = 0; - const grouping = 1; - const buy = {id: 999, groupingMode: grouping}; - + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 16e039cf0..2e6de83b9 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -143,12 +143,12 @@ - + {{::buy.packing | dashIfEmpty}} - + {{::buy.grouping | dashIfEmpty}} diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 655dcd66f..baa310bb6 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -121,12 +121,12 @@ {{::line.packagingFk | dashIfEmpty}} {{::line.weight}} - + {{::line.packing | dashIfEmpty}} - + {{::line.grouping | dashIfEmpty}} diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html index 429955ef5..e3b84655c 100644 --- a/modules/item/front/last-entries/index.html +++ b/modules/item/front/last-entries/index.html @@ -71,12 +71,12 @@ {{entry.stickers | dashIfEmpty}} - + {{::entry.packing | dashIfEmpty}} - + {{::entry.grouping | dashIfEmpty}} From 01d959f6f4ca1efec573298222f8f1380cb85161 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 16 Apr 2024 12:46:50 +0200 Subject: [PATCH 2/8] feat: refs #7219 --- db/routines/vn/procedures/sale_replaceItem.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 82c5d1ec2..1d9f6ff71 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -81,10 +81,6 @@ BEGIN ORDER BY (vQuantity % `grouping`) ASC LIMIT 1; - IF vNewPrice IS NULL THEN - CALL util.throw('price retrieval failed'); - END IF; - IF vNewPrice > vOldPrice THEN SET vFinalPrice = vOldPrice; SET vOption = 'substitution'; From c8e7706652702ff5106359c2d1e1f17c7de9e6fd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 07:15:24 +0200 Subject: [PATCH 3/8] feat: refs #6968 Requested changes --- db/routines/vn/procedures/sale_replaceItem.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 2514c14c7..9fece1ebd 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vWarehouseFk SMALLINT; DECLARE vDate DATE; DECLARE vGrouping INT; - DECLARE vGroupingModeFk VARCHAR(255); + DECLARE vGroupingMode VARCHAR(255); DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; DECLARE vLanded DATE; @@ -56,15 +56,15 @@ BEGIN CALL buyUltimate(vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing - INTO vGrouping,vGroupingModeFk,vPacking + INTO vGrouping,vGroupingMode,vPacking FROM buy b JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; - IF vGroupingModeFk = 'packing' AND vPacking > 0 THEN + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; - IF vGroupingModeFk = 'grouping' AND vGrouping > 0 THEN + IF vGroupingMode = 'grouping' AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; From 786a5a68b91632f922bb7be8753bf52f76fa885a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 08:40:25 +0200 Subject: [PATCH 4/8] hotfix: EKT --- db/routines/edi/procedures/ekt_load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index 34814453b..08ecddf1d 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -147,7 +147,7 @@ proc:BEGIN (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue, IFNULL(vItem, vDefaultEntry) itemFk, e.qty stickers, - @pac := GREATEST(1, IFNULL(i.stemMultiplier * e.pac / @t, 0)) packing, + @pac := GREATEST(1, IFNULL(i.stemMultiplier, 1) * e.pac / @t) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, vForceToPacking, From 6214da2c42eec2b1604bed71c76747e2418e4add Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 17 Apr 2024 09:52:53 +0200 Subject: [PATCH 5/8] feat(salix): refs #6930 Undo rollback salix-back --- back/methods/dms/downloadFile.js | 2 +- back/methods/docuware/download.js | 2 +- back/methods/image/download.js | 2 +- modules/claim/back/methods/claim/claimPickupPdf.js | 2 +- modules/claim/back/methods/claim/downloadFile.js | 2 +- modules/client/back/methods/client/campaignMetricsPdf.js | 2 +- modules/entry/back/methods/entry/entryOrderPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/download.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/downloadZip.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js | 2 +- modules/item/back/methods/item-image-queue/download.js | 2 +- modules/route/back/methods/route/cmr.js | 3 ++- modules/route/back/methods/route/downloadCmrsZip.js | 2 +- modules/route/back/methods/route/downloadZip.js | 2 +- modules/route/back/methods/route/driverRoutePdf.js | 2 +- modules/supplier/back/methods/supplier/campaignMetricsPdf.js | 2 +- modules/ticket/back/methods/ticket/deliveryNoteCsv.js | 2 +- modules/ticket/back/methods/ticket/deliveryNotePdf.js | 2 +- modules/travel/back/methods/travel/extraCommunityPdf.js | 2 +- modules/worker/back/methods/worker-dms/downloadFile.js | 2 +- 22 files changed, 23 insertions(+), 22 deletions(-) diff --git a/back/methods/dms/downloadFile.js b/back/methods/dms/downloadFile.js index 6f2451505..d64b15b70 100644 --- a/back/methods/dms/downloadFile.js +++ b/back/methods/dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index 4aa40197f..a1776cde5 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -43,7 +43,7 @@ module.exports = Self => { path: `/:id/download`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async function(id, fileCabinet, filter) { diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 9ac06f30b..201e16164 100644 --- a/back/methods/image/download.js +++ b/back/methods/image/download.js @@ -48,7 +48,7 @@ module.exports = Self => { path: `/:collection/:size/:id/download`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async function(ctx, collection, size, id) { diff --git a/modules/claim/back/methods/claim/claimPickupPdf.js b/modules/claim/back/methods/claim/claimPickupPdf.js index 390be33b9..4b66bd418 100644 --- a/modules/claim/back/methods/claim/claimPickupPdf.js +++ b/modules/claim/back/methods/claim/claimPickupPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/claim-pickup-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order'); diff --git a/modules/claim/back/methods/claim/downloadFile.js b/modules/claim/back/methods/claim/downloadFile.js index 7e49708f5..61784f39e 100644 --- a/modules/claim/back/methods/claim/downloadFile.js +++ b/modules/claim/back/methods/claim/downloadFile.js @@ -33,7 +33,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/modules/client/back/methods/client/campaignMetricsPdf.js b/modules/client/back/methods/client/campaignMetricsPdf.js index 14ae8646d..20c35494e 100644 --- a/modules/client/back/methods/client/campaignMetricsPdf.js +++ b/modules/client/back/methods/client/campaignMetricsPdf.js @@ -46,7 +46,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics'); diff --git a/modules/entry/back/methods/entry/entryOrderPdf.js b/modules/entry/back/methods/entry/entryOrderPdf.js index 2f6489d3f..93c1b6bd9 100644 --- a/modules/entry/back/methods/entry/entryOrderPdf.js +++ b/modules/entry/back/methods/entry/entryOrderPdf.js @@ -34,7 +34,7 @@ module.exports = Self => { path: '/:id/entry-order-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 24fb9fde3..cb71121d5 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/:id/download', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async function(ctx, id, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js index 13305f6ed..4f2a8aab3 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js +++ b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadZip = async function(ctx, ids, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js index a2d877189..0b08aec6d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:reference/exportation-pdf', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js index 6208d0625..6822e5a23 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:reference/invoice-csv', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.invoiceCsv = async reference => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js index 6970bf368..6ac56b68c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js @@ -40,7 +40,7 @@ module.exports = Self => { path: '/negativeBasesCsv', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.negativeBasesCsv = async(ctx, options) => { diff --git a/modules/item/back/methods/item-image-queue/download.js b/modules/item/back/methods/item-image-queue/download.js index 354771071..e1bc248ae 100644 --- a/modules/item/back/methods/item-image-queue/download.js +++ b/modules/item/back/methods/item-image-queue/download.js @@ -11,7 +11,7 @@ module.exports = Self => { path: `/download`, verb: 'POST', }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async() => { diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/route/cmr.js index cd7ef57ce..08a8182e0 100644 --- a/modules/route/back/methods/route/cmr.js +++ b/modules/route/back/methods/route/cmr.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: '/:id/cmr', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr'); diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index 1ef25d175..43f6e9648 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadCmrsZip', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadCmrsZip = async function(ctx, ids, options) { diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js index b226cf7f8..d7fc30aa3 100644 --- a/modules/route/back/methods/route/downloadZip.js +++ b/modules/route/back/methods/route/downloadZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadZip = async function(ctx, id, options) { diff --git a/modules/route/back/methods/route/driverRoutePdf.js b/modules/route/back/methods/route/driverRoutePdf.js index 9469356bb..e7b4dee17 100644 --- a/modules/route/back/methods/route/driverRoutePdf.js +++ b/modules/route/back/methods/route/driverRoutePdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/driver-route-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); diff --git a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js index 55767e9c6..51c626e69 100644 --- a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js +++ b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js @@ -45,7 +45,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics'); diff --git a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js index 29a859842..9fa3c183e 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:id/delivery-note-csv', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.deliveryNoteCsv = async id => { diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index 6155ff81e..adc9e4435 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -42,7 +42,7 @@ module.exports = Self => { path: '/:id/delivery-note-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note'); diff --git a/modules/travel/back/methods/travel/extraCommunityPdf.js b/modules/travel/back/methods/travel/extraCommunityPdf.js index 0c7f0a682..73748ac50 100644 --- a/modules/travel/back/methods/travel/extraCommunityPdf.js +++ b/modules/travel/back/methods/travel/extraCommunityPdf.js @@ -79,7 +79,7 @@ module.exports = Self => { path: '/extra-community-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community'); diff --git a/modules/worker/back/methods/worker-dms/downloadFile.js b/modules/worker/back/methods/worker-dms/downloadFile.js index 871bbffde..08fbcf924 100644 --- a/modules/worker/back/methods/worker-dms/downloadFile.js +++ b/modules/worker/back/methods/worker-dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { From 0a4cd4d4d02f74271ffebf3e7c71bf5f00e7ca4a Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 17 Apr 2024 09:58:27 +0200 Subject: [PATCH 6/8] feat: company_getSuppliersDebtHotFix --- .../procedures/company_getSuppliersDebt.sql | 360 +++++++++--------- 1 file changed, 180 insertions(+), 180 deletions(-) diff --git a/db/routines/vn/procedures/company_getSuppliersDebt.sql b/db/routines/vn/procedures/company_getSuppliersDebt.sql index f4814abcc..50c64669c 100644 --- a/db/routines/vn/procedures/company_getSuppliersDebt.sql +++ b/db/routines/vn/procedures/company_getSuppliersDebt.sql @@ -7,195 +7,195 @@ BEGIN * @param vSelf company id * @param vMonthAgo time interval to be consulted */ - DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE()); - DECLARE vCurrencyEuroFk INT; - DECLARE vStartDate DATE; - DECLARE vInvalidBalances DOUBLE; + DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE()); + DECLARE vCurrencyEuroFk INT; + DECLARE vStartDate DATE; + DECLARE vInvalidBalances DOUBLE; - SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig; - SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR'; + SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig; + SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR'; - DROP TEMPORARY TABLE IF EXISTS tOpeningBalances; - CREATE TEMPORARY TABLE tOpeningBalances ( - supplierFk INT NOT NULL, - companyFk INT NOT NULL, - openingBalances DOUBLE NOT NULL, - closingBalances DOUBLE NOT NULL, - currencyFk INT NOT NULL, - PRIMARY KEY (supplierFk, companyFk, currencyFk) - ) ENGINE = MEMORY; + DROP TEMPORARY TABLE IF EXISTS tOpeningBalances; + CREATE TEMPORARY TABLE tOpeningBalances ( + supplierFk INT NOT NULL, + companyFk INT NOT NULL, + openingBalances DOUBLE NOT NULL, + closingBalances DOUBLE NOT NULL, + currencyFk INT NOT NULL, + PRIMARY KEY (supplierFk, companyFk, currencyFk) + ) ENGINE = MEMORY; - -- Calculates the opening and closing balance for each supplier - INSERT INTO tOpeningBalances - SELECT supplierFk, - companyFk, - SUM(amount * isBeforeStarting) AS openingBalances, - SUM(amount) closingBalances, - currencyFk - FROM ( - SELECT p.supplierFk, - p.companyFk, - IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount, - p.dueDated < vStartingDate isBeforeStarting, - p.currencyFk - FROM payment p - WHERE p.received > vStartDate - AND p.companyFk = vSelf - UNION ALL - SELECT r.supplierFk, - r.companyFk, - - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total, - rv.dueDated < vStartingDate isBeforeStarting, - r.currencyFk - FROM invoiceIn r - INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk - WHERE r.issued > vStartDate - AND r.isBooked - AND r.companyFk = vSelf - ) sub GROUP BY companyFk, supplierFk, currencyFk; + -- Calculates the opening and closing balance for each supplier + INSERT INTO tOpeningBalances + SELECT supplierFk, + companyFk, + SUM(amount * isBeforeStarting) AS openingBalances, + SUM(amount) closingBalances, + currencyFk + FROM ( + SELECT p.supplierFk, + p.companyFk, + IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount, + p.dueDated < vStartingDate isBeforeStarting, + p.currencyFk + FROM payment p + WHERE p.received > vStartDate + AND p.companyFk = vSelf + UNION ALL + SELECT r.supplierFk, + r.companyFk, + - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total, + rv.dueDated < vStartingDate isBeforeStarting, + r.currencyFk + FROM invoiceIn r + INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk + WHERE r.issued > vStartDate + AND r.isBooked + AND r.companyFk = vSelf + ) sub GROUP BY companyFk, supplierFk, currencyFk; - DROP TEMPORARY TABLE IF EXISTS tPendingDuedates; - CREATE TEMPORARY TABLE tPendingDuedates ( - id INT auto_increment, - expirationId INT, - dated DATE, - supplierFk INT NOT NULL, - companyFk INT NOT NULL, - amount DECIMAL(10, 2) NOT NULL, - currencyFk INT NOT NULL, - pending DECIMAL(10, 2) DEFAULT 0, - balance DECIMAL(10, 2) DEFAULT 0, - endingBalance DECIMAL(10, 2) DEFAULT 0, - isPayment BOOLEAN, - isReconciled BOOLEAN, - PRIMARY KEY (id), - INDEX (supplierFk, companyFk, currencyFk) - ) ENGINE = MEMORY; + DROP TEMPORARY TABLE IF EXISTS tPendingDuedates; + CREATE TEMPORARY TABLE tPendingDuedates ( + id INT auto_increment, + expirationId INT, + dated DATE, + supplierFk INT NOT NULL, + companyFk INT NOT NULL, + amount DECIMAL(10, 2) NOT NULL, + currencyFk INT NOT NULL, + pending DECIMAL(10, 2) DEFAULT 0, + balance DECIMAL(10, 2) DEFAULT 0, + endingBalance DECIMAL(10, 2) DEFAULT 0, + isPayment BOOLEAN, + isReconciled BOOLEAN, + PRIMARY KEY (id), + INDEX (supplierFk, companyFk, currencyFk) + ) ENGINE = MEMORY; - INSERT INTO tPendingDuedates ( - expirationId, - dated, - supplierFk, - companyFk, - amount, - currencyFk, - isPayment, - isReconciled - )SELECT p.id, - p.dueDated, - p.supplierFk, - p.companyFk, - IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa), - p.currencyFk, - TRUE isPayment, - p.isConciliated - FROM payment p - WHERE p.dueDated >= vStartingDate - AND p.companyFk = vSelf - UNION ALL - SELECT r.id, - rv.dueDated, - r.supplierFk, - r.companyFk, - -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue), - r.currencyFk, - FALSE isPayment, - TRUE - FROM invoiceIn r - LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk - AND r.supplierFk = si.supplierFk - AND r.currencyFk = si.currencyFk - JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk - WHERE rv.dueDated >= vStartingDate - AND (si.closingBalances IS NULL OR si.closingBalances <> 0) - AND r.isBooked - AND r.companyFk = vSelf - ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id; - -- Now, we calculate the outstanding amount for each receipt in descending order - SET @risk := 0.0; - SET @supplier := 0.0; - SET @company := 0.0; - SET @moneda := 0.0; - SET @pending := 0.0; - SET @day := util.VN_CURDATE(); + INSERT INTO tPendingDuedates ( + expirationId, + dated, + supplierFk, + companyFk, + amount, + currencyFk, + isPayment, + isReconciled + )SELECT p.id, + p.dueDated, + p.supplierFk, + p.companyFk, + IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa), + p.currencyFk, + TRUE isPayment, + p.isConciliated + FROM payment p + WHERE p.dueDated >= vStartingDate + AND p.companyFk = vSelf + UNION ALL + SELECT r.id, + rv.dueDated, + r.supplierFk, + r.companyFk, + -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue), + r.currencyFk, + FALSE isPayment, + TRUE + FROM invoiceIn r + LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk + AND r.supplierFk = si.supplierFk + AND r.currencyFk = si.currencyFk + JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk + WHERE rv.dueDated >= vStartingDate + AND (si.closingBalances IS NULL OR si.closingBalances <> 0) + AND r.isBooked + AND r.companyFk = vSelf + ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id; + -- Now, we calculate the outstanding amount for each receipt in descending order + SET @risk := 0.0; + SET @supplier := 0.0; + SET @company := 0.0; + SET @moneda := 0.0; + SET @pending := 0.0; + SET @day := util.VN_CURDATE(); - UPDATE tPendingDuedates vp - LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk - AND vp.supplierFk = si.supplierFk - AND vp.currencyFk = si.currencyFk - SET vp.balance = @risk := ( - IF ( - @company <> vp.companyFk - OR @supplier <> vp.supplierFk - OR @moneda <> vp.currencyFk, - IFNULL(si.openingBalances, 0), - @risk - ) + - vp.amount - ), - -- if there is a change of company or supplier or currency, the balance is reset - vp.pending = @pending := IF ( - @company <> vp.companyFk - OR @supplier <> vp.supplierFk - OR @moneda <> vp.currencyFk - OR @day <> vp.dated, - vp.amount * (NOT vp.isPayment), - @pending + vp.amount - ), - vp.companyFk = @company := vp.companyFk, - vp.supplierFk = @supplier := vp.supplierFk, - vp.currencyFk = @moneda := vp.currencyFk, - vp.dated = @day := vp.dated, - vp.balance = @risk, - vp.pending = @pending; + UPDATE tPendingDuedates vp + LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk + AND vp.supplierFk = si.supplierFk + AND vp.currencyFk = si.currencyFk + SET vp.balance = @risk := ( + IF ( + @company <> vp.companyFk + OR @supplier <> vp.supplierFk + OR @moneda <> vp.currencyFk, + IFNULL(si.openingBalances, 0), + @risk + ) + + vp.amount + ), + -- if there is a change of company or supplier or currency, the balance is reset + vp.pending = @pending := IF ( + @company <> vp.companyFk + OR @supplier <> vp.supplierFk + OR @moneda <> vp.currencyFk + OR @day <> vp.dated, + vp.amount * (NOT vp.isPayment), + @pending + vp.amount + ), + vp.companyFk = @company := vp.companyFk, + vp.supplierFk = @supplier := vp.supplierFk, + vp.currencyFk = @moneda := vp.currencyFk, + vp.dated = @day := vp.dated, + vp.balance = @risk, + vp.pending = @pending; - CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY - SELECT expirationId, - dated, - supplierFk, - companyFk, - currencyFk, - balance - FROM tPendingDuedates - WHERE balance < vInvalidBalances - AND balance > - vInvalidBalances; + CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY + SELECT expirationId, + dated, + supplierFk, + companyFk, + currencyFk, + balance + FROM tPendingDuedates + WHERE balance < vInvalidBalances + AND balance > - vInvalidBalances; - DELETE vp.* - FROM tPendingDuedates vp - JOIN tRowsToDelete rd ON ( - vp.dated < rd.dated - OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId) - ) - AND vp.supplierFk = rd.supplierFk - AND vp.companyFk = rd.companyFk - AND vp.currencyFk = rd.currencyFk - WHERE NOT vp.isPayment; + DELETE vp.* + FROM tPendingDuedates vp + JOIN tRowsToDelete rd ON ( + vp.dated < rd.dated + OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId) + ) + AND vp.supplierFk = rd.supplierFk + AND vp.companyFk = rd.companyFk + AND vp.currencyFk = rd.currencyFk + WHERE NOT vp.isPayment; - SELECT vp.expirationId, - vp.dated, - vp.supplierFk, - vp.companyFk, - vp.currencyFk, - vp.amount, - vp.pending, - vp.balance, - s.payMethodFk, - vp.isPayment, - vp.isReconciled, - vp.endingBalance, - cr.amount clientRiskAmount, - co.CEE - FROM tPendingDuedates vp - LEFT JOIN supplier s ON s.id = vp.supplierFk - LEFT JOIN client c ON c.fi = s.nif - LEFT JOIN clientRisk cr ON cr.clientFk = c.id - LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id - LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk - LEFT JOIN country co ON co.id = be.countryFk - AND cr.companyFk = vp.companyFk; + SELECT vp.expirationId, + vp.dated, + vp.supplierFk, + vp.companyFk, + vp.currencyFk, + vp.amount, + vp.pending, + vp.balance, + s.payMethodFk, + vp.isPayment, + vp.isReconciled, + vp.endingBalance, + cr.amount clientRiskAmount, + co.CEE + FROM tPendingDuedates vp + LEFT JOIN supplier s ON s.id = vp.supplierFk + LEFT JOIN client c ON c.fi = s.nif + JOIN clientRisk cr ON cr.clientFk = c.id + AND cr.companyFk = vp.companyFk + LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id + LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk + LEFT JOIN country co ON co.id = be.countryFk; - DROP TEMPORARY TABLE tOpeningBalances; - DROP TEMPORARY TABLE tPendingDuedates; - DROP TEMPORARY TABLE tRowsToDelete; + DROP TEMPORARY TABLE tOpeningBalances; + DROP TEMPORARY TABLE tPendingDuedates; + DROP TEMPORARY TABLE tRowsToDelete; END$$ DELIMITER ; From d5cb52cb6459777cb5cedb0e44ce77b3bc747674 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 17 Apr 2024 10:03:01 +0200 Subject: [PATCH 7/8] feat(salix): refs #6930 Undo rollback salix-front --- front/core/services/auth.js | 3 +-- front/core/services/token.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index d77966aca..753bc3fba 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -86,8 +86,7 @@ export default class Auth { return this.$http.get('VnUsers/ShareToken', { headers: {Authorization: json.data.token} }).then(({data}) => { - // Usar data.multimediaToken.id cuando el resto de sistemas lo tengan completado - this.vnToken.set(json.data.token, json.data.token, now, json.data.ttl, remember); + this.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember); this.loadAcls().then(() => { let continueHash = this.$state.params.continue; if (continueHash) diff --git a/front/core/services/token.js b/front/core/services/token.js index 028ebd841..125de6b9a 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -59,8 +59,7 @@ export default class Token { getStorage(storage) { this.token = storage.getItem('vnToken'); - // Cambio realizado temporalmente - this.tokenMultimedia = this.token; // storage.getItem('vnTokenMultimedia'); + this.tokenMultimedia = storage.getItem('vnTokenMultimedia'); if (!this.token) return; const created = storage.getItem('vnTokenCreated'); this.created = created && new Date(created); From cffc1964b64adcf8575aa5a567fec4477fbe8e75 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 10:26:21 +0200 Subject: [PATCH 8/8] feat: refs #6968 Transactioned and isTriggerDisabled --- .../10997-crimsonCyca/00-groupingMode.sql | 16 ++++++++++++++++ db/versions/10997-crimsonCyca/00-part1.sql | 2 -- db/versions/10997-crimsonCyca/01-part2.sql | 7 ------- db/versions/10997-crimsonCyca/02-part3.sql | 2 -- 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 db/versions/10997-crimsonCyca/00-groupingMode.sql delete mode 100644 db/versions/10997-crimsonCyca/00-part1.sql delete mode 100644 db/versions/10997-crimsonCyca/01-part2.sql delete mode 100644 db/versions/10997-crimsonCyca/02-part3.sql diff --git a/db/versions/10997-crimsonCyca/00-groupingMode.sql b/db/versions/10997-crimsonCyca/00-groupingMode.sql new file mode 100644 index 000000000..dd4896cc1 --- /dev/null +++ b/db/versions/10997-crimsonCyca/00-groupingMode.sql @@ -0,0 +1,16 @@ +START TRANSACTION; + +SET @isTriggerDisabled = TRUE; + +ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; + +UPDATE vn.buy SET groupingMode2 = 'packing' WHERE groupingMode = 2; +UPDATE vn.buy SET groupingMode2 = 'grouping' WHERE groupingMode = 1; + +ALTER TABLE vn.buy DROP COLUMN groupingMode; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; + +SET @isTriggerDisabled = FALSE; + +COMMIT; \ No newline at end of file diff --git a/db/versions/10997-crimsonCyca/00-part1.sql b/db/versions/10997-crimsonCyca/00-part1.sql deleted file mode 100644 index 8811b81a7..000000000 --- a/db/versions/10997-crimsonCyca/00-part1.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; -ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; diff --git a/db/versions/10997-crimsonCyca/01-part2.sql b/db/versions/10997-crimsonCyca/01-part2.sql deleted file mode 100644 index 1f7a3c9f6..000000000 --- a/db/versions/10997-crimsonCyca/01-part2.sql +++ /dev/null @@ -1,7 +0,0 @@ -UPDATE vn.buy - SET groupingMode2 = 'packing' - WHERE groupingMode = 2; - -UPDATE vn.buy - SET groupingMode2 = 'grouping' - WHERE groupingMode = 1; diff --git a/db/versions/10997-crimsonCyca/02-part3.sql b/db/versions/10997-crimsonCyca/02-part3.sql deleted file mode 100644 index c63560957..000000000 --- a/db/versions/10997-crimsonCyca/02-part3.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.buy DROP COLUMN groupingMode; -ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;