From 8af2cabaea916122286dc2e0e4ab6c79608ea28e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 6 Feb 2024 13:31:58 +0100 Subject: [PATCH 001/110] refs #6281 feat:buyFk in itemShelving --- .../vn/procedures/itemShelvingTransfer.sql | 1 + .../vn/procedures/itemShelving_add.sql | 70 +++++++++++-------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingTransfer.sql b/db/routines/vn/procedures/itemShelvingTransfer.sql index 326f8108b..b75cef627 100644 --- a/db/routines/vn/procedures/itemShelvingTransfer.sql +++ b/db/routines/vn/procedures/itemShelvingTransfer.sql @@ -24,6 +24,7 @@ BEGIN ON ish2.itemFk = ish.itemFk AND ish2.packing = ish.packing AND date(ish2.created) = date(ish.created) + AND ish2.buyFk = ish.buyFk WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; IF vNewItemShelvingFk THEN diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 02762fa0b..cc6e9bb49 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,8 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) BEGIN - - /** * Añade registro o lo actualiza si ya existe. * @@ -15,12 +13,24 @@ BEGIN * @param vWarehouseFk indica el sector * **/ - DECLARE vItemFk INT; + DECLARE vBuyFk INT; - SELECT barcodeToItem(vBarcode) INTO vItemFk; + SELECT id INTO vBuyFk + FROM buy WHERE id = vBarcode; + + SELECT barcodeToItem(vBarcode) INTO vItemFk; + + IF vBuyFk IS NULL THEN + CALL cache.last_buy_refresh(FALSE); + + SELECT buy_id INTO vBuyFk + FROM cache.last_buy + WHERE item_id = vItemFk + AND warehouse_id = vWarehouseFk; + END IF; - IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN + IF NOT (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) THEN INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); INSERT INTO shelving(code, parkingFk) @@ -31,33 +41,37 @@ BEGIN END IF; IF (SELECT COUNT(*) FROM itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking + AND buyFk = vBuyFk) THEN UPDATE itemShelving - SET visible = visible+vQuantity - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; + SET visible = visible + vQuantity + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking + AND buyFk = vBuyFk; ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - visible, - grouping, - packing, - packagingFk) - SELECT vItemFk, - vShelvingFk, - vQuantity, - IFNULL(vGrouping, b.grouping), - IFNULL(vPacking, b.packing), - IFNULL(vPackagingFk, b.packagingFk) - FROM item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; + INSERT INTO itemShelving( + itemFk, + shelvingFk, + visible, + grouping, + packing, + packagingFk, + buyFk) + SELECT vItemFk, + vShelvingFk, + vQuantity, + IFNULL(vGrouping, b.grouping), + IFNULL(vPacking, b.packing), + IFNULL(vPackagingFk, b.packagingFk), + id + FROM buy b + WHERE id = vBuyFk; END IF; END$$ DELIMITER ; From bafd4456ef6b6f2c22ae4dec19a81a27cb7e3b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 15 Mar 2024 14:46:43 +0100 Subject: [PATCH 002/110] feat: conversion art. A1 a A2 refs #4979 --- db/routines/vn/procedures/buy_clone.sql | 61 +++ db/routines/vn/procedures/buy_cloneByBuy.sql | 23 ++ .../vn/procedures/entry_cloneHeader.sql | 2 +- db/routines/vn/procedures/entry_copyBuys.sql | 57 +-- db/routines/vn/procedures/item_devalueA2.sql | 352 ++++++++++++++++++ .../10955-orangeRuscus/00-firstScript.sql | 17 + 6 files changed, 462 insertions(+), 50 deletions(-) create mode 100644 db/routines/vn/procedures/buy_clone.sql create mode 100644 db/routines/vn/procedures/buy_cloneByBuy.sql create mode 100644 db/routines/vn/procedures/item_devalueA2.sql create mode 100644 db/versions/10955-orangeRuscus/00-firstScript.sql diff --git a/db/routines/vn/procedures/buy_clone.sql b/db/routines/vn/procedures/buy_clone.sql new file mode 100644 index 000000000..bbf742b23 --- /dev/null +++ b/db/routines/vn/procedures/buy_clone.sql @@ -0,0 +1,61 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_clone`(vEntryFk INT) +BEGIN +/** + * Clone buys to an entry + * + * @param vEntryFk The entry id + * @table tmp.buy(id) + */ + INSERT INTO buy( + entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + packageFk, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk) + SELECT vEntryFk, + b.itemFk, + b.quantity, + b.buyingValue, + b.freightValue, + b.isIgnored, + b.stickers, + b.packagingFk, + b.packing, + b.`grouping`, + b.groupingMode, + b.containerFk, + b.comissionValue, + b.packageValue, + b.packageFk, + b.price1, + b.price2, + b.price3, + b.minPrice, + b.isChecked, + b.location, + b.weight, + b.itemOriginalFk + FROM tmp.buy tb + JOIN vn.buy b ON b.id = tb.id; + +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/buy_cloneByBuy.sql b/db/routines/vn/procedures/buy_cloneByBuy.sql new file mode 100644 index 000000000..73e91a9df --- /dev/null +++ b/db/routines/vn/procedures/buy_cloneByBuy.sql @@ -0,0 +1,23 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_cloneByBuy`( + OUT vBuyClonedFk INT, + IN vSelf INT, + IN vEntryFk INT +) +BEGIN +/** + * Clone a buy to an entry + * + * @param OUT vBuyClonedFk The new cloned buy id + * @param vSelf The buy id to clone + * @param vEntryFk The destination entry id + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.buy + SELECT vSelf id; + + CALL buy_clone(vEntryFk); + SET vBuyClonedFk = LAST_INSERT_ID(); + + DROP TEMPORARY TABLE tmp.buy; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/entry_cloneHeader.sql b/db/routines/vn/procedures/entry_cloneHeader.sql index 6a6df9194..7f9426663 100644 --- a/db/routines/vn/procedures/entry_cloneHeader.sql +++ b/db/routines/vn/procedures/entry_cloneHeader.sql @@ -9,8 +9,8 @@ BEGIN * Clones an entry header. * * @param vSelf The entry id + * @param OUT vNewEntryFk The new entry id * @param vTravelFk Travel for the new entry or %NULL to use the source entry travel - * @param vNewEntryFk The new entry id */ INSERT INTO entry( travelFk, diff --git a/db/routines/vn/procedures/entry_copyBuys.sql b/db/routines/vn/procedures/entry_copyBuys.sql index a00fbc846..9bf4a55e4 100644 --- a/db/routines/vn/procedures/entry_copyBuys.sql +++ b/db/routines/vn/procedures/entry_copyBuys.sql @@ -1,59 +1,18 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vCopyTo INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vDestinationEntryFk INT) BEGIN /** - * Copies an entry buys to another buy. + * Copies all buys from an entry to an entry. * * @param vSelf The entry id - * @param vCopyTo The destination entry id + * @param vDestinationEntryFk The destination entry id */ - INSERT INTO buy( - entryFk, - itemFk, - quantity, - buyingValue, - freightValue, - isIgnored, - stickers, - packing, - `grouping`, - groupingMode, - containerFk, - comissionValue, - packageValue, - packagingFk, - price1, - price2, - price3, - minPrice, - isChecked, - location, - weight, - itemOriginalFk - ) - SELECT vCopyTo, - itemFk, - quantity, - buyingValue, - freightValue, - isIgnored, - stickers, - packing, - `grouping`, - groupingMode, - containerFk, - comissionValue, - packageValue, - packagingFk, - price1, - price2, - price3, - minPrice, - isChecked, - location, - weight, - itemOriginalFk + CREATE OR REPLACE TEMPORARY TABLE tmp.buy + SELECT id FROM buy WHERE entryFk = vSelf; + + CALL buy_clone(vDestinationEntryFk); + DROP TEMPORARY TABLE tmp.buy; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql new file mode 100644 index 000000000..e1fb08388 --- /dev/null +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -0,0 +1,352 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_devalueA2`( + vShelvingFK VARCHAR(10), + vItemFk INT, + vBuyingValue DECIMAL(10,4), + vQuantity INT +) +BEGIN +/** + * Devalua un item modificando su calidad de A1 a A2. + * Si no existe el item A2 lo crea y genera los movimientos de las entradas + * de almacén y shelvings correspondientes + * + * @param vShelvingFK Ubicación actual del artículo + * @param vItemFk Id de artículo a devaluar + * @param vBuyingValue Nuevo precio de coste + */ + DECLARE vItemA2Fk INT; + DECLARE vLastBuyFk BIGINT; + DECLARE vA1BuyFk INT; + DECLARE vA2BuyFk INT; + DECLARE vTargetEntryFk INT; + DECLARE vTargetEntryDate DATE; + DECLARE vTargetItemShelvingFk BIGINT; + DECLARE vWarehouseFk INT; + DECLARE vCacheFk INT; + DECLARE vLastEntryFk INT; + DECLARE vCurrentVisible INT; + DECLARE vInventoryTravelFk INT; + DECLARE vCurdate DATE; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT TRUE FROM item WHERE id = vItemFk AND (category <> 'A1' OR category IS NULL)) THEN + CALL util.throw('Item has not category A1'); + END IF; + + SELECT warehouseFk INTO vWarehouseFk + FROM userConfig + WHERE userFk = account.myUser_getId(); + + IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN + CALL util.throw ('Operator has not a valid warehouse'); + END IF; + + SELECT util.VN_CURDATE() INTO vCurdate; + + SELECT t.id INTO vInventoryTravelFk + FROM travel t + JOIN travelConfig tc + WHERE t.shipped = vCurdate + AND t.landed = vCurdate + AND t.warehouseInFk = vWarehouseFk + AND t.warehouseOutFk = tc.devalueWarehouseOutFk + AND t.agencyModeFk = tc.devalueAgencyModeFk + LIMIT 1; + + IF NOT vInventoryTravelFk OR vInventoryTravelFk IS NULL THEN + INSERT INTO travel ( + shipped, + landed, + warehouseInFk, + warehouseOutFk, + `ref`, + isReceived, + agencyModeFk) + SELECT vCurdate, + vCurdate, + vWarehouseFk, + tc.devalueWarehouseOutFk, + tc.devalueRef, + TRUE, + tc.devalueAgencyModeFk + FROM travelConfig tc; + SET vInventoryTravelFk = LAST_INSERT_ID(); + END IF; + + SELECT id, dated INTO vTargetEntryFk, vTargetEntryDate + FROM `entry` e + WHERE created = vCurdate + AND typeFk ='devaluation' + AND travelFk = vInventoryTravelFk + ORDER BY created DESC + LIMIT 1; + + CALL buyUltimate(vWarehouseFk, vCurdate); + + SELECT b.entryFk, bu.buyFk INTO vLastEntryFk,vLastBuyFk + FROM tmp.buyUltimate bu + JOIN vn.buy b ON b.id =bu.buyFk + WHERE bu.itemFk = vItemFk + AND bu.warehouseFk = vWarehouseFk; + + SELECT id,visible INTO vTargetItemShelvingFk,vCurrentVisible + FROM itemShelving + WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + AND itemFk = vItemFk + LIMIT 1; + + IF vQuantity >= vCurrentVisible THEN + CALL util.throw('Quantity is greater than visible'); + END IF; + + START TRANSACTION; + + IF NOT vTargetEntryFk OR vTargetEntryFk IS NULL + OR NOT vTargetEntryDate <=> vCurdate THEN + INSERT INTO entry( + travelFk, + supplierFk, + dated, + commission, + currencyFk, + companyFk, + clonedFrom, + typeFk + ) + SELECT vInventoryTravelFk, + supplierFk, + vCurdate, + commission, + currencyFk, + companyFk, + vLastEntryFk, + 'devaluation' + FROM entry + WHERE id = vLastEntryFk; + + SET vTargetEntryFk = LAST_INSERT_ID(); + END IF; + + SELECT i.id INTO vItemA2Fk + FROM item i + JOIN ( + SELECT i.id, + i.name, + i.subname, + i.value5, + i.value6, + i.value7, + i.value8, + i.value9, + i.value10, + i.NumberOfItemsPerCask, + i.EmbalageCode, + i.quality + FROM item i + WHERE i.id = vItemFk + )i2 ON i2.name <=> i.name + AND i2.subname <=> i.subname + AND i2.value5 <=> i.value5 + AND i2.value6 <=> i.value6 + AND i2.value8 <=> i.value8 + AND i2.value9 <=> i.value9 + AND i2.value10 <=> i.value10 + AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask + AND i2.EmbalageCode <=> i.EmbalageCode + AND i2.quality <=> i.quality + WHERE i.id <> i2.id + AND i.category = 'A2' + LIMIT 1; + + IF vItemA2Fk IS NULL THEN + INSERT INTO item ( + equivalent, + name, + `size`, + stems, + minPrice, + isToPrint, + family, + box, + category, + originFk, + doPhoto, + image, + inkFk, + intrastatFk, + hasMinPrice, + created, + comment, + typeFk, + generic, + producerFk, + description, + density, + relevancy, + expenseFk, + isActive, + longName, + subName, + tag5, + value5, + tag6, + value6, + tag7, + value7, + tag8, + value8, + tag9, + value9, + tag10, + value10, + minimum, + upToDown, + supplyResponseFk, + hasKgPrice, + isFloramondo, + isFragile, + numberOfItemsPerCask, + embalageCode, + quality, + stemMultiplier, + itemPackingTypeFk, + packingOut, + genericFk, + isLaid, + lastUsed, + weightByPiece, + editorFk, + recycledPlastic, + nonRecycledPlastic) + SELECT equivalent, + name, + `size`, + stems, + minPrice, + isToPrint, + family, + box, + 'A2', + originFk, + doPhoto, + image, + inkFk, + intrastatFk, + hasMinPrice, + created, + comment, + typeFk, + generic, + producerFk, + description, + density, + relevancy, + expenseFk, + isActive, + longName, + subName, + tag5, + value5, + tag6, + value6, + tag7, + value7, + tag8, + value8, + tag9, + value9, + tag10, + value10, + minimum, + upToDown, + supplyResponseFk, + hasKgPrice, + isFloramondo, + isFragile, + numberOfItemsPerCask, + embalageCode, + quality, + stemMultiplier, + itemPackingTypeFk, + packingOut, + genericFk, + isLaid, + lastUsed, + weightByPiece, + editorFk, + recycledPlastic, + nonRecycledPlastic + FROM item + WHERE id = vItemFk; + + SET vItemA2Fk = LAST_INSERT_ID(); + + UPDATE itemTaxCountry itc + JOIN itemTaxCountry itc2 ON itc2.itemFk = vItemFk + AND itc2.countryFk = itc.countryFk + SET itc2.taxClassFk = itc.taxClassFk + WHERE itc.id = vItemA2Fk; + + INSERT INTO itemBotanical (itemFk, genusFk, specieFk) + SELECT vItemA2Fk, genusFk, specieFk + FROM itemBotanical + WHERE itemFk = vItemFk; + END IF; + + IF vQuantity = vCurrentVisible THEN + DELETE FROM itemShelving + WHERE id = vTargetItemShelvingFk; + ELSE + UPDATE itemShelving + SET visible = vCurrentVisible - vQuantity + WHERE id = vTargetItemShelvingFk; + END IF; + + CALL buy_cloneByBuy(vA1BuyFk, vLastBuyFk, vTargetEntryFk); + UPDATE buy + SET quantity = - LEAST(vQuantity,vCurrentVisible), + isIgnored = TRUE, + buyingValue = vBuyingValue + WHERE id = vA1BuyFk; + + CALL buy_cloneByBuy(vA2BuyFk, vLastBuyFk, vTargetEntryFk); + UPDATE buy + SET quantity = vQuantity, + isIgnored = TRUE, + buyingValue = vBuyingValue, + itemFk = vItemA2Fk + WHERE id = vA2BuyFk; + + INSERT INTO itemShelving ( + itemFk, + shelvingFk, + visible, + `grouping`, + packing, + packagingFk, + userFk, + isChecked) + SELECT vItemA2Fk, + shelvingFk, + vQuantity, + `grouping`, + packing, + packagingFk, + account.myUser_getId(), + isChecked + FROM itemShelving + WHERE itemFK = vItemFk + AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci; + + COMMIT; + CALL cache.visible_refresh(vCacheFk, TRUE, vWarehouseFk); + CALL cache.available_refresh(vCacheFk, TRUE, vWarehouseFk, vCurdate); + CALL buy_recalcPricesByBuy(vA2BuyFk); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/10955-orangeRuscus/00-firstScript.sql b/db/versions/10955-orangeRuscus/00-firstScript.sql new file mode 100644 index 000000000..745c058bf --- /dev/null +++ b/db/versions/10955-orangeRuscus/00-firstScript.sql @@ -0,0 +1,17 @@ +INSERT IGNORE INTO vn.entryType (code, description) + VALUES ('devaluation', 'Devaluación'); + +ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueWarehouseOutFk SMALLINT(6) UNSIGNED NULL + COMMENT 'Datos del travel para las entradas generadas al devaluar artículos de A1 a A2'; + +ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueAgencyModeFk INT(11) NULL; +ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueRef varchar(20) NULL; + +ALTER TABLE vn.travelConfig DROP FOREIGN KEY IF EXISTS travelConfig_agencyMode_FK; + +ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_agencyMode_FK + FOREIGN KEY (devalueAgencyModeFk) REFERENCES vn.agencyMode(id) ON DELETE SET NULL ON UPDATE CASCADE; + +ALTER TABLE vn.travelConfig DROP FOREIGN KEY IF EXISTS travelConfig_warehouse_FK; +ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_warehouse_FK + FOREIGN KEY (devalueWarehouseOutFk) REFERENCES vn.warehouse(id) ON DELETE SET NULL ON UPDATE CASCADE; From 02bee2e07c143ad45df6891e3a1d6d9ec652b87e Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 4 Apr 2024 12:45:43 +0200 Subject: [PATCH 003/110] refs #6111 routeList sql --- db/versions/10978-wheatMoss/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10978-wheatMoss/00-firstScript.sql diff --git a/db/versions/10978-wheatMoss/00-firstScript.sql b/db/versions/10978-wheatMoss/00-firstScript.sql new file mode 100644 index 000000000..39bf1c318 --- /dev/null +++ b/db/versions/10978-wheatMoss/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +INSERT INTO salix.defaultViewConfig +(tableCode, `columns`) +VALUES('routesList', '{"ID":true,"worker":true,"agency":true,"vehicle":true,"date":true,"volume":true,"description":true,"started":true,"finished":true,"actions":true}'); From 976b18203eefa619c1db80ba38f8ba94e520dc04 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 16 Apr 2024 10:49:17 +0200 Subject: [PATCH 004/110] feat: refs #7187 check if is freelancer on insert & update --- .../deviceProductionUser_beforeInsert.sql | 16 +++++++++++++++- .../deviceProductionUser_beforeUpdate.sql | 16 +++++++++++++++- .../10993-brownAsparagus/00-dropUniqueKey.sql | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 db/versions/10993-brownAsparagus/00-dropUniqueKey.sql diff --git a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql index b392cf5a1..e81238748 100644 --- a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql +++ b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql @@ -3,6 +3,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_ BEFORE INSERT ON `deviceProductionUser` FOR EACH ROW BEGIN - SET NEW.editorFk = account.myUser_getId(); + DECLARE vHasPda BOOLEAN; + DECLARE visFreelancer BOOLEAN; + DECLARE vUserName VARCHAR(50); + + SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = NEW.userFk; + + SELECT name INTO vUserName FROM account.user WHERE id = NEW.userFk; + + SELECT account.user_hasRoleId(vUserName, (SELECT id FROM role WHERE name = 'freelancer')) INTO vIsFreelancer; + + IF NOT vIsFreelancer AND vHasPda THEN + CALL util.throw('You can only have one PDA'); + ELSE + SET NEW.editorFk = account.myUser_getId(); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql b/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql index 055f81790..903541894 100644 --- a/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql +++ b/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql @@ -3,6 +3,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_ BEFORE UPDATE ON `deviceProductionUser` FOR EACH ROW BEGIN - SET NEW.editorFk = account.myUser_getId(); + DECLARE vHasPda BOOLEAN; + DECLARE visFreelancer BOOLEAN; + DECLARE vUserName VARCHAR(50); + + SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = NEW.userFk; + + SELECT name INTO vUserName FROM account.user WHERE id = NEW.userFk; + + SELECT account.user_hasRoleId(vUserName, (SELECT id FROM role WHERE name = 'freelancer')) INTO vIsFreelancer; + + IF NOT vIsFreelancer AND vHasPda THEN + CALL util.throw('You can only have one PDA'); + ELSE + SET NEW.editorFk = account.myUser_getId(); + END IF; END$$ DELIMITER ; diff --git a/db/versions/10993-brownAsparagus/00-dropUniqueKey.sql b/db/versions/10993-brownAsparagus/00-dropUniqueKey.sql new file mode 100644 index 000000000..39bac8652 --- /dev/null +++ b/db/versions/10993-brownAsparagus/00-dropUniqueKey.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.deviceProductionUser DROP INDEX IF EXISTS deviceProductionUser_UN; + From bab2ee78c428aba027764a5106fbc76a333dd676 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 19 Apr 2024 13:13:57 +0200 Subject: [PATCH 005/110] feat: refs #6428 auto-changelog with bash --- CHANGELOG.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 6 ++++ changelog.sh | 34 +++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 changelog.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index b2be92faa..04a40cd20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,96 @@ +# Version XX.XX - XXXX-XX-XX (TEXTO DE PRUEBA CREADO APARTIR DE DEV → TEST) + +### Added 🆕 + +- feat: #7130 added "served" field to RouteList table(Salix). by:Jon +- feat(binlog): refs #4409 New function for binlog queue monitoring by:Juan Ferrer Toribio +- feat: bloquear facturas recibidas contabilizadas refs #7173 by:Carlos Andrés +- feat: commit by:pablone +- feat(delay): refs #6005 add new restriction by:pablone +- feat(git): add commit lint refs #6130 by:pablone +- feat(git): add commit lint refs#6130 by:pablone +- feat(githook) add reference by:pablone +- feat(noSpam): refs #6005 check if exists a previous notification by:pablone +- feat(notify): refs #6005 add restriction on created notification time by:pablone +- feat(operator.spec): refs #6005 add spec for delay and fix spec for spam by:pablone +- feat: permissions to vn.entry.isBooked refs#6724 by:Carlos Andrés +- feat: refs #12 peter by:pablone +- feat: refs #6005 move logic from report to hook by:pablone +- feat: refs #6005 mover sql a la ultima carpeta by:pablone +- feat: refs #6021 fix proc by:pablone +- feat: refs #6021 order_put refactor by:pablone +- feat: refs #6130 add commit by:pablone +- feat: refs #6130 handle branch without task by:pablone +- feat: refs #6130 test commitLint (6130-commitLint) by:alexm +- feat: refs #6500 by:robert +- feat: refs #6500 cambios solicitados by:robert +- feat: refs #6500 delete procedure by:robert +- feat: refs #6500 procRefactor8 by:robert +- feat: refs #6724 Added admon acl to vn-check by:guillermo +- feat: refs #6724 Grant changes by:guillermo +- feat: refs #6724 hook added by:jorgep +- feat: refs #6938 add scope & acls by:jorgep +- feat: refs #6968 Changed groupingMode to enum by:guillermo +- feat: refs #6968 Requested changes by:guillermo +- feat: refs #6968 Transactioned and isTriggerDisabled by:guillermo +- feat: refs #7173 Added restrictions in invoiceIn structure by:guillermo +- feat: refs #7173 Added traduction by:guillermo +- feat(salix): refs #6930 Undo rollback salix-back by:Javier Segarra +- feat(salix): refs #6930 Undo rollback salix-front by:Javier Segarra +- feat: sin concatenar en el nombre by:jgallego +- feat(spec): refs #6005 add spec by:pablone +- feat(spec): refs #6005 add spec to backup Notify by:pablone +- feat: test by:pablone +- refs #7190 feat: renewToken for multimedia by:Javier Segarra + +### Changed 📦 + +- feat: refs #6021 order_put refactor by:pablone +- refactor(main-labeler): refs #6005 refactor de mainLabeler a backupPrinterFk by:pablone +- refactor(printer-notification): refs #6005 refactor de la notificación by:pablone +- refactor: refs #6005 delay on productionConfig by:pablone +- refactor: refs #6005 move the logic to the report by:pablone +- refactor: refs #6005 refactor spec by:pablone +- refactor: refs #6724 Minor change by:guillermo +- refactor: refs #7139 replace warehouse with ticket by:Jon +- refactor: refs #7181 Added grant by:guillermo +- refactor: refs #7181 Minor change by:guillermo +- refactor: refs #7181 Requested changes by:guillermo +- refactor: refs #7181 vn2008.Deleted risk_vs_client_list by:guillermo + +### Fixed 🛠️ + +- feat(operator.spec): refs #6005 add spec for delay and fix spec for spam by:pablone +- feat: refs #6021 fix proc by:pablone +- fix(binlog): refs #4409 Fixtures for binlogQueue by:Juan Ferrer Toribio +- fix(changes): refs #6005 remove changes files by:pablone +- fix(claim): remove blank space refs #6130 by:pablone +- fix commit code by:pablone +- fix: husky by:alexm +- fix(notification): refs #6005 notification changes by:pablone +- fix: refs #6005 add fixtures for a spec by:pablone +- fix: refs #6005 move logic to hook by:pablone +- fix: refs #6021 catalogue_findById by:pablone +- fix: refs #6021 proc by:pablone +- fix: refs #6130 code by:pablone +- fix:refs #6130 code by:pablone +- fix: refs #6130 code:code by:pablone +- fix: refs #6130 code remove console.log by:pablone +- fix: refs #6130 test by:pablone +- fix: refs #6938 acls & scope by:jorgep +- fix: refs #6938 e2e tests by:jorgep +- fix: refs #6938 filters & scope by:jorgep +- fix: refs #6938 front tests by:jorgep +- fix: refs #6938 scope by:jorgep +- fix: remove logs (testHusky_deleteme) by:alexm +- fix(spec): refs #6005 backupLabeler spec by:pablone +- fix(sql): refs #6005 fix fk formation by:pablone +- fix(yml): refs #6005 backUpLabeler yml fix by:pablone +- refs #6641 fix PR changes by:jcasado +- refs #6641 fix test by:jcasado +- refs #6641 test fixtures by:jcasado +- refs #6835 fix: issue by:Javier Segarra + # Changelog All notable changes to this project will be documented in this file. diff --git a/README.md b/README.md index b420bc44f..53478f425 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,12 @@ For end-to-end tests run from project's root. $ npm run test:e2e ``` +## Generate changeLog test → master +``` +$ bash changelog.sh +``` + + ## Visual Studio Code extensions Open Visual Studio Code, press Ctrl+P and paste the following commands. diff --git a/changelog.sh b/changelog.sh new file mode 100644 index 000000000..8cd7b4716 --- /dev/null +++ b/changelog.sh @@ -0,0 +1,34 @@ +features_types=(chore feat style) +changes_types=(refactor perf) +fix_types=(fix revert) +file="CHANGELOG.md" +file_tmp="temp_log.txt" +file_current_tmp="temp_current_log.txt" + +setType(){ + echo "### $1" >> $file_tmp + arr=("$@") + echo "" > $file_current_tmp + for i in "${arr[@]}" + do + git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp + done + # remove duplicates + sort -o $file_current_tmp -u $file_current_tmp + cat $file_current_tmp >> $file_tmp + echo "" >> $file_tmp + # remove tmp current file + [ -e $file_current_tmp ] && rm $file_current_tmp +} + +echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp +echo "" >> $file_tmp + +setType "Added 🆕" "${features_types[@]}" +setType "Changed 📦" "${changes_types[@]}" +setType "Fixed 🛠️" "${fix_types[@]}" + +cat $file >> $file_tmp +mv $file_tmp $file + + From 71a9aed1bb64acfc8bbadda6541c1145845964f5 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Apr 2024 18:03:17 +0200 Subject: [PATCH 006/110] fix: refs #7187 check for multiple device on freelancer --- .../procedures/worker_checkMultipleDevice.sql | 22 +++++++++++++++++++ .../deviceProductionUser_beforeInsert.sql | 17 ++------------ .../deviceProductionUser_beforeUpdate.sql | 16 ++------------ 3 files changed, 26 insertions(+), 29 deletions(-) create mode 100644 db/routines/vn/procedures/worker_checkMultipleDevice.sql diff --git a/db/routines/vn/procedures/worker_checkMultipleDevice.sql b/db/routines/vn/procedures/worker_checkMultipleDevice.sql new file mode 100644 index 000000000..ecc485c9d --- /dev/null +++ b/db/routines/vn/procedures/worker_checkMultipleDevice.sql @@ -0,0 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_checkMultipleDevice`( + vSelf INT +) +BEGIN +/** + * Verify if a worker has multiple assigned devices, + * except for freelancers. + * + * @param vUserFk worker id. + */ + DECLARE vHasPda BOOLEAN; + DECLARE vIsFreelance BOOLEAN; + + SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = vSelf; + SELECT isFreelance INTO vIsFreelance FROM worker WHERE id = vSelf; + + IF NOT vIsFreelance AND vHasPda > 1 THEN + CALL util.throw('You can only have one PDA'); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql index e81238748..ccef618a4 100644 --- a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql +++ b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql @@ -3,20 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_ BEFORE INSERT ON `deviceProductionUser` FOR EACH ROW BEGIN - DECLARE vHasPda BOOLEAN; - DECLARE visFreelancer BOOLEAN; - DECLARE vUserName VARCHAR(50); - - SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = NEW.userFk; - - SELECT name INTO vUserName FROM account.user WHERE id = NEW.userFk; - - SELECT account.user_hasRoleId(vUserName, (SELECT id FROM role WHERE name = 'freelancer')) INTO vIsFreelancer; - - IF NOT vIsFreelancer AND vHasPda THEN - CALL util.throw('You can only have one PDA'); - ELSE - SET NEW.editorFk = account.myUser_getId(); - END IF; + CALL worker_checkMultipleDevice(NEW.userFk); + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql b/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql index 903541894..7318bd99b 100644 --- a/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql +++ b/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql @@ -3,20 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_ BEFORE UPDATE ON `deviceProductionUser` FOR EACH ROW BEGIN - DECLARE vHasPda BOOLEAN; - DECLARE visFreelancer BOOLEAN; - DECLARE vUserName VARCHAR(50); - SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = NEW.userFk; - - SELECT name INTO vUserName FROM account.user WHERE id = NEW.userFk; - - SELECT account.user_hasRoleId(vUserName, (SELECT id FROM role WHERE name = 'freelancer')) INTO vIsFreelancer; - - IF NOT vIsFreelancer AND vHasPda THEN - CALL util.throw('You can only have one PDA'); - ELSE - SET NEW.editorFk = account.myUser_getId(); - END IF; + CALL worker_checkMultipleDevice(NEW.userFk); + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; From fbc1614132bbe5474b02b2b55d052f1cf9bc00f1 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 23 Apr 2024 18:50:28 +0200 Subject: [PATCH 007/110] fix: refs #7187 sql creation for deviceProductionUser --- db/versions/11010-blackChrysanthemum/00-firstScript.sql | 6 ++++++ db/versions/11011-pinkMoss/00-firstScript.sql | 1 + 2 files changed, 7 insertions(+) create mode 100644 db/versions/11010-blackChrysanthemum/00-firstScript.sql create mode 100644 db/versions/11011-pinkMoss/00-firstScript.sql diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..79751d095 --- /dev/null +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here +ALTER TABLE vn.deviceProductionUser DROP FOREIGN KEY deviceProductionUser_FK; + +ALTER TABLE vn.deviceProductionUser DROP PRIMARY KEY; + +ALTER TABLE vn.deviceProductionUser ADD id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY FIRST; diff --git a/db/versions/11011-pinkMoss/00-firstScript.sql b/db/versions/11011-pinkMoss/00-firstScript.sql new file mode 100644 index 000000000..371c2c358 --- /dev/null +++ b/db/versions/11011-pinkMoss/00-firstScript.sql @@ -0,0 +1 @@ +-- Place your SQL code here From a15970c95ff32917af1853b6e83261bb35c43580 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 24 Apr 2024 11:08:57 +0200 Subject: [PATCH 008/110] fix: refs #7187 sql for pdaFreelancer --- .../vn/triggers/deviceProductionUser_afterInsert.sql | 8 ++++++++ .../vn/triggers/deviceProductionUser_beforeInsert.sql | 1 - db/versions/11010-blackChrysanthemum/00-firstScript.sql | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/triggers/deviceProductionUser_afterInsert.sql diff --git a/db/routines/vn/triggers/deviceProductionUser_afterInsert.sql b/db/routines/vn/triggers/deviceProductionUser_afterInsert.sql new file mode 100644 index 000000000..3c8a9a51d --- /dev/null +++ b/db/routines/vn/triggers/deviceProductionUser_afterInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_afterInsert` + AFTER INSERT ON `deviceProductionUser` + FOR EACH ROW +BEGIN + CALL worker_checkMultipleDevice(NEW.userFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql index ccef618a4..b392cf5a1 100644 --- a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql +++ b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_ BEFORE INSERT ON `deviceProductionUser` FOR EACH ROW BEGIN - CALL worker_checkMultipleDevice(NEW.userFk); SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql index 79751d095..483df99d0 100644 --- a/db/versions/11010-blackChrysanthemum/00-firstScript.sql +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -4,3 +4,7 @@ ALTER TABLE vn.deviceProductionUser DROP FOREIGN KEY deviceProductionUser_FK; ALTER TABLE vn.deviceProductionUser DROP PRIMARY KEY; ALTER TABLE vn.deviceProductionUser ADD id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY FIRST; + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_deviceProduction_FK FOREIGN KEY (deviceProductionFk) REFERENCES vn.deviceProduction(id); + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique UNIQUE KEY (deviceProductionFk); From 88ef12032b463274187dd131212669e86981971d Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 24 Apr 2024 14:05:18 +0200 Subject: [PATCH 009/110] feat: refs #7187 serialNumber new column --- db/versions/11010-blackChrysanthemum/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql index 483df99d0..dcf7585c2 100644 --- a/db/versions/11010-blackChrysanthemum/00-firstScript.sql +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -8,3 +8,6 @@ ALTER TABLE vn.deviceProductionUser ADD id INT UNSIGNED AUTO_INCREMENT NOT NULL ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_deviceProduction_FK FOREIGN KEY (deviceProductionFk) REFERENCES vn.deviceProduction(id); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique UNIQUE KEY (deviceProductionFk); + +ALTER TABLE vn.deviceProduction ADD simSerialNumber TEXT NULL; + From 008b6f6f416ed6c8faa57f023fbb14f1f5c8fcec Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 24 Apr 2024 14:08:26 +0200 Subject: [PATCH 010/110] fix: refs #7187 unify versions --- db/versions/10993-brownAsparagus/00-dropUniqueKey.sql | 2 -- db/versions/11010-blackChrysanthemum/00-firstScript.sql | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 db/versions/10993-brownAsparagus/00-dropUniqueKey.sql diff --git a/db/versions/10993-brownAsparagus/00-dropUniqueKey.sql b/db/versions/10993-brownAsparagus/00-dropUniqueKey.sql deleted file mode 100644 index 39bac8652..000000000 --- a/db/versions/10993-brownAsparagus/00-dropUniqueKey.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.deviceProductionUser DROP INDEX IF EXISTS deviceProductionUser_UN; - diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql index dcf7585c2..c274d1c71 100644 --- a/db/versions/11010-blackChrysanthemum/00-firstScript.sql +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -1,4 +1,5 @@ --- Place your SQL code here +ALTER TABLE vn.deviceProductionUser DROP INDEX IF EXISTS deviceProductionUser_UN; + ALTER TABLE vn.deviceProductionUser DROP FOREIGN KEY deviceProductionUser_FK; ALTER TABLE vn.deviceProductionUser DROP PRIMARY KEY; From e8a32d8e13ebd1878d2ddb6cc3d35b66b5b48231 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 24 Apr 2024 14:09:42 +0200 Subject: [PATCH 011/110] fix: refs #7187 db version --- db/versions/11011-pinkMoss/00-firstScript.sql | 1 - 1 file changed, 1 deletion(-) delete mode 100644 db/versions/11011-pinkMoss/00-firstScript.sql diff --git a/db/versions/11011-pinkMoss/00-firstScript.sql b/db/versions/11011-pinkMoss/00-firstScript.sql deleted file mode 100644 index 371c2c358..000000000 --- a/db/versions/11011-pinkMoss/00-firstScript.sql +++ /dev/null @@ -1 +0,0 @@ --- Place your SQL code here From f2d4283304d50a3420c232ac987662392d46e872 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 24 Apr 2024 14:29:57 +0200 Subject: [PATCH 012/110] fix: refs #7187 number on de code --- db/routines/vn/procedures/worker_checkMultipleDevice.sql | 6 ++++-- db/versions/11010-blackChrysanthemum/00-firstScript.sql | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/worker_checkMultipleDevice.sql b/db/routines/vn/procedures/worker_checkMultipleDevice.sql index ecc485c9d..00df08d49 100644 --- a/db/routines/vn/procedures/worker_checkMultipleDevice.sql +++ b/db/routines/vn/procedures/worker_checkMultipleDevice.sql @@ -11,11 +11,13 @@ BEGIN */ DECLARE vHasPda BOOLEAN; DECLARE vIsFreelance BOOLEAN; + DECLARE vMaxDevicesPerUser INT; SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = vSelf; - SELECT isFreelance INTO vIsFreelance FROM worker WHERE id = vSelf; + SELECT IFNULL(isFreelance, FALSE) INTO vIsFreelance FROM worker WHERE id = vSelf; + SELECT IFNULL(maxDevicesPerUser, FALSE) INTO vMaxDevicesPerUser FROM deviceProductionConfig LIMIT 1; - IF NOT vIsFreelance AND vHasPda > 1 THEN + IF NOT vIsFreelance AND vHasPda > vMaxDevicesPerUser THEN CALL util.throw('You can only have one PDA'); END IF; END$$ diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql index c274d1c71..556ddfc1b 100644 --- a/db/versions/11010-blackChrysanthemum/00-firstScript.sql +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -12,3 +12,6 @@ ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique U ALTER TABLE vn.deviceProduction ADD simSerialNumber TEXT NULL; +ALTER TABLE vn.deviceProductionConfig ADD maxDevicesPerUser INT UNSIGNED NULL; + +UPDATE vn.deviceProductionConfig SET maxDevicesPerUser=1 WHERE id=1; From f34c960f5dd126273c268d378464ce04bd64dd82 Mon Sep 17 00:00:00 2001 From: jcasado Date: Thu, 25 Apr 2024 10:10:14 +0200 Subject: [PATCH 013/110] refs: #6939 changeREADME --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index b420bc44f..e50e39de6 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,16 @@ Required applications. * Node.js * Docker * Git +* MYT You will need to install globally the following items. ``` $ sudo npm install -g jest gulp-cli ``` +After installing MYT you will need the following item. +``` +$ apt install libkrb5-dev libssl-dev +``` ## Installing dependencies and launching From 133b862dc0d0fc9660dc44ac0f11fbf1acc269ca Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 3 May 2024 14:20:16 +0200 Subject: [PATCH 014/110] fix: refs #7187 move column sim to deviceProductionUser --- .../11010-blackChrysanthemum/00-firstScript.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql index 556ddfc1b..a0d10891c 100644 --- a/db/versions/11010-blackChrysanthemum/00-firstScript.sql +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -1,17 +1,17 @@ ALTER TABLE vn.deviceProductionUser DROP INDEX IF EXISTS deviceProductionUser_UN; -ALTER TABLE vn.deviceProductionUser DROP FOREIGN KEY deviceProductionUser_FK; +ALTER TABLE vn.deviceProductionUser DROP FOREIGN KEY IF EXISTS deviceProductionUser_FK; ALTER TABLE vn.deviceProductionUser DROP PRIMARY KEY; -ALTER TABLE vn.deviceProductionUser ADD id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY FIRST; +ALTER TABLE vn.deviceProductionUser ADD IF NOT EXISTS id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY FIRST; -ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_deviceProduction_FK FOREIGN KEY (deviceProductionFk) REFERENCES vn.deviceProduction(id); +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_deviceProduction_FK FOREIGN KEY IF NOT EXISTS (deviceProductionFk) REFERENCES vn.deviceProduction(id); -ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique UNIQUE KEY (deviceProductionFk); +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique UNIQUE KEY IF NOT EXISTS (deviceProductionFk); -ALTER TABLE vn.deviceProduction ADD simSerialNumber TEXT NULL; +ALTER TABLE vn.deviceProductionUser ADD IF NOT EXISTS simSerialNumber TEXT NULL; -ALTER TABLE vn.deviceProductionConfig ADD maxDevicesPerUser INT UNSIGNED NULL; +ALTER TABLE vn.deviceProductionConfig ADD IF NOT EXISTS maxDevicesPerUser INT UNSIGNED NULL; UPDATE vn.deviceProductionConfig SET maxDevicesPerUser=1 WHERE id=1; From 699684bd656342b816d63f7410c02c98f41fb997 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 3 May 2024 14:22:48 +0200 Subject: [PATCH 015/110] feat: refs #7187 add sim column to the model and id --- modules/worker/back/models/device-production-user.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json index 35a90fb50..f11fd240c 100644 --- a/modules/worker/back/models/device-production-user.json +++ b/modules/worker/back/models/device-production-user.json @@ -14,6 +14,10 @@ } }, "properties": { + "id": { + "type": "number", + "id": true + }, "deviceProductionFk": { "type": "number", "id": true @@ -21,6 +25,9 @@ "userFk": { "type": "number" }, + "simSerialNumber": { + "type": "string" + }, "created": { "type": "date" } From d6451a94e3f080fed07f6406d92396ea2f1627d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 8 May 2024 17:38:52 +0200 Subject: [PATCH 016/110] feat: conversion art. A1 a A2 refs #4979 --- db/routines/vn/procedures/buy_clone.sql | 2 - db/routines/vn/procedures/buy_cloneByBuy.sql | 23 ----- db/routines/vn/procedures/item_devalueA2.sql | 88 ++++++++++++++++---- 3 files changed, 73 insertions(+), 40 deletions(-) delete mode 100644 db/routines/vn/procedures/buy_cloneByBuy.sql diff --git a/db/routines/vn/procedures/buy_clone.sql b/db/routines/vn/procedures/buy_clone.sql index bbf742b23..d3fbf888d 100644 --- a/db/routines/vn/procedures/buy_clone.sql +++ b/db/routines/vn/procedures/buy_clone.sql @@ -22,7 +22,6 @@ BEGIN containerFk, comissionValue, packageValue, - packageFk, price1, price2, price3, @@ -45,7 +44,6 @@ BEGIN b.containerFk, b.comissionValue, b.packageValue, - b.packageFk, b.price1, b.price2, b.price3, diff --git a/db/routines/vn/procedures/buy_cloneByBuy.sql b/db/routines/vn/procedures/buy_cloneByBuy.sql deleted file mode 100644 index 73e91a9df..000000000 --- a/db/routines/vn/procedures/buy_cloneByBuy.sql +++ /dev/null @@ -1,23 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_cloneByBuy`( - OUT vBuyClonedFk INT, - IN vSelf INT, - IN vEntryFk INT -) -BEGIN -/** - * Clone a buy to an entry - * - * @param OUT vBuyClonedFk The new cloned buy id - * @param vSelf The buy id to clone - * @param vEntryFk The destination entry id - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.buy - SELECT vSelf id; - - CALL buy_clone(vEntryFk); - SET vBuyClonedFk = LAST_INSERT_ID(); - - DROP TEMPORARY TABLE tmp.buy; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index e1fb08388..4ad6fcfa2 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -308,21 +308,79 @@ BEGIN WHERE id = vTargetItemShelvingFk; END IF; - CALL buy_cloneByBuy(vA1BuyFk, vLastBuyFk, vTargetEntryFk); - UPDATE buy - SET quantity = - LEAST(vQuantity,vCurrentVisible), - isIgnored = TRUE, - buyingValue = vBuyingValue - WHERE id = vA1BuyFk; - - CALL buy_cloneByBuy(vA2BuyFk, vLastBuyFk, vTargetEntryFk); - UPDATE buy - SET quantity = vQuantity, - isIgnored = TRUE, - buyingValue = vBuyingValue, - itemFk = vItemA2Fk - WHERE id = vA2BuyFk; - + INSERT INTO buy( + entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk) + SELECT vTargetEntryFk, + itemFk, + - LEAST(vQuantity, vCurrentVisible), + vBuyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk + UNION + SELECT vTargetEntryFk, + vItemA2Fk, + vQuantity, + vBuyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk; + INSERT INTO itemShelving ( itemFk, shelvingFk, From 9d7184ed7bc66f4a3a2a5a3e32076446f155edab Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 9 May 2024 12:35:26 +0200 Subject: [PATCH 017/110] refs #6965 Add Fk vehicleFk firstEditorFk --- db/versions/11040-grayMonstera/00-firstScript.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/versions/11040-grayMonstera/00-firstScript.sql diff --git a/db/versions/11040-grayMonstera/00-firstScript.sql b/db/versions/11040-grayMonstera/00-firstScript.sql new file mode 100644 index 000000000..0f20e771b --- /dev/null +++ b/db/versions/11040-grayMonstera/00-firstScript.sql @@ -0,0 +1,13 @@ +UPDATE vn.route + SET vehicleFk = NULL + WHERE vehicleFk NOT IN (SELECT id FROM vn.vehicle); + +ALTER TABLE vn.route +ADD CONSTRAINT route_vehicleFk FOREIGN KEY (vehicleFk) REFERENCES vn.vehicle(id); + +UPDATE vn.route + SET firstEditorFk = NULL + WHERE firstEditorFk NOT IN (SELECT id FROM vn.worker); + +ALTER TABLE vn.route +ADD CONSTRAINT route_firstEditorFk FOREIGN KEY (firstEditorFk) REFERENCES vn.worker(id); From cc941de606be39dfebce5cc529e84b1c609d503e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 9 May 2024 14:24:20 +0200 Subject: [PATCH 018/110] feat: conversion art. A1 a A2 refs #4979 --- .../vn/procedures/buy_recalcPricesByBuy.sql | 2 +- db/routines/vn/procedures/item_devalueA2.sql | 99 +++++++++---------- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/db/routines/vn/procedures/buy_recalcPricesByBuy.sql b/db/routines/vn/procedures/buy_recalcPricesByBuy.sql index b963bae14..12c0df985 100644 --- a/db/routines/vn/procedures/buy_recalcPricesByBuy.sql +++ b/db/routines/vn/procedures/buy_recalcPricesByBuy.sql @@ -8,7 +8,7 @@ BEGIN */ DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; - CREATE TEMPORARY TABLE tmp.buyRecalc + CREATE TEMPORARY TABLE tmp.buyRecalc SELECT vBuyFk id; CALL buy_recalcPrices(); diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index 4ad6fcfa2..276c5b508 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_devalueA2`( + vSelf INT, vShelvingFK VARCHAR(10), - vItemFk INT, vBuyingValue DECIMAL(10,4), vQuantity INT ) @@ -11,8 +11,8 @@ BEGIN * Si no existe el item A2 lo crea y genera los movimientos de las entradas * de almacén y shelvings correspondientes * + * @param vSelf Id de artículo a devaluar * @param vShelvingFK Ubicación actual del artículo - * @param vItemFk Id de artículo a devaluar * @param vBuyingValue Nuevo precio de coste */ DECLARE vItemA2Fk INT; @@ -26,7 +26,7 @@ BEGIN DECLARE vCacheFk INT; DECLARE vLastEntryFk INT; DECLARE vCurrentVisible INT; - DECLARE vInventoryTravelFk INT; + DECLARE vDevalueTravelFk INT; DECLARE vCurdate DATE; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION @@ -35,7 +35,7 @@ BEGIN RESIGNAL; END; - IF (SELECT TRUE FROM item WHERE id = vItemFk AND (category <> 'A1' OR category IS NULL)) THEN + IF (SELECT TRUE FROM item WHERE id = vSelf AND (category <> 'A1' OR category IS NULL)) THEN CALL util.throw('Item has not category A1'); END IF; @@ -47,11 +47,15 @@ BEGIN CALL util.throw ('Operator has not a valid warehouse'); END IF; + IF vQuantity <= 0 OR vQuantity IS NULL THEN + CALL util.throw ('The quantity is incorrect'); + END IF; + SELECT util.VN_CURDATE() INTO vCurdate; - SELECT t.id INTO vInventoryTravelFk + SELECT t.id INTO vDevalueTravelFk FROM travel t - JOIN travelConfig tc + JOIN travelConfig tc WHERE t.shipped = vCurdate AND t.landed = vCurdate AND t.warehouseInFk = vWarehouseFk @@ -59,7 +63,7 @@ BEGIN AND t.agencyModeFk = tc.devalueAgencyModeFk LIMIT 1; - IF NOT vInventoryTravelFk OR vInventoryTravelFk IS NULL THEN + IF NOT vDevalueTravelFk OR vDevalueTravelFk IS NULL THEN INSERT INTO travel ( shipped, landed, @@ -76,14 +80,14 @@ BEGIN TRUE, tc.devalueAgencyModeFk FROM travelConfig tc; - SET vInventoryTravelFk = LAST_INSERT_ID(); + SET vDevalueTravelFk = LAST_INSERT_ID(); END IF; - SELECT id, dated INTO vTargetEntryFk, vTargetEntryDate + SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate FROM `entry` e - WHERE created = vCurdate + WHERE DATE(dated) = vCurdate AND typeFk ='devaluation' - AND travelFk = vInventoryTravelFk + AND travelFk = vDevalueTravelFk ORDER BY created DESC LIMIT 1; @@ -92,23 +96,31 @@ BEGIN SELECT b.entryFk, bu.buyFk INTO vLastEntryFk,vLastBuyFk FROM tmp.buyUltimate bu JOIN vn.buy b ON b.id =bu.buyFk - WHERE bu.itemFk = vItemFk + WHERE bu.itemFk = vSelf AND bu.warehouseFk = vWarehouseFk; - SELECT id,visible INTO vTargetItemShelvingFk,vCurrentVisible + IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN + CALL util.throw ('The item has not a buy'); + END IF; + + SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible FROM itemShelving WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci - AND itemFk = vItemFk + AND itemFk = vSelf LIMIT 1; - IF vQuantity >= vCurrentVisible THEN + IF vCurrentVisible IS NULL THEN + CALL util.throw ('The shelving has not a visible for this item'); + END IF; + + IF vQuantity > vCurrentVisible THEN CALL util.throw('Quantity is greater than visible'); END IF; START TRANSACTION; IF NOT vTargetEntryFk OR vTargetEntryFk IS NULL - OR NOT vTargetEntryDate <=> vCurdate THEN + OR NOT vTargetEntryDate <=> vCurdate THEN INSERT INTO entry( travelFk, supplierFk, @@ -119,7 +131,7 @@ BEGIN clonedFrom, typeFk ) - SELECT vInventoryTravelFk, + SELECT vDevalueTravelFk, supplierFk, vCurdate, commission, @@ -149,7 +161,7 @@ BEGIN i.EmbalageCode, i.quality FROM item i - WHERE i.id = vItemFk + WHERE i.id = vSelf )i2 ON i2.name <=> i.name AND i2.subname <=> i.subname AND i2.value5 <=> i.value5 @@ -193,18 +205,6 @@ BEGIN isActive, longName, subName, - tag5, - value5, - tag6, - value6, - tag7, - value7, - tag8, - value8, - tag9, - value9, - tag10, - value10, minimum, upToDown, supplyResponseFk, @@ -250,19 +250,7 @@ BEGIN expenseFk, isActive, longName, - subName, - tag5, - value5, - tag6, - value6, - tag7, - value7, - tag8, - value8, - tag9, - value9, - tag10, - value10, + subName, minimum, upToDown, supplyResponseFk, @@ -283,20 +271,25 @@ BEGIN recycledPlastic, nonRecycledPlastic FROM item - WHERE id = vItemFk; + WHERE id = vSelf; SET vItemA2Fk = LAST_INSERT_ID(); + INSERT INTO itemTag (itemFk, tagFk, `value`, intValue, priority, editorFk) + SELECT vItemA2Fk, tagFk, `value`, intValue, priority, editorFk + FROM itemTag + WHERE id = vSelf; + UPDATE itemTaxCountry itc - JOIN itemTaxCountry itc2 ON itc2.itemFk = vItemFk + JOIN itemTaxCountry itc2 ON itc2.itemFk = vSelf AND itc2.countryFk = itc.countryFk SET itc2.taxClassFk = itc.taxClassFk WHERE itc.id = vItemA2Fk; - + INSERT INTO itemBotanical (itemFk, genusFk, specieFk) SELECT vItemA2Fk, genusFk, specieFk FROM itemBotanical - WHERE itemFk = vItemFk; + WHERE itemFk = vSelf; END IF; IF vQuantity = vCurrentVisible THEN @@ -334,7 +327,7 @@ BEGIN SELECT vTargetEntryFk, itemFk, - LEAST(vQuantity, vCurrentVisible), - vBuyingValue, + buyingValue, freightValue, TRUE, stickers, @@ -381,7 +374,7 @@ BEGIN FROM vn.buy WHERE id = vLastBuyFk; - INSERT INTO itemShelving ( + INSERT IGNORE INTO itemShelving ( itemFk, shelvingFk, visible, @@ -392,15 +385,17 @@ BEGIN isChecked) SELECT vItemA2Fk, shelvingFk, - vQuantity, + vQuantity , `grouping`, packing, packagingFk, account.myUser_getId(), isChecked FROM itemShelving - WHERE itemFK = vItemFk - AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci; + WHERE itemFK = vSelf + AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + ON DUPLICATE KEY UPDATE + visible = vQuantity + VALUES(visible); COMMIT; CALL cache.visible_refresh(vCacheFk, TRUE, vWarehouseFk); From a797fca2ddfb42f31ad0265de0ac43e55ce49187 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 13 May 2024 08:30:20 +0200 Subject: [PATCH 019/110] feat: refs #7187 merge dev --- modules/worker/back/models/device-production-user.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json index f11fd240c..d63fe0148 100644 --- a/modules/worker/back/models/device-production-user.json +++ b/modules/worker/back/models/device-production-user.json @@ -43,5 +43,10 @@ "model": "User", "foreignKey": "userFk" } + }, + "scope": { + "include":{ + "relation": "deviceProduction" + } } } From a8299383b9dcf889bef75bef3d4f8f649186f13f Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 13 May 2024 16:28:29 +0200 Subject: [PATCH 020/110] refs #6428 remove sh --- changelog.sh | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 changelog.sh diff --git a/changelog.sh b/changelog.sh deleted file mode 100644 index 8cd7b4716..000000000 --- a/changelog.sh +++ /dev/null @@ -1,34 +0,0 @@ -features_types=(chore feat style) -changes_types=(refactor perf) -fix_types=(fix revert) -file="CHANGELOG.md" -file_tmp="temp_log.txt" -file_current_tmp="temp_current_log.txt" - -setType(){ - echo "### $1" >> $file_tmp - arr=("$@") - echo "" > $file_current_tmp - for i in "${arr[@]}" - do - git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp - done - # remove duplicates - sort -o $file_current_tmp -u $file_current_tmp - cat $file_current_tmp >> $file_tmp - echo "" >> $file_tmp - # remove tmp current file - [ -e $file_current_tmp ] && rm $file_current_tmp -} - -echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp -echo "" >> $file_tmp - -setType "Added 🆕" "${features_types[@]}" -setType "Changed 📦" "${changes_types[@]}" -setType "Fixed 🛠️" "${fix_types[@]}" - -cat $file >> $file_tmp -mv $file_tmp $file - - From ebcf8e2927b8246b609b29efb7c3e2e6cf1e8cff Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 14 May 2024 08:30:22 +0200 Subject: [PATCH 021/110] refs #6428 change file --- CHANGELOG.md | 92 ---------------------------------------------------- changelog.sh | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 92 deletions(-) create mode 100644 changelog.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 04a40cd20..e11a5a6ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,95 +1,3 @@ -# Version XX.XX - XXXX-XX-XX (TEXTO DE PRUEBA CREADO APARTIR DE DEV → TEST) - -### Added 🆕 - -- feat: #7130 added "served" field to RouteList table(Salix). by:Jon -- feat(binlog): refs #4409 New function for binlog queue monitoring by:Juan Ferrer Toribio -- feat: bloquear facturas recibidas contabilizadas refs #7173 by:Carlos Andrés -- feat: commit by:pablone -- feat(delay): refs #6005 add new restriction by:pablone -- feat(git): add commit lint refs #6130 by:pablone -- feat(git): add commit lint refs#6130 by:pablone -- feat(githook) add reference by:pablone -- feat(noSpam): refs #6005 check if exists a previous notification by:pablone -- feat(notify): refs #6005 add restriction on created notification time by:pablone -- feat(operator.spec): refs #6005 add spec for delay and fix spec for spam by:pablone -- feat: permissions to vn.entry.isBooked refs#6724 by:Carlos Andrés -- feat: refs #12 peter by:pablone -- feat: refs #6005 move logic from report to hook by:pablone -- feat: refs #6005 mover sql a la ultima carpeta by:pablone -- feat: refs #6021 fix proc by:pablone -- feat: refs #6021 order_put refactor by:pablone -- feat: refs #6130 add commit by:pablone -- feat: refs #6130 handle branch without task by:pablone -- feat: refs #6130 test commitLint (6130-commitLint) by:alexm -- feat: refs #6500 by:robert -- feat: refs #6500 cambios solicitados by:robert -- feat: refs #6500 delete procedure by:robert -- feat: refs #6500 procRefactor8 by:robert -- feat: refs #6724 Added admon acl to vn-check by:guillermo -- feat: refs #6724 Grant changes by:guillermo -- feat: refs #6724 hook added by:jorgep -- feat: refs #6938 add scope & acls by:jorgep -- feat: refs #6968 Changed groupingMode to enum by:guillermo -- feat: refs #6968 Requested changes by:guillermo -- feat: refs #6968 Transactioned and isTriggerDisabled by:guillermo -- feat: refs #7173 Added restrictions in invoiceIn structure by:guillermo -- feat: refs #7173 Added traduction by:guillermo -- feat(salix): refs #6930 Undo rollback salix-back by:Javier Segarra -- feat(salix): refs #6930 Undo rollback salix-front by:Javier Segarra -- feat: sin concatenar en el nombre by:jgallego -- feat(spec): refs #6005 add spec by:pablone -- feat(spec): refs #6005 add spec to backup Notify by:pablone -- feat: test by:pablone -- refs #7190 feat: renewToken for multimedia by:Javier Segarra - -### Changed 📦 - -- feat: refs #6021 order_put refactor by:pablone -- refactor(main-labeler): refs #6005 refactor de mainLabeler a backupPrinterFk by:pablone -- refactor(printer-notification): refs #6005 refactor de la notificación by:pablone -- refactor: refs #6005 delay on productionConfig by:pablone -- refactor: refs #6005 move the logic to the report by:pablone -- refactor: refs #6005 refactor spec by:pablone -- refactor: refs #6724 Minor change by:guillermo -- refactor: refs #7139 replace warehouse with ticket by:Jon -- refactor: refs #7181 Added grant by:guillermo -- refactor: refs #7181 Minor change by:guillermo -- refactor: refs #7181 Requested changes by:guillermo -- refactor: refs #7181 vn2008.Deleted risk_vs_client_list by:guillermo - -### Fixed 🛠️ - -- feat(operator.spec): refs #6005 add spec for delay and fix spec for spam by:pablone -- feat: refs #6021 fix proc by:pablone -- fix(binlog): refs #4409 Fixtures for binlogQueue by:Juan Ferrer Toribio -- fix(changes): refs #6005 remove changes files by:pablone -- fix(claim): remove blank space refs #6130 by:pablone -- fix commit code by:pablone -- fix: husky by:alexm -- fix(notification): refs #6005 notification changes by:pablone -- fix: refs #6005 add fixtures for a spec by:pablone -- fix: refs #6005 move logic to hook by:pablone -- fix: refs #6021 catalogue_findById by:pablone -- fix: refs #6021 proc by:pablone -- fix: refs #6130 code by:pablone -- fix:refs #6130 code by:pablone -- fix: refs #6130 code:code by:pablone -- fix: refs #6130 code remove console.log by:pablone -- fix: refs #6130 test by:pablone -- fix: refs #6938 acls & scope by:jorgep -- fix: refs #6938 e2e tests by:jorgep -- fix: refs #6938 filters & scope by:jorgep -- fix: refs #6938 front tests by:jorgep -- fix: refs #6938 scope by:jorgep -- fix: remove logs (testHusky_deleteme) by:alexm -- fix(spec): refs #6005 backupLabeler spec by:pablone -- fix(sql): refs #6005 fix fk formation by:pablone -- fix(yml): refs #6005 backUpLabeler yml fix by:pablone -- refs #6641 fix PR changes by:jcasado -- refs #6641 fix test by:jcasado -- refs #6641 test fixtures by:jcasado -- refs #6835 fix: issue by:Javier Segarra # Changelog diff --git a/changelog.sh b/changelog.sh new file mode 100644 index 000000000..8cd7b4716 --- /dev/null +++ b/changelog.sh @@ -0,0 +1,34 @@ +features_types=(chore feat style) +changes_types=(refactor perf) +fix_types=(fix revert) +file="CHANGELOG.md" +file_tmp="temp_log.txt" +file_current_tmp="temp_current_log.txt" + +setType(){ + echo "### $1" >> $file_tmp + arr=("$@") + echo "" > $file_current_tmp + for i in "${arr[@]}" + do + git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp + done + # remove duplicates + sort -o $file_current_tmp -u $file_current_tmp + cat $file_current_tmp >> $file_tmp + echo "" >> $file_tmp + # remove tmp current file + [ -e $file_current_tmp ] && rm $file_current_tmp +} + +echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp +echo "" >> $file_tmp + +setType "Added 🆕" "${features_types[@]}" +setType "Changed 📦" "${changes_types[@]}" +setType "Fixed 🛠️" "${fix_types[@]}" + +cat $file >> $file_tmp +mv $file_tmp $file + + From 599f22a25de9e25e26a405a223770be432468134 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 14 May 2024 09:03:49 +0200 Subject: [PATCH 022/110] catalogue tiene en cuenta apc --- db/routines/floranet/procedures/catalogue_get.sql | 9 +++++++-- db/routines/floranet/procedures/contact_request.sql | 13 +++++++++++-- .../floranet/procedures/deliveryDate_get.sql | 2 +- db/routines/floranet/procedures/order_put.sql | 12 ++++++------ db/routines/floranet/procedures/sliders_get.sql | 13 ++++++------- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index 32624f383..d67f7555e 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -42,8 +42,8 @@ proc:BEGIN image, description ) - SELECT i.name, - i.`size`, + SELECT CONCAT(i.name, ' by ',a.nickname), + i.`size` + apc.deliveryCost, i.id, vLanded, vPostalCode, @@ -52,6 +52,11 @@ proc:BEGIN i.description FROM vn.item i JOIN vn.itemType it ON it.id = i.typeFk + JOIN addressPostCode apc + ON apc.dayOfWeek = dayOfWeek(vLanded) + AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR + AND apc.postCode = vPostalCode + JOIN vn.address a ON a.id = apc.addressFk WHERE it.code IN ('FNR','FNP'); SELECT * diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql index 2ca25b87d..c479945cc 100644 --- a/db/routines/floranet/procedures/contact_request.sql +++ b/db/routines/floranet/procedures/contact_request.sql @@ -13,8 +13,17 @@ BEGIN /** * Set actions for contact request * - * @param vPostalCode Delivery address postal code + * @param vName Name + * @param vPhone Phone number + * @param vEmail e-mail + * @param vMessage text of the message */ - + + CALL vn.mail_insert( + 'pako@verdnatura.es', + vEmail, + 'Contact request', + CONCAT('Phone: ',vPhone, ' Message: ', vMessage) + ); END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql index 75e9d6257..a235e8c31 100644 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -21,7 +21,7 @@ BEGIN apc.dayOfWeek - vCurrentDayOfWeek, 7 - apc.dayOfWeek ) DAY nextDay, - NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime + NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime FROM addressPostCode apc WHERE apc.postCode = vPostalCode HAVING nextDay > minDeliveryTime) sub; diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql index 979588f8f..ec0295ca7 100644 --- a/db/routines/floranet/procedures/order_put.sql +++ b/db/routines/floranet/procedures/order_put.sql @@ -10,12 +10,12 @@ BEGIN INSERT INTO `order` SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')), customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')), - email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), - customerPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerPhone')), - message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), - deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), - address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), - deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); + email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), + customerPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerPhone')), + message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), + deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), + address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), + deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); SELECT LAST_INSERT_ID() orderFk; END$$ diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql index 0e4aa297a..bafda4732 100644 --- a/db/routines/floranet/procedures/sliders_get.sql +++ b/db/routines/floranet/procedures/sliders_get.sql @@ -9,12 +9,11 @@ BEGIN * Returns list of url for sliders. */ SELECT - CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, - i.longName - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP') - LIMIT 3; - + CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, + i.longName + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.code IN ('FNR','FNP') + LIMIT 3; END$$ DELIMITER ; \ No newline at end of file From bb4f78961f411a0469218606e224524e5197c30d Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 14 May 2024 14:01:13 +0200 Subject: [PATCH 023/110] element table --- .../floranet/procedures/contact_request.sql | 2 +- .../floranet/procedures/order_confirm.sql | 72 +++++++++++++++++-- .../11050-wheatAnthurium/00-firstScript.sql | 4 ++ .../11050-wheatAnthurium/01-elementFilter.sql | 6 ++ 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 db/versions/11050-wheatAnthurium/00-firstScript.sql create mode 100644 db/versions/11050-wheatAnthurium/01-elementFilter.sql diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql index c479945cc..2132a86fc 100644 --- a/db/routines/floranet/procedures/contact_request.sql +++ b/db/routines/floranet/procedures/contact_request.sql @@ -20,7 +20,7 @@ BEGIN */ CALL vn.mail_insert( - 'pako@verdnatura.es', + 'floranet@verdnatura.es', vEmail, 'Contact request', CONCAT('Phone: ',vPhone, ' Message: ', vMessage) diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql index b6aec033d..c5d61bf48 100644 --- a/db/routines/floranet/procedures/order_confirm.sql +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -1,23 +1,87 @@ -DROP PROCEDURE IF EXISTS floranet.order_confirm; - DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) READS SQL DATA BEGIN -/** Update order.isPaid field. +/** Update order.isPaid field, and makes the ticket * * @param vCatalogueFk floranet.catalogue.id * * @returns floranet.order.isPaid */ + DECLARE vNewTicketFk INT; + DECLARE vZoneFk INT; + UPDATE `order` SET isPaid = TRUE, payed = NOW() WHERE catalogueFk = vCatalogueFk; + SELECT zoneFk + INTO vZoneFk + FROM ( + SELECT zoneFk, COUNT(*) totalCount + FROM vn.ticket t + JOIN catalogue c ON c.id = vCatalogueFk + WHERE t.shipped > util.VN_CURDATE() - INTERVAL 1 YEAR + AND t.addressFk = c.addressFk + GROUP BY zoneFk + ORDER BY totalCount DESC + LIMIT 10000000000000000000 + ) sub + LIMIT 1; + + INSERT INTO ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + routeFk, + companyFk, + landed, + zoneFk + ) + SELECT a.clientFk, + c.dated - INTERVAL 1 DAY, + c.addressFk, + a.agencyModeFk, + a.nickname, + ag.warehouseFk, + NULL, + co.id, + c.dated, + vZoneFk + FROM vn.address a + JOIN vn.agencyMode am ON am.id = a.agencyModeFk + JOIN vn.agency ag ON ag.id = am.agencyFk + JOIN catalogue c ON c.addressFk = a.id + JOIN vn.company co ON co.code = 'VNL' + WHERE c.id = vCatalogueFk; + + SET vNewTicketFk = LAST_INSERT_ID(); + + INSERT INTO vn.sale( + ticketFk, + itemFk, + concept, + price, + quantity) + SELECT + vNewTicketFk, + c.itemFk, + CONCAT('Entrega: ',c.name), + - c.price, + 1 + FROM catalogue c + JOIN addressPostCode apc + ON apc.addressFk = c.addressFk + AND apc.dayOfWeek = dayOfWeek(vDated) + WHERE c.id = vCatalogueFk; + SELECT isPaid FROM `order` WHERE catalogueFk = vCatalogueFk; diff --git a/db/versions/11050-wheatAnthurium/00-firstScript.sql b/db/versions/11050-wheatAnthurium/00-firstScript.sql new file mode 100644 index 000000000..cb8034ff5 --- /dev/null +++ b/db/versions/11050-wheatAnthurium/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here + +ALTER TABLE floranet.catalogue ADD addressFk int(11) NOT NULL; +ALTER TABLE floranet.catalogue ADD CONSTRAINT catalogue_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11050-wheatAnthurium/01-elementFilter.sql b/db/versions/11050-wheatAnthurium/01-elementFilter.sql new file mode 100644 index 000000000..3f2bb78ac --- /dev/null +++ b/db/versions/11050-wheatAnthurium/01-elementFilter.sql @@ -0,0 +1,6 @@ +ALTER TABLE floranet.builder DROP FOREIGN KEY builder_FK_1; +ALTER TABLE floranet.`element` DROP PRIMARY KEY; +ALTER TABLE floranet.`element` ADD id INT NOT NULL; +ALTER TABLE floranet.`element` ADD CONSTRAINT element_pk PRIMARY KEY (id); +ALTER TABLE floranet.builder ADD CONSTRAINT builder_element_FK FOREIGN KEY (elementFk) REFERENCES floranet.`element`(id) ON DELETE CASCADE ON UPDATE CASCADE; + From 9ed90412ded9c7cf8b0368fcf710209265d08e03 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 15 May 2024 13:15:27 +0200 Subject: [PATCH 024/110] refs #6965 Points to user instead of worker --- db/versions/11040-grayMonstera/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11040-grayMonstera/00-firstScript.sql b/db/versions/11040-grayMonstera/00-firstScript.sql index 0f20e771b..8fb0e85c3 100644 --- a/db/versions/11040-grayMonstera/00-firstScript.sql +++ b/db/versions/11040-grayMonstera/00-firstScript.sql @@ -7,7 +7,7 @@ ADD CONSTRAINT route_vehicleFk FOREIGN KEY (vehicleFk) REFERENCES vn.vehicle(id) UPDATE vn.route SET firstEditorFk = NULL - WHERE firstEditorFk NOT IN (SELECT id FROM vn.worker); + WHERE firstEditorFk NOT IN (SELECT id FROM account.user); ALTER TABLE vn.route -ADD CONSTRAINT route_firstEditorFk FOREIGN KEY (firstEditorFk) REFERENCES vn.worker(id); +ADD CONSTRAINT route_firstEditorFk FOREIGN KEY (firstEditorFk) REFERENCES account.user(id); From 9b73cdfa6ffe0edfa39a228b0e9d40fc241a868b Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 15 May 2024 17:03:33 +0200 Subject: [PATCH 025/110] refs #4979 feat:getInfoDetails && item_devalueA2 --- .../itemShelving_getItemDetails.sql | 90 +++++++++++++++++++ db/routines/vn/procedures/item_devalueA2.sql | 14 ++- 2 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 db/routines/vn/procedures/itemShelving_getItemDetails.sql diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql new file mode 100644 index 000000000..2134f00c4 --- /dev/null +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -0,0 +1,90 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(vBarcodeItem INT, vShelvingFK VARCHAR(10) ) +BEGIN + +/** + * Obtiene el precio y visible de un item + * + * @param vBarcodeItem barcode de artículo + * @param vBarcodeItem Ubicación actual del artículo + */ + DECLARE vIsItem BOOL; + DECLARE vItemFk INT; + DECLARE vItemCost DECIMAL(10,4); + DECLARE vCacheVisibleFk INT; + DECLARE vWarehouseFk INT; + DECLARE vVisible INT; + + + SELECT COUNT(*)>0 INTO vIsItem + FROM vn.item + WHERE id = vBarcodeItem; + + IF NOT vIsItem THEN + + SELECT IFNULL(b.buyingValue, 0) + + IFNULL(b.freightValue, 0) + + IFNULL(b.comissionValue, 0) + + IFNULL(b.packageValue, 0), + SUM(is2.visible) , + b.itemFk + INTO vItemCost, vVisible, vItemFk + FROM itemShelving is2 + JOIN buy b ON b.itemFk = is2.itemFk AND b.id = vBarcodeItem + WHERE is2.shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + GROUP BY shelvingFK; + + SELECT vItemFk itemFk, + vShelvingFK shelvingFk, + vItemCost itemCost, + vVisible quantity; + + END IF; + + IF vItemCost IS NULL THEN + + SELECT warehouseFk INTO vWarehouseFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + SELECT barcodeToItem(vBarcodeItem) INTO vItemFk; + + IF vItemFk IS NULL THEN + CALL util.throw ('Item not valid'); + ELSE + CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + + SELECT IFNULL(b.buyingValue, 0) + + IFNULL(b.freightValue, 0) + + IFNULL(b.comissionValue, 0) + + IFNULL(b.packageValue, 0) itemCost, + SUM(is2.visible) visible, + is2.itemFk + INTO vItemCost, vVisible, vItemFk + FROM itemShelving is2 + JOIN tmp.buyUltimate bu ON bu.itemFk = is2.itemFk + JOIN buy b ON b.id = bu.buyFk + WHERE is2.itemFk = vBarcodeItem AND + is2.shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci; + + IF vItemFk IS NULL THEN + CALL util.throw ('Item not valid'); + ELSE + SELECT vItemFk itemFk, + vShelvingFK shelvingFk, + vItemCost itemCost, + vVisible quantity; + END IF; + + DELETE FROM tmp.buyUltimate; + + END IF; + + END IF; + + IF vItemCost IS NULL THEN + CALL util.throw ('Item not valid'); + END IF; + +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index 276c5b508..f331c7230 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -14,6 +14,7 @@ BEGIN * @param vSelf Id de artículo a devaluar * @param vShelvingFK Ubicación actual del artículo * @param vBuyingValue Nuevo precio de coste + * @param vQuantity Cantidad del ítem a pasar a A2 */ DECLARE vItemA2Fk INT; DECLARE vLastBuyFk BIGINT; @@ -28,6 +29,7 @@ BEGIN DECLARE vCurrentVisible INT; DECLARE vDevalueTravelFk INT; DECLARE vCurdate DATE; + DECLARE vBuyingValueOriginal DECIMAL(10,4); DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN @@ -86,19 +88,23 @@ BEGIN SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate FROM `entry` e WHERE DATE(dated) = vCurdate - AND typeFk ='devaluation' + AND typeFk = 'devaluation' AND travelFk = vDevalueTravelFk ORDER BY created DESC LIMIT 1; CALL buyUltimate(vWarehouseFk, vCurdate); - SELECT b.entryFk, bu.buyFk INTO vLastEntryFk,vLastBuyFk + SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal FROM tmp.buyUltimate bu - JOIN vn.buy b ON b.id =bu.buyFk + JOIN vn.buy b ON b.id = bu.buyFk WHERE bu.itemFk = vSelf AND bu.warehouseFk = vWarehouseFk; - + + IF vBuyingValue > vBuyingValueOriginal THEN + CALL util.throw ('Price not valid'); + END IF; + IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN CALL util.throw ('The item has not a buy'); END IF; From 115d1aaf856f759687d0af79ed274e9faaf6ad41 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 16 May 2024 08:10:53 +0200 Subject: [PATCH 026/110] Fix version --- db/versions/11051-blueAralia/00-sipConfig_callLimit.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11051-blueAralia/00-sipConfig_callLimit.sql b/db/versions/11051-blueAralia/00-sipConfig_callLimit.sql index 9fbb7bb90..0ef08a3fa 100644 --- a/db/versions/11051-blueAralia/00-sipConfig_callLimit.sql +++ b/db/versions/11051-blueAralia/00-sipConfig_callLimit.sql @@ -1,3 +1,3 @@ ALTER TABLE pbx.sipConfig CHANGE incomingLimit `call-limit` varchar(10) - CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; + CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; From 11a0b98495d7f6a5b2d15db726a3dae261cd5c10 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 16 May 2024 10:20:08 +0200 Subject: [PATCH 027/110] feat: refs #7296 roadmapStop --- modules/route/back/methods/roadmap/clone.js | 10 +++++----- modules/route/back/model-config.json | 2 +- modules/route/back/models/roadmap.json | 2 +- ...{expedition-truck.json => roadmapStop.json} | 4 ++-- modules/route/front/roadmap/stops/index.html | 16 ++++++++-------- modules/route/front/roadmap/summary/index.html | 18 +++++++++--------- modules/route/front/roadmap/summary/index.js | 12 ++++++------ .../ticket/back/models/expeditionPallet.json | 2 +- myt.config.yml | 2 +- 9 files changed, 34 insertions(+), 34 deletions(-) rename modules/route/back/models/{expedition-truck.json => roadmapStop.json} (92%) diff --git a/modules/route/back/methods/roadmap/clone.js b/modules/route/back/methods/roadmap/clone.js index 456ed823d..2226b1e50 100644 --- a/modules/route/back/methods/roadmap/clone.js +++ b/modules/route/back/methods/roadmap/clone.js @@ -62,12 +62,12 @@ module.exports = Self => { const clone = await models.Roadmap.create(roadmap, options); - const expeditionTrucks = roadmap.expeditionTruck(); - expeditionTrucks.map(expeditionTruck => { - expeditionTruck.roadmapFk = clone.id; - return expeditionTruck; + const roadmapStops = roadmap.roadmapStop(); + roadmapStops.map(roadmapStop => { + roadmapStop.roadmapFk = clone.id; + return roadmapStop; }); - await models.ExpeditionTruck.create(expeditionTrucks, options); + await models.roadmapStop.create(roadmapStops, options); } await tx.commit(); diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index 6cf8da986..09cda6b2d 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -8,7 +8,7 @@ "DeliveryPoint": { "dataSource": "vn" }, - "ExpeditionTruck": { + "RoadmapStop": { "dataSource": "vn" }, "Roadmap": { diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json index 2f6bb8c02..2b02c64f2 100644 --- a/modules/route/back/models/roadmap.json +++ b/modules/route/back/models/roadmap.json @@ -56,7 +56,7 @@ }, "expeditionTruck": { "type": "hasMany", - "model": "ExpeditionTruck", + "model": "roadmapStop", "foreignKey": "roadmapFk" } } diff --git a/modules/route/back/models/expedition-truck.json b/modules/route/back/models/roadmapStop.json similarity index 92% rename from modules/route/back/models/expedition-truck.json rename to modules/route/back/models/roadmapStop.json index 8edc7347f..51aa3a6db 100644 --- a/modules/route/back/models/expedition-truck.json +++ b/modules/route/back/models/roadmapStop.json @@ -1,9 +1,9 @@ { - "name": "ExpeditionTruck", + "name": "RoadmapStop", "base": "VnModel", "options": { "mysql": { - "table": "expeditionTruck" + "table": "roadmapStop" } }, "properties": { diff --git a/modules/route/front/roadmap/stops/index.html b/modules/route/front/roadmap/stops/index.html index b69492a21..82f30c326 100644 --- a/modules/route/front/roadmap/stops/index.html +++ b/modules/route/front/roadmap/stops/index.html @@ -1,22 +1,22 @@
- + + ng-model="roadmapStop.eta"> diff --git a/modules/route/front/roadmap/summary/index.html b/modules/route/front/roadmap/summary/index.html index 9fab0bf87..abf5ff90a 100644 --- a/modules/route/front/roadmap/summary/index.html +++ b/modules/route/front/roadmap/summary/index.html @@ -49,7 +49,7 @@ vn-bind="+" vn-tooltip="Add stop" icon="add_circle" - vn-click-stop="addExpeditionTruck.show()"> + vn-click-stop="addRoadmapStop.show()"> @@ -61,9 +61,9 @@ - - {{expeditionTruck.warehouse.name}} - {{expeditionTruck.eta | date:'dd/MM/yyyy HH:mm'}} + + {{roadmapStop.warehouse.name}} + {{roadmapStop.eta | date:'dd/MM/yyyy HH:mm'}} @@ -75,14 +75,14 @@ + ng-model="$ctrl.roadmapStop.eta"> diff --git a/modules/route/front/roadmap/summary/index.js b/modules/route/front/roadmap/summary/index.js index 041b43ce3..e0903f3a7 100644 --- a/modules/route/front/roadmap/summary/index.js +++ b/modules/route/front/roadmap/summary/index.js @@ -20,7 +20,7 @@ class Controller extends Component { include: [ {relation: 'supplier'}, {relation: 'worker'}, - {relation: 'expeditionTruck', + {relation: 'ExpeditionTruck', scope: { include: [ {relation: 'warehouse'} @@ -36,19 +36,19 @@ class Controller extends Component { const eta = new Date(this.roadmap.etd); eta.setDate(eta.getDate() + 1); - this.expeditionTruck = {eta: eta}; + this.roadmapStop = {eta: eta}; } onAddAccept() { try { const data = { roadmapFk: this.roadmap.id, - warehouseFk: this.expeditionTruck.warehouseFk, - eta: this.expeditionTruck.eta, - description: this.expeditionTruck.description + warehouseFk: this.roadmapStop.warehouseFk, + eta: this.roadmapStop.eta, + description: this.roadmapStop.description }; - this.$http.post(`ExpeditionTrucks`, data) + this.$http.post(`roadmapStops`, data) .then(() => { this.loadData(); this.vnApp.showSuccess(this.$t('Data saved!')); diff --git a/modules/ticket/back/models/expeditionPallet.json b/modules/ticket/back/models/expeditionPallet.json index cab3af6ec..8384ab883 100644 --- a/modules/ticket/back/models/expeditionPallet.json +++ b/modules/ticket/back/models/expeditionPallet.json @@ -25,7 +25,7 @@ "relations": { "expeditionTruck": { "type": "belongsTo", - "model": "ExpeditionTruck", + "model": "RoadmapStop", "foreignKey": "truckFk" } } diff --git a/myt.config.yml b/myt.config.yml index 17300aa37..56239ca3c 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -227,7 +227,7 @@ localFixtures: - expeditionScan - expeditionState - expeditionStateType - - expeditionTruck + - roadmapStop - expense - genus - greuge From bcb3ea48372aea93a01e50de2bfbabfa5f7500d7 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 16 May 2024 10:23:33 +0200 Subject: [PATCH 028/110] feat: refs #7187 new method available pda --- .../00-firstScript.sql | 4 +++ loopback/locale/en.json | 9 ++++--- loopback/locale/es.json | 7 +++--- .../back/methods/worker/getAvailablePda.js | 25 +++++++++++++++++++ .../worker/specs/getAvailablePda.spec.js | 13 ++++++++++ .../back/models/device-production-user.js | 8 ++++++ .../back/models/device-production-user.json | 4 +-- .../worker/back/models/device-production.json | 5 ++++ modules/worker/back/models/worker.js | 1 + 9 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 modules/worker/back/methods/worker/getAvailablePda.js create mode 100644 modules/worker/back/methods/worker/specs/getAvailablePda.spec.js create mode 100644 modules/worker/back/models/device-production-user.js diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql index a0d10891c..c8dce54b2 100644 --- a/db/versions/11010-blackChrysanthemum/00-firstScript.sql +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -15,3 +15,7 @@ ALTER TABLE vn.deviceProductionUser ADD IF NOT EXISTS simSerialNumber TEXT NULL; ALTER TABLE vn.deviceProductionConfig ADD IF NOT EXISTS maxDevicesPerUser INT UNSIGNED NULL; UPDATE vn.deviceProductionConfig SET maxDevicesPerUser=1 WHERE id=1; + +INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','getAvailablePda','READ','ALLOW','ROLE','hr'); + diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ca76eae42..601a26f5b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -223,7 +223,8 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", - "They're not your subordinate": "They're not your subordinate", - "InvoiceIn is already booked": "InvoiceIn is already booked" -} + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate", + "InvoiceIn is already booked": "InvoiceIn is already booked", + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index f1c57455e..c67f7ecd6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -355,6 +355,7 @@ "No results found": "No se han encontrado resultados", "InvoiceIn is already booked": "La factura recibida está contabilizada", "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", - "Select ticket or client": "Elija un ticket o un client", - "It was not able to create the invoice": "No se pudo crear la factura" -} + "Select ticket or client": "Elija un ticket o un client", + "It was not able to create the invoice": "No se pudo crear la factura", + "This PDA is already assigned to another user": "This PDA is already assigned to another user" +} \ No newline at end of file diff --git a/modules/worker/back/methods/worker/getAvailablePda.js b/modules/worker/back/methods/worker/getAvailablePda.js new file mode 100644 index 000000000..5c97e15e1 --- /dev/null +++ b/modules/worker/back/methods/worker/getAvailablePda.js @@ -0,0 +1,25 @@ +module.exports = Self => { + Self.remoteMethod('getAvailablePda', { + description: 'returns devices without user', + accessType: 'READ', + accepts: [], + returns: { + type: 'array', + root: true + }, + http: { + path: `/getAvailablePda`, + verb: 'GET' + } + }); + Self.getAvailablePda = async() => { + const models = Self.app.models; + + return models.DeviceProduction.rawSql( + `SELECT d.* + FROM deviceProduction d + LEFT JOIN deviceProductionUser du ON du.deviceProductionFk = d.id + WHERE du.deviceProductionFk IS NULL` + ); + }; +}; diff --git a/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js b/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js new file mode 100644 index 000000000..7649225f1 --- /dev/null +++ b/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js @@ -0,0 +1,13 @@ +const models = require('vn-loopback/server/server').models; + +describe('worker getAvailablePda()', () => { + fit('should return a Pda that has no user assigned', async() => { + const [{id}] = await models.Worker.getAvailablePda(); + + const deviceProductionUser = await models.DeviceProductionUser.findOne({ + where: {deviceProductionFk: id} + }); + + expect(!deviceProductionUser).toBeTruthy(); + }); +}); diff --git a/modules/worker/back/models/device-production-user.js b/modules/worker/back/models/device-production-user.js new file mode 100644 index 000000000..81af484d3 --- /dev/null +++ b/modules/worker/back/models/device-production-user.js @@ -0,0 +1,8 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`This PDA is already assigned to another user`); + return err; + }); +}; diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json index d63fe0148..37955ab76 100644 --- a/modules/worker/back/models/device-production-user.json +++ b/modules/worker/back/models/device-production-user.json @@ -34,9 +34,9 @@ }, "relations": { "deviceProduction": { - "type": "belongsTo", + "type": "hasOne", "model": "DeviceProduction", - "foreignKey": "deviceProductionFk" + "foreignKey": "id" }, "user": { "type": "belongsTo", diff --git a/modules/worker/back/models/device-production.json b/modules/worker/back/models/device-production.json index f6e5105ad..91b05eb85 100644 --- a/modules/worker/back/models/device-production.json +++ b/modules/worker/back/models/device-production.json @@ -55,6 +55,11 @@ "type": "belongsTo", "model": "DeviceProductionState", "foreignKey": "stateFk" + }, + "deviceProductionUser": { + "type": "hasMany", + "model": "DeviceProductionUser", + "foreignKey": "deviceProductionFk" } } } diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index b475bf26e..7128f973c 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -20,6 +20,7 @@ module.exports = Self => { require('../methods/worker/search')(Self); require('../methods/worker/isAuthorized')(Self); require('../methods/worker/setPassword')(Self); + require('../methods/worker/getAvailablePda')(Self); Self.validatesUniquenessOf('locker', { message: 'This locker has already been assigned' From 993dd0d8bd07a53c8689a664c395f8813e66df23 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 16 May 2024 13:15:55 +0200 Subject: [PATCH 029/110] refs #6965 Modify firstEditorFk NULL --- db/versions/11040-grayMonstera/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/versions/11040-grayMonstera/00-firstScript.sql b/db/versions/11040-grayMonstera/00-firstScript.sql index 8fb0e85c3..1fabe4ff5 100644 --- a/db/versions/11040-grayMonstera/00-firstScript.sql +++ b/db/versions/11040-grayMonstera/00-firstScript.sql @@ -5,6 +5,9 @@ UPDATE vn.route ALTER TABLE vn.route ADD CONSTRAINT route_vehicleFk FOREIGN KEY (vehicleFk) REFERENCES vn.vehicle(id); +ALTER TABLE vn.route +MODIFY COLUMN firstEditorFk int(10) unsigned NULL; + UPDATE vn.route SET firstEditorFk = NULL WHERE firstEditorFk NOT IN (SELECT id FROM account.user); From 1abacdc42b76a65a7096bea23d36838c87697da6 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 16 May 2024 14:00:42 +0200 Subject: [PATCH 030/110] fix: refs #7187 method --- modules/worker/back/methods/worker/getAvailablePda.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker/getAvailablePda.js b/modules/worker/back/methods/worker/getAvailablePda.js index 5c97e15e1..65641a9e6 100644 --- a/modules/worker/back/methods/worker/getAvailablePda.js +++ b/modules/worker/back/methods/worker/getAvailablePda.js @@ -13,9 +13,7 @@ module.exports = Self => { } }); Self.getAvailablePda = async() => { - const models = Self.app.models; - - return models.DeviceProduction.rawSql( + return Self.app.models.DeviceProduction.rawSql( `SELECT d.* FROM deviceProduction d LEFT JOIN deviceProductionUser du ON du.deviceProductionFk = d.id From 4cf5457690309837dbb5cb69d2a96260472dd238 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 16 May 2024 14:01:41 +0200 Subject: [PATCH 031/110] fix: refs #7187 remove focus on spec --- .../worker/back/methods/worker/specs/getAvailablePda.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js b/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js index 7649225f1..c7051f0b4 100644 --- a/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js +++ b/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('worker getAvailablePda()', () => { - fit('should return a Pda that has no user assigned', async() => { + it('should return a Pda that has no user assigned', async() => { const [{id}] = await models.Worker.getAvailablePda(); const deviceProductionUser = await models.DeviceProductionUser.findOne({ From b299e842b944e43ab13d3ba04c427de9e6a8c106 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 16 May 2024 14:04:21 +0200 Subject: [PATCH 032/110] fix: refs #7187 model foreignKey --- modules/worker/back/models/device-production-user.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json index 37955ab76..a024cc94c 100644 --- a/modules/worker/back/models/device-production-user.json +++ b/modules/worker/back/models/device-production-user.json @@ -34,9 +34,9 @@ }, "relations": { "deviceProduction": { - "type": "hasOne", - "model": "DeviceProduction", - "foreignKey": "id" + "type": "belongsTo", + "model": "DeviceProduction", + "foreignKey": "deviceProductionFk" }, "user": { "type": "belongsTo", From 1372f817bdb852bb83741fe6c96a4e71ba561aab Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 16 May 2024 14:05:22 +0200 Subject: [PATCH 033/110] fix: refs #7187 model --- modules/worker/back/models/device-production.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/worker/back/models/device-production.json b/modules/worker/back/models/device-production.json index 91b05eb85..f6e5105ad 100644 --- a/modules/worker/back/models/device-production.json +++ b/modules/worker/back/models/device-production.json @@ -55,11 +55,6 @@ "type": "belongsTo", "model": "DeviceProductionState", "foreignKey": "stateFk" - }, - "deviceProductionUser": { - "type": "hasMany", - "model": "DeviceProductionUser", - "foreignKey": "deviceProductionFk" } } } From 2f4f199fad9607fdb901192621b0faf5930cf2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 16 May 2024 14:40:02 +0200 Subject: [PATCH 034/110] fix: invoiceInTax_getFromEntries (referenceRate) --- .../invoiceInTax_getFromEntries.sql | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql index b64996a66..5f2ceeb4f 100644 --- a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql +++ b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql @@ -1,24 +1,24 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`(IN vInvoiceInFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`( + IN vInvoiceInFk INT +) BEGIN DECLARE vRate DOUBLE DEFAULT 1; - DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10); - SELECT MAX(rr.dated) INTO vDated - FROM referenceRate rr - JOIN invoiceIn ii ON ii.id = vInvoiceInFk - WHERE rr.dated <= ii.issued - AND rr.currencyFk = ii.currencyFk ; - - IF vDated THEN - SELECT `value` INTO vRate - FROM referenceRate - WHERE dated = vDated; - END IF; + WITH rate AS( + SELECT MAX(rr.dated) dated, ii.currencyFk + FROM vn.invoiceIn ii + JOIN vn.referenceRate rr ON rr.currencyFk = ii.currencyFk + WHERE ii.id = vInvoiceInFk + AND rr.dated <= ii.issued + ) SELECT `value` INTO vRate + FROM vn.referenceRate rr + JOIN rate r ON r.dated = rr.dated + AND r.currencyFk = rr.currencyFk; SELECT id INTO vExpenseFk - FROM vn.expense + FROM expense WHERE `name` = 'Adquisición mercancia Extracomunitaria' GROUP BY id LIMIT 1; @@ -26,19 +26,25 @@ BEGIN DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; - INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk) - SELECT ii.id, - SUM(b.buyingValue * b.quantity) / IFNULL(vRate,1) taxableBase, - vExpenseFk, - IF(ii.currencyFk = 1,NULL,SUM(b.buyingValue * b.quantity )) divisa, - taxTypeSageFk, + INSERT INTO invoiceInTax( + invoiceInFk, + taxableBase, + expenseFk, + foreignValue, + taxTypeSageFk, transactionTypeSageFk + )SELECT ii.id, + SUM(b.buyingValue * b.quantity) / vRate taxableBase, + vExpenseFk, + IF(ii.currencyFk = 1, + NULL, + SUM(b.buyingValue * b.quantity )), + taxTypeSageFk, + transactionTypeSageFk FROM invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id JOIN supplier s ON s.id = e.supplierFk JOIN buy b ON b.entryFk = e.id - LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk - AND rr.dated = ii.issued WHERE ii.id = vInvoiceInFk HAVING taxableBase IS NOT NULL; END$$ From 01d1a2391dda59132c367de1e9219458b559ad98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 16 May 2024 18:48:59 +0200 Subject: [PATCH 035/110] refs #7400 feat: book ledger with counters --- db/routines/vn/functions/xdiario_new.sql | 43 +-- db/routines/vn/procedures/duaTaxBooking.sql | 213 +++++++------- .../vn/procedures/invoiceIn_booking.sql | 4 +- .../vn/procedures/invoiceOutBooking.sql | 261 +++++++++--------- .../vn/procedures/ledger_doCompensation.sql | 103 ++++--- db/routines/vn/procedures/ledger_next.sql | 9 +- .../vn/triggers/payment_beforeInsert.sql | 167 +++++------ .../11054-orangeBamboo/00-firstScript.sql | 9 + 8 files changed, 421 insertions(+), 388 deletions(-) create mode 100644 db/versions/11054-orangeBamboo/00-firstScript.sql diff --git a/db/routines/vn/functions/xdiario_new.sql b/db/routines/vn/functions/xdiario_new.sql index 06e6e57b2..4f4b3f3fd 100644 --- a/db/routines/vn/functions/xdiario_new.sql +++ b/db/routines/vn/functions/xdiario_new.sql @@ -1,5 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(vAsiento INT, +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`( + vBookNumber INT, vDated DATE, vSubaccount VARCHAR(12), vAccount VARCHAR(12), @@ -12,33 +13,33 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(vAsient vVat DOUBLE, vRe DOUBLE, vAux TINYINT, - vCompany INT + vCompanyFk INT ) RETURNS int(11) NOT DETERMINISTIC NO SQL BEGIN - IF vAsiento IS NULL THEN - CALL vn.ledger_next(vAsiento); + IF vBookNumber IS NULL THEN + CALL ledger_next(YEAR(vDated), vBookNumber); END IF; INSERT INTO XDiario - SET ASIEN = vAsiento, - FECHA = vDated, - SUBCTA = vSubaccount, - CONTRA = vAccount, - CONCEPTO = vConcept, - EURODEBE = vDebit, - EUROHABER = vCredit, - BASEEURO = vEuro, - SERIE = vSerie, - FACTURA = vInvoice, - IVA = vVat, - RECEQUIV = vRe, - AUXILIAR = IF(vAux = FALSE, NULL, '*'), - MONEDAUSO = 2, - empresa_id = vCompany; + SET ASIEN = vBookNumber, + FECHA = vDated, + SUBCTA = vSubaccount, + CONTRA = vAccount, + CONCEPTO = vConcept, + EURODEBE = vDebit, + EUROHABER = vCredit, + BASEEURO = vEuro, + SERIE = vSerie, + FACTURA = vInvoice, + IVA = vVat, + RECEQUIV = vRe, + AUXILIAR = IF(vAux = FALSE, NULL, '*'), + MONEDAUSO = 2, + empresa_id = vCompanyFk; - RETURN vAsiento; + RETURN vBookNumber; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/duaTaxBooking.sql b/db/routines/vn/procedures/duaTaxBooking.sql index 1fef11e96..5d4a98933 100644 --- a/db/routines/vn/procedures/duaTaxBooking.sql +++ b/db/routines/vn/procedures/duaTaxBooking.sql @@ -2,127 +2,121 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT) BEGIN DECLARE vBookNumber INT; - DECLARE vBookDated DATE; - DECLARE vDiff DECIMAL(10,2); - DECLARE vApunte BIGINT; - - SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated - FROM dua + DECLARE vBookDated DATE; + DECLARE vDiff DECIMAL(10,2); + DECLARE vApunte BIGINT; + + SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) + INTO vBookNumber, vBookDated + FROM dua WHERE id = vDuaFk; - + IF vBookNumber IS NULL OR NOT vBookNumber THEN - CALL ledger_next(vBookNumber); + CALL ledger_next(YEAR(vBookDated), vBookNumber); END IF; -- Apunte de la aduana - INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONCEPTO, - EUROHABER, - SERIE, - empresa_id, - CLAVE, - FACTURA) + ASIEN, + FECHA, + SUBCTA, + CONCEPTO, + EUROHABER, + SERIE, + empresa_id, + CLAVE, + FACTURA) + SELECT vBookNumber, + d.bookEntried, + '4700000999', + CONCAT('DUA ',d.`code`), + sum(dt.base * dt.rate / 100) EUROHABER, + 'R', + d.companyFk, + vDuaFk, + vDuaFk + FROM duaTax dt + JOIN dua d ON d.id = dt.duaFk + WHERE dt.duaFk = vDuaFk; - SELECT - vBookNumber, - d.bookEntried, - '4700000999', - CONCAT('DUA ',d.`code`), - sum(dt.base * dt.rate / 100) EUROHABER, - 'R', - d.companyFk, - vDuaFk, - vDuaFk - FROM duaTax dt - JOIN dua d ON d.id = dt.duaFk - WHERE dt.duaFk = vDuaFk; - - -- Apuntes por tipo de IVA y proveedor - - INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - FECHA_EX, - FECHA_OP, - FACTURAEX, - NFACTICK, - L340, - LDIFADUAN, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - empresa_id, - FECREGCON - ) - - SELECT - vBookNumber ASIEN, - vBookDated FECHA, - tr.account SUBCTA, - '4330002067' CONTRA, - sum(dt.tax) EURODEBE, - sum(dt.base) BASEEURO, - CONCAT('DUA nº',d.code) CONCEPTO, - d.id FACTURA, - dt.rate IVA, - '*' AUXILIAR, - 'D' SERIE, - d.issued FECHA_EX, - d.operated FECHA_OP, - d.code FACTURAEX, - 1 NFACTICK, - 1 L340, - TRUE LDIFADUAN, - 1 TIPOCLAVE, - 1 TIPOEXENCI, - 1 TIPONOSUJE, - 5 TIPOFACT, - 1 TIPORECTIF, - IF(c.code = 'ES', 1, 4) TERIDNIF, - s.nif TERNIF, - s.name TERNOM, - d.companyFk, - d.booked FECREGCON - FROM duaTax dt - JOIN dua d ON dt.duaFk = d.id - JOIN (SELECT account, rate - FROM - (SELECT rate, account - FROM invoiceInTaxBookingAccount ta - WHERE ta.effectived <= vBookDated - AND taxAreaFk = 'WORLD' - ORDER BY ta.effectived DESC - LIMIT 10000000000000000000 - ) tba - GROUP BY rate + -- Apuntes por tipo de IVA y proveedor + INSERT INTO XDiario( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + FECHA_EX, + FECHA_OP, + FACTURAEX, + NFACTICK, + L340, + LDIFADUAN, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id, + FECREGCON) + SELECT vBookNumber ASIEN, + vBookDated FECHA, + tr.account SUBCTA, + '4330002067' CONTRA, + SUM(dt.tax) EURODEBE, + SUM(dt.base) BASEEURO, + CONCAT('DUA nº',d.code) CONCEPTO, + d.id FACTURA, + dt.rate IVA, + '*' AUXILIAR, + 'D' SERIE, + d.issued FECHA_EX, + d.operated FECHA_OP, + d.code FACTURAEX, + 1 NFACTICK, + 1 L340, + TRUE LDIFADUAN, + 1 TIPOCLAVE, + 1 TIPOEXENCI, + 1 TIPONOSUJE, + 5 TIPOFACT, + 1 TIPORECTIF, + IF(c.code = 'ES', 1, 4) TERIDNIF, + s.nif TERNIF, + s.name TERNOM, + d.companyFk, + d.booked FECREGCON + FROM duaTax dt + JOIN dua d ON dt.duaFk = d.id + JOIN (SELECT account, rate + FROM + (SELECT rate, account + FROM invoiceInTaxBookingAccount ta + WHERE ta.effectived <= vBookDated + AND taxAreaFk = 'WORLD' + ORDER BY ta.effectived DESC + LIMIT 10000000000000000000 + ) tba + GROUP BY rate ) tr ON tr.rate = dt.rate - JOIN supplier s ON s.id = d.companyFk - JOIN country c ON c.id = s.countryFk - WHERE d.id = vDuaFk - GROUP BY dt.rate; + JOIN supplier s ON s.id = d.companyFk + JOIN country c ON c.id = s.countryFk + WHERE d.id = vDuaFk + GROUP BY dt.rate; SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte FROM XDiario WHERE ASIEN = vBookNumber; - + UPDATE XDiario SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA, EURODEBE = EURODEBE - vDiff @@ -131,6 +125,5 @@ BEGIN UPDATE dua SET ASIEN = vBookNumber WHERE id = vDuaFk; - END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index a75b2269a..4b015750f 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -2,6 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT) BEGIN DECLARE vBookNumber INT; + DECLARE vFiscalYear INT; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn ENGINE = MEMORY @@ -56,7 +57,8 @@ BEGIN LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva WHERE ii.id = vSelf; - CALL vn.ledger_next(vBookNumber); + SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; + CALL ledger_next(vFiscalYear, vBookNumber); -- Apunte del proveedor INSERT INTO XDiario( diff --git a/db/routines/vn/procedures/invoiceOutBooking.sql b/db/routines/vn/procedures/invoiceOutBooking.sql index bd109e1ec..913035576 100644 --- a/db/routines/vn/procedures/invoiceOutBooking.sql +++ b/db/routines/vn/procedures/invoiceOutBooking.sql @@ -1,22 +1,24 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT) BEGIN -/* Asienta la factura emitida -* -* param vInvoice factura_id -*/ +/** + * Asienta una factura emitida + * + * @param vInvoice Id invoiceOut + */ DECLARE vBookNumber INT; - DECLARE vExpenseConcept VARCHAR(50); - DECLARE vSpainCountryFk INT; - DECLARE vOldBookNumber INT; + DECLARE vExpenseConcept VARCHAR(50); + DECLARE vSpainCountryFk INT; + DECLARE vOldBookNumber INT; + DECLARE vFiscalYear INT; - SELECT id INTO vSpainCountryFk FROM country WHERE code = 'ES'; + SELECT id INTO vSpainCountryFk FROM country WHERE `code` = 'ES'; - SELECT ASIEN + SELECT ASIEN INTO vOldBookNumber FROM XDiario x JOIN invoiceOut io ON io.id = vInvoice - WHERE x.SERIE = io.serial + WHERE x.SERIE = io.serial AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1) LIMIT 1; @@ -26,140 +28,133 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS rs; CREATE TEMPORARY TABLE rs - SELECT - c.accountingAccount AS clientBookingAccount, - io.amount as totalAmount, - CONCAT('n/fra ', io.ref) as simpleConcept, - CONCAT('n/fra ', io.ref, ' ', c.name) as Concept, - io.serial AS SERIE, - io.issued AS FECHA_EX, - io.issued AS FECHA_OP, - io.issued AS FECHA, - 1 AS NFACTICK, - IF(ic.correctingFk,'D','') AS TIPOOPE, - io.siiTrascendencyInvoiceOutFk AS TIPOCLAVE, - io.cplusTaxBreakFk AS TIPOEXENCI, - io.cplusSubjectOpFk AS TIPONOSUJE, - io.siiTypeInvoiceOutFk AS TIPOFACT, - ic.cplusRectificationTypeFk AS TIPORECTIF, + SELECT c.accountingAccount clientBookingAccount, + io.amount totalAmount, + CONCAT('n/fra ', io.ref) simpleConcept, + CONCAT('n/fra ', io.ref, ' ', c.name) Concept, + io.serial SERIE, + io.issued FECHA_EX, + io.issued FECHA_OP, + io.issued FECHA, + 1 NFACTICK, + IF(ic.correctingFk,'D','') TIPOOPE, + io.siiTrascendencyInvoiceOutFk TIPOCLAVE, + io.cplusTaxBreakFk TIPOEXENCI, + io.cplusSubjectOpFk TIPONOSUJE, + io.siiTypeInvoiceOutFk TIPOFACT, + ic.cplusRectificationTypeFk TIPORECTIF, io.companyFk, - RIGHT(io.ref, LENGTH(io.ref) - 1) AS invoiceNum, - IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) AS TERIDNIF, - CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) AS TERNIF, - c.socialName AS TERNOM, - ior.serial AS SERIE_RT, - RIGHT(ior.ref, LENGTH(ior.ref) - 1) AS FACTU_RT, - ior.issued AS FECHA_RT, - IF(ior.id,TRUE,FALSE) AS RECTIFICA + RIGHT(io.ref, LENGTH(io.ref) - 1) invoiceNum, + IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) TERIDNIF, + CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) TERNIF, + c.socialName TERNOM, + ior.serial SERIE_RT, + RIGHT(ior.ref, LENGTH(ior.ref) - 1) FACTU_RT, + ior.issued FECHA_RT, + IF(ior.id,TRUE,FALSE) RECTIFICA FROM invoiceOut io JOIN invoiceOutSerial ios ON ios.code = io.serial JOIN client c ON c.id = io.clientFk JOIN country ct ON ct.id = c.countryFk LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id - LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk + LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk WHERE io.id = vInvoice; - CALL vn.ledger_next(vBookNumber); - + SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1; + CALL ledger_next(vFiscalYear, vBookNumber); -- Linea del cliente INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - EURODEBE, - CONCEPTO, - FECHA_EX, - FECHA_OP, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, + ASIEN, + FECHA, + SUBCTA, + EURODEBE, + CONCEPTO, + FECHA_EX, + FECHA_OP, + empresa_id) + SELECT vBookNumber, rs.FECHA, - rs.clientBookingAccount AS SUBCTA, - rs.totalAmount AS EURODEBE, - rs.simpleConcept AS CONCEPTO, + rs.clientBookingAccount, + rs.totalAmount, + rs.simpleConcept, rs.FECHA_EX, rs.FECHA_OP, - rs.companyFk AS empresa_id + rs.companyFk FROM rs; -- Lineas de gasto INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - CONCEPTO, - FECHA_EX, - FECHA_OP, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, - rs.FECHA, - ioe.expenseFk AS SUBCTA, - rs.clientBookingAccount AS CONTRA, - ioe.amount AS EUROHABER, - rs.Concept AS CONCEPTO, - rs.FECHA_EX, - rs.FECHA_OP, - rs.companyFk AS empresa_id - FROM rs - JOIN invoiceOutExpense ioe - WHERE ioe.invoiceOutFk = vInvoice; + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + CONCEPTO, + FECHA_EX, + FECHA_OP, + empresa_id) + SELECT vBookNumber, + rs.FECHA, + ioe.expenseFk, + rs.clientBookingAccount, + ioe.amount, + rs.Concept, + rs.FECHA_EX, + rs.FECHA_OP, + rs.companyFk + FROM rs + JOIN invoiceOutExpense ioe + WHERE ioe.invoiceOutFk = vInvoice; - SELECT GROUP_CONCAT(`name` SEPARATOR ',') - INTO vExpenseConcept - FROM expense e - JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id - WHERE ioe.invoiceOutFk = vInvoice; + SELECT GROUP_CONCAT(`name` SEPARATOR ',') + INTO vExpenseConcept + FROM expense e + JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id + WHERE ioe.invoiceOutFk = vInvoice; - -- Lineas de IVA + -- Lineas de IVA INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - RECEQUIV, - AUXILIAR, - SERIE, - SERIE_RT, - FACTU_RT, - RECTIFICA, - FECHA_RT, - FECHA_OP, - FECHA_EX, - TIPOOPE, - NFACTICK, - TERIDNIF, - TERNIF, - TERNOM, - L340, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + RECEQUIV, + AUXILIAR, + SERIE, + SERIE_RT, + FACTU_RT, + RECTIFICA, + FECHA_RT, + FECHA_OP, + FECHA_EX, + TIPOOPE, + NFACTICK, + TERIDNIF, + TERNIF, + TERNOM, + L340, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + empresa_id) + SELECT vBookNumber ASIEN, rs.FECHA, - iot.pgcFk AS SUBCTA, - rs.clientBookingAccount AS CONTRA, - iot.vat AS EUROHABER, - iot.taxableBase AS BASEEURO, - CONCAT(vExpenseConcept,' : ',rs.Concept) AS CONCEPTO, - rs.invoiceNum AS FACTURA, - IF(pe2.equFk,0,pgc.rate) AS IVA, - IF(pe2.equFk,0,pgce.rate) AS RECEQUIV, - IF(pgc.mod347,'','*') AS AUXILIAR, + iot.pgcFk SUBCTA, + rs.clientBookingAccount CONTRA, + iot.vat EUROHABER, + iot.taxableBase BASEEURO, + CONCAT(vExpenseConcept,' : ',rs.Concept) CONCEPTO, + rs.invoiceNum FACTURA, + IF(pe2.equFk,0,pgc.rate) IVA, + IF(pe2.equFk,0,pgce.rate) RECEQUIV, + IF(pgc.mod347,'','*') AUXILIAR, rs.SERIE, rs.SERIE_RT, rs.FACTU_RT, @@ -168,27 +163,27 @@ BEGIN rs.FECHA_OP, rs.FECHA_EX, rs.TIPOOPE, - rs.NFACTICK, + rs.NFACTICK, rs.TERIDNIF, rs.TERNIF, rs.TERNOM, - pgc.mod340 AS L340, - pgc.siiTrascendencyInvoiceOutFk AS TIPOCLAVE, - pgc.cplusTaxBreakFk as TIPOEXENCI, + pgc.mod340 L340, + pgc.siiTrascendencyInvoiceOutFk TIPOCLAVE, + pgc.cplusTaxBreakFk TIPOEXENCI, rs.TIPONOSUJE, rs.TIPOFACT, rs.TIPORECTIF, - rs.companyFk AS empresa_id + rs.companyFk FROM rs JOIN invoiceOutTax iot JOIN pgc ON pgc.code = iot.pgcFk LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado LEFT JOIN pgc pgce ON pgce.code = pe.equFk - LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv. + LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv. WHERE iot.invoiceOutFk = vInvoice; - - UPDATE invoiceOut - SET booked = util.VN_CURDATE() - WHERE id = vInvoice; + + UPDATE invoiceOut + SET booked = util.VN_CURDATE() + WHERE id = vInvoice; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ledger_doCompensation.sql b/db/routines/vn/procedures/ledger_doCompensation.sql index e45db376c..80475ac08 100644 --- a/db/routines/vn/procedures/ledger_doCompensation.sql +++ b/db/routines/vn/procedures/ledger_doCompensation.sql @@ -1,5 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`( + vDated DATE, + vCompensationAccount VARCHAR(10), + vBankFk VARCHAR(10), + vConcept VARCHAR(255), + vAmount DECIMAL(10,2), + vCompanyFk INT, + vOriginalAccount VARCHAR(10) +) BEGIN /** * Compensa un pago o un recibo insertando en contabilidad @@ -9,29 +17,31 @@ BEGIN * @param vBankFk banco de la compensacion * @param vConcept descripcion * @param vAmount cantidad que se compensa - * @param vCompany empresa + * @param vCompanyFk empresa * @param vOriginalAccount cuenta contable desde la cual se compensa * - */ + */ DECLARE vNewBookEntry INT; - DECLARE vIsClientCompensation INT; + DECLARE vIsClientCompensation INT; DECLARE vClientFk INT; - DECLARE vSupplierFk INT; - DECLARE vIsOriginalAClient BOOL; - DECLARE vPayMethodCompensation INT; - - CALL ledger_next(vNewBookEntry); + DECLARE vSupplierFk INT; + DECLARE vIsOriginalAClient BOOL; + DECLARE vPayMethodCompensation INT; - SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci; + CALL ledger_next(YEAR(vDated), vNewBookEntry); + + SELECT COUNT(id) INTO vIsOriginalAClient + FROM client + WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci; SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation FROM client WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci; - + SET @vAmount1:= 0.0; SET @vAmount2:= 0.0; - INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) + INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) VALUES ( vNewBookEntry, vDated, vOriginalAccount, @@ -49,30 +59,51 @@ BEGIN ), vCompanyFk ), - ( vNewBookEntry, - vDated, - vCompensationAccount, - vOriginalAccount, - vConcept, - @vAmount2, + ( vNewBookEntry, + vDated, + vCompensationAccount, + vOriginalAccount, + vConcept, + @vAmount2, @vAmount1, - vCompanyFk); - - IF vIsClientCompensation THEN - IF vIsOriginalAClient THEN - SET vAmount = -vAmount; - END IF; - INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate) - VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE); - ELSE - IF NOT vIsOriginalAClient THEN - SET vAmount = -vAmount; - END IF; - SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci; - SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation'; - - INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated) - VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE); - END IF; + vCompanyFk); + + IF vIsClientCompensation THEN + IF vIsOriginalAClient THEN + SET vAmount = -vAmount; + END IF; + + INSERT INTO receipt + SET invoiceFk = vConcept, + amountPaid = vAmount, + payed = vDated, + bankFk = vBankFk, + companyFk = vCompanyFk, + clientFk = vClientFk, + isConciliate = TRUE; + ELSE + IF NOT vIsOriginalAClient THEN + SET vAmount = -vAmount; + END IF; + + SELECT id INTO vSupplierFk + FROM supplier + WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci; + + SELECT id INTO vPayMethodCompensation + FROM payMethod + WHERE `code` = 'compensation'; + + INSERT INTO payment + SET received = vDated, + dueDated = vDated, + supplierFk = vSupplierFk, + amount = vAmount, + bankFk = vBankFk, + payMethodFk = vPayMethodCompensation, + concept = vConcept, + companyFk = vCompanyFk, + isConciliated = TRUE; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ledger_next.sql b/db/routines/vn/procedures/ledger_next.sql index a45ebdd29..88cc242fa 100644 --- a/db/routines/vn/procedures/ledger_next.sql +++ b/db/routines/vn/procedures/ledger_next.sql @@ -1,9 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(OUT vNewBookEntry INT) BEGIN - - UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1); - SET vNewBookEntry = LAST_INSERT_ID(); - + UPDATE ledgerCompany + SET bookEntry = LAST_INSERT_ID(bookEntry + 1) + WHERE fiscalYear = vFiscalYear; + + SET vNewBookEntry = LAST_INSERT_ID(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/payment_beforeInsert.sql b/db/routines/vn/triggers/payment_beforeInsert.sql index 1b343712f..0a4cd1f12 100644 --- a/db/routines/vn/triggers/payment_beforeInsert.sql +++ b/db/routines/vn/triggers/payment_beforeInsert.sql @@ -3,92 +3,93 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW BEGIN - DECLARE cuenta_banco,cuenta_proveedor DOUBLE; - DECLARE vNewBookEntry INT; - DECLARE bolCASH BOOLEAN; - DECLARE isSupplierActive BOOLEAN; + DECLARE vBankAccount DOUBLE; + DECLARE vSupplierAccount DOUBLE; + DECLARE vNewBookEntry INT; + DECLARE vIsCash BOOLEAN; + DECLARE vIsSupplierActive BOOLEAN; - -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH - SELECT (at2.code = 'cash') INTO bolCASH - FROM accounting a - JOIN accountingType at2 ON at2.id = a.accountingTypeFk - WHERE a.id = NEW.bankFk; + -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH + SELECT (at2.code = 'cash') INTO vIsCash + FROM accounting a + JOIN accountingType at2 ON at2.id = a.accountingTypeFk + WHERE a.id = NEW.bankFk; - IF bolCASH THEN - - SELECT account INTO cuenta_banco - FROM accounting - WHERE id = NEW.bankFk; - - SELECT account INTO cuenta_proveedor - FROM supplier - WHERE id = NEW.supplierFk; + IF vIsCash THEN + SELECT account INTO vBankAccount + FROM accounting + WHERE id = NEW.bankFk; - CALL ledger_next(vNewBookEntry); - - INSERT INTO XDiario ( ASIEN, - FECHA, - SUBCTA, - CONTRA, - CONCEPTO, - EURODEBE, - EUROHABER, - empresa_id) - SELECT vNewBookEntry, - NEW.received, - SUBCTA, - CONTRA, - NEW.concept, - EURODEBE, - EUROHABER, - NEW.companyFk - FROM ( SELECT cuenta_banco SUBCTA, - cuenta_proveedor CONTRA, - 0 EURODEBE, - NEW.amount + NEW.bankingFees EUROHABER - UNION ALL - SELECT cuenta_proveedor SUBCTA, - cuenta_banco CONTRA, - NEW.amount EURODEBE, - 0 EUROHABER) gf; - - IF NEW.bankingFees <> 0 THEN - INSERT INTO XDiario ( ASIEN, - FECHA, - SUBCTA, - CONTRA, - CONCEPTO, - EURODEBE, - EUROHABER, - empresa_id) - SELECT vNewBookEntry, - NEW.received, - IF(c.id = 1,6260000002, - IF(CEE = 1,6260000003,6260000004)), - cuenta_banco, - NEW.concept, - NEW.bankingFees, - 0, - NEW.companyFk - FROM supplier s - JOIN country c ON s.countryFk = c.id - WHERE s.id = NEW.supplierFk; - END IF; - END IF; - - SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); - - SELECT isActive INTO isSupplierActive + SELECT account INTO vSupplierAccount FROM supplier WHERE id = NEW.supplierFk; - - IF isSupplierActive = FALSE THEN - CALL util.throw('SUPPLIER_INACTIVE'); - END IF; - - IF ISNULL(NEW.workerFk) THEN - SET NEW.workerFk = account.myUser_getId(); - END IF; - - END$$ + + CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry); + + INSERT INTO XDiario ( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + CONCEPTO, + EURODEBE, + EUROHABER, + empresa_id) + SELECT vNewBookEntry, + NEW.received, + SUBCTA, + CONTRA, + NEW.concept, + EURODEBE, + EUROHABER, + NEW.companyFk + FROM (SELECT vBankAccount SUBCTA, + vSupplierAccount CONTRA, + 0 EURODEBE, + NEW.amount + NEW.bankingFees EUROHABER + UNION ALL + SELECT vSupplierAccount SUBCTA, + vBankAccount CONTRA, + NEW.amount EURODEBE, + 0 EUROHABER) gf; + + IF NEW.bankingFees <> 0 THEN + INSERT INTO XDiario ( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + CONCEPTO, + EURODEBE, + EUROHABER, + empresa_id) + SELECT vNewBookEntry, + NEW.received, + IF(c.id = 1,6260000002, + IF(CEE = 1,6260000003,6260000004)), + vBankAccount, + NEW.concept, + NEW.bankingFees, + 0, + NEW.companyFk + FROM supplier s + JOIN country c ON s.countryFk = c.id + WHERE s.id = NEW.supplierFk; + END IF; + END IF; + + SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); + + SELECT isActive INTO vIsSupplierActive + FROM supplier + WHERE id = NEW.supplierFk; + + IF vIsSupplierActive = FALSE THEN + CALL util.throw('SUPPLIER_INACTIVE'); + END IF; + + IF ISNULL(NEW.workerFk) THEN + SET NEW.workerFk = account.myUser_getId(); + END IF; +END$$ DELIMITER ; diff --git a/db/versions/11054-orangeBamboo/00-firstScript.sql b/db/versions/11054-orangeBamboo/00-firstScript.sql new file mode 100644 index 000000000..5758cd5a2 --- /dev/null +++ b/db/versions/11054-orangeBamboo/00-firstScript.sql @@ -0,0 +1,9 @@ +CREATE OR REPLACE TABLE vn.ledgerCompany ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `fiscalYear` int(10) unsigned NOT NULL COMMENT 'Año del ejercicio contable', + `bookEntry` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Contador asiento contable', + PRIMARY KEY (`id`), + UNIQUE KEY `ledgerCompany_unique` (`fiscalYear`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci + COMMENT='Contador para asientos contables'; + \ No newline at end of file From 38c505fb7a7f3d4e2d5da4a9d16dc19f5e320d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 16 May 2024 19:07:48 +0200 Subject: [PATCH 036/110] refs #7400 feat: book ledger with counters --- .../11054-orangeBamboo/00-firstScript.sql | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/db/versions/11054-orangeBamboo/00-firstScript.sql b/db/versions/11054-orangeBamboo/00-firstScript.sql index 5758cd5a2..7fc1a2166 100644 --- a/db/versions/11054-orangeBamboo/00-firstScript.sql +++ b/db/versions/11054-orangeBamboo/00-firstScript.sql @@ -1,9 +1,16 @@ -CREATE OR REPLACE TABLE vn.ledgerCompany ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fiscalYear` int(10) unsigned NOT NULL COMMENT 'Año del ejercicio contable', - `bookEntry` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Contador asiento contable', - PRIMARY KEY (`id`), - UNIQUE KEY `ledgerCompany_unique` (`fiscalYear`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci - COMMENT='Contador para asientos contables'; - \ No newline at end of file + CREATE OR REPLACE TABLE vn.ledgerCompany ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `fiscalYear` int(10) unsigned NOT NULL COMMENT 'Año del ejercicio contable', + `bookEntry` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Contador asiento contable', + PRIMARY KEY (`id`), + UNIQUE KEY `ledgerCompany_unique` (`fiscalYear`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci + COMMENT='Contador para asientos contables'; + + INSERT IGNORE INTO vn.ledgerCompany (fiscalYear, bookEntry) + SELECT YEAR(util.VN_CURDATE()), lastBookEntry + FROM vn.ledgerConfig; + + ALTER TABLE vn.ledgerConfig CHANGE IF EXISTS lastBookEntry lastBookEntry__ int(11) NOT NULL + COMMENT '@deprecated 2024-05-28 refs #7400 Modificar contador asientos contables'; + \ No newline at end of file From 8d8cfa24decd31af99e9cfab42a30151cc2c0929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 16 May 2024 19:16:25 +0200 Subject: [PATCH 037/110] refs #7400 feat: book ledger with counters --- db/routines/vn/procedures/ledger_next.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ledger_next.sql b/db/routines/vn/procedures/ledger_next.sql index 88cc242fa..5cde90def 100644 --- a/db/routines/vn/procedures/ledger_next.sql +++ b/db/routines/vn/procedures/ledger_next.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(OUT vNewBookEntry INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( + IN vFiscalYear INT, + OUT vNewBookEntry INT +) BEGIN UPDATE ledgerCompany SET bookEntry = LAST_INSERT_ID(bookEntry + 1) From bddc9a8386733f73c1bfe71662513aa62bc2ffd8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 17 May 2024 07:51:51 +0200 Subject: [PATCH 038/110] Deleted insert into util.debug (deletedState) --- db/routines/vn/triggers/ticketTracking_afterDelete.sql | 5 ----- 1 file changed, 5 deletions(-) diff --git a/db/routines/vn/triggers/ticketTracking_afterDelete.sql b/db/routines/vn/triggers/ticketTracking_afterDelete.sql index 2f1bbbcee..2683e8d3c 100644 --- a/db/routines/vn/triggers/ticketTracking_afterDelete.sql +++ b/db/routines/vn/triggers/ticketTracking_afterDelete.sql @@ -18,11 +18,6 @@ BEGIN `changedModel` = 'TicketTracking', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL util.debugAdd('deletedState', - CONCAT('interFk: ', OLD.id, - ' ticketFk: ', OLD.ticketFk, - ' stateFk: ', OLD.stateFk)); SELECT i.ticketFk, i.id, s.`name` INTO vTicketFk, vTicketTrackingFk, vStateName From a99554c773c5b6dfd0383e3d03017629eb190d48 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 17 May 2024 09:50:53 +0200 Subject: [PATCH 039/110] fix: Occasionally saleVolume bad index --- db/routines/vn/views/saleVolume.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/saleVolume.sql b/db/routines/vn/views/saleVolume.sql index aec739678..ffc6714c6 100644 --- a/db/routines/vn/views/saleVolume.sql +++ b/db/routines/vn/views/saleVolume.sql @@ -37,7 +37,7 @@ FROM ( ) JOIN `vn`.`volumeConfig` `vc` ) - JOIN `vn`.`itemCost` `ic` ON( + JOIN `vn`.`itemCost` `ic` FORCE INDEX (`PRIMARY`) ON( `ic`.`itemFk` = `s`.`itemFk` AND `ic`.`warehouseFk` = `t`.`warehouseFk` ) From 47c573a324c1c314ce0385d22f6cc7c472f3c8af Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 17 May 2024 10:51:37 +0200 Subject: [PATCH 040/110] fix: refs #6095 filter by refFk null --- modules/invoiceOut/front/index/manual/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/invoiceOut/front/index/manual/index.html b/modules/invoiceOut/front/index/manual/index.html index 5872911e4..3b991618d 100644 --- a/modules/invoiceOut/front/index/manual/index.html +++ b/modules/invoiceOut/front/index/manual/index.html @@ -27,7 +27,7 @@ Date: Fri, 17 May 2024 11:20:26 +0200 Subject: [PATCH 041/110] refs #4979 feat:getInfoDetails && item_devalueA2 --- db/routines/vn/procedures/itemShelving_getItemDetails.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql index 2134f00c4..fdfd2a5b6 100644 --- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -6,7 +6,7 @@ BEGIN * Obtiene el precio y visible de un item * * @param vBarcodeItem barcode de artículo - * @param vBarcodeItem Ubicación actual del artículo + * @param vShelvingFK Ubicación actual del artículo */ DECLARE vIsItem BOOL; DECLARE vItemFk INT; From 968effc93641ab9948274122a2d3966b8ba9c552 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 17 May 2024 11:56:04 +0200 Subject: [PATCH 042/110] hotfix: ticket 135539 Unroute tickets --- modules/ticket/back/methods/ticket/closeAll.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index d35bd1e3e..e3cbc83e2 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -138,12 +138,10 @@ module.exports = Self => { JOIN alertLevel al ON al.id = ts.alertLevel JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - JOIN zone z ON z.id = t.zoneFk SET t.routeFk = NULL WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) - AND al.code NOT IN('DELIVERED','PACKED') - AND t.routeFk - AND z.name LIKE '%MADRID%'`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); + AND al.code NOT IN ('DELIVERED', 'PACKED') + AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); return { message: 'Success' From 0b5f05cbed5305df285d47a491c637f2da75bff5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 17 May 2024 12:36:54 +0200 Subject: [PATCH 043/110] refactor: refs #7375 Refactor clientsDisable --- db/routines/vn/events/client_userDisable.sql | 8 +++++ db/routines/vn/events/clientsDisable.sql | 25 -------------- .../vn/procedures/client_userDisable.sql | 33 +++++++++++++++++++ .../11055-wheatPaniculata/00-firstScript.sql | 5 +++ 4 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 db/routines/vn/events/client_userDisable.sql delete mode 100644 db/routines/vn/events/clientsDisable.sql create mode 100644 db/routines/vn/procedures/client_userDisable.sql create mode 100644 db/versions/11055-wheatPaniculata/00-firstScript.sql diff --git a/db/routines/vn/events/client_userDisable.sql b/db/routines/vn/events/client_userDisable.sql new file mode 100644 index 000000000..b3354f8fd --- /dev/null +++ b/db/routines/vn/events/client_userDisable.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`client_userDisable` + ON SCHEDULE EVERY 1 MONTH + STARTS '2023-06-01 00:00:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL client_userDisable()$$ +DELIMITER ; diff --git a/db/routines/vn/events/clientsDisable.sql b/db/routines/vn/events/clientsDisable.sql deleted file mode 100644 index 35e6554a2..000000000 --- a/db/routines/vn/events/clientsDisable.sql +++ /dev/null @@ -1,25 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`clientsDisable` - ON SCHEDULE EVERY 1 MONTH - STARTS '2023-06-01 00:00:00.000' - ON COMPLETION PRESERVE - ENABLE -DO BEGIN - UPDATE account.user u - JOIN client c ON c.id = u.id - LEFT JOIN account.account a ON a.id = u.id - SET u.active = FALSE - WHERE c.typeFk = 'normal' - AND a.id IS NULL - AND u.active - AND c.created < util.VN_CURDATE() - INTERVAL 12 MONTH - AND u.id NOT IN ( - SELECT DISTINCT c.id - FROM client c - LEFT JOIN ticket t ON t.clientFk = c.id - WHERE c.salesPersonFk IS NOT NULL - OR t.created > util.VN_CURDATE() - INTERVAL 12 MONTH - OR shipped > util.VN_CURDATE() - INTERVAL 12 MONTH - ); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/client_userDisable.sql b/db/routines/vn/procedures/client_userDisable.sql new file mode 100644 index 000000000..f2ba65c1c --- /dev/null +++ b/db/routines/vn/procedures/client_userDisable.sql @@ -0,0 +1,33 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_userDisable`() +BEGIN +/** +* Desactiva los clientes inactivos en los últimos X meses. +*/ + DECLARE vMonths INT; + + SELECT monthsToDisableUser INTO vMonths + FROM clientConfig; + + IF vMonths IS NULL THEN + CALL util.throw('Config parameter not set'); + END IF; + + UPDATE account.user u + JOIN client c ON c.id = u.id + LEFT JOIN account.account a ON a.id = u.id + SET u.active = FALSE + WHERE c.typeFk = 'normal' + AND a.id IS NULL + AND u.active + AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH + AND u.id NOT IN ( + SELECT DISTINCT c.id + FROM client c + LEFT JOIN ticket t ON t.clientFk = c.id + WHERE c.salesPersonFk IS NOT NULL + OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH + OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH + ); +END$$ +DELIMITER ; diff --git a/db/versions/11055-wheatPaniculata/00-firstScript.sql b/db/versions/11055-wheatPaniculata/00-firstScript.sql new file mode 100644 index 000000000..6eec62fd8 --- /dev/null +++ b/db/versions/11055-wheatPaniculata/00-firstScript.sql @@ -0,0 +1,5 @@ +ALTER TABLE vn.clientConfig + ADD monthsToDisableUser int(10) unsigned DEFAULT NULL NULL; + +UPDATE IGNORE vn.clientConfig + SET monthsToDisableUser = 12; \ No newline at end of file From c8db0a3aa817e1bbd1e4a7e4891414e9364f1cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 17 May 2024 12:48:16 +0200 Subject: [PATCH 044/110] refs #4979 feat:getInfoDetails && item_devalueA2 --- db/.pullinfo.json | 2 +- .../itemShelving_getItemDetails.sql | 101 ++++++------------ 2 files changed, 34 insertions(+), 69 deletions(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index f4afbc5fb..0defed845 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb" + "expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" } } } diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql index fdfd2a5b6..25afd192b 100644 --- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -1,7 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(vBarcodeItem INT, vShelvingFK VARCHAR(10) ) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`( + vBarcodeItem INT, + vShelvingFK VARCHAR(10) +) BEGIN - /** * Obtiene el precio y visible de un item * @@ -9,82 +11,45 @@ BEGIN * @param vShelvingFK Ubicación actual del artículo */ DECLARE vIsItem BOOL; - DECLARE vItemFk INT; - DECLARE vItemCost DECIMAL(10,4); - DECLARE vCacheVisibleFk INT; + DECLARE vBuyFk INT; DECLARE vWarehouseFk INT; - DECLARE vVisible INT; - - SELECT COUNT(*)>0 INTO vIsItem - FROM vn.item + SELECT COUNT(*) > 0 INTO vIsItem + FROM item WHERE id = vBarcodeItem; - IF NOT vIsItem THEN - - SELECT IFNULL(b.buyingValue, 0) + - IFNULL(b.freightValue, 0) + - IFNULL(b.comissionValue, 0) + - IFNULL(b.packageValue, 0), - SUM(is2.visible) , - b.itemFk - INTO vItemCost, vVisible, vItemFk - FROM itemShelving is2 - JOIN buy b ON b.itemFk = is2.itemFk AND b.id = vBarcodeItem - WHERE is2.shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci - GROUP BY shelvingFK; - - SELECT vItemFk itemFk, - vShelvingFK shelvingFk, - vItemCost itemCost, - vVisible quantity; - - END IF; - - IF vItemCost IS NULL THEN - + IF vIsItem THEN SELECT warehouseFk INTO vWarehouseFk FROM operator WHERE workerFk = account.myUser_getId(); - SELECT barcodeToItem(vBarcodeItem) INTO vItemFk; + CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); - IF vItemFk IS NULL THEN - CALL util.throw ('Item not valid'); - ELSE - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); - - SELECT IFNULL(b.buyingValue, 0) + - IFNULL(b.freightValue, 0) + - IFNULL(b.comissionValue, 0) + - IFNULL(b.packageValue, 0) itemCost, - SUM(is2.visible) visible, - is2.itemFk - INTO vItemCost, vVisible, vItemFk - FROM itemShelving is2 - JOIN tmp.buyUltimate bu ON bu.itemFk = is2.itemFk - JOIN buy b ON b.id = bu.buyFk - WHERE is2.itemFk = vBarcodeItem AND - is2.shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci; - - IF vItemFk IS NULL THEN - CALL util.throw ('Item not valid'); - ELSE - SELECT vItemFk itemFk, - vShelvingFK shelvingFk, - vItemCost itemCost, - vVisible quantity; - END IF; - - DELETE FROM tmp.buyUltimate; - - END IF; + SELECT buyFk INTO vBuyFk + FROM tmp.buyUltimate + WHERE itemFk = vBarcodeItem + AND warehouseFk = vWarehouseFk; + DELETE FROM tmp.buyUltimate; + ELSE + SELECT vBarcodeItem INTO vBuyFk; END IF; - - IF vItemCost IS NULL THEN - CALL util.throw ('Item not valid'); - END IF; - + + WITH visible AS( + SELECT itemFk, + IFNULL(buyingValue, 0) + + IFNULL(freightValue, 0) + + IFNULL(comissionValue, 0) + + IFNULL(packageValue, 0) itemCost + FROM vn.buy b + WHERE b.id = vBuyFk + ) SELECT v.itemFk, + vShelvingFK, + v.itemCost, + SUM(ish.visible) visible + FROM vn.itemShelving ish + JOIN visible v + WHERE ish.shelvingFK = vShelvingFK + AND ish.itemFk = v.itemFk; END$$ DELIMITER ; \ No newline at end of file From 6a576e69e1f64546b9ed95815bd5353950043714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 17 May 2024 12:50:51 +0200 Subject: [PATCH 045/110] refs #4979 feat:getInfoDetails && item_devalueA2 --- db/.pullinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 0defed845..f4afbc5fb 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" + "expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb" } } } From 2694f277d28009dd3da7796040dbf41486e03cac Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 17 May 2024 12:59:39 +0200 Subject: [PATCH 046/110] fix: refs #6744 add es locale --- loopback/locale/es.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index f1c57455e..bc3a8c2a5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -355,6 +355,7 @@ "No results found": "No se han encontrado resultados", "InvoiceIn is already booked": "La factura recibida está contabilizada", "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", - "Select ticket or client": "Elija un ticket o un client", - "It was not able to create the invoice": "No se pudo crear la factura" -} + "Select ticket or client": "Elija un ticket o un client", + "It was not able to create the invoice": "No se pudo crear la factura", + "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" +} \ No newline at end of file From dd7ee27e9b8b1cabdb487b6cddc453efbb5e7e88 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 17 May 2024 14:28:28 +0200 Subject: [PATCH 047/110] refs #7396 fix worker model --- loopback/locale/en.json | 9 +++++---- modules/worker/back/models/worker.json | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ca76eae42..601a26f5b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -223,7 +223,8 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", - "They're not your subordinate": "They're not your subordinate", - "InvoiceIn is already booked": "InvoiceIn is already booked" -} + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate", + "InvoiceIn is already booked": "InvoiceIn is already booked", + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" +} \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index adfe2c58e..4e7617aab 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -62,7 +62,23 @@ }, "isFreelance": { "type" : "boolean" + }, + "fiDueDate": { + "type": "date" + }, + "hasMachineryAuthorized": { + "type": "boolean" + }, + "seniority": { + "type": "date" + }, + "isDisable": { + "type": "boolean" + }, + "isSsDiscounted": { + "type": "boolean" } + }, "relations": { "user": { From 7fb6ecd6178c3064e420e9c9e8a867d62968b145 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 17 May 2024 14:46:49 +0200 Subject: [PATCH 048/110] feat: refs #7187 redirect to lilium --- modules/worker/front/pda/index.html | 50 ------------------ modules/worker/front/pda/index.js | 48 +++-------------- modules/worker/front/pda/index.spec.js | 72 -------------------------- modules/worker/front/pda/style.scss | 6 --- 4 files changed, 8 insertions(+), 168 deletions(-) delete mode 100644 modules/worker/front/pda/index.html delete mode 100644 modules/worker/front/pda/index.spec.js delete mode 100644 modules/worker/front/pda/style.scss diff --git a/modules/worker/front/pda/index.html b/modules/worker/front/pda/index.html deleted file mode 100644 index c6d31dc85..000000000 --- a/modules/worker/front/pda/index.html +++ /dev/null @@ -1,50 +0,0 @@ -
- - - - - - - - - - -
- - - - - -
- ID: {{id}} -
-
- {{modelFk}}, {{serialNumber}} -
-
-
-
-
- - - - - diff --git a/modules/worker/front/pda/index.js b/modules/worker/front/pda/index.js index 885261e5c..b1f8dcac2 100644 --- a/modules/worker/front/pda/index.js +++ b/modules/worker/front/pda/index.js @@ -1,53 +1,21 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -import './style.scss'; class Controller extends Section { constructor($element, $) { super($element, $); - const filter = { - where: {userFk: this.$params.id}, - include: {relation: 'deviceProduction'} - }; - this.$http.get('DeviceProductionUsers', {filter}). - then(res => { - if (res.data && res.data.length > 0) - this.setCurrentPDA(res.data[0]); - }); } - deallocatePDA() { - this.$http.post(`Workers/${this.$params.id}/deallocatePDA`, {pda: this.currentPDA.deviceProductionFk}) - .then(() => { - this.vnApp.showSuccess(this.$t('PDA deallocated')); - delete this.currentPDA; - }); - } - - allocatePDA() { - this.$http.post(`Workers/${this.$params.id}/allocatePDA`, {pda: this.newPDA}) - .then(res => { - if (res.data) - this.setCurrentPDA(res.data); - - this.vnApp.showSuccess(this.$t('PDA allocated')); - delete this.newPDA; - }); - } - - setCurrentPDA(data) { - this.currentPDA = data; - this.currentPDA.description = []; - this.currentPDA.description.push(`ID: ${this.currentPDA.deviceProductionFk}`); - this.currentPDA.description.push(`${this.$t('Model')}: ${this.currentPDA.deviceProduction.modelFk}`); - this.currentPDA.description.push(`${this.$t('Serial Number')}: ${this.currentPDA.deviceProduction.serialNumber}`); - this.currentPDA.description = this.currentPDA.description.join(' '); + async $onInit() { + const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`); + console.log('url: ', url); + window.location.href = url; } } -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnWorkerPda', { - template: require('./index.html'), +ngModule.vnComponent('vnClaimPhotos', { controller: Controller, + bindings: { + claim: '<' + } }); diff --git a/modules/worker/front/pda/index.spec.js b/modules/worker/front/pda/index.spec.js deleted file mode 100644 index a0540af45..000000000 --- a/modules/worker/front/pda/index.spec.js +++ /dev/null @@ -1,72 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnWorkerPda', () => { - let $httpBackend; - let $scope; - let $element; - let controller; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - $element = angular.element(''); - controller = $componentController('vnWorkerPda', {$element, $scope}); - $httpBackend.expectGET(`DeviceProductionUsers`).respond(); - })); - - describe('deallocatePDA()', () => { - it('should make an HTTP Post query to deallocatePDA', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.currentPDA = {deviceProductionFk: 1}; - controller.$params.id = 1; - - $httpBackend - .expectPOST(`Workers/${controller.$params.id}/deallocatePDA`, - {pda: controller.currentPDA.deviceProductionFk}) - .respond(); - controller.deallocatePDA(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.currentPDA).toBeUndefined(); - }); - }); - - describe('allocatePDA()', () => { - it('should make an HTTP Post query to allocatePDA', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.newPDA = 4; - controller.$params.id = 1; - - $httpBackend - .expectPOST(`Workers/${controller.$params.id}/allocatePDA`, - {pda: controller.newPDA}) - .respond(); - controller.allocatePDA(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.newPDA).toBeUndefined(); - }); - }); - - describe('setCurrentPDA()', () => { - it('should set CurrentPDA', () => { - const data = { - deviceProductionFk: 1, - deviceProduction: { - modelFk: 1, - serialNumber: 1 - } - }; - controller.setCurrentPDA(data); - - expect(controller.currentPDA).toBeDefined(); - expect(controller.currentPDA.description).toBeDefined(); - }); - }); - }); -}); diff --git a/modules/worker/front/pda/style.scss b/modules/worker/front/pda/style.scss deleted file mode 100644 index c55c9d218..000000000 --- a/modules/worker/front/pda/style.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import "./variables"; - -.text-grey { - color: $color-font-light; -} - From 05f09d0b875f29b9d4838dcfbbe708ca1e447b36 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 17 May 2024 14:56:40 +0200 Subject: [PATCH 049/110] refs #7187 fix workerPda --- modules/worker/front/pda/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/worker/front/pda/index.js b/modules/worker/front/pda/index.js index b1f8dcac2..a57886556 100644 --- a/modules/worker/front/pda/index.js +++ b/modules/worker/front/pda/index.js @@ -8,12 +8,11 @@ class Controller extends Section { async $onInit() { const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`); - console.log('url: ', url); window.location.href = url; } } -ngModule.vnComponent('vnClaimPhotos', { +ngModule.vnComponent('vnWorkerPda', { controller: Controller, bindings: { claim: '<' From c822a64dc7b2074c5a4a01bc1363c8d77901acf3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 17 May 2024 16:38:11 +0200 Subject: [PATCH 050/110] refs #4979 feat:getInfoDetails && item_devalueA2 --- db/routines/vn/procedures/itemShelving_getItemDetails.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql index 25afd192b..c01bc348c 100644 --- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -49,7 +49,7 @@ BEGIN SUM(ish.visible) visible FROM vn.itemShelving ish JOIN visible v - WHERE ish.shelvingFK = vShelvingFK + WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci AND ish.itemFk = v.itemFk; END$$ DELIMITER ; \ No newline at end of file From 9d98ae4a037f6c672708637167f5e5c229e3e360 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 20 May 2024 07:02:00 +0200 Subject: [PATCH 051/110] Merge branch 'test' into dev --- loopback/locale/es.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 458f5b1f0..77e707590 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -357,9 +357,6 @@ "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", -<<<<<<< HEAD - "This PDA is already assigned to another user": "This PDA is already assigned to another user" -======= + "This PDA is already assigned to another user": "This PDA is already assigned to another user", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" ->>>>>>> test } \ No newline at end of file From 9a5acedd38b0ab3bfda5264507ab735722107417 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 20 May 2024 08:21:54 +0200 Subject: [PATCH 052/110] improved proc --- .../supplierPackaging_ReportSource.sql | 88 ++++++++++++++++++- 1 file changed, 85 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index f9d43f925..2cf9b85c5 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -35,7 +35,7 @@ BEGIN itemFk, longName, supplier, - entryFk, + CONCAT('E',entryFk) entryFk, landed, `in`, `out`, @@ -49,16 +49,98 @@ BEGIN itemFk, longName, supplier, - 'previous', + 'E previous', vFromDated, SUM(`in`), SUM(`out`), NULL, - buyingValue + AVG(buyingValue) FROM supplierPackaging WHERE supplierFk = vSupplierFk AND landed < vFromDated GROUP BY itemFk + UNION ALL + SELECT vSupplierFk, + s.itemFk, + i.longName, + c.name, + CONCAT('T',s.ticketFk), + DATE(t.shipped), + -LEAST(s.quantity,0) `in`, + GREATEST(s.quantity,0) `out`, + t.warehouseFk, + s.price * (100 - s.discount) / 100 + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN packaging p ON p.itemFk = i.id + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + UNION ALL + SELECT vSupplierFk, + s.itemFk, + i.longName, + c.name, + 'T previous', + vFromDated, + SUM(-LEAST(s.quantity,0)) `in`, + SUM(GREATEST(s.quantity,0)) `out`, + NULL, + AVG(s.price * (100 - s.discount) / 100) + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN packaging p ON p.itemFk = i.id + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped < vFromDated + AND p.isPackageReturnable + GROUP BY s.itemFk + UNION ALL + SELECT vSupplierFk, + p.itemFk, + i.longName, + c.name, + CONCAT('TP',tp.ticketFk), + DATE(t.shipped), + -LEAST(tp.quantity,0) `in`, + GREATEST(tp.quantity,0) `out`, + t.warehouseFk, + 0 + FROM ticketPackaging tp + JOIN packaging p ON p.id = tp.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = tp.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + UNION ALL + SELECT vSupplierFk, + p.itemFk, + i.longName, + c.name, + 'TP previous', + vFromDated, + SUM(-LEAST(tp.quantity,0)) `in`, + SUM(GREATEST(tp.quantity,0)) `out`, + NULL, + 0 + FROM ticketPackaging tp + JOIN packaging p ON p.id = tp.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = tp.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + GROUP BY p.itemFk ORDER BY itemFk, landed, entryFk ) sub WHERE `out` OR `in`; From dd76168bc3779f110049871cfbfd06d89a8b1b8a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 20 May 2024 09:15:24 +0200 Subject: [PATCH 053/110] 6281 feat:buyFk in itemShekving --- db/routines/vn/procedures/itemShelving_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 005a9f8cb..f991c3c63 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) BEGIN From 20bf2b73b6a46f5050b4bace3dcefe9fdc2ce080 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 20 May 2024 09:27:20 +0200 Subject: [PATCH 054/110] 6281 feat:buyFk in itemShelving --- .../vn/procedures/itemShelving_add.sql | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index f991c3c63..d05c5aac1 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) BEGIN - +ç /** * Añade registro o lo actualiza si ya existe. @@ -18,8 +18,20 @@ BEGIN DECLARE vItemFk INT; DECLARE vBuyFk INT; + SELECT id INTO vBuyFk + FROM buy WHERE id = vBarcode; + SELECT barcodeToItem(vBarcode) INTO vItemFk; + IF vBuyFk IS NULL THEN + CALL cache.last_buy_refresh(FALSE); + + SELECT buy_id INTO vBuyFk + FROM cache.last_buy + WHERE item_id = vItemFk + AND warehouse_id = vWarehouseFk; + END IF; + IF vPacking IS NULL THEN SET vPacking = itemPacking(vBarcode, vWarehouseFk); @@ -29,10 +41,11 @@ BEGIN IF (SELECT COUNT(*) FROM itemShelving WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN + AND packing = vPacking + AND buyFk = vBuyFk) THEN UPDATE itemShelving - SET visible = visible+vQuantity + SET visible = visible + vQuantity WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; ELSE From 2b2406ae5248305dd70a9a96857dde5ffb960b45 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 20 May 2024 09:32:12 +0200 Subject: [PATCH 055/110] 6281 feat:buyFk in itemShelving --- db/routines/vn/procedures/itemShelving_add.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index d05c5aac1..9395f5d80 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,7 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) BEGIN -ç /** * Añade registro o lo actualiza si ya existe. From 598a7eefbcab27f6518f56215f7796d4f1c872e9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 20 May 2024 09:39:23 +0200 Subject: [PATCH 056/110] 6281 feat:buyFk in itemShelving --- db/routines/vn/procedures/itemShelvingTransfer.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingTransfer.sql b/db/routines/vn/procedures/itemShelvingTransfer.sql index b75cef627..ae82bfe9d 100644 --- a/db/routines/vn/procedures/itemShelvingTransfer.sql +++ b/db/routines/vn/procedures/itemShelvingTransfer.sql @@ -17,7 +17,8 @@ BEGIN SELECT itemFk, packing, - created + created, + buyFk FROM itemShelving WHERE id = vItemShelvingFk ) ish2 From 7f0f1b954710ec4b382c0ec551248a87a4c6430b Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 20 May 2024 09:54:30 +0200 Subject: [PATCH 057/110] refactor: refs #7422 Deleted tables --- .../11057-chocolateMoss/00-firstScript.sql | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 db/versions/11057-chocolateMoss/00-firstScript.sql diff --git a/db/versions/11057-chocolateMoss/00-firstScript.sql b/db/versions/11057-chocolateMoss/00-firstScript.sql new file mode 100644 index 000000000..7484b8c33 --- /dev/null +++ b/db/versions/11057-chocolateMoss/00-firstScript.sql @@ -0,0 +1,106 @@ +DROP TABLE vn2008.scanTree__; +DROP TABLE vn2008.payroll_embargos__; +DROP TABLE vn2008.unary_scan_line__; +DROP TABLE vn2008.unary_source__; +DROP TABLE vn2008.unary_scan__; +DROP TABLE vn2008.scan_line__; +DROP TABLE vn2008.Familias__; +DROP TABLE vn2008.language__; +DROP TABLE vn2008.Clientes_dits__; +DROP TABLE vn2008.unary_scan_line_expedition__; +DROP TABLE vn2008.warehouse_group__; +DROP TABLE vn2008.Espionajes__; +DROP TABLE vn2008.jerarquia__; +DROP TABLE vn2008.wks__; +DROP TABLE vn2008.Proveedores_comunicados__; +DROP TABLE vn2008.integra2_escala__; +DROP TABLE vn2008.cp__; +DROP TABLE vn2008.unary__; +DROP TABLE vn2008.Estados__; +DROP TABLE vn2008.agency_hour__; +DROP TABLE vn2008.Reservas__; +DROP TABLE vn2008.cyc_declaration__; +DROP TABLE vn2008.route__; +DROP TABLE vn2008.Proveedores_escritos__; +DROP TABLE vn2008.config__; +DROP TABLE vn2008.guillen__; +DROP TABLE vn2008.expeditions_deleted__; +DROP TABLE vn2008.Tipos_f11__; +DROP TABLE vn2008.commission__; +DROP TABLE vn2008.Movimientos_revisar__; +DROP TABLE vn2008.recibida_agricola__; +DROP TABLE vn2008.tipsa__; +DROP TABLE vn2008.rounding__; +DROP TABLE vn2008.Informes__; +DROP TABLE vn2008.Forms__; +DROP TABLE vn2008.Clientes_event__; +DROP TABLE vn2008.wh_selection__; +DROP TABLE vn2008.template_bionic_component__; +DROP TABLE vn2008.Agencias_province__; +DROP TABLE vn2008.travel_pattern__; +DROP TABLE vn2008.sort_merge_results_ernesto__; +DROP TABLE vn2008.Conteo__; +DROP TABLE vn2008.Consignatarios_devices__; +DROP TABLE vn2008.link__; +DROP TABLE vn2008.agency_warehouse__; +DROP TABLE vn2008.warehouse_lc__; +DROP TABLE vn2008.emp_day_pay__; +DROP TABLE vn2008.Entradas_kop__; +DROP TABLE vn2008.dock__; +DROP TABLE vn2008.unaryScanFilter__; +DROP TABLE vn2008.Grupos__; +DROP TABLE vn2008.nichos__; +DROP TABLE vn2008.form_query__; +DROP TABLE vn2008.filtros__; +DROP TABLE vn2008.Objetivos__; +DROP TABLE vn2008.zones__; +DROP TABLE vn2008.rec_translator__; +DROP TABLE vn2008.warehouse_joined__; +DROP TABLE vn2008.warehouse_filtro__; +DROP TABLE vn2008.viaxpress__; +DROP TABLE vn2008.cl_que__; +DROP TABLE vn2008.Recibos_recorded__; +DROP TABLE vn2008.cooler_path__; +DROP TABLE vn2008.payrroll_apEmpresarial__; +DROP TABLE vn2008.Compres_ok__; +DROP TABLE vn2008.Movimientos_avisar__; +DROP TABLE vn2008.Clases__; +DROP TABLE vn2008.payroll_tipobasess__; +DROP TABLE vn2008.guillen_carry__; +DROP TABLE vn2008.unary_scan_line_buy__; +DROP TABLE vn2008.Series__; +DROP TABLE vn2008.Permisos__; +DROP TABLE vn2008.container__; +DROP TABLE vn2008.travel_reserve__; +DROP TABLE vn2008.tmpNEWTARIFAS__; +DROP TABLE vn2008.Clientes_potenciales__; +DROP TABLE vn2008.duaDismissed__; +DROP TABLE vn2008.cl_pet__; +DROP TABLE vn2008.preparation_exception__; +DROP TABLE vn2008.Clientes_empresa__; +DROP TABLE vn2008.call_information__; +DROP TABLE vn2008.template_bionic_price__; +DROP TABLE vn2008.invoice_observation__; +DROP TABLE vn2008.edi_testigos__; +DROP TABLE vn2008.cl_dep__; +DROP TABLE vn2008.agencia_descuadre__; +DROP TABLE vn2008.Monitoring__; +DROP TABLE vn2008.payroll_datos__; +DROP TABLE vn2008.tblIVA__; +DROP TABLE vn2008.cyc__; +DROP TABLE vn2008.Tickets_stack__; +DROP TABLE vn2008.config_host_forms__; +DROP TABLE vn2008.template_bionic_lot__; +DROP TABLE vn2008.payroll_bonificaciones__; +DROP TABLE vn2008.widget__; +DROP TABLE vn2008.accion_dits__; +DROP TABLE vn2008.credit_card__; +DROP TABLE vn2008.Brasa__; +DROP TABLE vn2008.Jefes__; +DROP TABLE vn2008.call_option__; +DROP TABLE vn2008.expeditions_pictures__; +DROP TABLE vn2008.scan__; +DROP TABLE vn2008.trolley__; +DROP TABLE vn2008.transport__; +DROP TABLE vn2008.Baldas__; +DROP TABLE vn2008.payroll_basess__; \ No newline at end of file From 7f1210e712f43d38a874d8a92e76e796649a868b Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 20 May 2024 10:26:09 +0200 Subject: [PATCH 058/110] refs #6820 fix back --- back/model-config.json | 3 +++ back/models/routeConfig.json | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 back/models/routeConfig.json diff --git a/back/model-config.json b/back/model-config.json index e64386300..b643ab54f 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -186,5 +186,8 @@ }, "AgencyWorkCenter": { "dataSource": "vn" + }, + "RouteConfig": { + "dataSource": "vn" } } diff --git a/back/models/routeConfig.json b/back/models/routeConfig.json new file mode 100644 index 000000000..28adbe756 --- /dev/null +++ b/back/models/routeConfig.json @@ -0,0 +1,21 @@ +{ + "name": "RouteConfig", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "routeConfig" + } + }, + "properties": { + "id": { + "type": "number", + "description": "Identifier" + }, + "kmMax": { + "type": "number" + } + } +} From abdacb362751559fe51bc0d8de6badb78ca3bb62 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 20 May 2024 10:33:01 +0200 Subject: [PATCH 059/110] casting values --- db/routines/vn/procedures/supplierPackaging_ReportSource.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index 2cf9b85c5..a3401843a 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -151,8 +151,8 @@ BEGIN supplier, entryFk, landed, - `in`, - `out`, + CAST(`in` AS DECIMAL(10,0)) `in`, + CAST(`out` AS DECIMAL(10,0)) `out`, warehouse, buyingValue, balance From 6d66c0f71f6c6765b46ae7fdad2a8747f02d0889 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 20 May 2024 11:14:30 +0200 Subject: [PATCH 060/110] hotfix TicketLog filter --- modules/ticket/back/models/ticket-log.json | 3 ++- modules/ticket/front/descriptor-menu/index.js | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json index 32b4afd13..d75589f11 100644 --- a/modules/ticket/back/models/ticket-log.json +++ b/modules/ticket/back/models/ticket-log.json @@ -8,7 +8,8 @@ }, "properties": { "id": { - "type": "string" + "type": "number", + "id": true }, "originFk": { "type": "number" diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 52cac141c..89590e86a 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -37,14 +37,15 @@ class Controller extends Section { }); const filter = { - fields: ['originFk', 'creationDate', 'newInstance'], + fields: ['id', 'originFk', 'creationDate', 'newInstance'], where: { originFk: value, newInstance: {like: '%"isDeleted":true%'} }, - order: 'creationDate DESC' + order: 'creationDate DESC', + limit: 1 }; - this.$http.get(`TicketLogs/findOne`, {filter}) + this.$http.get(`TicketLogs`, {filter}) .then(res => { if (res && res.data) { const now = Date.vnNew(); From f82b1054306ad370948010248e5cdfded6fff6b2 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 20 May 2024 11:30:43 +0200 Subject: [PATCH 061/110] fix: TicketLog res.data --- modules/ticket/front/descriptor-menu/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 89590e86a..32f245454 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -47,9 +47,9 @@ class Controller extends Section { }; this.$http.get(`TicketLogs`, {filter}) .then(res => { - if (res && res.data) { + if (res && res.data && res.data.length) { const now = Date.vnNew(); - const maxDate = new Date(res.data.creationDate); + const maxDate = new Date(res.data[0].creationDate); maxDate.setHours(maxDate.getHours() + 1); if (now <= maxDate) return this.canRestoreTicket = true; From b203d94b272d33131272cf47a152482c37565480 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 20 May 2024 11:37:40 +0200 Subject: [PATCH 062/110] feat: refs #6021 add new column --- db/versions/11058-aquaCataractarum/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11058-aquaCataractarum/00-firstScript.sql diff --git a/db/versions/11058-aquaCataractarum/00-firstScript.sql b/db/versions/11058-aquaCataractarum/00-firstScript.sql new file mode 100644 index 000000000..98fc910ad --- /dev/null +++ b/db/versions/11058-aquaCataractarum/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE floranet.`order` ADD IF NOT EXISTS observations TEXT NULL; From d51c9fc12061bd612fd48697fe22ad4decfaf108 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 20 May 2024 12:14:59 +0200 Subject: [PATCH 063/110] fix: refs #6404 fix cancel shipment --- back/methods/mrw-config/cancelShipment.js | 4 ++-- back/methods/mrw-config/createShipment.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 218b6a96b..dd33694ea 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -39,8 +39,8 @@ module.exports = Self => { const xmlString = response.data; const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - const [resultElement] = xmlDoc.getElementsByTagName('Mensaje'); + const resultElement = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; - return resultElement.textContent; + return resultElement; }; }; diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 12263de03..7d226a5bc 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -42,7 +42,8 @@ module.exports = Self => { throw new UserError(`Some mrwConfig parameters are not set`); const query = - `SELECT CASE co.code + `SELECT + CASE co.code WHEN 'ES' THEN a.postalCode WHEN 'PT' THEN LEFT(a.postalCode, 4) WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00') From 143f9cf0bbbdf93e539ff15ae8db887096687a6e Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 20 May 2024 12:17:10 +0200 Subject: [PATCH 064/110] fix: refs #6404 fix return --- back/methods/mrw-config/cancelShipment.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index dd33694ea..86bbb7410 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -39,8 +39,6 @@ module.exports = Self => { const xmlString = response.data; const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - const resultElement = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; - - return resultElement; + return xmlDoc.getElementsByTagName('Mensaje')[0].textContent; }; }; From 62ca4885c4ccad02f9c8826f0e7bbeb79a8b27e7 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 20 May 2024 12:28:27 +0200 Subject: [PATCH 065/110] feat: refs #7296 requested changes --- modules/route/back/models/roadmap.json | 2 +- modules/ticket/back/models/expeditionPallet.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json index 2b02c64f2..c7c1f15eb 100644 --- a/modules/route/back/models/roadmap.json +++ b/modules/route/back/models/roadmap.json @@ -54,7 +54,7 @@ "model": "Supplier", "foreignKey": "supplierFk" }, - "expeditionTruck": { + "roadmapStop": { "type": "hasMany", "model": "roadmapStop", "foreignKey": "roadmapFk" diff --git a/modules/ticket/back/models/expeditionPallet.json b/modules/ticket/back/models/expeditionPallet.json index 8384ab883..017c5e5d4 100644 --- a/modules/ticket/back/models/expeditionPallet.json +++ b/modules/ticket/back/models/expeditionPallet.json @@ -23,7 +23,7 @@ } }, "relations": { - "expeditionTruck": { + "RoadmapStop": { "type": "belongsTo", "model": "RoadmapStop", "foreignKey": "truckFk" From 34f48e46e7c8b18e4fef7e7c287bba0fba2c5e94 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 20 May 2024 13:19:01 +0200 Subject: [PATCH 066/110] feat: refs #7296 requested changes2 --- modules/route/front/roadmap/summary/index.js | 4 ++-- modules/ticket/back/models/expeditionPallet.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/route/front/roadmap/summary/index.js b/modules/route/front/roadmap/summary/index.js index e0903f3a7..46abe5ca2 100644 --- a/modules/route/front/roadmap/summary/index.js +++ b/modules/route/front/roadmap/summary/index.js @@ -20,7 +20,7 @@ class Controller extends Component { include: [ {relation: 'supplier'}, {relation: 'worker'}, - {relation: 'ExpeditionTruck', + {relation: 'roadmapStop', scope: { include: [ {relation: 'warehouse'} @@ -48,7 +48,7 @@ class Controller extends Component { description: this.roadmapStop.description }; - this.$http.post(`roadmapStops`, data) + this.$http.post(`RoadmapStops`, data) .then(() => { this.loadData(); this.vnApp.showSuccess(this.$t('Data saved!')); diff --git a/modules/ticket/back/models/expeditionPallet.json b/modules/ticket/back/models/expeditionPallet.json index 017c5e5d4..64b3092ae 100644 --- a/modules/ticket/back/models/expeditionPallet.json +++ b/modules/ticket/back/models/expeditionPallet.json @@ -23,7 +23,7 @@ } }, "relations": { - "RoadmapStop": { + "roadmapStop": { "type": "belongsTo", "model": "RoadmapStop", "foreignKey": "truckFk" From 823e8fd7a154a4631fdb454d04297658913d7e89 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 20 May 2024 13:27:38 +0200 Subject: [PATCH 067/110] feat: refs #7296 requested changes3 --- modules/route/back/methods/roadmap/clone.js | 2 +- modules/route/back/models/roadmap.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/route/back/methods/roadmap/clone.js b/modules/route/back/methods/roadmap/clone.js index 2226b1e50..b74cf803c 100644 --- a/modules/route/back/methods/roadmap/clone.js +++ b/modules/route/back/methods/roadmap/clone.js @@ -67,7 +67,7 @@ module.exports = Self => { roadmapStop.roadmapFk = clone.id; return roadmapStop; }); - await models.roadmapStop.create(roadmapStops, options); + await models.RoadmapStop.create(roadmapStops, options); } await tx.commit(); diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json index c7c1f15eb..01572d718 100644 --- a/modules/route/back/models/roadmap.json +++ b/modules/route/back/models/roadmap.json @@ -56,7 +56,7 @@ }, "roadmapStop": { "type": "hasMany", - "model": "roadmapStop", + "model": "RoadmapStop", "foreignKey": "roadmapFk" } } From 3fa557f90d1e5adaefc826c74b2356ee836d62ea Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 20 May 2024 13:58:32 +0200 Subject: [PATCH 068/110] fix: refs #6404 create shipment --- back/methods/mrw-config/createShipment.js | 11 +++-------- back/methods/mrw-config/specs/createShipment.spec.js | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 7d226a5bc..081a83382 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -90,14 +90,9 @@ module.exports = Self => { const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml'); const file = getTextByTag(getLabelResponse, 'EtiquetaFile'); - try { - await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions); - if (tx) await tx.commit(); - } catch (error) { - if (tx) await tx.rollback(); - throw error; - } - return file; + if (tx) await tx.commit(); + + return {shipmentId, file}; }; function getTextByTag(xmlDoc, tag) { diff --git a/back/methods/mrw-config/specs/createShipment.spec.js b/back/methods/mrw-config/specs/createShipment.spec.js index 0f48bc2d3..f05f9a81d 100644 --- a/back/methods/mrw-config/specs/createShipment.spec.js +++ b/back/methods/mrw-config/specs/createShipment.spec.js @@ -81,9 +81,9 @@ describe('MRWConfig createShipment()', () => { spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop())); - const base64Binary = await models.MrwConfig.createShipment(expedition1.id, options); + const {file} = await models.MrwConfig.createShipment(expedition1.id, options); - expect(base64Binary).toEqual(mockBase64Binary); + expect(file).toEqual(mockBase64Binary); }); it('should fail if mrwConfig has no data', async() => { From 119102b0b3cf5fef4390364e7e6d16ff6788cd17 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 20 May 2024 16:00:38 +0200 Subject: [PATCH 069/110] refs #6820 acl --- db/versions/11059-crimsonAnthurium/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11059-crimsonAnthurium/00-firstScript.sql diff --git a/db/versions/11059-crimsonAnthurium/00-firstScript.sql b/db/versions/11059-crimsonAnthurium/00-firstScript.sql new file mode 100644 index 000000000..7fe3e01ca --- /dev/null +++ b/db/versions/11059-crimsonAnthurium/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('RouteConfig','*','*','ALLOW','ROLE','employee'); From 335b9caaa40337e4db2661cd68f19e582f16de0c Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 21 May 2024 01:10:53 +0200 Subject: [PATCH 070/110] fix: refs #7187 got summary before lilium --- modules/worker/front/pda/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/worker/front/pda/index.js b/modules/worker/front/pda/index.js index a57886556..099e0e34c 100644 --- a/modules/worker/front/pda/index.js +++ b/modules/worker/front/pda/index.js @@ -8,6 +8,7 @@ class Controller extends Section { async $onInit() { const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`); + this.$state.go('worker.card.summary', {id: this.$params.id}); window.location.href = url; } } From 82d985ff3a8a77e72698f0afcff4e2e70bc0fda3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 07:19:04 +0200 Subject: [PATCH 071/110] refs #7422 Fix --- .../11057-chocolateMoss/00-firstScript.sql | 106 ------------------ db/versions/11057-chocolateMoss/00-part.sql | 26 +++++ db/versions/11057-chocolateMoss/01-part.sql | 26 +++++ db/versions/11057-chocolateMoss/02-part.sql | 26 +++++ db/versions/11057-chocolateMoss/03-part.sql | 28 +++++ 5 files changed, 106 insertions(+), 106 deletions(-) delete mode 100644 db/versions/11057-chocolateMoss/00-firstScript.sql create mode 100644 db/versions/11057-chocolateMoss/00-part.sql create mode 100644 db/versions/11057-chocolateMoss/01-part.sql create mode 100644 db/versions/11057-chocolateMoss/02-part.sql create mode 100644 db/versions/11057-chocolateMoss/03-part.sql diff --git a/db/versions/11057-chocolateMoss/00-firstScript.sql b/db/versions/11057-chocolateMoss/00-firstScript.sql deleted file mode 100644 index 7484b8c33..000000000 --- a/db/versions/11057-chocolateMoss/00-firstScript.sql +++ /dev/null @@ -1,106 +0,0 @@ -DROP TABLE vn2008.scanTree__; -DROP TABLE vn2008.payroll_embargos__; -DROP TABLE vn2008.unary_scan_line__; -DROP TABLE vn2008.unary_source__; -DROP TABLE vn2008.unary_scan__; -DROP TABLE vn2008.scan_line__; -DROP TABLE vn2008.Familias__; -DROP TABLE vn2008.language__; -DROP TABLE vn2008.Clientes_dits__; -DROP TABLE vn2008.unary_scan_line_expedition__; -DROP TABLE vn2008.warehouse_group__; -DROP TABLE vn2008.Espionajes__; -DROP TABLE vn2008.jerarquia__; -DROP TABLE vn2008.wks__; -DROP TABLE vn2008.Proveedores_comunicados__; -DROP TABLE vn2008.integra2_escala__; -DROP TABLE vn2008.cp__; -DROP TABLE vn2008.unary__; -DROP TABLE vn2008.Estados__; -DROP TABLE vn2008.agency_hour__; -DROP TABLE vn2008.Reservas__; -DROP TABLE vn2008.cyc_declaration__; -DROP TABLE vn2008.route__; -DROP TABLE vn2008.Proveedores_escritos__; -DROP TABLE vn2008.config__; -DROP TABLE vn2008.guillen__; -DROP TABLE vn2008.expeditions_deleted__; -DROP TABLE vn2008.Tipos_f11__; -DROP TABLE vn2008.commission__; -DROP TABLE vn2008.Movimientos_revisar__; -DROP TABLE vn2008.recibida_agricola__; -DROP TABLE vn2008.tipsa__; -DROP TABLE vn2008.rounding__; -DROP TABLE vn2008.Informes__; -DROP TABLE vn2008.Forms__; -DROP TABLE vn2008.Clientes_event__; -DROP TABLE vn2008.wh_selection__; -DROP TABLE vn2008.template_bionic_component__; -DROP TABLE vn2008.Agencias_province__; -DROP TABLE vn2008.travel_pattern__; -DROP TABLE vn2008.sort_merge_results_ernesto__; -DROP TABLE vn2008.Conteo__; -DROP TABLE vn2008.Consignatarios_devices__; -DROP TABLE vn2008.link__; -DROP TABLE vn2008.agency_warehouse__; -DROP TABLE vn2008.warehouse_lc__; -DROP TABLE vn2008.emp_day_pay__; -DROP TABLE vn2008.Entradas_kop__; -DROP TABLE vn2008.dock__; -DROP TABLE vn2008.unaryScanFilter__; -DROP TABLE vn2008.Grupos__; -DROP TABLE vn2008.nichos__; -DROP TABLE vn2008.form_query__; -DROP TABLE vn2008.filtros__; -DROP TABLE vn2008.Objetivos__; -DROP TABLE vn2008.zones__; -DROP TABLE vn2008.rec_translator__; -DROP TABLE vn2008.warehouse_joined__; -DROP TABLE vn2008.warehouse_filtro__; -DROP TABLE vn2008.viaxpress__; -DROP TABLE vn2008.cl_que__; -DROP TABLE vn2008.Recibos_recorded__; -DROP TABLE vn2008.cooler_path__; -DROP TABLE vn2008.payrroll_apEmpresarial__; -DROP TABLE vn2008.Compres_ok__; -DROP TABLE vn2008.Movimientos_avisar__; -DROP TABLE vn2008.Clases__; -DROP TABLE vn2008.payroll_tipobasess__; -DROP TABLE vn2008.guillen_carry__; -DROP TABLE vn2008.unary_scan_line_buy__; -DROP TABLE vn2008.Series__; -DROP TABLE vn2008.Permisos__; -DROP TABLE vn2008.container__; -DROP TABLE vn2008.travel_reserve__; -DROP TABLE vn2008.tmpNEWTARIFAS__; -DROP TABLE vn2008.Clientes_potenciales__; -DROP TABLE vn2008.duaDismissed__; -DROP TABLE vn2008.cl_pet__; -DROP TABLE vn2008.preparation_exception__; -DROP TABLE vn2008.Clientes_empresa__; -DROP TABLE vn2008.call_information__; -DROP TABLE vn2008.template_bionic_price__; -DROP TABLE vn2008.invoice_observation__; -DROP TABLE vn2008.edi_testigos__; -DROP TABLE vn2008.cl_dep__; -DROP TABLE vn2008.agencia_descuadre__; -DROP TABLE vn2008.Monitoring__; -DROP TABLE vn2008.payroll_datos__; -DROP TABLE vn2008.tblIVA__; -DROP TABLE vn2008.cyc__; -DROP TABLE vn2008.Tickets_stack__; -DROP TABLE vn2008.config_host_forms__; -DROP TABLE vn2008.template_bionic_lot__; -DROP TABLE vn2008.payroll_bonificaciones__; -DROP TABLE vn2008.widget__; -DROP TABLE vn2008.accion_dits__; -DROP TABLE vn2008.credit_card__; -DROP TABLE vn2008.Brasa__; -DROP TABLE vn2008.Jefes__; -DROP TABLE vn2008.call_option__; -DROP TABLE vn2008.expeditions_pictures__; -DROP TABLE vn2008.scan__; -DROP TABLE vn2008.trolley__; -DROP TABLE vn2008.transport__; -DROP TABLE vn2008.Baldas__; -DROP TABLE vn2008.payroll_basess__; \ No newline at end of file diff --git a/db/versions/11057-chocolateMoss/00-part.sql b/db/versions/11057-chocolateMoss/00-part.sql new file mode 100644 index 000000000..f58507e4f --- /dev/null +++ b/db/versions/11057-chocolateMoss/00-part.sql @@ -0,0 +1,26 @@ +DROP TABLE IF EXISTS vn2008.scanTree__; +DROP TABLE IF EXISTS vn2008.payroll_embargos__; +DROP TABLE IF EXISTS vn2008.unary_scan_line__; +DROP TABLE IF EXISTS vn2008.unary_source__; +DROP TABLE IF EXISTS vn2008.unary_scan__; +DROP TABLE IF EXISTS vn2008.scan_line__; +DROP TABLE IF EXISTS vn2008.Familias__; +DROP TABLE IF EXISTS vn2008.language__; +DROP TABLE IF EXISTS vn2008.Clientes_dits__; +DROP TABLE IF EXISTS vn2008.unary_scan_line_expedition__; +DROP TABLE IF EXISTS vn2008.warehouse_group__; +DROP TABLE IF EXISTS vn2008.Espionajes__; +DROP TABLE IF EXISTS vn2008.jerarquia__; +DROP TABLE IF EXISTS vn2008.wks__; +DROP TABLE IF EXISTS vn2008.Proveedores_comunicados__; +DROP TABLE IF EXISTS vn2008.integra2_escala__; +DROP TABLE IF EXISTS vn2008.cp__; +DROP TABLE IF EXISTS vn2008.unary__; +DROP TABLE IF EXISTS vn2008.Estados__; +DROP TABLE IF EXISTS vn2008.agency_hour__; +DROP TABLE IF EXISTS vn2008.Reservas__; +DROP TABLE IF EXISTS vn2008.cyc_declaration__; +DROP TABLE IF EXISTS vn2008.route__; +DROP TABLE IF EXISTS vn2008.Proveedores_escritos__; +DROP TABLE IF EXISTS vn2008.config__; +DROP TABLE IF EXISTS vn2008.guillen__; diff --git a/db/versions/11057-chocolateMoss/01-part.sql b/db/versions/11057-chocolateMoss/01-part.sql new file mode 100644 index 000000000..bba2167aa --- /dev/null +++ b/db/versions/11057-chocolateMoss/01-part.sql @@ -0,0 +1,26 @@ +DROP TABLE IF EXISTS vn2008.expeditions_deleted__; +DROP TABLE IF EXISTS vn2008.Tipos_f11__; +DROP TABLE IF EXISTS vn2008.commission__; +DROP TABLE IF EXISTS vn2008.Movimientos_revisar__; +DROP TABLE IF EXISTS vn2008.recibida_agricola__; +DROP TABLE IF EXISTS vn2008.tipsa__; +DROP TABLE IF EXISTS vn2008.rounding__; +DROP TABLE IF EXISTS vn2008.Informes__; +DROP TABLE IF EXISTS vn2008.Forms__; +DROP TABLE IF EXISTS vn2008.Clientes_event__; +DROP TABLE IF EXISTS vn2008.wh_selection__; +DROP TABLE IF EXISTS vn2008.template_bionic_component__; +DROP TABLE IF EXISTS vn2008.Agencias_province__; +DROP TABLE IF EXISTS vn2008.travel_pattern__; +DROP TABLE IF EXISTS vn2008.sort_merge_results_ernesto__; +DROP TABLE IF EXISTS vn2008.Conteo__; +DROP TABLE IF EXISTS vn2008.Consignatarios_devices__; +DROP TABLE IF EXISTS vn2008.link__; +DROP TABLE IF EXISTS vn2008.agency_warehouse__; +DROP TABLE IF EXISTS vn2008.warehouse_lc__; +DROP TABLE IF EXISTS vn2008.emp_day_pay__; +DROP TABLE IF EXISTS vn2008.Entradas_kop__; +DROP TABLE IF EXISTS vn2008.dock__; +DROP TABLE IF EXISTS vn2008.unaryScanFilter__; +DROP TABLE IF EXISTS vn2008.Grupos__; +DROP TABLE IF EXISTS vn2008.nichos__; diff --git a/db/versions/11057-chocolateMoss/02-part.sql b/db/versions/11057-chocolateMoss/02-part.sql new file mode 100644 index 000000000..d3b083775 --- /dev/null +++ b/db/versions/11057-chocolateMoss/02-part.sql @@ -0,0 +1,26 @@ +DROP TABLE IF EXISTS vn2008.form_query__; +DROP TABLE IF EXISTS vn2008.filtros__; +DROP TABLE IF EXISTS vn2008.Objetivos__; +DROP TABLE IF EXISTS vn2008.zones__; +DROP TABLE IF EXISTS vn2008.rec_translator__; +DROP TABLE IF EXISTS vn2008.warehouse_joined__; +DROP TABLE IF EXISTS vn2008.warehouse_filtro__; +DROP TABLE IF EXISTS vn2008.viaxpress__; +DROP TABLE IF EXISTS vn2008.cl_que__; +DROP TABLE IF EXISTS vn2008.Recibos_recorded__; +DROP TABLE IF EXISTS vn2008.cooler_path__; +DROP TABLE IF EXISTS vn2008.payrroll_apEmpresarial__; +DROP TABLE IF EXISTS vn2008.Compres_ok__; +DROP TABLE IF EXISTS vn2008.Movimientos_avisar__; +DROP TABLE IF EXISTS vn2008.Clases__; +DROP TABLE IF EXISTS vn2008.payroll_tipobasess__; +DROP TABLE IF EXISTS vn2008.guillen_carry__; +DROP TABLE IF EXISTS vn2008.unary_scan_line_buy__; +DROP TABLE IF EXISTS vn2008.Series__; +DROP TABLE IF EXISTS vn2008.Permisos__; +DROP TABLE IF EXISTS vn2008.container__; +DROP TABLE IF EXISTS vn2008.travel_reserve__; +DROP TABLE IF EXISTS vn2008.tmpNEWTARIFAS__; +DROP TABLE IF EXISTS vn2008.Clientes_potenciales__; +DROP TABLE IF EXISTS vn2008.duaDismissed__; +DROP TABLE IF EXISTS vn2008.cl_pet__; diff --git a/db/versions/11057-chocolateMoss/03-part.sql b/db/versions/11057-chocolateMoss/03-part.sql new file mode 100644 index 000000000..f5e4e45c0 --- /dev/null +++ b/db/versions/11057-chocolateMoss/03-part.sql @@ -0,0 +1,28 @@ +DROP TABLE IF EXISTS vn2008.preparation_exception__; +DROP TABLE IF EXISTS vn2008.Clientes_empresa__; +DROP TABLE IF EXISTS vn2008.call_information__; +DROP TABLE IF EXISTS vn2008.template_bionic_price__; +DROP TABLE IF EXISTS vn2008.invoice_observation__; +DROP TABLE IF EXISTS vn2008.edi_testigos__; +DROP TABLE IF EXISTS vn2008.cl_dep__; +DROP TABLE IF EXISTS vn2008.agencia_descuadre__; +DROP TABLE IF EXISTS vn2008.Monitoring__; +DROP TABLE IF EXISTS vn2008.payroll_datos__; +DROP TABLE IF EXISTS vn2008.tblIVA__; +DROP TABLE IF EXISTS vn2008.cyc__; +DROP TABLE IF EXISTS vn2008.Tickets_stack__; +DROP TABLE IF EXISTS vn2008.config_host_forms__; +DROP TABLE IF EXISTS vn2008.template_bionic_lot__; +DROP TABLE IF EXISTS vn2008.payroll_bonificaciones__; +DROP TABLE IF EXISTS vn2008.widget__; +DROP TABLE IF EXISTS vn2008.accion_dits__; +DROP TABLE IF EXISTS vn2008.credit_card__; +DROP TABLE IF EXISTS vn2008.Brasa__; +DROP TABLE IF EXISTS vn2008.Jefes__; +DROP TABLE IF EXISTS vn2008.call_option__; +DROP TABLE IF EXISTS vn2008.expeditions_pictures__; +DROP TABLE IF EXISTS vn2008.scan__; +DROP TABLE IF EXISTS vn2008.trolley__; +DROP TABLE IF EXISTS vn2008.transport__; +DROP TABLE IF EXISTS vn2008.Baldas__; +DROP TABLE IF EXISTS vn2008.payroll_basess__; From cc2b5764e97ad30c71d9da163ed4aa1851353580 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 07:26:54 +0200 Subject: [PATCH 072/110] refs #7422 Fix --- db/versions/11057-chocolateMoss/00-part.sql | 6 ++++-- db/versions/11057-chocolateMoss/02-part.sql | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/db/versions/11057-chocolateMoss/00-part.sql b/db/versions/11057-chocolateMoss/00-part.sql index f58507e4f..09555d0d6 100644 --- a/db/versions/11057-chocolateMoss/00-part.sql +++ b/db/versions/11057-chocolateMoss/00-part.sql @@ -1,8 +1,11 @@ DROP TABLE IF EXISTS vn2008.scanTree__; DROP TABLE IF EXISTS vn2008.payroll_embargos__; -DROP TABLE IF EXISTS vn2008.unary_scan_line__; DROP TABLE IF EXISTS vn2008.unary_source__; +ALTER TABLE vn2008.unary_scan__ DROP FOREIGN KEY unary_scan; +ALTER TABLE vn2008.unary_scan_line__ DROP FOREIGN KEY unary_line; DROP TABLE IF EXISTS vn2008.unary_scan__; +DROP TABLE IF EXISTS vn2008.unary_scan_line_buy__; +DROP TABLE IF EXISTS vn2008.unary_scan_line__; DROP TABLE IF EXISTS vn2008.scan_line__; DROP TABLE IF EXISTS vn2008.Familias__; DROP TABLE IF EXISTS vn2008.language__; @@ -23,4 +26,3 @@ DROP TABLE IF EXISTS vn2008.cyc_declaration__; DROP TABLE IF EXISTS vn2008.route__; DROP TABLE IF EXISTS vn2008.Proveedores_escritos__; DROP TABLE IF EXISTS vn2008.config__; -DROP TABLE IF EXISTS vn2008.guillen__; diff --git a/db/versions/11057-chocolateMoss/02-part.sql b/db/versions/11057-chocolateMoss/02-part.sql index d3b083775..dbdd6b3c4 100644 --- a/db/versions/11057-chocolateMoss/02-part.sql +++ b/db/versions/11057-chocolateMoss/02-part.sql @@ -14,8 +14,8 @@ DROP TABLE IF EXISTS vn2008.Compres_ok__; DROP TABLE IF EXISTS vn2008.Movimientos_avisar__; DROP TABLE IF EXISTS vn2008.Clases__; DROP TABLE IF EXISTS vn2008.payroll_tipobasess__; +DROP TABLE IF EXISTS vn2008.guillen__; DROP TABLE IF EXISTS vn2008.guillen_carry__; -DROP TABLE IF EXISTS vn2008.unary_scan_line_buy__; DROP TABLE IF EXISTS vn2008.Series__; DROP TABLE IF EXISTS vn2008.Permisos__; DROP TABLE IF EXISTS vn2008.container__; From 93314d67b62ae342db55826a4a6aaf06dbd6fc2f Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 07:31:24 +0200 Subject: [PATCH 073/110] refs #7422 Fix --- db/versions/11057-chocolateMoss/00-part.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/versions/11057-chocolateMoss/00-part.sql b/db/versions/11057-chocolateMoss/00-part.sql index 09555d0d6..4cabb0e33 100644 --- a/db/versions/11057-chocolateMoss/00-part.sql +++ b/db/versions/11057-chocolateMoss/00-part.sql @@ -1,8 +1,6 @@ DROP TABLE IF EXISTS vn2008.scanTree__; DROP TABLE IF EXISTS vn2008.payroll_embargos__; DROP TABLE IF EXISTS vn2008.unary_source__; -ALTER TABLE vn2008.unary_scan__ DROP FOREIGN KEY unary_scan; -ALTER TABLE vn2008.unary_scan_line__ DROP FOREIGN KEY unary_line; DROP TABLE IF EXISTS vn2008.unary_scan__; DROP TABLE IF EXISTS vn2008.unary_scan_line_buy__; DROP TABLE IF EXISTS vn2008.unary_scan_line__; From cbf9a4c4e902a452d24b74bda85a78af08748761 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 07:58:51 +0200 Subject: [PATCH 074/110] refs #7422 Fixed all problems --- db/versions/11057-chocolateMoss/01-part.sql | 67 +++++++++++++-------- db/versions/11057-chocolateMoss/02-part.sql | 53 ++++++++-------- db/versions/11057-chocolateMoss/03-part.sql | 2 - 3 files changed, 68 insertions(+), 54 deletions(-) diff --git a/db/versions/11057-chocolateMoss/01-part.sql b/db/versions/11057-chocolateMoss/01-part.sql index bba2167aa..db6a5774d 100644 --- a/db/versions/11057-chocolateMoss/01-part.sql +++ b/db/versions/11057-chocolateMoss/01-part.sql @@ -1,26 +1,41 @@ -DROP TABLE IF EXISTS vn2008.expeditions_deleted__; -DROP TABLE IF EXISTS vn2008.Tipos_f11__; -DROP TABLE IF EXISTS vn2008.commission__; -DROP TABLE IF EXISTS vn2008.Movimientos_revisar__; -DROP TABLE IF EXISTS vn2008.recibida_agricola__; -DROP TABLE IF EXISTS vn2008.tipsa__; -DROP TABLE IF EXISTS vn2008.rounding__; -DROP TABLE IF EXISTS vn2008.Informes__; -DROP TABLE IF EXISTS vn2008.Forms__; -DROP TABLE IF EXISTS vn2008.Clientes_event__; -DROP TABLE IF EXISTS vn2008.wh_selection__; -DROP TABLE IF EXISTS vn2008.template_bionic_component__; -DROP TABLE IF EXISTS vn2008.Agencias_province__; -DROP TABLE IF EXISTS vn2008.travel_pattern__; -DROP TABLE IF EXISTS vn2008.sort_merge_results_ernesto__; -DROP TABLE IF EXISTS vn2008.Conteo__; -DROP TABLE IF EXISTS vn2008.Consignatarios_devices__; -DROP TABLE IF EXISTS vn2008.link__; -DROP TABLE IF EXISTS vn2008.agency_warehouse__; -DROP TABLE IF EXISTS vn2008.warehouse_lc__; -DROP TABLE IF EXISTS vn2008.emp_day_pay__; -DROP TABLE IF EXISTS vn2008.Entradas_kop__; -DROP TABLE IF EXISTS vn2008.dock__; -DROP TABLE IF EXISTS vn2008.unaryScanFilter__; -DROP TABLE IF EXISTS vn2008.Grupos__; -DROP TABLE IF EXISTS vn2008.nichos__; +DROP TABLE IF EXISTS vn2008.form_query__; +DROP TABLE IF EXISTS vn2008.filtros__; +DROP TABLE IF EXISTS vn2008.Objetivos__; +UPDATE IGNORE vn.province + SET zoneFk = NULL + WHERE zoneFk IN ( + SELECT zoneFk + FROM vn.province + WHERE zoneFk IS NOT NULL AND zoneFk NOT IN (SELECT id FROM vn.`zone`) + ); +ALTER TABLE vn.province DROP FOREIGN KEY province_zone_fk; +ALTER TABLE vn.province MODIFY COLUMN zoneFk int(11) DEFAULT NULL NULL; +ALTER TABLE vn.province ADD CONSTRAINT + province_zone_FK FOREIGN KEY (zoneFk) REFERENCES vn.`zone`(id) ON DELETE CASCADE ON UPDATE CASCADE; +DROP TABLE IF EXISTS vn2008.zones__; +DROP TABLE IF EXISTS vn2008.rec_translator__; +DROP TABLE IF EXISTS vn2008.warehouse_joined__; +DROP TABLE IF EXISTS vn2008.warehouse_filtro__; +DROP TABLE IF EXISTS vn2008.viaxpress__; +DROP TABLE IF EXISTS vn2008.cl_que__; +DROP TABLE IF EXISTS vn2008.Recibos_recorded__; +RENAME TABLE vn.coolerPathDetail TO vn.coolerPathDetail__; +ALTER TABLE vn.coolerPathDetail DROP FOREIGN KEY coolerPathDetail_FK; +DROP TABLE IF EXISTS vn2008.cooler_path__; +DROP TABLE IF EXISTS vn2008.payrroll_apEmpresarial__; +DROP TABLE IF EXISTS vn2008.Compres_ok__; +DROP TABLE IF EXISTS vn2008.Movimientos_avisar__; +DROP TABLE IF EXISTS vn2008.Clases__; +DROP TABLE IF EXISTS vn2008.payroll_basess__; +DROP TABLE IF EXISTS vn2008.payroll_tipobasess__; +DROP TABLE IF EXISTS vn2008.guillen__; +DROP TABLE IF EXISTS vn2008.guillen_carry__; +DROP TABLE IF EXISTS vn2008.Series__; +DROP TABLE IF EXISTS vn2008.Permisos__; +ALTER TABLE vn.buy DROP FOREIGN KEY buy_FK_1; +DROP TABLE IF EXISTS vn2008.container__; +DROP TABLE IF EXISTS vn2008.travel_reserve__; +DROP TABLE IF EXISTS vn2008.tmpNEWTARIFAS__; +DROP TABLE IF EXISTS vn2008.Clientes_potenciales__; +DROP TABLE IF EXISTS vn2008.duaDismissed__; +DROP TABLE IF EXISTS vn2008.cl_pet__; diff --git a/db/versions/11057-chocolateMoss/02-part.sql b/db/versions/11057-chocolateMoss/02-part.sql index dbdd6b3c4..46cda539a 100644 --- a/db/versions/11057-chocolateMoss/02-part.sql +++ b/db/versions/11057-chocolateMoss/02-part.sql @@ -1,26 +1,27 @@ -DROP TABLE IF EXISTS vn2008.form_query__; -DROP TABLE IF EXISTS vn2008.filtros__; -DROP TABLE IF EXISTS vn2008.Objetivos__; -DROP TABLE IF EXISTS vn2008.zones__; -DROP TABLE IF EXISTS vn2008.rec_translator__; -DROP TABLE IF EXISTS vn2008.warehouse_joined__; -DROP TABLE IF EXISTS vn2008.warehouse_filtro__; -DROP TABLE IF EXISTS vn2008.viaxpress__; -DROP TABLE IF EXISTS vn2008.cl_que__; -DROP TABLE IF EXISTS vn2008.Recibos_recorded__; -DROP TABLE IF EXISTS vn2008.cooler_path__; -DROP TABLE IF EXISTS vn2008.payrroll_apEmpresarial__; -DROP TABLE IF EXISTS vn2008.Compres_ok__; -DROP TABLE IF EXISTS vn2008.Movimientos_avisar__; -DROP TABLE IF EXISTS vn2008.Clases__; -DROP TABLE IF EXISTS vn2008.payroll_tipobasess__; -DROP TABLE IF EXISTS vn2008.guillen__; -DROP TABLE IF EXISTS vn2008.guillen_carry__; -DROP TABLE IF EXISTS vn2008.Series__; -DROP TABLE IF EXISTS vn2008.Permisos__; -DROP TABLE IF EXISTS vn2008.container__; -DROP TABLE IF EXISTS vn2008.travel_reserve__; -DROP TABLE IF EXISTS vn2008.tmpNEWTARIFAS__; -DROP TABLE IF EXISTS vn2008.Clientes_potenciales__; -DROP TABLE IF EXISTS vn2008.duaDismissed__; -DROP TABLE IF EXISTS vn2008.cl_pet__; +DROP TABLE IF EXISTS vn2008.expeditions_deleted__; +DROP TABLE IF EXISTS vn2008.Tipos_f11__; +DROP TABLE IF EXISTS vn2008.commission__; +DROP TABLE IF EXISTS vn2008.Movimientos_revisar__; +DROP TABLE IF EXISTS vn2008.recibida_agricola__; +DROP TABLE IF EXISTS vn2008.tipsa__; +DROP TABLE IF EXISTS vn2008.rounding__; +DROP TABLE IF EXISTS vn2008.Informes__; +DROP TABLE IF EXISTS vn2008.Monitoring__; +DROP TABLE IF EXISTS vn2008.Forms__; +DROP TABLE IF EXISTS vn2008.Clientes_event__; +DROP TABLE IF EXISTS vn2008.wh_selection__; +DROP TABLE IF EXISTS vn2008.template_bionic_component__; +DROP TABLE IF EXISTS vn2008.Agencias_province__; +DROP TABLE IF EXISTS vn2008.travel_pattern__; +DROP TABLE IF EXISTS vn2008.sort_merge_results_ernesto__; +DROP TABLE IF EXISTS vn2008.Conteo__; +DROP TABLE IF EXISTS vn2008.Consignatarios_devices__; +DROP TABLE IF EXISTS vn2008.link__; +DROP TABLE IF EXISTS vn2008.agency_warehouse__; +DROP TABLE IF EXISTS vn2008.warehouse_lc__; +DROP TABLE IF EXISTS vn2008.emp_day_pay__; +DROP TABLE IF EXISTS vn2008.Entradas_kop__; +DROP TABLE IF EXISTS vn2008.dock__; +DROP TABLE IF EXISTS vn2008.unaryScanFilter__; +DROP TABLE IF EXISTS vn2008.Grupos__; +DROP TABLE IF EXISTS vn2008.nichos__; diff --git a/db/versions/11057-chocolateMoss/03-part.sql b/db/versions/11057-chocolateMoss/03-part.sql index f5e4e45c0..e1947f064 100644 --- a/db/versions/11057-chocolateMoss/03-part.sql +++ b/db/versions/11057-chocolateMoss/03-part.sql @@ -6,7 +6,6 @@ DROP TABLE IF EXISTS vn2008.invoice_observation__; DROP TABLE IF EXISTS vn2008.edi_testigos__; DROP TABLE IF EXISTS vn2008.cl_dep__; DROP TABLE IF EXISTS vn2008.agencia_descuadre__; -DROP TABLE IF EXISTS vn2008.Monitoring__; DROP TABLE IF EXISTS vn2008.payroll_datos__; DROP TABLE IF EXISTS vn2008.tblIVA__; DROP TABLE IF EXISTS vn2008.cyc__; @@ -25,4 +24,3 @@ DROP TABLE IF EXISTS vn2008.scan__; DROP TABLE IF EXISTS vn2008.trolley__; DROP TABLE IF EXISTS vn2008.transport__; DROP TABLE IF EXISTS vn2008.Baldas__; -DROP TABLE IF EXISTS vn2008.payroll_basess__; From ac2ed0956b94cc6c2b010c67b69d6dd8fb2a4c34 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 08:04:28 +0200 Subject: [PATCH 075/110] refs #7422 Fixed all problems --- db/versions/11057-chocolateMoss/01-part.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11057-chocolateMoss/01-part.sql b/db/versions/11057-chocolateMoss/01-part.sql index db6a5774d..59df77f20 100644 --- a/db/versions/11057-chocolateMoss/01-part.sql +++ b/db/versions/11057-chocolateMoss/01-part.sql @@ -20,7 +20,7 @@ DROP TABLE IF EXISTS vn2008.viaxpress__; DROP TABLE IF EXISTS vn2008.cl_que__; DROP TABLE IF EXISTS vn2008.Recibos_recorded__; RENAME TABLE vn.coolerPathDetail TO vn.coolerPathDetail__; -ALTER TABLE vn.coolerPathDetail DROP FOREIGN KEY coolerPathDetail_FK; +ALTER TABLE vn.coolerPathDetail__ DROP FOREIGN KEY coolerPathDetail_FK; DROP TABLE IF EXISTS vn2008.cooler_path__; DROP TABLE IF EXISTS vn2008.payrroll_apEmpresarial__; DROP TABLE IF EXISTS vn2008.Compres_ok__; From 030106f06d653263a0331642a057a75e5c9880cc Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 08:13:06 +0200 Subject: [PATCH 076/110] refactor: refs #7422 Deprecated column --- db/versions/11061-silverMastic/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11061-silverMastic/00-firstScript.sql diff --git a/db/versions/11061-silverMastic/00-firstScript.sql b/db/versions/11061-silverMastic/00-firstScript.sql new file mode 100644 index 000000000..32dbc0c2e --- /dev/null +++ b/db/versions/11061-silverMastic/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.buy CHANGE containerFk containerFk__ smallint(5) unsigned DEFAULT NULL NULL; From c4b8cef4f8697eb8f6dc5178b2c14c940e5923d6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 08:17:37 +0200 Subject: [PATCH 077/110] refactor: refs #7422 Deleted column of Compres --- db/routines/vn2008/views/Compres.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn2008/views/Compres.sql b/db/routines/vn2008/views/Compres.sql index 557136192..b99dd2b73 100644 --- a/db/routines/vn2008/views/Compres.sql +++ b/db/routines/vn2008/views/Compres.sql @@ -28,6 +28,5 @@ AS SELECT `c`.`id` AS `Id_Compra`, `c`.`workerFk` AS `Id_Trabajador`, `c`.`weight` AS `weight`, `c`.`dispatched` AS `dispatched`, - `c`.`containerFk` AS `container_id`, `c`.`itemOriginalFk` AS `itemOriginalFk` FROM `vn`.`buy` `c` From 1fef00789f5636c4839a074a87f4c1664bb627bb Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 21 May 2024 08:54:53 +0200 Subject: [PATCH 078/110] fix: refs #7187 remove bindings --- modules/worker/front/pda/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/worker/front/pda/index.js b/modules/worker/front/pda/index.js index 099e0e34c..c3616b41e 100644 --- a/modules/worker/front/pda/index.js +++ b/modules/worker/front/pda/index.js @@ -14,8 +14,5 @@ class Controller extends Section { } ngModule.vnComponent('vnWorkerPda', { - controller: Controller, - bindings: { - claim: '<' - } + controller: Controller }); From 6438ce3a164464c92156b348cf9468b63007d23c Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 21 May 2024 09:13:31 +0200 Subject: [PATCH 079/110] fix: refs #7187 e2e --- e2e/paths/03-worker/07_pda.spec.js | 41 ------------------------------ 1 file changed, 41 deletions(-) delete mode 100644 e2e/paths/03-worker/07_pda.spec.js diff --git a/e2e/paths/03-worker/07_pda.spec.js b/e2e/paths/03-worker/07_pda.spec.js deleted file mode 100644 index 2b743823e..000000000 --- a/e2e/paths/03-worker/07_pda.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker pda path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSearchResult('employeeNick'); - await page.accessToSection('worker.card.pda'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check if worker has already a PDA allocated', async() => { - expect(await page.waitToGetProperty(selectors.workerPda.currentPDA, 'value')).toContain('serialNumber1'); - }); - - it('should deallocate the PDA', async() => { - await page.waitToClick(selectors.workerPda.delete); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('PDA deallocated'); - }); - - it('should allocate a new PDA', async() => { - await page.autocompleteSearch(selectors.workerPda.newPDA, 'serialNumber2'); - await page.waitToClick(selectors.workerPda.submit); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('PDA allocated'); - }); - - it('should check if a new PDA has been allocated', async() => { - expect(await page.waitToGetProperty(selectors.workerPda.currentPDA, 'value')).toContain('serialNumber2'); - }); -}); From cb866b4ab77992af7e2a0b5ba5a3fa0b0f8fc1cb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 21 May 2024 09:16:47 +0200 Subject: [PATCH 080/110] refs #7431 feat: itemPlacementSupplyStockGetTargetList --- .../procedures/itemPlacementSupplyStockGetTargetList.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql index bdc13ae9d..0a99703f3 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql @@ -18,11 +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 + WHERE ish.visible > 0 AND ish.itemFk = vItemFk GROUP BY ish.id - ORDER BY sh.priority DESC, + ORDER BY + (sc.id = vSectorFk) DESC + sh.priority DESC, ish.created, p.pickingOrder; END$$ From 6dad3d8af4fb9dea158e2d01626c213e7a7cc9ed Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 21 May 2024 09:37:29 +0200 Subject: [PATCH 081/110] refs #7431 feat: itemPlacementSupplyStockGetTargetList --- .../vn/procedures/itemPlacementSupplyStockGetTargetList.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql index 0a99703f3..86d62cad4 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql @@ -22,7 +22,7 @@ BEGIN AND ish.itemFk = vItemFk GROUP BY ish.id ORDER BY - (sc.id = vSectorFk) DESC + (sc.id = vSectorFk) DESC, sh.priority DESC, ish.created, p.pickingOrder; From 6f9826421d1b07abcd4db09567f60879c792f077 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 09:39:09 +0200 Subject: [PATCH 082/110] refactor: refs #7422 Fix e2e --- db/routines/vn/procedures/buy_clone.sql | 2 -- db/routines/vn/procedures/entry_fixMisfit.sql | 2 -- db/routines/vn/procedures/entry_moveNotPrinted.sql | 4 ---- db/routines/vn/procedures/entry_splitByShelving.sql | 2 -- db/routines/vn/procedures/item_devalueA2.sql | 3 --- modules/entry/back/methods/entry/addFromBuy.js | 1 - modules/entry/back/models/buy.json | 3 --- 7 files changed, 17 deletions(-) diff --git a/db/routines/vn/procedures/buy_clone.sql b/db/routines/vn/procedures/buy_clone.sql index d3fbf888d..7b77204c9 100644 --- a/db/routines/vn/procedures/buy_clone.sql +++ b/db/routines/vn/procedures/buy_clone.sql @@ -19,7 +19,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, price1, @@ -41,7 +40,6 @@ BEGIN b.packing, b.`grouping`, b.groupingMode, - b.containerFk, b.comissionValue, b.packageValue, b.price1, diff --git a/db/routines/vn/procedures/entry_fixMisfit.sql b/db/routines/vn/procedures/entry_fixMisfit.sql index 3e57d362e..986a0ae9e 100644 --- a/db/routines/vn/procedures/entry_fixMisfit.sql +++ b/db/routines/vn/procedures/entry_fixMisfit.sql @@ -26,7 +26,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -46,7 +45,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, diff --git a/db/routines/vn/procedures/entry_moveNotPrinted.sql b/db/routines/vn/procedures/entry_moveNotPrinted.sql index 526ae9d43..3a12007d1 100644 --- a/db/routines/vn/procedures/entry_moveNotPrinted.sql +++ b/db/routines/vn/procedures/entry_moveNotPrinted.sql @@ -56,7 +56,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, packagingFk, @@ -77,7 +76,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, packagingFk, @@ -114,7 +112,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -133,7 +130,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index b7d9c77b3..2898141ea 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -76,7 +76,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -103,7 +102,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index f331c7230..c9f716d8f 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -319,7 +319,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, price1, @@ -341,7 +340,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, price1, @@ -366,7 +364,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, price1, diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index 307c04b97..e5cc427a8 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -76,7 +76,6 @@ module.exports = Self => { packing: buyUltimate.packing, grouping: buyUltimate.grouping, groupingMode: buyUltimate.groupingMode, - containerFk: buyUltimate.containerFk, comissionValue: buyUltimate.comissionValue, packageValue: buyUltimate.packageValue, location: buyUltimate.location, diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index 35861fd81..14cafde06 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -63,9 +63,6 @@ "isIgnored": { "type": "boolean" }, - "containerFk": { - "type": "number" - }, "location": { "type": "number" }, From 7065cf0b38ec8558b0f0651992c5eccbc398273d Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 21 May 2024 09:58:03 +0200 Subject: [PATCH 083/110] feat: refs #6281 change fixtures --- db/dump/fixtures.before.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 3e6edf07d..8a86e2786 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1205,11 +1205,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (32, 36, -92.324), (32, 39, 0.994); -INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk`) +INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`) VALUES - (2, 'GVC', 1, 1, 1, 1106), - (4, 'HEJ', 1, 1, 1, 1106), - (1, 'UXN', 2, 12, 12, 1106); + (2, 'GVC', 1, 1, 1, 2,1106), + (4, 'HEJ', 1, 1, 1, NULL,1106), + (1, 'UXN', 2, 12, 12, NULL,1106); INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) VALUES From 35e892a90c1d8dbba89f3501ad8e65e443aec69f Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 10:07:51 +0200 Subject: [PATCH 084/110] refs #7422 Fix --- db/.pullinfo.json | 2 +- db/versions/11057-chocolateMoss/00-part.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index f4afbc5fb..0defed845 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb" + "expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" } } } diff --git a/db/versions/11057-chocolateMoss/00-part.sql b/db/versions/11057-chocolateMoss/00-part.sql index 4cabb0e33..bd6c69955 100644 --- a/db/versions/11057-chocolateMoss/00-part.sql +++ b/db/versions/11057-chocolateMoss/00-part.sql @@ -1,9 +1,9 @@ DROP TABLE IF EXISTS vn2008.scanTree__; DROP TABLE IF EXISTS vn2008.payroll_embargos__; DROP TABLE IF EXISTS vn2008.unary_source__; -DROP TABLE IF EXISTS vn2008.unary_scan__; DROP TABLE IF EXISTS vn2008.unary_scan_line_buy__; DROP TABLE IF EXISTS vn2008.unary_scan_line__; +DROP TABLE IF EXISTS vn2008.unary_scan__; DROP TABLE IF EXISTS vn2008.scan_line__; DROP TABLE IF EXISTS vn2008.Familias__; DROP TABLE IF EXISTS vn2008.language__; From 9bd5244f647663a2e9f515ff6f6cf841adf65645 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 21 May 2024 10:19:21 +0200 Subject: [PATCH 085/110] refs #7292 hook ueemember --- e2e/paths/02-client/05_add_address.spec.js | 2 +- loopback/locale/en.json | 3 ++- modules/client/back/methods/client/createAddress.js | 11 ++++++----- .../back/methods/client/specs/createAddress.spec.js | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index 0581635d0..2f5999359 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -51,7 +51,7 @@ describe('Client Add address path', () => { await page.waitToClick(selectors.clientAddresses.saveButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Incoterms is required for a non UEE member'); + expect(message.text).toContain('Incoterms and Customs agent are required for a non UEE member'); }); it(`should receive an error after clicking save button as customsAgent is empty`, async() => { diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 601a26f5b..1fffe7f35 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -226,5 +226,6 @@ "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", "They're not your subordinate": "They're not your subordinate", "InvoiceIn is already booked": "InvoiceIn is already booked", - "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", + "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member" } \ No newline at end of file diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index 8e6db2a22..cb55025ce 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -92,11 +92,12 @@ module.exports = function(Self) { }, myOptions); const isUeeMember = province.country().isUeeMember; - if (!isUeeMember && !args.incotermsFk) - throw new UserError(`Incoterms is required for a non UEE member`); - - if (!isUeeMember && !args.customsAgentFk) - throw new UserError(`Customs agent is required for a non UEE member`); + if (!isUeeMember && (!args.incotermsFk || !args.customsAgentFk)) { + if (!args.incotermsFk) + throw new UserError(`Incoterms and Customs agent are required for a non UEE member`); + else + throw new UserError(`Customs agent is required for a non UEE member`); + } delete args.ctx; // Remove unwanted properties const newAddress = await models.Address.create(args, myOptions); diff --git a/modules/client/back/methods/client/specs/createAddress.spec.js b/modules/client/back/methods/client/specs/createAddress.spec.js index 0841ad98c..bd41d9c50 100644 --- a/modules/client/back/methods/client/specs/createAddress.spec.js +++ b/modules/client/back/methods/client/specs/createAddress.spec.js @@ -50,7 +50,7 @@ describe('Address createAddress', () => { } expect(error).toBeDefined(); - expect(error.message).toEqual('Incoterms is required for a non UEE member'); + expect(error.message).toEqual('Incoterms and Customs agent are required for a non UEE member'); }); it('should throw a non uee member error if no customsAgent is defined', async() => { From cf630a72135635f722b24dc25955b130d4957b5d Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 21 May 2024 10:20:54 +0200 Subject: [PATCH 086/110] refs #7292 traduction es --- loopback/locale/es.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 77e707590..090cfe059 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -358,5 +358,6 @@ "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", "This PDA is already assigned to another user": "This PDA is already assigned to another user", - "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" -} \ No newline at end of file + "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", + "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE" +} From da75bf95c99b50462b5e12a559233771afb44907 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 May 2024 11:16:12 +0200 Subject: [PATCH 087/110] deploy: init version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 390b61be1..c2f630974 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.0", + "version": "24.24.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From d672385776020c1a97236e15880f27260012f0b9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 11:44:11 +0200 Subject: [PATCH 088/110] =?UTF-8?q?hotfix:=20Rectificaci=C3=B3n=20Pepe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/ticket/back/methods/ticket/closeAll.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index e3cbc83e2..35b9b1e37 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -138,9 +138,12 @@ module.exports = Self => { JOIN alertLevel al ON al.id = ts.alertLevel JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id SET t.routeFk = NULL WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) AND al.code NOT IN ('DELIVERED', 'PACKED') + AND NOT t.packages + AND tob.id IS NULL AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); return { From dfde2f684650e045bde67d6617a94a071f901bd9 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 21 May 2024 13:28:05 +0200 Subject: [PATCH 089/110] evita facturacion proveedores --- db/routines/vn/procedures/ticketPackaging_add.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticketPackaging_add.sql b/db/routines/vn/procedures/ticketPackaging_add.sql index d669b95f5..f96068b56 100644 --- a/db/routines/vn/procedures/ticketPackaging_add.sql +++ b/db/routines/vn/procedures/ticketPackaging_add.sql @@ -27,7 +27,10 @@ BEGIN SELECT DISTINCT clientFk FROM ( SELECT clientFk, SUM(quantity) totalQuantity - FROM tmp.packagingToInvoice + FROM tmp.packagingToInvoice tpi + JOIN client c ON c.id = tpi.clientFk + LEFT JOIN supplier s ON s.nif = c.fi + WHERE s.id IS NULL GROUP BY itemFk, clientFk HAVING totalQuantity > 0)sub; From 18bb8a4ea558fc1a722bcd9b18c2a792ee1a63f1 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 May 2024 13:50:45 +0200 Subject: [PATCH 090/110] fix: checking process.env.NODE_ENV --- back/methods/chat/sendCheckingPresence.js | 2 +- back/methods/chat/sendQueued.js | 4 ++-- back/methods/dms/deleteTrashFiles.js | 2 +- back/methods/docuware/upload.js | 2 +- back/methods/image/scrub.js | 3 +-- back/methods/image/upload.js | 2 +- back/methods/notification/send.js | 2 +- loopback/common/methods/application/isProduction.js | 3 +++ loopback/common/models/application.js | 5 +++++ modules/account/back/models/ldap-config.js | 3 ++- modules/account/back/models/samba-config.js | 3 ++- modules/client/back/methods/sms/send.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/download.js | 2 +- modules/invoiceOut/back/models/invoice-out.js | 2 +- modules/mdb/back/methods/mdbVersion/upload.js | 2 +- 15 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 loopback/common/methods/application/isProduction.js diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 85b66e94b..12cadec04 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -37,7 +37,7 @@ module.exports = Self => { if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); - if (process.env.NODE_ENV == 'test') + if (!Self.app.models.Application.isProduction()) message = `[Test:Environment to user ${userId}] ` + message; const chat = await models.Chat.create({ diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index 9a23af379..1ab4cb6e0 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -94,7 +94,7 @@ module.exports = Self => { * @return {Promise} - The request promise */ Self.sendMessage = async function sendMessage(senderFk, recipient, message) { - if (process.env.NODE_ENV !== 'production') { + if (!Self.app.models.Application.isProduction()) { return new Promise(resolve => { return resolve({ statusCode: 200, @@ -149,7 +149,7 @@ module.exports = Self => { * @return {Promise} - The request promise */ Self.getUserStatus = async function getUserStatus(username) { - if (process.env.NODE_ENV !== 'production') { + if (!Self.app.models.Application.isProduction()) { return new Promise(resolve => { return resolve({ data: { diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js index 239d654ef..77e33929a 100644 --- a/back/methods/dms/deleteTrashFiles.js +++ b/back/methods/dms/deleteTrashFiles.js @@ -22,7 +22,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - if (process.env.NODE_ENV == 'test') + if (!Self.app.models.Application.isProduction()) throw new UserError(`Action not allowed on the test environment`); const models = Self.app.models; diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index 27be72295..ae3989def 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -119,7 +119,7 @@ module.exports = Self => { ] }; - if (process.env.NODE_ENV != 'production') + if (!Self.app.models.Application.isProduction(false)) throw new UserError('Action not allowed on the test environment'); // delete old diff --git a/back/methods/image/scrub.js b/back/methods/image/scrub.js index 99c6bcbf3..4af2d8d49 100644 --- a/back/methods/image/scrub.js +++ b/back/methods/image/scrub.js @@ -43,8 +43,7 @@ module.exports = Self => { Self.scrub = async function(collection, remove, limit, dryRun, skipLock) { const $ = Self.app.models; - const env = process.env.NODE_ENV; - dryRun = dryRun || (env && env !== 'production'); + dryRun = dryRun || !Self.app.models.Application.isProduction(false); const instance = await $.ImageCollection.findOne({ fields: ['id'], diff --git a/back/methods/image/upload.js b/back/methods/image/upload.js index 51da327f6..81d9759e6 100644 --- a/back/methods/image/upload.js +++ b/back/methods/image/upload.js @@ -41,7 +41,7 @@ module.exports = Self => { if (!hasWriteRole) throw new UserError(`You don't have enough privileges`); - if (process.env.NODE_ENV == 'test') + if (!Self.app.models.Application.isProduction()) throw new UserError(`Action not allowed on the test environment`); // Upload file to temporary path diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index b2748477d..4f8f436da 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -70,7 +70,7 @@ module.exports = Self => { const newParams = Object.assign({}, queueParams, sendParams); const email = new Email(queueName, newParams); - if (process.env.NODE_ENV != 'test') + if (Self.app.models.Application.isProduction()) await email.send(); await queue.updateAttribute('status', statusSent); diff --git a/loopback/common/methods/application/isProduction.js b/loopback/common/methods/application/isProduction.js new file mode 100644 index 000000000..9479b67af --- /dev/null +++ b/loopback/common/methods/application/isProduction.js @@ -0,0 +1,3 @@ +module.exports = (localAsProduction = true) => { + if ((!process.env.NODE_ENV && localAsProduction) || process.env.NODE_ENV == 'production') return true; +}; diff --git a/loopback/common/models/application.js b/loopback/common/models/application.js index 6bdc2c13a..70db17de2 100644 --- a/loopback/common/models/application.js +++ b/loopback/common/models/application.js @@ -1,3 +1,4 @@ +const isProductionFn = require('../methods/application/isProduction'); module.exports = function(Self) { require('../methods/application/status')(Self); @@ -6,4 +7,8 @@ module.exports = function(Self) { require('../methods/application/executeProc')(Self); require('../methods/application/executeFunc')(Self); require('../methods/application/getEnumValues')(Self); + + Self.isProduction = (localAsProduction = true) => { + return isProductionFn(localAsProduction); + }; }; diff --git a/modules/account/back/models/ldap-config.js b/modules/account/back/models/ldap-config.js index 89f0add48..4f5c0218d 100644 --- a/modules/account/back/models/ldap-config.js +++ b/modules/account/back/models/ldap-config.js @@ -3,9 +3,10 @@ const app = require('vn-loopback/server/server'); const ldap = require('../util/ldapjs-extra'); const crypto = require('crypto'); const nthash = require('smbhash').nthash; +const isProduction = require('vn-loopback/common/methods/application/isProduction'); module.exports = Self => { - const shouldSync = process.env.NODE_ENV !== 'test'; + const shouldSync = isProduction(); Self.getLinker = async function() { return await Self.findOne({ diff --git a/modules/account/back/models/samba-config.js b/modules/account/back/models/samba-config.js index 927510a29..aa68af35d 100644 --- a/modules/account/back/models/samba-config.js +++ b/modules/account/back/models/samba-config.js @@ -1,6 +1,7 @@ const ldap = require('../util/ldapjs-extra'); const execFile = require('child_process').execFile; +const isProduction = require('vn-loopback/common/methods/application/isProduction'); /** * Summary of userAccountControl flags: @@ -12,7 +13,7 @@ const UserAccountControlFlags = { }; module.exports = Self => { - const shouldSync = process.env.NODE_ENV !== 'test'; + const shouldSync = isProduction(); Self.getLinker = async function() { return await Self.findOne({ diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index 94b2b6c27..269dedacb 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -47,7 +47,7 @@ module.exports = Self => { let response; try { - if (process.env.NODE_ENV !== 'production') + if (!Self.app.models.Application.isProduction(false)) response = {result: [{status: 'ok'}]}; else { const jsonTest = { diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 748e2df17..5a9d5bc51 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -66,7 +66,7 @@ module.exports = Self => { console.error(err); }); - if (process.env.NODE_ENV == 'test') { + if (!Self.app.models.Application.isProduction()) { try { await fs.access(file.path); } catch (error) { diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index e4fcc1a69..166565fe2 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -59,7 +59,7 @@ module.exports = Self => { hasPdf: true }, options); - if (process.env.NODE_ENV !== 'test') { + if (Self.app.models.Application.isProduction()) { await print.storage.write(buffer, { type: 'invoice', path: pdfFile.path, diff --git a/modules/mdb/back/methods/mdbVersion/upload.js b/modules/mdb/back/methods/mdbVersion/upload.js index 58fc46abb..9edaf454f 100644 --- a/modules/mdb/back/methods/mdbVersion/upload.js +++ b/modules/mdb/back/methods/mdbVersion/upload.js @@ -111,7 +111,7 @@ module.exports = Self => { const destinationFile = path.join( accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`); - if (process.env.NODE_ENV == 'test') + if (!Self.app.models.Application.isProduction()) await fs.unlink(srcFile); else { await fs.move(srcFile, destinationFile, { From d8841920665fcf07e3c0eb63a9e5e81f953bebf8 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 May 2024 13:52:50 +0200 Subject: [PATCH 091/110] fix: checking process.env.NODE_ENV --- back/methods/chat/sendQueued.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index 1ab4cb6e0..ee1a82be2 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -94,7 +94,7 @@ module.exports = Self => { * @return {Promise} - The request promise */ Self.sendMessage = async function sendMessage(senderFk, recipient, message) { - if (!Self.app.models.Application.isProduction()) { + if (!Self.app.models.Application.isProduction(false)) { return new Promise(resolve => { return resolve({ statusCode: 200, @@ -149,7 +149,7 @@ module.exports = Self => { * @return {Promise} - The request promise */ Self.getUserStatus = async function getUserStatus(username) { - if (!Self.app.models.Application.isProduction()) { + if (!Self.app.models.Application.isProduction(false)) { return new Promise(resolve => { return resolve({ data: { From 1f2017c2727ce8e653e61124445735ea3436650f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 May 2024 14:03:13 +0200 Subject: [PATCH 092/110] fix: simplify --- loopback/common/methods/application/isProduction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/common/methods/application/isProduction.js b/loopback/common/methods/application/isProduction.js index 9479b67af..151afa9cb 100644 --- a/loopback/common/methods/application/isProduction.js +++ b/loopback/common/methods/application/isProduction.js @@ -1,3 +1,3 @@ module.exports = (localAsProduction = true) => { - if ((!process.env.NODE_ENV && localAsProduction) || process.env.NODE_ENV == 'production') return true; + return (!process.env.NODE_ENV && localAsProduction) || process.env.NODE_ENV == 'production'; }; From 2ffdce3c64753453d8b0f53fe0e34eb5efb2808d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 21 May 2024 14:40:42 +0200 Subject: [PATCH 093/110] refactor: refs #7398 Refactor and change ekt_scan --- db/routines/edi/procedures/ekt_scan.sql | 66 +++++++++++++------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/db/routines/edi/procedures/ekt_scan.sql b/db/routines/edi/procedures/ekt_scan.sql index b0b75a6a7..ccb9adf0a 100644 --- a/db/routines/edi/procedures/ekt_scan.sql +++ b/db/routines/edi/procedures/ekt_scan.sql @@ -23,42 +23,39 @@ BEGIN DECLARE vXtraLongAgj INT; DECLARE vDefaultKlo INT; - SELECT - ec.usefulAuctionLeftSegmentLength, - ec.standardBarcodeLength, - ec.floridayBarcodeLength, - ec.floramondoBarcodeLength, - ec.defaultKlo - INTO - vUsefulAuctionLeftSegmentLength, + SELECT usefulAuctionLeftSegmentLength, + standardBarcodeLength, + floridayBarcodeLength, + floramondoBarcodeLength, + defaultKlo + INTO vUsefulAuctionLeftSegmentLength, vStandardBarcodeLength, vFloridayBarcodeLength, vFloramondoBarcodeLength, vDefaultKlo - FROM edi.ektConfig ec; + FROM ektConfig; - DROP TEMPORARY TABLE IF EXISTS tmp.ekt; - CREATE TEMPORARY TABLE tmp.ekt + CREATE OR REPLACE TEMPORARY TABLE tmp.ekt ENGINE = MEMORY SELECT id ektFk FROM ekt LIMIT 0; - CASE + CASE WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e + FROM ektRecent e WHERE e.cps = vBarcode OR e.batchNumber = vBarcode; WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN INSERT INTO tmp.ekt SELECT e.id - FROM edi.ektRecent e + FROM ektRecent e WHERE e.pro = MID(vBarcode,2,6) - AND CAST(e.ptd AS SIGNED) = MID(vBarcode,8,5); + AND CAST(e.ptd AS SIGNED) = MID(vBarcode, 8, 5); ELSE - SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0'); + SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0'); SET vAuction = MID(vBarcode, 1, 3); SET vKlo = MID(vBarcode, 4, 2); SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3)); @@ -69,21 +66,25 @@ BEGIN -- Clásico de subasta -- Trade standard -- Trade que construye como la subasta - -- Trade como el anterior pero sin trade code + -- Trade como el anterior pero sin trade code INSERT INTO tmp.ekt SELECT id FROM ekt WHERE fec >= vFec - INTERVAL 1 DAY - AND (( - vKlo = vDefaultKlo + AND ( + (vKlo = vDefaultKlo AND (klo = vKlo OR klo IS NULL OR klo = 0) - AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)) - OR (klo = vKlo + AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj) + ) OR ( + klo = vKlo AND auction = vAuction - AND agj = vShortAgj) + AND agj = vShortAgj + ) OR ( + klo = auction -- No se si se refiere a esto + ) ) - ORDER BY agj DESC, fec DESC - LIMIT 1; + ORDER BY agj DESC, fec DESC + LIMIT 1; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; @@ -91,9 +92,11 @@ BEGIN IF NOT vIsFound THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e - WHERE e.batchNumber - = LEFT(vBarcode,vUsefulAuctionLeftSegmentLength) + FROM ektRecent e + WHERE e.batchNumber = LEFT( + vBarcode, + vUsefulAuctionLeftSegmentLength + ) AND e.batchNumber > 0; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; @@ -103,7 +106,7 @@ BEGIN IF NOT vIsFound THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e + FROM ektRecent e WHERE e.putOrderFk = vBarcode; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; @@ -113,9 +116,8 @@ BEGIN IF NOT vIsFound THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e - WHERE e.deliveryNumber - = MID(vBarcode, 4, 13) + FROM ektRecent e + WHERE e.deliveryNumber = MID(vBarcode, 4, 13) AND e.deliveryNumber > 0; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; @@ -124,7 +126,7 @@ BEGIN IF vIsFound THEN UPDATE ekt e - JOIN tmp.ekt t ON t.ektFk = e.id + JOIN tmp.ekt t ON t.ektFk = e.id SET e.scanned = TRUE; END IF; END$$ From ff33c926af40723cbb57ed05641deefe8c6c64f6 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 May 2024 15:11:32 +0200 Subject: [PATCH 094/110] fix: move to boot --- back/methods/chat/sendCheckingPresence.js | 4 +++- back/methods/chat/sendQueued.js | 6 ++++-- back/methods/dms/deleteTrashFiles.js | 3 ++- back/methods/docuware/upload.js | 3 ++- back/methods/image/scrub.js | 3 ++- back/methods/image/upload.js | 3 ++- back/methods/notification/send.js | 3 ++- loopback/common/models/application.js | 6 ------ .../methods/application => server/boot}/isProduction.js | 0 modules/account/back/models/ldap-config.js | 2 +- modules/account/back/models/samba-config.js | 2 +- modules/client/back/methods/sms/send.js | 3 ++- modules/invoiceOut/back/methods/invoiceOut/download.js | 3 ++- modules/invoiceOut/back/models/invoice-out.js | 3 ++- modules/mdb/back/methods/mdbVersion/upload.js | 3 ++- 15 files changed, 27 insertions(+), 20 deletions(-) rename loopback/{common/methods/application => server/boot}/isProduction.js (100%) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 12cadec04..7ab5d63fe 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -1,3 +1,5 @@ +const isProduction = require('vn-loopback/server/boot/isProduction'); + module.exports = Self => { Self.remoteMethodCtx('sendCheckingPresence', { description: 'Creates a message in the chat model checking the user status', @@ -37,7 +39,7 @@ module.exports = Self => { if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); - if (!Self.app.models.Application.isProduction()) + if (!isProduction()) message = `[Test:Environment to user ${userId}] ` + message; const chat = await models.Chat.create({ diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index ee1a82be2..abda2ddc1 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -1,4 +1,6 @@ const axios = require('axios'); +const isProduction = require('vn-loopback/server/boot/isProduction'); + module.exports = Self => { Self.remoteMethodCtx('sendQueued', { description: 'Send a RocketChat message', @@ -94,7 +96,7 @@ module.exports = Self => { * @return {Promise} - The request promise */ Self.sendMessage = async function sendMessage(senderFk, recipient, message) { - if (!Self.app.models.Application.isProduction(false)) { + if (!isProduction(false)) { return new Promise(resolve => { return resolve({ statusCode: 200, @@ -149,7 +151,7 @@ module.exports = Self => { * @return {Promise} - The request promise */ Self.getUserStatus = async function getUserStatus(username) { - if (!Self.app.models.Application.isProduction(false)) { + if (!isProduction(false)) { return new Promise(resolve => { return resolve({ data: { diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js index 77e33929a..e07f93c90 100644 --- a/back/methods/dms/deleteTrashFiles.js +++ b/back/methods/dms/deleteTrashFiles.js @@ -1,6 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); const fs = require('fs-extra'); const path = require('path'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethod('deleteTrashFiles', { @@ -22,7 +23,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - if (!Self.app.models.Application.isProduction()) + if (!isProduction()) throw new UserError(`Action not allowed on the test environment`); const models = Self.app.models; diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index ae3989def..0102911e0 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -1,5 +1,6 @@ const UserError = require('vn-loopback/util/user-error'); const axios = require('axios'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethodCtx('upload', { @@ -119,7 +120,7 @@ module.exports = Self => { ] }; - if (!Self.app.models.Application.isProduction(false)) + if (!isProduction(false)) throw new UserError('Action not allowed on the test environment'); // delete old diff --git a/back/methods/image/scrub.js b/back/methods/image/scrub.js index 4af2d8d49..3c83b3be7 100644 --- a/back/methods/image/scrub.js +++ b/back/methods/image/scrub.js @@ -1,6 +1,7 @@ const fs = require('fs-extra'); const path = require('path'); const UserError = require('vn-loopback/util/user-error'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethod('scrub', { @@ -43,7 +44,7 @@ module.exports = Self => { Self.scrub = async function(collection, remove, limit, dryRun, skipLock) { const $ = Self.app.models; - dryRun = dryRun || !Self.app.models.Application.isProduction(false); + dryRun = dryRun || !isProduction(false); const instance = await $.ImageCollection.findOne({ fields: ['id'], diff --git a/back/methods/image/upload.js b/back/methods/image/upload.js index 81d9759e6..b3cdfb88b 100644 --- a/back/methods/image/upload.js +++ b/back/methods/image/upload.js @@ -1,6 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); const fs = require('fs/promises'); const path = require('path'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethodCtx('upload', { @@ -41,7 +42,7 @@ module.exports = Self => { if (!hasWriteRole) throw new UserError(`You don't have enough privileges`); - if (!Self.app.models.Application.isProduction()) + if (!isProduction()) throw new UserError(`Action not allowed on the test environment`); // Upload file to temporary path diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index 4f8f436da..1bff7f686 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -1,4 +1,5 @@ const {Email} = require('vn-print'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethod('send', { @@ -70,7 +71,7 @@ module.exports = Self => { const newParams = Object.assign({}, queueParams, sendParams); const email = new Email(queueName, newParams); - if (Self.app.models.Application.isProduction()) + if (isProduction()) await email.send(); await queue.updateAttribute('status', statusSent); diff --git a/loopback/common/models/application.js b/loopback/common/models/application.js index 70db17de2..80c58ddc1 100644 --- a/loopback/common/models/application.js +++ b/loopback/common/models/application.js @@ -1,5 +1,3 @@ -const isProductionFn = require('../methods/application/isProduction'); - module.exports = function(Self) { require('../methods/application/status')(Self); require('../methods/application/post')(Self); @@ -7,8 +5,4 @@ module.exports = function(Self) { require('../methods/application/executeProc')(Self); require('../methods/application/executeFunc')(Self); require('../methods/application/getEnumValues')(Self); - - Self.isProduction = (localAsProduction = true) => { - return isProductionFn(localAsProduction); - }; }; diff --git a/loopback/common/methods/application/isProduction.js b/loopback/server/boot/isProduction.js similarity index 100% rename from loopback/common/methods/application/isProduction.js rename to loopback/server/boot/isProduction.js diff --git a/modules/account/back/models/ldap-config.js b/modules/account/back/models/ldap-config.js index 4f5c0218d..583ce084b 100644 --- a/modules/account/back/models/ldap-config.js +++ b/modules/account/back/models/ldap-config.js @@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server'); const ldap = require('../util/ldapjs-extra'); const crypto = require('crypto'); const nthash = require('smbhash').nthash; -const isProduction = require('vn-loopback/common/methods/application/isProduction'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { const shouldSync = isProduction(); diff --git a/modules/account/back/models/samba-config.js b/modules/account/back/models/samba-config.js index aa68af35d..359b4b187 100644 --- a/modules/account/back/models/samba-config.js +++ b/modules/account/back/models/samba-config.js @@ -1,7 +1,7 @@ const ldap = require('../util/ldapjs-extra'); const execFile = require('child_process').execFile; -const isProduction = require('vn-loopback/common/methods/application/isProduction'); +const isProduction = require('vn-loopback/server/boot/isProduction'); /** * Summary of userAccountControl flags: diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index 269dedacb..2b5674f86 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -1,5 +1,6 @@ const got = require('got'); const UserError = require('vn-loopback/util/user-error'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethod('send', { @@ -47,7 +48,7 @@ module.exports = Self => { let response; try { - if (!Self.app.models.Application.isProduction(false)) + if (!isProduction(false)) response = {result: [{status: 'ok'}]}; else { const jsonTest = { diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 5a9d5bc51..f8d42072c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -1,5 +1,6 @@ const fs = require('fs-extra'); const path = require('path'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethodCtx('download', { @@ -66,7 +67,7 @@ module.exports = Self => { console.error(err); }); - if (!Self.app.models.Application.isProduction()) { + if (!isProduction()) { try { await fs.access(file.path); } catch (error) { diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index 166565fe2..b0e05b626 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -1,6 +1,7 @@ const print = require('vn-print'); const path = require('path'); const UserError = require('vn-loopback/util/user-error'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { require('../methods/invoiceOut/filter')(Self); @@ -59,7 +60,7 @@ module.exports = Self => { hasPdf: true }, options); - if (Self.app.models.Application.isProduction()) { + if (isProduction()) { await print.storage.write(buffer, { type: 'invoice', path: pdfFile.path, diff --git a/modules/mdb/back/methods/mdbVersion/upload.js b/modules/mdb/back/methods/mdbVersion/upload.js index 9edaf454f..64de72679 100644 --- a/modules/mdb/back/methods/mdbVersion/upload.js +++ b/modules/mdb/back/methods/mdbVersion/upload.js @@ -1,6 +1,7 @@ const fs = require('fs-extra'); const path = require('path'); const UserError = require('vn-loopback/util/user-error'); +const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.remoteMethodCtx('upload', { @@ -111,7 +112,7 @@ module.exports = Self => { const destinationFile = path.join( accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`); - if (!Self.app.models.Application.isProduction()) + if (!isProduction()) await fs.unlink(srcFile); else { await fs.move(srcFile, destinationFile, { From 365e5a3ba365a24ef4e2460b7aa24d66d5d670c5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 21 May 2024 17:31:29 +0200 Subject: [PATCH 095/110] fix: refs # 7400 ledger_next --- db/dump/fixtures.before.sql | 31 +++-- .../procedures/tpvTransaction_confirm.sql | 2 +- db/routines/vn/functions/till_new.sql | 110 +++++++++--------- db/routines/vn/functions/xdiario_new.sql | 45 ------- db/routines/vn/procedures/ledger_next.sql | 52 ++++++++- db/routines/vn/procedures/xdiario_new.sql | 64 ++++++++++ .../back/methods/client/createReceipt.js | 10 +- 7 files changed, 189 insertions(+), 125 deletions(-) delete mode 100644 db/routines/vn/functions/xdiario_new.sql create mode 100644 db/routines/vn/procedures/xdiario_new.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 3e6edf07d..b8094471a 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2549,18 +2549,18 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV (7, 7, 1.00, 1.00, 1.00), (8, 8, 1.00, 1.00, 1.00); -REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) +REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`, `bookEntried`) VALUES - (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1), - (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1), - (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1), - (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1), - (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1), - (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1), - (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1), - (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1), - (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1), - (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1); + (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1,util.VN_CURDATE()), + (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1,util.VN_CURDATE()), + (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1,util.VN_CURDATE()), + (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1,util.VN_CURDATE()), + (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1,util.VN_CURDATE()), + (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1,util.VN_CURDATE()), + (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1,util.VN_CURDATE()), + (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1,util.VN_CURDATE()), + (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()), + (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE()); INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`) VALUES @@ -3791,4 +3791,11 @@ INSERT INTO vn.workerTeam(id, team, workerFk) INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); -UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; \ No newline at end of file +UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; + +INSERT INTO `vn`.`ledgerCompany` SET + fiscalYear = YEAR(util.VN_CURDATE()), + bookEntry = 2; + +INSERT INTO `vn`.`ledgerConfig` SET + maxTolerance = 0.01; diff --git a/db/routines/hedera/procedures/tpvTransaction_confirm.sql b/db/routines/hedera/procedures/tpvTransaction_confirm.sql index e4a8c932f..60a6d8452 100644 --- a/db/routines/hedera/procedures/tpvTransaction_confirm.sql +++ b/db/routines/hedera/procedures/tpvTransaction_confirm.sql @@ -81,7 +81,7 @@ BEGIN -- Código redundante - DO vn.till_new( + CALL vn.till_new( vCustomer ,vBank ,vAmount / 100 diff --git a/db/routines/vn/functions/till_new.sql b/db/routines/vn/functions/till_new.sql index 24f4f2b79..b93072596 100644 --- a/db/routines/vn/functions/till_new.sql +++ b/db/routines/vn/functions/till_new.sql @@ -1,79 +1,73 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`till_new`(vClient INT - ,vBank INT - ,vAmount DOUBLE - ,vConcept VARCHAR(25) - ,vDated DATE - ,vSerie CHAR(1) - ,vBatch TINYINT - ,vNumber INT - ,vCompany SMALLINT - ,vWorker INT +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`till_new`( + vClient INT, + vBank INT, + vAmount DOUBLE, + vConcept VARCHAR(25), + vDated DATE, + vSerie CHAR(1), + vBatch TINYINT, + vNumber INT, + vCompany SMALLINT, + vWorker INT ) - RETURNS int(11) - DETERMINISTIC BEGIN DECLARE vAccount VARCHAR(12); DECLARE vSubaccount VARCHAR(12); DECLARE vAsiento INT DEFAULT NULL; -- Inserta el registro en cajas - INSERT INTO till SET - workerFk = vWorker - ,bankFk = vBank - ,`in` = vAmount - ,concept = vConcept - ,dated = vDated - ,serie = vSerie - ,isAccountable = vBatch - ,`number` = vNumber - ,companyFk = vCompany; + workerFk = vWorker, + bankFk = vBank, + `in` = vAmount, + concept = vConcept, + dated = vDated, + serie = vSerie, + isAccountable = vBatch, + `number` = vNumber, + companyFk = vCompany; -- Inserta los asientos contables - SELECT account INTO vAccount FROM accounting WHERE id = vBank; SELECT accountingAccount INTO vSubaccount FROM `client` WHERE id = vClient; - SET vAsiento = xdiario_new - ( - vAsiento - ,vDated - ,vAccount - ,vSubaccount - ,vConcept - ,vAmount - ,0 - ,0 - ,NULL -- Serie - ,NULL -- Factura - ,NULL -- IVA - ,NULL -- Recargo - ,FALSE -- Auxiliar - ,vCompany - ); - DO xdiario_new - ( - vAsiento - ,vDated - ,vSubaccount - ,vAccount - ,vConcept - ,0 - ,vAmount - ,0 - ,NULL -- Serie - ,NULL -- Factura - ,NULL -- IVA - ,NULL -- Recargo - ,FALSE -- Auxiliar - ,vCompany - ); + CALL xdiario_new( + vAsiento, + vDated, + vAccount, + vSubaccount, + vConcept, + vAmount, + 0, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); - RETURN NULL; + CALL xdiario_new( + vAsiento, + vDated, + vSubaccount, + vAccount, + vConcept, + 0, + vAmount, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); END$$ DELIMITER ; diff --git a/db/routines/vn/functions/xdiario_new.sql b/db/routines/vn/functions/xdiario_new.sql deleted file mode 100644 index 4f4b3f3fd..000000000 --- a/db/routines/vn/functions/xdiario_new.sql +++ /dev/null @@ -1,45 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`( - vBookNumber INT, - vDated DATE, - vSubaccount VARCHAR(12), - vAccount VARCHAR(12), - vConcept VARCHAR(25), - vDebit DOUBLE, - vCredit DOUBLE, - vEuro DOUBLE, - vSerie CHAR(1), - vInvoice VARCHAR(8), - vVat DOUBLE, - vRe DOUBLE, - vAux TINYINT, - vCompanyFk INT -) - RETURNS int(11) - NOT DETERMINISTIC - NO SQL -BEGIN - IF vBookNumber IS NULL THEN - CALL ledger_next(YEAR(vDated), vBookNumber); - END IF; - - INSERT INTO XDiario - SET ASIEN = vBookNumber, - FECHA = vDated, - SUBCTA = vSubaccount, - CONTRA = vAccount, - CONCEPTO = vConcept, - EURODEBE = vDebit, - EUROHABER = vCredit, - BASEEURO = vEuro, - SERIE = vSerie, - FACTURA = vInvoice, - IVA = vVat, - RECEQUIV = vRe, - AUXILIAR = IF(vAux = FALSE, NULL, '*'), - MONEDAUSO = 2, - empresa_id = vCompanyFk; - - RETURN vBookNumber; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ledger_next.sql b/db/routines/vn/procedures/ledger_next.sql index 5cde90def..dccce3a76 100644 --- a/db/routines/vn/procedures/ledger_next.sql +++ b/db/routines/vn/procedures/ledger_next.sql @@ -1,13 +1,55 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( IN vFiscalYear INT, - OUT vNewBookEntry INT + OUT vLastBookEntry INT ) BEGIN - UPDATE ledgerCompany - SET bookEntry = LAST_INSERT_ID(bookEntry + 1) + DECLARE vHasStartTransaction BOOLEAN; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + + IF vHasStartTransaction THEN + ROLLBACK TO sp; + RESIGNAL; + ELSE + ROLLBACK; + CALL util.throw ('It has not been possible to generate a new ledger'); + END IF; + END; + + IF vFiscalYear IS NULL THEN + CALL util.throw('Fiscal year is required'); + END IF; + + SELECT @@in_transaction INTO vHasStartTransaction; + + IF NOT vHasStartTransaction THEN + START TRANSACTION; + ELSE + SAVEPOINT sp; + END IF; + + SELECT bookEntry + 1 INTO vLastBookEntry + FROM ledgerCompany + WHERE fiscalYear = vFiscalYear + FOR UPDATE; + + IF vLastBookEntry IS NULL THEN + INSERT INTO ledgerCompany + SET fiscalYear = vFiscalYear, + bookEntry = 1; + SET vLastBookEntry = 1; + END IF; + + UPDATE ledgerCompany + SET bookEntry = vLastBookEntry WHERE fiscalYear = vFiscalYear; - SET vNewBookEntry = LAST_INSERT_ID(); + IF vHasStartTransaction THEN + RELEASE SAVEPOINT sp; + ELSE + COMMIT; + END IF; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/xdiario_new.sql b/db/routines/vn/procedures/xdiario_new.sql new file mode 100644 index 000000000..8204f4652 --- /dev/null +++ b/db/routines/vn/procedures/xdiario_new.sql @@ -0,0 +1,64 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`( + vBookNumber INT, + vDated DATE, + vSubaccount VARCHAR(12), + vAccount VARCHAR(12), + vConcept VARCHAR(25), + vDebit DOUBLE, + vCredit DOUBLE, + vEuro DOUBLE, + vSerie CHAR(1), + vInvoice VARCHAR(8), + vVat DOUBLE, + vRe DOUBLE, + vAux TINYINT, + vCompanyFk INT, + OUT vNewBookNumber INT +) +/** + * Este procedimiento se encarga de la inserción de registros en la tabla XDiario. + * Si el número de asiento (vBookNumber) no está definido, se genera uno nuevo utilizando + * vn.ledger_next. + * + * @param vBookNumber Número de asiento. Si es NULL, se generará uno nuevo. + * @param vDated Fecha utilizada para generar un nuevo número de libro si vBookNumber es NULL. + * @param vSubaccount Subcuenta para la transacción. + * @param vAccount Cuenta para la transacción. + * @param vConcept Concepto de la transacción. + * @param vDebit Monto del débito para la transacción. + * @param vCredit Monto del crédito para la transacción. + * @param vEuro Monto en euros para la transacción. + * @param vSerie Serie para la transacción. + * @param vInvoice Número de factura para la transacción. + * @param vVat Monto del IVA para la transacción. + * @param vRe Monto del RE para la transacción. + * @param vAux Variable auxiliar para la transacción. + * @param vCompanyFk Clave foránea de la compañía para la transacción. + * @return No retorna un valor, pero realiza una inserción en la tabla XDiario. + */ +BEGIN + IF vBookNumber IS NULL THEN + CALL ledger_next(YEAR(vDated), vBookNumber); + END IF; + + INSERT INTO XDiario + SET ASIEN = vBookNumber, + FECHA = vDated, + SUBCTA = vSubaccount, + CONTRA = vAccount, + CONCEPTO = vConcept, + EURODEBE = vDebit, + EUROHABER = vCredit, + BASEEURO = vEuro, + SERIE = vSerie, + FACTURA = vInvoice, + IVA = vVat, + RECEQUIV = vRe, + AUXILIAR = IF(vAux = FALSE, NULL, '*'), + MONEDAUSO = 2, + empresa_id = vCompanyFk; + + SET vNewBookNumber = vBookNumber; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/modules/client/back/methods/client/createReceipt.js b/modules/client/back/methods/client/createReceipt.js index e2a57272b..23570baf2 100644 --- a/modules/client/back/methods/client/createReceipt.js +++ b/modules/client/back/methods/client/createReceipt.js @@ -95,9 +95,11 @@ module.exports = function(Self) { myOptions ); } else if (accountingType.isAutoConciliated == true) { - const description = `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`; - const [xdiarioNew] = await Self.rawSql( - `SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`, + const description = + `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`; + const [, [xdiarioNew]] = await Self.rawSql( + `CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew); + SELECT @xdiarioNew ledger;`, [ null, date, @@ -118,7 +120,7 @@ module.exports = function(Self) { ); await Self.rawSql( - `SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`, + `CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew);`, [ xdiarioNew.ledger, date, From 2142b78deba30e7587e0b3af598d987eb9c62c5b Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 21 May 2024 19:25:18 +0200 Subject: [PATCH 096/110] feat: refs #7187 Add support for multiple PDAs per user --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 5 +++-- modules/worker/back/models/device-production-user.js | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 601a26f5b..551b544b6 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -226,5 +226,6 @@ "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", "They're not your subordinate": "They're not your subordinate", "InvoiceIn is already booked": "InvoiceIn is already booked", - "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", + "You can only have one PDA": "You can only have one PDA" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 77e707590..4a7e1505c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -357,6 +357,7 @@ "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", - "This PDA is already assigned to another user": "This PDA is already assigned to another user", - "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" + "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", + "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", + "You can only have one PDA": "Solo puedes tener un PDA" } \ No newline at end of file diff --git a/modules/worker/back/models/device-production-user.js b/modules/worker/back/models/device-production-user.js index 81af484d3..692a804f0 100644 --- a/modules/worker/back/models/device-production-user.js +++ b/modules/worker/back/models/device-production-user.js @@ -3,6 +3,9 @@ module.exports = Self => { Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`This PDA is already assigned to another user`); + + if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA') + return new UserError(`You can only have one active PDA`); return err; }); }; From 0d620c6f33cb061abbf3f9aa6efd03b80ea11c7d Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 22 May 2024 08:11:27 +0200 Subject: [PATCH 097/110] feat: refs #7398 Change --- db/routines/edi/procedures/ekt_scan.sql | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/db/routines/edi/procedures/ekt_scan.sql b/db/routines/edi/procedures/ekt_scan.sql index ccb9adf0a..0cf8bb466 100644 --- a/db/routines/edi/procedures/ekt_scan.sql +++ b/db/routines/edi/procedures/ekt_scan.sql @@ -79,8 +79,6 @@ BEGIN klo = vKlo AND auction = vAuction AND agj = vShortAgj - ) OR ( - klo = auction -- No se si se refiere a esto ) ) ORDER BY agj DESC, fec DESC @@ -122,6 +120,17 @@ BEGIN SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; END IF; + + -- Solo campo agj + IF NOT vIsFound THEN + INSERT INTO tmp.ekt + SELECT id + FROM ektRecent + WHERE agj = vShortAgj; + + SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; + END IF; + END CASE; IF vIsFound THEN From bc6af32962a17c26d9df113a4cb8a3482105c41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 22 May 2024 14:50:45 +0200 Subject: [PATCH 098/110] fix: problems in colums ticket and sale refs #7213 --- .../sale_setProblemComponentLackByComponent.sql | 15 +++++++++------ .../vn/procedures/sale_setProblemRounding.sql | 6 +++--- .../vn/procedures/ticket_setProblemFreeze.sql | 2 +- .../vn/procedures/ticket_setProblemRisk.sql | 2 +- .../vn/procedures/ticket_setProblemRounding.sql | 6 +++--- .../ticket_setProblemTooLittleItemCost.sql | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql index 895598e84..62db0d9cf 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql @@ -12,12 +12,15 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk)) ENGINE = MEMORY - SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - WHERE t.shipped >= util.midnight() - AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk); + SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem + FROM ( + SELECT s.id saleFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + WHERE t.shipped >= util.midnight() + AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk) + GROUP BY s.id) sub; CALL sale_setProblem('hasComponentLack'); diff --git a/db/routines/vn/procedures/sale_setProblemRounding.sql b/db/routines/vn/procedures/sale_setProblemRounding.sql index 366fbf8fd..f14cd408f 100644 --- a/db/routines/vn/procedures/sale_setProblemRounding.sql +++ b/db/routines/vn/procedures/sale_setProblemRounding.sql @@ -20,15 +20,15 @@ BEGIN CALL buyUltimate(vWarehouseFk, vShipped); - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem FROM tmp.buyUltimate bu JOIN buy b ON b.id = bu.buyFk WHERE bu.itemFk = vItemFk; CALL sale_setProblem('hasRounding'); - DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.buyUltimate; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemFreeze.sql b/db/routines/vn/procedures/ticket_setProblemFreeze.sql index bdb32b3fe..2a5d67b0d 100644 --- a/db/routines/vn/procedures/ticket_setProblemFreeze.sql +++ b/db/routines/vn/procedures/ticket_setProblemFreeze.sql @@ -22,7 +22,7 @@ BEGIN SET t.hasProblem = TRUE WHERE c.isFreezed; - CALL ticket_setProblem('hasTicketRequest'); + CALL ticket_setProblem('isFreezed'); DROP TEMPORARY TABLE tmp.ticket; END$$ diff --git a/db/routines/vn/procedures/ticket_setProblemRisk.sql b/db/routines/vn/procedures/ticket_setProblemRisk.sql index 7c499f5ba..5f73ee838 100644 --- a/db/routines/vn/procedures/ticket_setProblemRisk.sql +++ b/db/routines/vn/procedures/ticket_setProblemRisk.sql @@ -19,7 +19,7 @@ BEGIN WHERE t.id = vSelf; CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf ticketFk, vRisk hasProblem; + SELECT vSelf ticketFk, vHasRisk hasProblem; CALL ticket_setProblem('hasRisk'); diff --git a/db/routines/vn/procedures/ticket_setProblemRounding.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql index 272a48151..81294325c 100644 --- a/db/routines/vn/procedures/ticket_setProblemRounding.sql +++ b/db/routines/vn/procedures/ticket_setProblemRounding.sql @@ -18,17 +18,17 @@ BEGIN CALL buyUltimate(vWarehouseFk, vDated); - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + CREATE OR REPLACE TEMPORARY TABLE tmp.sale SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem FROM ticket t - JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN sale s ON s.ticketFk = t.id JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN buy b ON b.id = bu.buyFk WHERE t.id = vSelf; CALL sale_setProblem('hasRounding'); - DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.buyUltimate; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql index 9a7852ac5..4403292fc 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql @@ -15,7 +15,7 @@ BEGIN WITH tickets AS( SELECT t.id ticketFk FROM vn.ticket t - JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.sale s ON s.ticketFk = t.id WHERE t.shipped >= util.midnight() AND (s.itemFk = vItemFk OR vItemFk IS NULL) GROUP BY t.id From 4dee90ff57ff0e6283bb2d622eb4e4fea34a39aa Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 22 May 2024 14:56:46 +0200 Subject: [PATCH 099/110] refs #6820 fix pr --- back/models/routeConfig.json | 3 --- db/versions/11059-crimsonAnthurium/00-firstScript.sql | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/back/models/routeConfig.json b/back/models/routeConfig.json index 28adbe756..f3d929749 100644 --- a/back/models/routeConfig.json +++ b/back/models/routeConfig.json @@ -1,9 +1,6 @@ { "name": "RouteConfig", "base": "VnModel", - "mixins": { - "Loggable": true - }, "options": { "mysql": { "table": "routeConfig" diff --git a/db/versions/11059-crimsonAnthurium/00-firstScript.sql b/db/versions/11059-crimsonAnthurium/00-firstScript.sql index 7fe3e01ca..b0eade302 100644 --- a/db/versions/11059-crimsonAnthurium/00-firstScript.sql +++ b/db/versions/11059-crimsonAnthurium/00-firstScript.sql @@ -1,3 +1,3 @@ -- Place your SQL code here INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('RouteConfig','*','*','ALLOW','ROLE','employee'); + VALUES ('RouteConfig','*','READ','ALLOW','ROLE','employee'); From 56aec1c781fbdb889e82fdab8f8075dd703915bc Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 23 May 2024 09:44:18 +0200 Subject: [PATCH 100/110] refs #7440 Optimized item_comparative --- .../vn/procedures/item_comparative.sql | 134 +++++++++--------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/db/routines/vn/procedures/item_comparative.sql b/db/routines/vn/procedures/item_comparative.sql index e72188363..430f84756 100644 --- a/db/routines/vn/procedures/item_comparative.sql +++ b/db/routines/vn/procedures/item_comparative.sql @@ -6,23 +6,23 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`( vAvailableSince DATE, vBuyerFk INT, vIsFloramondo BOOL, - vCountryFk INT + vCountryFk INT ) proc: BEGIN /** - * Genera una tabla de comparativa de artículos por itemType/comprador/fecha. - * Los datos se calculan en función de los parámetros proporcionados. - * - * @param vDate La fecha para la cual se generará la comparativa. - * @param vDayRange El rango de días a considerar para la comparativa. - * @param vWarehouseFk El identificador del almacén para filtrar los artículos. - * @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. - * @param vBuyerFk El identificador del comprador para filtrar los artículos. - * @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). - * @param vCountryFk El identificador del país. - * @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) - * @return tmp.comparative - */ +* Genera una tabla de comparativa de artículos por itemType/comprador/fecha. +* Los datos se calculan en función de los parámetros proporcionados. +* +* @param vDate La fecha para la cual se generará la comparativa. +* @param vDayRange El rango de días a considerar para la comparativa. +* @param vWarehouseFk El identificador del almacén para filtrar los artículos. +* @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. +* @param vBuyerFk El identificador del comprador para filtrar los artículos. +* @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). +* @param vCountryFk El identificador del país. +* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) +* @return tmp.comparative +*/ DECLARE vDayRangeStart DATE; DECLARE vDayRangeEnd DATE; @@ -59,14 +59,14 @@ proc: BEGIN END IF; SELECT MIN(dated) INTO vDayRangeStart - FROM vn.time + FROM `time` WHERE dated <= vDate GROUP BY period ORDER BY dated desc LIMIT 1 OFFSET vWeekRange; SELECT MAX(dated) INTO vDayRangeEnd - FROM vn.time + FROM `time` WHERE dated >= vDate GROUP BY period ORDER BY dated ASC @@ -83,12 +83,11 @@ proc: BEGIN JOIN itemType t ON t.id = i.typeFk JOIN itemCategory c ON c.id = t.categoryFk LEFT JOIN worker w ON w.id = t.workerFk - WHERE (NOT vHasTypeFilter - OR t.id IN (SELECT itemTypeFk FROM tmp.comparativeFilterType)) - AND (vBuyerFk IS NULL - OR t.workerFk = vBuyerFk) - AND (vIsFloramondo IS NULL - OR i.isFloramondo = vIsFloramondo); + WHERE (NOT vHasTypeFilter OR t.id IN ( + SELECT itemTypeFk FROM tmp.comparativeFilterType + )) + AND (vBuyerFk IS NULL OR t.workerFk = vBuyerFk) + AND (vIsFloramondo IS NULL OR i.isFloramondo = vIsFloramondo); IF vDate < util.VN_CURDATE() THEN ALTER TABLE tmp.itemInventory @@ -115,10 +114,11 @@ proc: BEGIN SET i = i + 1; SELECT t.period INTO vPeriod - FROM vn.`time` t + FROM `time` t WHERE t.dated = vDayRangeStart + INTERVAL (vWeekCount * (i - 1)) DAY; - INSERT IGNORE INTO tTable(cy, ly, zy) VALUES(vPeriod, vPeriod - 100, vPeriod - 200); + INSERT IGNORE INTO tTable(cy, ly, zy) + VALUES(vPeriod, vPeriod - 100, vPeriod - 200); UNTIL i = vWeekCount END REPEAT; SELECT cy, ly, zy INTO w1, y1, z1 FROM tTable LIMIT 1; @@ -130,7 +130,6 @@ proc: BEGIN SELECT cy, ly, zy INTO w7, y7, z7 FROM tTable WHERE cy > w6 LIMIT 1; -- Genera una tabla con los datos del año pasado. - CREATE OR REPLACE TEMPORARY TABLE tLastYear (KEY (lItemFk)) ENGINE = MEMORY @@ -153,13 +152,12 @@ proc: BEGIN JOIN comparative c ON c.itemFk = ai.id JOIN warehouse w on w.id = c.warehouseFk JOIN tTable wt ON c.timePeriod = wt.ly - WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk + WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk) AND w.isComparative AND (vCountryFk IS NULL OR c.countryFk = vCountryFk) GROUP BY ai.id; -- Genera una tabla con los datos de hace DOS años. - CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo (KEY (tItemFk)) ENGINE = MEMORY @@ -182,71 +180,70 @@ proc: BEGIN JOIN comparative c ON c.itemFk = ai.id JOIN warehouse w on w.id = c.warehouseFk JOIN tTable wt ON c.timePeriod = wt.zy - WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk + WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk) AND w.isComparative AND (vCountryFk IS NULL OR c.countryFk = vCountryFk) GROUP BY ai.id; - -- Genera una tabla con los datos de este año.ss - + -- Genera una tabla con los datos de este año CREATE OR REPLACE TEMPORARY TABLE tCurrentYear (KEY (cItemFk)) ENGINE = MEMORY SELECT t.itemFk cItemFk, - SUM(IF(week = w1, total, 0)) cweek1, - SUM(IF(week = w2, total, 0)) cweek2, - SUM(IF(week = w3, total, 0)) cweek3, - SUM(IF(week = w4, total, 0)) cweek4, - SUM(IF(week = w5, total, 0)) cweek5, - SUM(IF(week = w6, total, 0)) cweek6, - SUM(IF(week = w7, total, 0)) cweek7, - SUM(IF(week = w1, price, 0)) cprice1, - SUM(IF(week = w2, price, 0)) cprice2, - SUM(IF(week = w3, price, 0)) cprice3, - SUM(IF(week = w4, price, 0)) cprice4, - SUM(IF(week = w5, price, 0)) cprice5, - SUM(IF(week = w6, price, 0)) cprice6, - SUM(IF(week = w7, price, 0)) cprice7 + SUM(IF(`week` = w1, total, 0)) cweek1, + SUM(IF(`week` = w2, total, 0)) cweek2, + SUM(IF(`week` = w3, total, 0)) cweek3, + SUM(IF(`week` = w4, total, 0)) cweek4, + SUM(IF(`week` = w5, total, 0)) cweek5, + SUM(IF(`week` = w6, total, 0)) cweek6, + SUM(IF(`week` = w7, total, 0)) cweek7, + SUM(IF(`week` = w1, price, 0)) cprice1, + SUM(IF(`week` = w2, price, 0)) cprice2, + SUM(IF(`week` = w3, price, 0)) cprice3, + SUM(IF(`week` = w4, price, 0)) cprice4, + SUM(IF(`week` = w5, price, 0)) cprice5, + SUM(IF(`week` = w6, price, 0)) cprice6, + SUM(IF(`week` = w7, price, 0)) cprice7 FROM ( SELECT s.itemFk, ti.period `week`, SUM(s.quantity) total, - TRUNCATE(SUM(s.quantity * s.priceFixed),0) price - FROM ticket t + TRUNCATE(SUM(s.quantity * s.priceFixed), 0) price + FROM ticket t FORCE INDEX (Fecha) JOIN sale s ON t.id = s.ticketFk - JOIN tmp.itemInventory it ON it.id = s.itemFk - JOIN time ti ON ti.dated = DATE(t.shipped) + JOIN tmp.itemInventory it ON it.id = s.itemFk + JOIN `time` ti ON ti.dated = DATE(t.shipped) JOIN item i ON i.id = s.itemFk JOIN itemType tp ON tp.id = i.typeFk JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN warehouse w ON w.id = t.warehouseFk - STRAIGHT_JOIN address ad ON ad.id = t.addressFk - JOIN province p ON p.id = ad.provinceFk + JOIN `address` ad ON ad.id = t.addressFk + JOIN province p ON p.id = ad.provinceFk JOIN `client` c ON c.id = ad.clientFk WHERE t.shipped BETWEEN vDayRangeStart AND util.dayEnd(vDayRangeEnd) - AND c.typeFk IN ('Normal','handMaking') - AND w.id = COALESCE(vWarehouseFk, w.id) + AND c.typeFk IN ('normal', 'handMaking') + AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id) + AND (vCountryFk IS NULL OR p.countryFk = vCountryFk) AND w.isComparative - AND (vCountryFk IS NULL OR p.countryFk = vCountryFk) - GROUP BY i.id, week + GROUP BY i.id, `week` ) t GROUP BY t.itemFk; -- Genera la tabla con la comparativa. CREATE OR REPLACE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY - SELECT it.subName productor, - b.packing, + SELECT it.subName productor, + b.packing, b.buyingValue costefijo, b.groupingMode caja, it.image ArticleImage, - IFNULL(it.inkFk,"?") color, + IFNULL(it.inkFk, '?') color, tp.code tipo, it.typeFk tipo_id, o.code origen, it.category categoria, it.stems tallos, - it.size medida, + it.`size` medida, it.name article, w.code codigoTrabajador, tp.categoryFk reino_id, @@ -257,24 +254,27 @@ proc: BEGIN it.id Id_Article, i.buy_id, tp.life, - IFNULL(i.sd,0) sd, + IFNULL(i.sd, 0) sd, i.avalaible, i.visible, i.buy_date, e.id provider_id, it.comment comments, it.description itemDescription, - IF(cy.cItemFk IS NULL AND i.visible = 0 AND i.avalaible = 0 - AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) filtret, + IF(cy.cItemFk IS NULL AND i.visible = 0 + AND i.avalaible = 0 AND (i.sd IS NULL OR i.sd = 0), + FALSE, + TRUE + ) filtret, IF(it.hasMinPrice, FORMAT(it.minPrice, 2), "") pvp, s.company_name FROM tmp.itemInventory i JOIN item it ON it.id = i.id - LEFT JOIN itemType tp ON tp.id = it.typeFk - LEFT JOIN worker w ON w.id = tp.workerFk + JOIN itemType tp ON tp.id = it.typeFk + JOIN worker w ON w.id = tp.workerFk LEFT JOIN buy b ON b.id = i.buy_id - LEFT JOIN entry e ON e.id = b.entryFk - LEFT JOIN origin o ON o.id = it.originFk + LEFT JOIN `entry` e ON e.id = b.entryFk + JOIN origin o ON o.id = it.originFk LEFT JOIN tLastYear ly ON ly.lItemFk = it.id LEFT JOIN tCurrentYear cy ON cy.cItemFk = it.id LEFT JOIN tTwoYearsAgo zy ON zy.tItemFk = it.id @@ -287,8 +287,8 @@ proc: BEGIN OR ly.lweek1 OR ly.lweek2 OR ly.lweek3 OR ly.lweek4 OR ly.lweek5 OR ly.lweek6 OR ly.lweek7 OR zy.vlweek1 OR zy.vlweek2 OR zy.vlweek3 OR zy.vlweek4 OR zy.vlweek5 OR zy.vlweek6 OR zy.vlweek7; - -- Elimina las tablas temporales creadas... - DROP TEMPORARY TABLE IF EXISTS tmp.itemInventory, + DROP TEMPORARY TABLE IF EXISTS + tmp.itemInventory, tTwoYearsAgo, tLastYear, tCurrentYear, From bbd948c6545a1af1ad3e7d80d87d961cdabbbd94 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 23 May 2024 09:47:14 +0200 Subject: [PATCH 101/110] refs #7440 Minor change --- .../vn/procedures/item_comparative.sql | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/db/routines/vn/procedures/item_comparative.sql b/db/routines/vn/procedures/item_comparative.sql index 430f84756..d429cf009 100644 --- a/db/routines/vn/procedures/item_comparative.sql +++ b/db/routines/vn/procedures/item_comparative.sql @@ -10,20 +10,19 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`( ) proc: BEGIN /** -* Genera una tabla de comparativa de artículos por itemType/comprador/fecha. -* Los datos se calculan en función de los parámetros proporcionados. -* -* @param vDate La fecha para la cual se generará la comparativa. -* @param vDayRange El rango de días a considerar para la comparativa. -* @param vWarehouseFk El identificador del almacén para filtrar los artículos. -* @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. -* @param vBuyerFk El identificador del comprador para filtrar los artículos. -* @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). -* @param vCountryFk El identificador del país. -* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) -* @return tmp.comparative -*/ - + * Genera una tabla de comparativa de artículos por itemType/comprador/fecha. + * Los datos se calculan en función de los parámetros proporcionados. + * + * @param vDate La fecha para la cual se generará la comparativa. + * @param vDayRange El rango de días a considerar para la comparativa. + * @param vWarehouseFk El identificador del almacén para filtrar los artículos. + * @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. + * @param vBuyerFk El identificador del comprador para filtrar los artículos. + * @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). + * @param vCountryFk El identificador del país. + * @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) + * @return tmp.comparative + */ DECLARE vDayRangeStart DATE; DECLARE vDayRangeEnd DATE; DECLARE w1, w2, w3, w4, w5, w6, w7 INT; @@ -150,14 +149,14 @@ proc: BEGIN SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7 FROM tmp.itemInventory ai JOIN comparative c ON c.itemFk = ai.id - JOIN warehouse w on w.id = c.warehouseFk + JOIN warehouse w ON w.id = c.warehouseFk JOIN tTable wt ON c.timePeriod = wt.ly WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk) AND w.isComparative AND (vCountryFk IS NULL OR c.countryFk = vCountryFk) GROUP BY ai.id; - -- Genera una tabla con los datos de hace DOS años. + -- Genera una tabla con los datos de hace 2 años CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo (KEY (tItemFk)) ENGINE = MEMORY @@ -178,7 +177,7 @@ proc: BEGIN SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7 FROM tmp.itemInventory ai JOIN comparative c ON c.itemFk = ai.id - JOIN warehouse w on w.id = c.warehouseFk + JOIN warehouse w ON w.id = c.warehouseFk JOIN tTable wt ON c.timePeriod = wt.zy WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk) AND w.isComparative @@ -229,7 +228,7 @@ proc: BEGIN ) t GROUP BY t.itemFk; - -- Genera la tabla con la comparativa. + -- Genera la tabla con la comparativa CREATE OR REPLACE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY SELECT it.subName productor, From 86a6211cd813a9f4926878688c4de2c677ad875c Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 23 May 2024 12:23:31 +0200 Subject: [PATCH 102/110] fix: refs #7187 fix duplicate --- modules/worker/back/models/device-production-user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/device-production-user.js b/modules/worker/back/models/device-production-user.js index 692a804f0..8eead58e0 100644 --- a/modules/worker/back/models/device-production-user.js +++ b/modules/worker/back/models/device-production-user.js @@ -5,7 +5,7 @@ module.exports = Self => { return new UserError(`This PDA is already assigned to another user`); if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA') - return new UserError(`You can only have one active PDA`); + return new UserError(err.sqlMessage); return err; }); }; From 35ce259e5aa29e60536f8cdb44459b293c9b8d82 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 23 May 2024 14:26:11 +0200 Subject: [PATCH 103/110] feat: refs #7438 Added volume to item_valuateInventory --- .../vn/procedures/item_ValuateInventory.sql | 81 +++++++++---------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/db/routines/vn/procedures/item_ValuateInventory.sql b/db/routines/vn/procedures/item_ValuateInventory.sql index bfd96fa82..137f76654 100644 --- a/db/routines/vn/procedures/item_ValuateInventory.sql +++ b/db/routines/vn/procedures/item_ValuateInventory.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_ValuateInventory`(vDated DATE, vIsDetailed BOOLEAN) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_valuateInventory`( + vDated DATE +) BEGIN DECLARE vInventoried DATE; DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; @@ -38,13 +40,14 @@ BEGIN END IF; CREATE OR REPLACE TEMPORARY TABLE tInventory( - warehouseFk SMALLINT, - itemFk BIGINT, - quantity INT, - cost DOUBLE DEFAULT 0, - total DOUBLE DEFAULT 0, - warehouseInventory VARCHAR(20), - PRIMARY KEY (warehouseInventory, itemFk) USING HASH + warehouseFk SMALLINT, + itemFk BIGINT, + quantity INT, + volume DECIMAL(10,2), + cost DOUBLE DEFAULT 0, + total DOUBLE DEFAULT 0, + warehouseInventory VARCHAR(20), + PRIMARY KEY (warehouseInventory, itemFk) USING HASH ) ENGINE = MEMORY; @@ -183,7 +186,7 @@ BEGIN AND e.isConfirmed ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); - CALL vn.buyUltimate(NULL, vDateDayEnd); + CALL buyUltimate(NULL, vDateDayEnd); UPDATE tInventory i JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk @@ -192,43 +195,31 @@ BEGIN cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0) WHERE i.quantity; - DELETE FROM tInventory - WHERE quantity IS NULL OR NOT quantity; + DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; - IF vIsDetailed THEN - SELECT ti.warehouseFk, - i.id itemFk, - i.longName, - i.size, - ti.quantity, - tp.name Tipo, - ic.name Reino, - ti.cost, - CAST(ti.total AS DECIMAL(10, 2)) total, - ti.warehouseInventory almacen - FROM tInventory ti - JOIN warehouse w ON w.id = warehouseFk - JOIN item i ON i.id = ti.itemFk - JOIN itemType tp ON tp.id = i.typeFk - JOIN itemCategory ic ON ic.id = tp.categoryFk - WHERE w.valuatedInventory - AND ti.total > 0 - ORDER BY ti.total DESC; - ELSE - SELECT i.warehouseInventory Almacen, - ic.name Reino, - CAST(i.total AS DECIMAL(10, 2)) Euros, - w.code Comprador, - it.id - FROM tInventory i - JOIN warehouse wh ON wh.id = warehouseFk - JOIN item it ON it.id = i.itemFk - JOIN itemType itp ON itp.id = it.typeFk - LEFT JOIN worker w ON w.id = itp.workerFk - JOIN itemCategory ic ON ic.id = itp.categoryFk - WHERE wh.valuatedInventory - AND i.total > 0; - END IF; + UPDATE tInventory i + JOIN itemCost ic ON ic.itemFk = i.itemFk + AND ic.warehouseFk = i.warehouseFk + SET i.volume = i.quantity * ic.cm3delivery / 1000000; + + SELECT ti.warehouseFk, + i.id, + i.longName, + i.size, + ti.quantity, + ti.volume, + tp.name itemTypeName, + ic.name itemCategoryName, + ti.cost, + ti.total, + ti.warehouseInventory + FROM tInventory ti + JOIN warehouse w ON w.id = warehouseFk + JOIN item i ON i.id = ti.itemFk + JOIN itemType tp ON tp.id = i.typeFk + JOIN itemCategory ic ON ic.id = tp.categoryFk + WHERE w.valuatedInventory + AND ti.total > 0; DROP TEMPORARY TABLE tmp.buyUltimate, From ee010a3bb3ae6b28eda418dcd503b2085703e0ae Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 23 May 2024 14:44:47 +0200 Subject: [PATCH 104/110] refs #7296 fix pr errors, trad --- loopback/locale/es.json | 3 ++- modules/client/back/methods/client/createAddress.js | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 090cfe059..8586301fb 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -359,5 +359,6 @@ "It was not able to create the invoice": "No se pudo crear la factura", "This PDA is already assigned to another user": "This PDA is already assigned to another user", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", - "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE" + "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", + "Cannot add holidays on this day": "No se pueden agregar vacaciones en este día" } diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index cb55025ce..2709632cb 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -92,12 +92,8 @@ module.exports = function(Self) { }, myOptions); const isUeeMember = province.country().isUeeMember; - if (!isUeeMember && (!args.incotermsFk || !args.customsAgentFk)) { - if (!args.incotermsFk) - throw new UserError(`Incoterms and Customs agent are required for a non UEE member`); - else - throw new UserError(`Customs agent is required for a non UEE member`); - } + if (!isUeeMember && (!args.incotermsFk || !args.customsAgentFk)) + throw new UserError(`Incoterms and Customs agent are required for a non UEE member`); delete args.ctx; // Remove unwanted properties const newAddress = await models.Address.create(args, myOptions); From ee17ea4842ef5bf7f042d3eabc565f456080a54d Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 23 May 2024 21:38:02 +0200 Subject: [PATCH 105/110] feat: refs #6021 add new field --- db/routines/floranet/procedures/order_put.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql index 979588f8f..c5eb71472 100644 --- a/db/routines/floranet/procedures/order_put.sql +++ b/db/routines/floranet/procedures/order_put.sql @@ -7,7 +7,7 @@ BEGIN * * @param vJsonData The order data in json format */ - INSERT INTO `order` + REPLACE `order` SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')), customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')), email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), @@ -15,7 +15,8 @@ BEGIN message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), - deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); + deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')), + observations = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.observations')); SELECT LAST_INSERT_ID() orderFk; END$$ From 2fe279ed47f3a54dcfad9e9b44865a4f7abd82e0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 24 May 2024 07:20:27 +0200 Subject: [PATCH 106/110] feat: refs #7438 Requested changes and little changes --- ...nventory.sql => item_valuateInventory.sql} | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) rename db/routines/vn/procedures/{item_ValuateInventory.sql => item_valuateInventory.sql} (89%) diff --git a/db/routines/vn/procedures/item_ValuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql similarity index 89% rename from db/routines/vn/procedures/item_ValuateInventory.sql rename to db/routines/vn/procedures/item_valuateInventory.sql index 137f76654..18aefdf7b 100644 --- a/db/routines/vn/procedures/item_ValuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -17,8 +17,7 @@ BEGIN SELECT tr.landed INTO vInventoried FROM travel tr JOIN `entry` e ON e.travelFk = tr.id - JOIN entryConfig ec - WHERE landed <= vDateDayEnd + WHERE tr.landed <= vDateDayEnd AND e.supplierFk = vInventorySupplierFk ORDER BY tr.landed DESC LIMIT 1; @@ -29,8 +28,7 @@ BEGIN SELECT landed INTO vInventoryClone FROM travel tr JOIN `entry` e ON e.travelFk = tr.id - JOIN entryConfig ec - WHERE landed >= vDated + WHERE tr.landed >= vDated AND e.supplierFk = vInventorySupplierFk ORDER BY landed ASC LIMIT 1; @@ -63,9 +61,8 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk - JOIN warehouse w ON w.id = warehouseInFk - JOIN entryConfig ec - WHERE landed = vDateDayEnd + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vDateDayEnd AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory @@ -81,9 +78,8 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk - JOIN warehouse w ON w.id = warehouseInFk - JOIN entryConfig ec - WHERE landed = vInventoried + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vInventoried AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory @@ -102,7 +98,6 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk JOIN warehouse w ON w.id = tr.warehouseInFk - JOIN entryConfig ec WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) AND NOT e.isRaid @@ -188,19 +183,16 @@ BEGIN CALL buyUltimate(NULL, vDateDayEnd); - UPDATE tInventory i - JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk - JOIN buy b ON b.id = bu.buyFk - SET total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), - cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0) - WHERE i.quantity; - DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; UPDATE tInventory i - JOIN itemCost ic ON ic.itemFk = i.itemFk - AND ic.warehouseFk = i.warehouseFk - SET i.volume = i.quantity * ic.cm3delivery / 1000000; + JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk + JOIN buy b ON b.id = bu.buyFk + LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk + AND ic.warehouseFk = i.warehouseFk + SET i.total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), + i.cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0), + i.volume = i.quantity * ic.cm3delivery / 1000000; SELECT ti.warehouseFk, i.id, From 4c3428da552415d30f615232f2015045f22b6636 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 24 May 2024 08:21:28 +0200 Subject: [PATCH 107/110] refs #7292 add traduction --- loopback/locale/es.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d95ba6d70..fff7ebf70 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -359,5 +359,6 @@ "It was not able to create the invoice": "No se pudo crear la factura", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", - "You can only have one PDA": "Solo puedes tener un PDA" + "You can only have one PDA": "Solo puedes tener un PDA", + "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE" } From a435d88e55d1218ea7e1cdbfb6d316d21f468f71 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 24 May 2024 08:37:46 +0200 Subject: [PATCH 108/110] refs #7292 fix tback --- modules/client/back/methods/client/specs/createAddress.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/methods/client/specs/createAddress.spec.js b/modules/client/back/methods/client/specs/createAddress.spec.js index bd41d9c50..ae179cf6c 100644 --- a/modules/client/back/methods/client/specs/createAddress.spec.js +++ b/modules/client/back/methods/client/specs/createAddress.spec.js @@ -81,7 +81,7 @@ describe('Address createAddress', () => { } expect(error).toBeDefined(); - expect(error.message).toEqual('Customs agent is required for a non UEE member'); + expect(error.message).toEqual('Incoterms and Customs agent are required for a non UEE member'); }); it('should create a new address and set as a client default address', async() => { From 49a2e6fc84c677c62d58fc708367020624c0d8e3 Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 24 May 2024 11:44:58 +0200 Subject: [PATCH 109/110] tickets y email --- .../floranet/procedures/catalogue_get.sql | 8 +-- .../floranet/procedures/order_confirm.sql | 49 +++++++++++++++++-- .../11068-blueGerbera/00-firstScript.sql | 9 ++++ 3 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 db/versions/11068-blueGerbera/00-firstScript.sql diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index d67f7555e..523026a41 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -40,16 +40,18 @@ proc:BEGIN postalCode, `type`, image, - description + description, + addressFk ) SELECT CONCAT(i.name, ' by ',a.nickname), - i.`size` + apc.deliveryCost, + i.minPrice + apc.deliveryCost, i.id, vLanded, vPostalCode, it.name, CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), - i.description + i.description, + apc.addressFk FROM vn.item i JOIN vn.itemType it ON it.id = i.typeFk JOIN addressPostCode apc diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql index c5d61bf48..903d348a2 100644 --- a/db/routines/floranet/procedures/order_confirm.sql +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -4,7 +4,7 @@ $$ CREATE OR REPLACE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) READS SQL DATA -BEGIN +proc:BEGIN /** Update order.isPaid field, and makes the ticket * * @param vCatalogueFk floranet.catalogue.id @@ -12,8 +12,16 @@ BEGIN * @returns floranet.order.isPaid */ DECLARE vNewTicketFk INT; + DECLARE vCustomerEmail VARCHAR(255); + DECLARE vFloranetEmail VARCHAR(255); + DECLARE vSubjectEmail VARCHAR(100); + DECLARE vBodyEmail TEXT; DECLARE vZoneFk INT; + IF (SELECT isPaid FROM `order` WHERE catalogueFk = vCatalogueFk) THEN + CALL util.throw('Esta orden ya está confirmada'); + END IF; + UPDATE `order` SET isPaid = TRUE, payed = NOW() @@ -33,7 +41,7 @@ BEGIN ) sub LIMIT 1; - INSERT INTO ticket ( + INSERT INTO vn.ticket ( clientFk, shipped, addressFk, @@ -57,7 +65,7 @@ BEGIN vZoneFk FROM vn.address a JOIN vn.agencyMode am ON am.id = a.agencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk + JOIN vn.agency ag ON ag.id = am.agencyFk JOIN catalogue c ON c.addressFk = a.id JOIN vn.company co ON co.code = 'VNL' WHERE c.id = vCatalogueFk; @@ -79,10 +87,41 @@ BEGIN FROM catalogue c JOIN addressPostCode apc ON apc.addressFk = c.addressFk - AND apc.dayOfWeek = dayOfWeek(vDated) + AND apc.dayOfWeek = dayOfWeek(c.dated) WHERE c.id = vCatalogueFk; + + SELECT cl.email, + cf.email, + CONCAT('Nuevo pedido FLORANET para entrega el ',c.dated), + CONCAT_WS('\n', + CONCAT('Producto: ', c.name), + CONCAT('Fecha de entrega: ',c.dated), + CONCAT('Destinatario: ', o.deliveryName), + CONCAT('Dirección: ', o.address), + CONCAT('CP: ', c.postalCode), + CONCAT('Foto: ', c.image), + CONCAT('Mensaje: ', IFNULL(o.message,"Ninguno.")), + CONCAT('Teléfono: ',IFNULL(o.deliveryPhone,"--")), + CONCAT('Observaciones: ', IFNULL(o.observations,"No hay.")) + ) + INTO vCustomerEmail, + vFloranetEmail, + vSubjectEmail, + vBodyEmail + FROM vn.client cl + JOIN vn.address a ON a.clientFk = cl.id + JOIN catalogue c ON c.addressFk = a.id + JOIN `order` o ON o.catalogueFk = c.id + JOIN config cf + WHERE c.id = vCatalogueFk; + + CALL vn.mail_insert( + vCustomerEmail, + vFloranetEmail, + vSubjectEmail, + vBodyEmail); - SELECT isPaid + SELECT isPaid, vNewTicketFk FROM `order` WHERE catalogueFk = vCatalogueFk; END$$ diff --git a/db/versions/11068-blueGerbera/00-firstScript.sql b/db/versions/11068-blueGerbera/00-firstScript.sql new file mode 100644 index 000000000..6342981a7 --- /dev/null +++ b/db/versions/11068-blueGerbera/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +CREATE OR REPLACE TABLE floranet.config ( + email varchar(255) DEFAULT 'floranet@verdnatura.es' NOT NULL +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + + From ab3b58ec3c4342e94cf251661e98fa068696eeab Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 24 May 2024 13:41:02 +0200 Subject: [PATCH 110/110] modificacion recipe y element --- .../00-firstScript.sql | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 db/versions/11069-brownChrysanthemum/00-firstScript.sql diff --git a/db/versions/11069-brownChrysanthemum/00-firstScript.sql b/db/versions/11069-brownChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..3220d1257 --- /dev/null +++ b/db/versions/11069-brownChrysanthemum/00-firstScript.sql @@ -0,0 +1,35 @@ +-- Place your SQL code here +DROP TABLE IF EXISTS floranet.builder; + +CREATE OR REPLACE TABLE floranet.`element` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(30) NOT NULL, + `itemFk` int(11) DEFAULT NULL, + `longNameFilter` varchar(30) DEFAULT NULL, + `typeFk` smallint(5) unsigned DEFAULT NULL, + `minSize` int(10) unsigned DEFAULT NULL, + `maxSize` int(10) unsigned DEFAULT NULL, + `inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `element_FK` (`itemFk`), + KEY `element_FK_1` (`typeFk`), + KEY `element_FK_2` (`inkFk`), + KEY `element_FK_3` (`originFk`), + CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción'; + +CREATE OR REPLACE TABLE floranet.`recipe` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL, + `elementFk` int(11) NOT NULL, + `quantity` int(10) unsigned NOT NULL DEFAULT 1, + PRIMARY KEY (`id`), + KEY `recipe_FK` (`itemFk`), + KEY `recipe_FK_1` (`elementFk`), + CONSTRAINT `recipe_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `recipe_element_FK` FOREIGN KEY (`elementFk`) REFERENCES `element` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements';