From 3a6d4753dbf9ebb2484416049cfc3b56b66a7cc9 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 15 Feb 2024 12:48:17 +0100 Subject: [PATCH 01/23] feat: refs #5855 drop temporary table --- db/routines/bi/procedures/claim_ratio_routine.sql | 2 ++ .../cache/procedures/availableNoRaids_refresh.sql | 2 +- db/routines/cache/procedures/available_refresh.sql | 2 +- .../edi/procedures/floramondo_offerRefresh.sql | 11 ++++++----- db/routines/hedera/procedures/item_calcCatalog.sql | 3 ++- .../vn/procedures/copyComponentsFromSaleList.sql | 1 + db/routines/vn/procedures/itemShelvingRadar.sql | 2 +- db/routines/vn/procedures/itemShelving_inventory.sql | 2 ++ db/routines/vn/procedures/item_getMinacum.sql | 2 ++ db/routines/vn/procedures/productionSectorList.sql | 1 + db/routines/vn/procedures/ticket_DelayTruck.sql | 1 + db/routines/vn/procedures/ticket_add.sql | 2 ++ db/routines/vn/procedures/ticket_cloneWeekly.sql | 2 +- db/routines/vn/procedures/zone_getCollisions.sql | 3 ++- 14 files changed, 25 insertions(+), 11 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 10cb717cf..4ad028433 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -164,5 +164,7 @@ BEGIN ) sub SET cr.recobro = sub.recobro WHERE Id_Cliente IN ( 5189,8942); + + DROP TEMPORARY TABLE tmp.ticket_list; END$$ DELIMITER ; diff --git a/db/routines/cache/procedures/availableNoRaids_refresh.sql b/db/routines/cache/procedures/availableNoRaids_refresh.sql index 383e35436..37715d270 100644 --- a/db/routines/cache/procedures/availableNoRaids_refresh.sql +++ b/db/routines/cache/procedures/availableNoRaids_refresh.sql @@ -117,7 +117,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, tItemRange; + DROP TEMPORARY TABLE tmp.itemCalc, tItemRange, tmp.itemList; CALL cache_calc_end (vCalc); END$$ DELIMITER ; diff --git a/db/routines/cache/procedures/available_refresh.sql b/db/routines/cache/procedures/available_refresh.sql index d0939e568..abf023a41 100644 --- a/db/routines/cache/procedures/available_refresh.sql +++ b/db/routines/cache/procedures/available_refresh.sql @@ -121,7 +121,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, itemRange; + DROP TEMPORARY TABLE tmp.itemCalc, itemRange, tmp.itemList; CALL cache_calc_end (vCalc); END$$ DELIMITER ; diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql index 26e09ebaf..6fdd1b3bb 100644 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ b/db/routines/edi/procedures/floramondo_offerRefresh.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() proc: BEGIN DECLARE vLanded DATETIME; DECLARE vDone INT DEFAULT FALSE; @@ -484,7 +484,8 @@ proc: BEGIN DROP TEMPORARY TABLE edi.offer, - itemToInsert; + itemToInsert, + tmp.buyRecalc; SET @isTriggerDisabled = FALSE; @@ -518,5 +519,5 @@ proc: BEGIN fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/hedera/procedures/item_calcCatalog.sql b/db/routines/hedera/procedures/item_calcCatalog.sql index 81b3adf5a..6db11c034 100644 --- a/db/routines/hedera/procedures/item_calcCatalog.sql +++ b/db/routines/hedera/procedures/item_calcCatalog.sql @@ -30,6 +30,7 @@ BEGIN tmp.ticketComponentPrice, tmp.ticketComponent, tmp.ticketLot, - tmp.zoneGetShipped; + tmp.zoneGetShipped, + tmp.item; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/copyComponentsFromSaleList.sql b/db/routines/vn/procedures/copyComponentsFromSaleList.sql index 17cf487b1..13487af17 100644 --- a/db/routines/vn/procedures/copyComponentsFromSaleList.sql +++ b/db/routines/vn/procedures/copyComponentsFromSaleList.sql @@ -30,5 +30,6 @@ BEGIN JOIN tmp.saleList s ON s.saleFk = sc.saleFk JOIN tmp.newSaleList ns ON ns.orden = s.orden; + DROP TEMPORARY TABLE IF EXISTS tmp.newSaleList; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingRadar.sql b/db/routines/vn/procedures/itemShelvingRadar.sql index c89a190ae..db56c07a0 100644 --- a/db/routines/vn/procedures/itemShelvingRadar.sql +++ b/db/routines/vn/procedures/itemShelvingRadar.sql @@ -188,7 +188,7 @@ proc:BEGIN SELECT * FROM tmp.itemShelvingRadar; END IF; - DROP TEMPORARY TABLE tmp.itemShelvingRadar; + DROP TEMPORARY TABLE tmp.itemShelvingRadar, tmp.itemOutTime; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_inventory.sql b/db/routines/vn/procedures/itemShelving_inventory.sql index ce2934426..89adc0be4 100644 --- a/db/routines/vn/procedures/itemShelving_inventory.sql +++ b/db/routines/vn/procedures/itemShelving_inventory.sql @@ -58,5 +58,7 @@ BEGIN WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo AND p.sectorFk = vSectorFk ORDER BY p.pickingOrder; + + DROP TEMPORARY TABLE IF EXISTS tmp.stockMisfit; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index ed987637c..ddf2ae2c6 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -75,5 +75,7 @@ BEGIN i.quantity amount FROM tmp.itemAtp i HAVING amount != 0; + + DROP TEMPORARY TABLE tmp.itemAtp; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/productionSectorList.sql b/db/routines/vn/procedures/productionSectorList.sql index 5447f10d0..e1445ca52 100644 --- a/db/routines/vn/procedures/productionSectorList.sql +++ b/db/routines/vn/procedures/productionSectorList.sql @@ -104,5 +104,6 @@ BEGIN ) sub; DROP TEMPORARY TABLE tmp.whiteTicket; DROP TEMPORARY TABLE tmp.sectorTypeTicket; + DROP TEMPORARY TABLE tmp.productionBuffer; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_DelayTruck.sql b/db/routines/vn/procedures/ticket_DelayTruck.sql index 7a3170d68..20006fa65 100644 --- a/db/routines/vn/procedures/ticket_DelayTruck.sql +++ b/db/routines/vn/procedures/ticket_DelayTruck.sql @@ -30,5 +30,6 @@ BEGIN END LOOP; CLOSE cur1; + DROP TEMPORARY TABLE tmp.ticket, tmp.productionBuffer; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_add.sql b/db/routines/vn/procedures/ticket_add.sql index 5c3c28081..c85000218 100644 --- a/db/routines/vn/procedures/ticket_add.sql +++ b/db/routines/vn/procedures/ticket_add.sql @@ -65,6 +65,8 @@ BEGIN IF (vZoneFk IS NULL OR vZoneFk = 0) AND vIsRequiredZone THEN CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; END IF; INSERT INTO ticket ( diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index 6bceb2fdf..f9e8d2cb6 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -197,6 +197,6 @@ BEGIN END; END LOOP; CLOSE rsTicket; - DROP TEMPORARY TABLE IF EXISTS tmp.time; + DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/zone_getCollisions.sql b/db/routines/vn/procedures/zone_getCollisions.sql index f6779e1b7..4f104eaad 100644 --- a/db/routines/vn/procedures/zone_getCollisions.sql +++ b/db/routines/vn/procedures/zone_getCollisions.sql @@ -120,6 +120,7 @@ BEGIN DROP TEMPORARY TABLE geoCollision, tmp.zone, - tmp.zoneNodes; + tmp.zoneNodes, + tmp.zoneOption; END$$ DELIMITER ; From 2985e1c9e80dd7ff9b879199b2a9e38d3f13c7e1 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 31 May 2024 13:08:48 +0200 Subject: [PATCH 02/23] feat: roadMap refs #7195 --- back/models/warehouse.json | 33 +++++++++++++------ .../11081-wheatRaphis/00-firstScript.sql | 8 +++++ modules/route/back/models/roadmap.json | 12 +++---- 3 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 db/versions/11081-wheatRaphis/00-firstScript.sql diff --git a/back/models/warehouse.json b/back/models/warehouse.json index dcbf7f2d2..69c74f153 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -9,21 +9,28 @@ }, "properties": { "id": { - "id": true, - "type": "number", - "forceId": false + "id": true, + "type": "number", + "forceId": false }, "name": { - "type": "string" + "type": "string" }, "code": { - "type": "string" + "type": "string" }, "isInventory": { - "type": "number" + "type": "number" }, - "isManaged":{ - "type": "boolean" + "isManaged": { + "type": "boolean" + } + }, + "relations": { + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" } }, "acls": [ @@ -34,5 +41,11 @@ "permission": "ALLOW" } ], - "scope" : {"where": {"isForTicket": {"neq": 0}}} -} + "scope": { + "where": { + "isForTicket": { + "neq": 0 + } + } + } +} \ No newline at end of file diff --git a/db/versions/11081-wheatRaphis/00-firstScript.sql b/db/versions/11081-wheatRaphis/00-firstScript.sql new file mode 100644 index 000000000..70bbaabdb --- /dev/null +++ b/db/versions/11081-wheatRaphis/00-firstScript.sql @@ -0,0 +1,8 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.roadmap ADD kmStart mediumint(9) DEFAULT NULL NULL; +ALTER TABLE vn.roadmap ADD kmEnd mediumint(9) DEFAULT NULL NULL; +ALTER TABLE vn.roadmap ADD started DATETIME NULL; +ALTER TABLE vn.roadmap ADD finished DATETIME NULL; diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json index 01572d718..ac6cdae9f 100644 --- a/modules/route/back/models/roadmap.json +++ b/modules/route/back/models/roadmap.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "roadmap" + "table": "roadmap" } }, "properties": { @@ -43,8 +43,8 @@ "type": "string" } }, - "relations": { - "worker": { + "relations": { + "worker": { "type": "belongsTo", "model": "Worker", "foreignKey": "id" @@ -57,7 +57,7 @@ "roadmapStop": { "type": "hasMany", "model": "RoadmapStop", - "foreignKey": "roadmapFk" + "foreignKey": "roadMapFk" } - } -} + } +} \ No newline at end of file From 882d5bf036c731a2b74888fcee367d8a554299ff Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 3 Jun 2024 18:39:11 +0200 Subject: [PATCH 03/23] feat: roadMap refs #7195 --- .../roadmapStop/getPalletMatchState.js | 63 +++++++++++++++++++ .../specs/getPalletMatchState.spec.js | 12 ++++ modules/route/back/models/roadmap.json | 12 ++++ modules/route/back/models/roadmapStop.js | 3 + 4 files changed, 90 insertions(+) create mode 100644 modules/route/back/methods/roadmapStop/getPalletMatchState.js create mode 100644 modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js create mode 100644 modules/route/back/models/roadmapStop.js diff --git a/modules/route/back/methods/roadmapStop/getPalletMatchState.js b/modules/route/back/methods/roadmapStop/getPalletMatchState.js new file mode 100644 index 000000000..efed64327 --- /dev/null +++ b/modules/route/back/methods/roadmapStop/getPalletMatchState.js @@ -0,0 +1,63 @@ +module.exports = Self => { + Self.remoteMethod('getPalletMatchState', { + description: 'Get pallet', + accessType: 'WRITE', + accepts: [{ + arg: 'roadMapStopFk', + type: 'number', + required: true, + description: 'The roadmapFk id' + }, + { + arg: 'state', + type: 'string', + required: true, + description: 'State code' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/getPalletMatchState`, + verb: 'GET' + } + }); + + Self.getPalletMatchState = async(roadMapStopFk, state, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const result = await Self.rawSql(` + WITH tPallet AS( + SELECT ep.truckFk roadMapStop,ep.id pallet, e.id expedition, e.stateTypeFk + FROM vn.expeditionPallet ep + JOIN vn.expeditionScan es ON es.palletFk = ep.id + JOIN expedition e ON e.id = es.expeditionFk + WHERE ep.truckFk = ? + ),totalPalletExpedition AS( + SELECT t.*, COUNT(expedition) totalPalletExpedition + FROM tPallet t + GROUP BY expedition + ),totalPalletExpeditionCode AS( + SELECT t.*, COUNT(expedition) totalPalletExpeditionCode + FROM tPallet t + JOIN vn.expeditionStateType est ON est.id = t.stateTypeFk + WHERE code = ? + GROUP BY expedition + ) + SELECT t.roadMapStop, + t.pallet, + IF (tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode, 'TRUE', 'FALSE') hasMatchStateCode + FROM tPallet t + LEFT JOIN totalPalletExpedition tpe ON tpe.expedition = t.expedition + LEFT JOIN totalPalletExpeditionCode tpec ON tpec.expedition = t.expedition + GROUP BY t.pallet;`, + [roadMapStopFk, state], + myOptions); + + return result; + }; +}; diff --git a/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js new file mode 100644 index 000000000..ac782561a --- /dev/null +++ b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js @@ -0,0 +1,12 @@ + +const {models} = require('vn-loopback/server/server'); + +describe('roadMapStop getPalletMatchState()', () => { + fit('should return list of pallet with true or false if state is matched', async() => { + const roadmapStopFk = 1; + const state = 'ON DELIVERY'; + const result = await models.RoadmapStop.getPalletMatchState(roadmapStopFk, state); + + expect(result[0].hasMatchStateCode).toBe('TRUE'); + }); +}); diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json index ac6cdae9f..5321af7c3 100644 --- a/modules/route/back/models/roadmap.json +++ b/modules/route/back/models/roadmap.json @@ -41,6 +41,18 @@ }, "driverName": { "type": "string" + }, + "kmStart": { + "type": "number" + }, + "kmEnd": { + "type": "number" + }, + "started": { + "type": "date" + }, + "finished": { + "type": "date" } }, "relations": { diff --git a/modules/route/back/models/roadmapStop.js b/modules/route/back/models/roadmapStop.js new file mode 100644 index 000000000..9e286776d --- /dev/null +++ b/modules/route/back/models/roadmapStop.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/roadmapStop/getPalletMatchState')(Self); +}; From a42562b0ca1d572d8c9dca5d4864ec8eaee47b48 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 19 Jun 2024 10:01:32 +0200 Subject: [PATCH 05/23] fear: refs #5855 claim_ratio_routine --- db/routines/bi/procedures/claim_ratio_routine.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index e22162fff..bd273a2c9 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -55,8 +55,8 @@ BEGIN -- Recobros - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list + DROP TEMPORARY TABLE IF EXISTS tTicket_list; + CREATE TEMPORARY TABLE tTicket_list (PRIMARY KEY (Id_Ticket)) SELECT DISTINCT t.id Id_Ticket FROM vn.saleComponent sc @@ -74,7 +74,7 @@ BEGIN DELETE g.* FROM vn.greuge g - JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket + JOIN tTicket_list t ON g.ticketFk = t.Id_Ticket WHERE g.greugeTypeFk = 2; INSERT INTO vn.greuge(clientFk, description, amount,shipped, @@ -87,7 +87,7 @@ BEGIN ,tt.Id_Ticket FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id + JOIN tTicket_list tt ON tt.Id_Ticket = t.id JOIN vn.saleComponent sc ON sc.saleFk = s.id AND sc.componentFk = 17 GROUP BY t.id @@ -95,7 +95,7 @@ BEGIN UPDATE vn.saleComponent sc JOIN vn.sale s ON s.id = sc.saleFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk + JOIN tTicket_list tt ON tt.Id_Ticket = s.ticketFk SET sc.isGreuge = 1 WHERE sc.componentFk = 17; @@ -164,6 +164,6 @@ BEGIN SET cr.recobro = sub.recobro WHERE Id_Cliente IN ( 5189,8942); - DROP TEMPORARY TABLE tmp.ticket_list; + DROP TEMPORARY TABLE tTicket_list; END$$ DELIMITER ; From 0128dfd967d6cebf6a0206c4ce4a064fa1638592 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 19 Jun 2024 11:30:50 +0200 Subject: [PATCH 06/23] feat: refs #5855 changes required --- db/routines/edi/procedures/floramondo_offerRefresh.sql | 3 +-- db/routines/vn/procedures/copyComponentsFromSaleList.sql | 8 ++++---- db/routines/vn/procedures/ticket_DelayTruck.sql | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql index 312de7ffb..18d3f8b7e 100644 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ b/db/routines/edi/procedures/floramondo_offerRefresh.sql @@ -484,8 +484,7 @@ proc: BEGIN DROP TEMPORARY TABLE edi.offer, - itemToInsert, - tmp.buyRecalc; + itemToInsert; SET @isTriggerDisabled = FALSE; diff --git a/db/routines/vn/procedures/copyComponentsFromSaleList.sql b/db/routines/vn/procedures/copyComponentsFromSaleList.sql index 13487af17..ab75486d1 100644 --- a/db/routines/vn/procedures/copyComponentsFromSaleList.sql +++ b/db/routines/vn/procedures/copyComponentsFromSaleList.sql @@ -16,9 +16,9 @@ BEGIN SET @order = 0; - DROP TEMPORARY TABLE IF EXISTS tmp.newSaleList; + DROP TEMPORARY TABLE IF EXISTS tNewSaleList; - CREATE TEMPORARY TABLE tmp.newSaleList + CREATE TEMPORARY TABLE tNewSaleList SELECT id as saleFk, @order := @order + 1 as orden FROM vn.sale WHERE ticketFk = vTargetTicketFk @@ -28,8 +28,8 @@ BEGIN SELECT ns.saleFk, sc.componentFk, sc.value FROM vn.saleComponent sc JOIN tmp.saleList s ON s.saleFk = sc.saleFk - JOIN tmp.newSaleList ns ON ns.orden = s.orden; + JOIN tNewSaleList ns ON ns.orden = s.orden; - DROP TEMPORARY TABLE IF EXISTS tmp.newSaleList; + DROP TEMPORARY TABLE IF EXISTS tNewSaleList; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_DelayTruck.sql b/db/routines/vn/procedures/ticket_DelayTruck.sql index 2fb98d07d..81896dd8e 100644 --- a/db/routines/vn/procedures/ticket_DelayTruck.sql +++ b/db/routines/vn/procedures/ticket_DelayTruck.sql @@ -3,14 +3,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruck`( BEGIN DECLARE done INT DEFAULT FALSE; DECLARE vTicketFk INT; - DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tmp.ticket; + DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tTicket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; CALL vn.productionControl(vWarehouserFk,0) ; - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket + DROP TEMPORARY TABLE IF EXISTS tTicket; + CREATE TEMPORARY TABLE tTicket SELECT ticketFk FROM tmp.productionBuffer JOIN alertLevel al ON al.code = 'FREE' @@ -31,6 +31,6 @@ BEGIN END LOOP; CLOSE cur1; - DROP TEMPORARY TABLE tmp.ticket, tmp.productionBuffer; + DROP TEMPORARY TABLE tTicket, tmp.productionBuffer; END$$ DELIMITER ; From 9022f6211639d163a4049962077d0d0d7acff180 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 24 Jun 2024 08:03:43 +0200 Subject: [PATCH 07/23] feat: refs #5855 changes required --- db/routines/vn/procedures/copyComponentsFromSaleList.sql | 2 +- db/routines/vn/procedures/itemShelving_inventory.sql | 2 +- db/routines/vn/procedures/ticket_add.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/copyComponentsFromSaleList.sql b/db/routines/vn/procedures/copyComponentsFromSaleList.sql index ab75486d1..8db8409f1 100644 --- a/db/routines/vn/procedures/copyComponentsFromSaleList.sql +++ b/db/routines/vn/procedures/copyComponentsFromSaleList.sql @@ -30,6 +30,6 @@ BEGIN JOIN tmp.saleList s ON s.saleFk = sc.saleFk JOIN tNewSaleList ns ON ns.orden = s.orden; - DROP TEMPORARY TABLE IF EXISTS tNewSaleList; + DROP TEMPORARY TABLE tNewSaleList; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_inventory.sql b/db/routines/vn/procedures/itemShelving_inventory.sql index 6d780c342..f4b8ae165 100644 --- a/db/routines/vn/procedures/itemShelving_inventory.sql +++ b/db/routines/vn/procedures/itemShelving_inventory.sql @@ -60,6 +60,6 @@ BEGIN AND p.sectorFk = vSectorFk ORDER BY p.pickingOrder; - DROP TEMPORARY TABLE IF EXISTS tmp.stockMisfit; + DROP TEMPORARY TABLE tmp.stockMisfit; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_add.sql b/db/routines/vn/procedures/ticket_add.sql index c85000218..d9b68997c 100644 --- a/db/routines/vn/procedures/ticket_add.sql +++ b/db/routines/vn/procedures/ticket_add.sql @@ -66,7 +66,7 @@ BEGIN CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); END IF; - DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; + DROP TEMPORARY TABLE tmp.zoneGetShipped; END IF; INSERT INTO ticket ( From cbc00b90b96797da9672aed997c2f77cd6fe9b53 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 26 Jun 2024 14:02:25 +0200 Subject: [PATCH 08/23] feat front-reservas refs #6861 --- modules/worker/back/models/operator.json | 44 +++++++++++++----------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index a2f3ee01c..d4832bccf 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -26,29 +26,33 @@ }, "labelerFk": { "type": "number" + }, + "isOnReservationMode": { + "type": "boolean", + "required": true } - }, + }, "relations": { - "sector": { - "type": "belongsTo", - "model": "Sector", - "foreignKey": "sectorFk" - }, + "sector": { + "type": "belongsTo", + "model": "Sector", + "foreignKey": "sectorFk" + }, "train": { - "type": "belongsTo", - "model": "Train", - "foreignKey": "trainFk" - }, + "type": "belongsTo", + "model": "Train", + "foreignKey": "trainFk" + }, "printer": { - "type": "belongsTo", - "model": "Printer", - "foreignKey": "labelerFk" - }, + "type": "belongsTo", + "model": "Printer", + "foreignKey": "labelerFk" + }, "itemPackingType": { - "type": "belongsTo", - "model": "ItemPackingType", - "foreignKey": "itemPackingTypeFk", + "type": "belongsTo", + "model": "ItemPackingType", + "foreignKey": "itemPackingTypeFk", "primaryKey": "code" - } - } -} + } + } +} \ No newline at end of file From 3ad23465042d1476ce47f97c403a7752a489640e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 1 Jul 2024 09:25:00 +0200 Subject: [PATCH 09/23] feat refactor setParking REGEXP refs #7575 --- db/routines/vn/procedures/setParking.sql | 66 ++++++++++++------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/db/routines/vn/procedures/setParking.sql b/db/routines/vn/procedures/setParking.sql index 97a40bbe0..d6def07de 100644 --- a/db/routines/vn/procedures/setParking.sql +++ b/db/routines/vn/procedures/setParking.sql @@ -22,40 +22,42 @@ proc: BEGIN CALL util.throw('parkingNotExist'); LEAVE proc; END IF; + + IF vParam REGEXP '^[0-9]+$' THEN + -- Se comprueba si es una preparación previa + SELECT COUNT(*) INTO vIsSaleGroup + FROM vn.saleGroup sg + WHERE sg.id = vParam; - -- Se comprueba si es una preparación previa - SELECT COUNT(*) INTO vIsSaleGroup - FROM vn.saleGroup sg - WHERE sg.id = vParam; + IF vIsSaleGroup THEN + CALL vn.saleGroup_setParking(vParam, vParkingFk); + LEAVE proc; + END IF; - IF vIsSaleGroup THEN - CALL vn.saleGroup_setParking(vParam, vParkingFk); - LEAVE proc; + -- Se comprueba si es un ticket + SELECT COUNT(*) INTO vIsTicket + FROM vn.ticket t + WHERE t.id = vParam + AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + + IF vIsTicket THEN + CALL vn.ticket_setParking(vParam, vParkingFk); + LEAVE proc; + END IF; + + -- Se comprueba si es una coleccion de tickets + SELECT COUNT(*) INTO vIsCollection + FROM vn.collection c + WHERE c.id = vParam + AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + + IF vIsCollection THEN + CALL vn.collection_setParking(vParam, vParkingFk); + LEAVE proc; + END IF; + ELSE + -- Por descarte, se considera una matrícula + CALL vn.shelving_setParking(vParam, vParkingFk); END IF; - - -- Se comprueba si es un ticket - SELECT COUNT(*) INTO vIsTicket - FROM vn.ticket t - WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsTicket THEN - CALL vn.ticket_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Se comprueba si es una coleccion de tickets - SELECT COUNT(*) INTO vIsCollection - FROM vn.collection c - WHERE c.id = vParam - AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsCollection THEN - CALL vn.collection_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Por descarte, se considera una matrícula - CALL vn.shelving_setParking(vParam, vParkingFk); END$$ DELIMITER ; From 2bf06d8add02bb222600727bd92ea8da0aac0045 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 10:06:34 +0200 Subject: [PATCH 10/23] fix: refs #7552 Hotfix --- db/routines/vn/procedures/item_getSimilar.sql | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 762c25342..86791b926 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -15,11 +15,13 @@ BEGIN * @param vDated Fecha * @param vShowType Mostrar tipos */ - DECLARE vCalcFk INT; + DECLARE vAvailableCalcFk INT; + DECLARE vVisibleCalcFk INT; DECLARE vTypeFk INT; DECLARE vPriority INT DEFAULT 1; - CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); + CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); + CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); -- Añadido temporalmente para que no se cuelgue la db SET vShowType = TRUE; @@ -65,21 +67,21 @@ BEGIN WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END AS minQuantity, - iss.visible located, + v.visible located, b.price2 FROM vn.item i JOIN cache.available a ON a.item_id = i.id - AND a.calc_id = vCalcFk + AND a.calc_id = vAvailableCalcFk + LEFT JOIN cache.visible v ON v.item_id = i.id + AND v.calc_id = vVisibleCalcFk + LEFT JOIN cache.last_buy lb ON lb.item_id = i.id + AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vSelf LEFT JOIN vn.itemTag it ON it.itemFk = i.id AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id - AND iss.warehouseFk = vWarehouseFk JOIN itemTags its WHERE a.available > 0 AND (i.typeFk = its.typeFk OR NOT vShowType) From 8409ffa95064a8e131788350f985ce4a6bf4801b Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 10:26:46 +0200 Subject: [PATCH 11/23] fix: refs #7552 Hotfix --- db/routines/vn/procedures/item_getSimilar.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 86791b926..557d77bdf 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -23,9 +23,6 @@ BEGIN CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); - -- Añadido temporalmente para que no se cuelgue la db - SET vShowType = TRUE; - WITH itemTags AS ( SELECT i.id, typeFk, From a23f485296c594c23779a8879ba9cc3e1b4a781e Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 11:11:16 +0200 Subject: [PATCH 12/23] refactor: refs #7424 Component type refactor --- db/routines/bi/procedures/rutasAnalyze.sql | 2 +- .../bi/views/tarifa_componentes_series.sql | 2 +- db/routines/vn/procedures/sale_PriceFix.sql | 2 +- .../procedures/ticket_checkNoComponents.sql | 3 +- .../procedures/ticket_getFromFloramondo.sql | 4 +- db/routines/vn/views/saleCost.sql | 2 +- .../vn/views/sale_freightComponent.sql | 2 +- .../11119-tealGerbera/00-firstScript.sql | 9 ++ .../ticket/back/models/component-type.json | 2 +- modules/ticket/front/component/index.html | 2 +- modules/ticket/front/component/index.js | 2 +- .../reports/delivery-note/sql/sales.sql | 85 +++++++++---------- 12 files changed, 63 insertions(+), 54 deletions(-) create mode 100644 db/versions/11119-tealGerbera/00-firstScript.sql diff --git a/db/routines/bi/procedures/rutasAnalyze.sql b/db/routines/bi/procedures/rutasAnalyze.sql index 5f0d55c7a..e277968bf 100644 --- a/db/routines/bi/procedures/rutasAnalyze.sql +++ b/db/routines/bi/procedures/rutasAnalyze.sql @@ -59,7 +59,7 @@ BEGIN JOIN vn.saleComponent sc ON sc.saleFk = s.id JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' AND r.created BETWEEN vDatedFrom AND vDatedTo GROUP BY r.id ) sub ON sub.routeFk = r.Id_Ruta diff --git a/db/routines/bi/views/tarifa_componentes_series.sql b/db/routines/bi/views/tarifa_componentes_series.sql index f231ae420..ed2f8e29a 100644 --- a/db/routines/bi/views/tarifa_componentes_series.sql +++ b/db/routines/bi/views/tarifa_componentes_series.sql @@ -2,7 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `bi`.`tarifa_componentes_series` AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`, - `ct`.`type` AS `Serie`, + `ct`.`name` AS `Serie`, `ct`.`isBase` AS `base`, `ct`.`isMargin` AS `margen` FROM `vn`.`componentType` `ct` diff --git a/db/routines/vn/procedures/sale_PriceFix.sql b/db/routines/vn/procedures/sale_PriceFix.sql index 8ffa77070..5f956cba8 100644 --- a/db/routines/vn/procedures/sale_PriceFix.sql +++ b/db/routines/vn/procedures/sale_PriceFix.sql @@ -8,7 +8,7 @@ BEGIN JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk WHERE s.ticketFk = vTicketFk - AND ct.`type` = 'otros'; + AND ct.code = 'other'; UPDATE vn.sale s JOIN ( diff --git a/db/routines/vn/procedures/ticket_checkNoComponents.sql b/db/routines/vn/procedures/ticket_checkNoComponents.sql index 28fe333f0..b03427192 100644 --- a/db/routines/vn/procedures/ticket_checkNoComponents.sql +++ b/db/routines/vn/procedures/ticket_checkNoComponents.sql @@ -20,7 +20,8 @@ BEGIN JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN saleComponent sc ON sc.saleFk = s.id JOIN component c ON c.id = sc.componentFk - JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 + JOIN componentType ct ON ct.id = c.typeFk + AND ct.code = 'cost' WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo AND ic.merchandise; diff --git a/db/routines/vn/procedures/ticket_getFromFloramondo.sql b/db/routines/vn/procedures/ticket_getFromFloramondo.sql index 4d83d6dda..5f2bedbb1 100644 --- a/db/routines/vn/procedures/ticket_getFromFloramondo.sql +++ b/db/routines/vn/procedures/ticket_getFromFloramondo.sql @@ -66,7 +66,7 @@ BEGIN JOIN vn.componentType ct ON ct.id = c.typeFk JOIN vn.sale s ON s.id = sc.saleFk JOIN tmp.ticket t ON t.ticketFk = s.ticketFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' GROUP BY t.ticketFk) sb ON sb.ticketFk = tf.ticketFk SET tf.freight = sb.freight; @@ -88,7 +88,7 @@ BEGIN -- Margin UPDATE tmp.ticketFloramondo tf - JOIN (SELECT SUM(IF(ct.code = 'COST',sc.value, 0)) cost, + JOIN (SELECT SUM(IF(ct.code = 'cost',sc.value, 0)) cost, SUM(IF(ct.isMargin, sc.value, 0)) margin, t.ticketFk FROM vn.saleComponent sc diff --git a/db/routines/vn/views/saleCost.sql b/db/routines/vn/views/saleCost.sql index 27265aa93..304b9e3a3 100644 --- a/db/routines/vn/views/saleCost.sql +++ b/db/routines/vn/views/saleCost.sql @@ -19,4 +19,4 @@ FROM ( ) JOIN `vn`.`componentType` `ct` ON(`ct`.`id` = `c`.`typeFk`) ) -WHERE `ct`.`type` = 'coste' +WHERE `ct`.`code` = 'cost' diff --git a/db/routines/vn/views/sale_freightComponent.sql b/db/routines/vn/views/sale_freightComponent.sql index 7a329e0ee..269a8cca1 100644 --- a/db/routines/vn/views/sale_freightComponent.sql +++ b/db/routines/vn/views/sale_freightComponent.sql @@ -16,6 +16,6 @@ FROM ( ) JOIN `vn`.`componentType` `ct` ON( `ct`.`id` = `c`.`typeFk` - AND `ct`.`type` = 'agencia' + AND `ct`.`code` = 'freight' ) ) diff --git a/db/versions/11119-tealGerbera/00-firstScript.sql b/db/versions/11119-tealGerbera/00-firstScript.sql new file mode 100644 index 000000000..40b3b0424 --- /dev/null +++ b/db/versions/11119-tealGerbera/00-firstScript.sql @@ -0,0 +1,9 @@ +ALTER TABLE vn.componentType + CHANGE code code varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL AFTER id; +ALTER TABLE vn.componentType + CHANGE `type` name varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL; +UPDATE IGNORE vn.componentType + SET code = LOWER(code); +UPDATE IGNORE vn.componentType + SET code = 'other' + WHERE id = 12; \ No newline at end of file diff --git a/modules/ticket/back/models/component-type.json b/modules/ticket/back/models/component-type.json index 26daf5216..735227a35 100644 --- a/modules/ticket/back/models/component-type.json +++ b/modules/ticket/back/models/component-type.json @@ -12,7 +12,7 @@ "type": "number", "description": "Identifier" }, - "type": { + "name": { "type": "string" }, "isBase":{ diff --git a/modules/ticket/front/component/index.html b/modules/ticket/front/component/index.html index 39b54b461..2a3a80f3e 100644 --- a/modules/ticket/front/component/index.html +++ b/modules/ticket/front/component/index.html @@ -51,7 +51,7 @@ ng-repeat="saleComponent in sale.components track by saleComponent.componentFk" class="components"> - {{::saleComponent.component.componentType.type}} + {{::saleComponent.component.componentType.name}} {{::saleComponent.component.name}} diff --git a/modules/ticket/front/component/index.js b/modules/ticket/front/component/index.js index 3f262f457..aa755e808 100644 --- a/modules/ticket/front/component/index.js +++ b/modules/ticket/front/component/index.js @@ -20,7 +20,7 @@ class Controller extends Section { include: { relation: 'componentType', scope: { - fields: ['type', 'isBase'] + fields: ['name', 'isBase'] } } } diff --git a/print/templates/reports/delivery-note/sql/sales.sql b/print/templates/reports/delivery-note/sql/sales.sql index c449030cf..636bbc228 100644 --- a/print/templates/reports/delivery-note/sql/sales.sql +++ b/print/templates/reports/delivery-note/sql/sales.sql @@ -1,43 +1,42 @@ -SELECT - s.id, - s.itemFk, - s.concept, - s.quantity, - s.price, - s.price - SUM(IF(ctr.id = 6, sc.value, 0)) netPrice, - s.discount, - i.size, - i.stems, - i.category, - it.id itemTypeId, - o.code AS origin, - i.inkFk, - s.ticketFk, - tcl.code vatType, - ib.ediBotanic botanical, - i.tag5, - i.value5, - i.tag6, - i.value6, - i.tag7, - i.value7 -FROM vn.sale s - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component cr ON cr.id = sc.componentFk - LEFT JOIN componentType ctr ON ctr.id = cr.typeFk - LEFT JOIN item i ON i.id = s.itemFk - LEFT JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN country c ON c.id = o.countryFk - LEFT JOIN supplier sp ON sp.id = t.companyFk - LEFT JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id - AND itc.countryFk = sp.countryFk - LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk - LEFT JOIN itemBotanicalWithGenus ib ON ib.itemFk = i.id - AND ic.code = 'plant' - AND ib.ediBotanic IS NOT NULL -WHERE s.ticketFk = ? -GROUP BY s.id -ORDER BY (it.isPackaging), s.concept, s.itemFk \ No newline at end of file +SELECT s.id, + s.itemFk, + s.concept, + s.quantity, + s.price, + s.price - SUM(IF(ctr.code = 'freight', sc.value, 0)) netPrice, + s.discount, + i.size, + i.stems, + i.category, + it.id itemTypeId, + o.code origin, + i.inkFk, + s.ticketFk, + tcl.code vatType, + ib.ediBotanic botanical, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7 + FROM vn.sale s + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN component cr ON cr.id = sc.componentFk + LEFT JOIN componentType ctr ON ctr.id = cr.typeFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN country c ON c.id = o.countryFk + LEFT JOIN supplier sp ON sp.id = t.companyFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = sp.countryFk + LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk + LEFT JOIN itemBotanicalWithGenus ib ON ib.itemFk = i.id + AND ic.code = 'plant' + AND ib.ediBotanic IS NOT NULL + WHERE s.ticketFk = ? + GROUP BY s.id + ORDER BY (it.isPackaging), s.concept, s.itemFk \ No newline at end of file From 9e5f416d55bc2b159c99c33498da8ed0d33b0967 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 12:06:30 +0200 Subject: [PATCH 13/23] refactor: refs #7418 Item type refactor --- db/dump/fixtures.before.sql | 1 - db/routines/vn2008/views/Tipos.sql | 7 +------ db/versions/11120-brownTulip/00-firstScript.sql | 6 ++++++ 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 db/versions/11120-brownTulip/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 27f84bdfb..61d46d133 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3232,7 +3232,6 @@ INSERT IGNORE INTO vn.itemType workerFk = 103, isInventory = TRUE, life = 10, - density = 250, itemPackingTypeFk = NULL, temperatureFk = 'warm'; diff --git a/db/routines/vn2008/views/Tipos.sql b/db/routines/vn2008/views/Tipos.sql index 4cde954f1..5b96c1766 100644 --- a/db/routines/vn2008/views/Tipos.sql +++ b/db/routines/vn2008/views/Tipos.sql @@ -9,14 +9,9 @@ AS SELECT `it`.`id` AS `tipo_id`, `it`.`workerFk` AS `Id_Trabajador`, `it`.`life` AS `life`, `it`.`isPackaging` AS `isPackaging`, - `it`.`density` AS `density`, `it`.`isInventory` AS `inventory`, `it`.`created` AS `odbc_date`, `it`.`making` AS `confeccion`, `it`.`temperatureFk` AS `Temperatura`, - `it`.`promo` AS `promo`, - `it`.`maneuver` AS `maneuver`, - `it`.`target` AS `target`, - `it`.`topMargin` AS `top_margin`, - `it`.`profit` AS `profit` + `it`.`promo` AS `promo` FROM `vn`.`itemType` `it` diff --git a/db/versions/11120-brownTulip/00-firstScript.sql b/db/versions/11120-brownTulip/00-firstScript.sql new file mode 100644 index 000000000..c4ded80bb --- /dev/null +++ b/db/versions/11120-brownTulip/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.itemType + CHANGE maneuver maneuver__ double DEFAULT 0.21 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE target target__ double DEFAULT 0.15 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE topMargin topMargin__ double DEFAULT 0.3 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE profit profit__ double DEFAULT 0.02 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE density density__ double DEFAULT 167 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418 Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta'; \ No newline at end of file From 2ed31ee1d3702df9a7e3f31571b91f50f13e2b9e Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 1 Jul 2024 13:26:59 +0200 Subject: [PATCH 14/23] refs #7651 Add editorFk and triggers --- .../account/triggers/mailAliasAccount_beforeInsert.sql | 8 ++++++++ .../account/triggers/mailAliasAccount_beforeUpdate.sql | 8 ++++++++ db/versions/11121-silverAralia/00-firstScript.sql | 4 ++++ 3 files changed, 20 insertions(+) create mode 100644 db/routines/account/triggers/mailAliasAccount_beforeInsert.sql create mode 100644 db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql create mode 100644 db/versions/11121-silverAralia/00-firstScript.sql diff --git a/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql b/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql new file mode 100644 index 000000000..a435832f2 --- /dev/null +++ b/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeInsert` + BEFORE INSERT ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql b/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql new file mode 100644 index 000000000..471a34900 --- /dev/null +++ b/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeUpdate` + BEFORE UPDATE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/11121-silverAralia/00-firstScript.sql b/db/versions/11121-silverAralia/00-firstScript.sql new file mode 100644 index 000000000..e74ca2e95 --- /dev/null +++ b/db/versions/11121-silverAralia/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE account.mailAliasAccount + ADD editorFk INT UNSIGNED NULL, + ADD CONSTRAINT mailAliasAccount_editorFk FOREIGN KEY (editorFk) + REFERENCES account.`user`(id); \ No newline at end of file From a0ea742f9e523a9fec3ef12304a9399ec28840fa Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 13:38:25 +0200 Subject: [PATCH 15/23] fix: refs #7486 Hotfix --- db/routines/vn/procedures/ticket_splitItemPackingType.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index b28b16432..d6e8e8a53 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -44,7 +44,6 @@ BEGIN WHERE s.ticketFk = vTicketFk; CREATE OR REPLACE TEMPORARY TABLE tmp.saleGroup - (PRIMARY KEY (itemPackingTypeFk)) ENGINE = MEMORY SELECT itemPackingTypeFk, SUM(litros) totalLitros FROM tmp.sale @@ -56,8 +55,7 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT ( ticketFk INT, - itemPackingTypeFk VARCHAR(1), - PRIMARY KEY (ticketFk) + itemPackingTypeFk VARCHAR(1) ) ENGINE = MEMORY; CASE vPackingTypesToSplit From 29aecd62a527c203430e0b84ad3ffe466d4bff9f Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 1 Jul 2024 14:51:32 +0200 Subject: [PATCH 16/23] refs #7651 add afterDelete trigger --- .../triggers/mailAliasAccount_afterDelete.sql | 12 ++++++++++++ db/versions/11121-silverAralia/00-firstScript.sql | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/routines/account/triggers/mailAliasAccount_afterDelete.sql diff --git a/db/routines/account/triggers/mailAliasAccount_afterDelete.sql b/db/routines/account/triggers/mailAliasAccount_afterDelete.sql new file mode 100644 index 000000000..83af7169c --- /dev/null +++ b/db/routines/account/triggers/mailAliasAccount_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_afterDelete` + AFTER DELETE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + INSERT INTO userLog + SET `action` = 'delete', + `changedModel` = 'MailAliasAccount', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/11121-silverAralia/00-firstScript.sql b/db/versions/11121-silverAralia/00-firstScript.sql index e74ca2e95..20b0e8195 100644 --- a/db/versions/11121-silverAralia/00-firstScript.sql +++ b/db/versions/11121-silverAralia/00-firstScript.sql @@ -1,4 +1,4 @@ ALTER TABLE account.mailAliasAccount - ADD editorFk INT UNSIGNED NULL, + ADD editorFk INT(10) UNSIGNED DEFAULT NULL, ADD CONSTRAINT mailAliasAccount_editorFk FOREIGN KEY (editorFk) REFERENCES account.`user`(id); \ No newline at end of file From d9742afc9b4fdaaf143fe91c227527e684d3c931 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 1 Jul 2024 17:45:45 +0200 Subject: [PATCH 17/23] feat roadmap refs #7195 --- modules/route/back/models/roadmapStop.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json index 74b02cd7a..93eae0113 100644 --- a/modules/route/back/models/roadmapStop.json +++ b/modules/route/back/models/roadmapStop.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "roadmapStop" + "table": "roadmapStop" } }, "properties": { @@ -28,16 +28,16 @@ "type": "number" } }, - "relations": { - "roadmap": { + "relations": { + "roadmap": { "type": "belongsTo", "model": "Roadmap", "foreignKey": "roadmapFk" }, "address": { "type": "belongsTo", - "model": "Address", + "model": "RoadmapAddress", "foreignKey": "addressFk" } - } -} + } +} \ No newline at end of file From 08cf79b09bc68104a2547e95e1f4b165b8ac6ea8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 2 Jul 2024 08:39:42 +0200 Subject: [PATCH 18/23] feat roadmap refs #7195 --- .../back/methods/roadmapStop/getPalletMatchState.js | 9 ++++----- .../roadmapStop/specs/getPalletMatchState.spec.js | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/route/back/methods/roadmapStop/getPalletMatchState.js b/modules/route/back/methods/roadmapStop/getPalletMatchState.js index efed64327..138d62411 100644 --- a/modules/route/back/methods/roadmapStop/getPalletMatchState.js +++ b/modules/route/back/methods/roadmapStop/getPalletMatchState.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('getPalletMatchState', { - description: 'Get pallet', + description: 'Get list of pallet from roadMapStop with true or false if state is matched', accessType: 'WRITE', accepts: [{ arg: 'roadMapStopFk', @@ -32,7 +32,7 @@ module.exports = Self => { const result = await Self.rawSql(` WITH tPallet AS( - SELECT ep.truckFk roadMapStop,ep.id pallet, e.id expedition, e.stateTypeFk + SELECT ep.id pallet, e.id expedition, e.stateTypeFk FROM vn.expeditionPallet ep JOIN vn.expeditionScan es ON es.palletFk = ep.id JOIN expedition e ON e.id = es.expeditionFk @@ -48,9 +48,8 @@ module.exports = Self => { WHERE code = ? GROUP BY expedition ) - SELECT t.roadMapStop, - t.pallet, - IF (tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode, 'TRUE', 'FALSE') hasMatchStateCode + SELECT t.pallet, + tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode hasMatchStateCode FROM tPallet t LEFT JOIN totalPalletExpedition tpe ON tpe.expedition = t.expedition LEFT JOIN totalPalletExpeditionCode tpec ON tpec.expedition = t.expedition diff --git a/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js index ac782561a..3e89bd528 100644 --- a/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js +++ b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js @@ -2,11 +2,11 @@ const {models} = require('vn-loopback/server/server'); describe('roadMapStop getPalletMatchState()', () => { - fit('should return list of pallet with true or false if state is matched', async() => { + it('should return list of pallet with true or false if state is matched', async() => { const roadmapStopFk = 1; const state = 'ON DELIVERY'; const result = await models.RoadmapStop.getPalletMatchState(roadmapStopFk, state); - expect(result[0].hasMatchStateCode).toBe('TRUE'); + expect(result[0].hasMatchStateCode).toBe(1); }); }); From 028278ebcfd923335abff83b89da0148386a3130 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 2 Jul 2024 11:52:25 +0200 Subject: [PATCH 19/23] refs #6626 Hotfix --- .../vn/procedures/invoiceInTax_afterUpsert.sql | 13 ------------- db/routines/vn/procedures/invoiceIn_booking.sql | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 60ec34696..962cc5224 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -8,7 +8,6 @@ BEGIN */ DECLARE vTaxRowLimit INT; DECLARE vLines INT; - DECLARE vHasDistinctTransactions INT; SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; @@ -20,17 +19,5 @@ BEGIN IF vLines >= vTaxRowLimit THEN CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit)); END IF; - - SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions - FROM invoiceIn ii - JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN invoiceInSerial iis ON iis.code = ii.serial - WHERE ii.id = vInvoiceInFk - AND iis.taxAreaFk = 'CEE' - AND transactionTypeSageFk; - - IF vHasDistinctTransactions > 1 THEN - CALL util.throw ('This invoice does not allow different types of transactions'); - END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index ef124bb46..cd838861a 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -13,6 +13,19 @@ BEGIN * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo */ DECLARE vFiscalYear INT; + DECLARE vHasDistinctTransactions INT; + + SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions + FROM invoiceIn ii + JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id + JOIN invoiceInSerial iis ON iis.code = ii.serial + WHERE ii.id = vSelf + AND iis.taxAreaFk = 'CEE' + AND transactionTypeSageFk; + + IF vHasDistinctTransactions > 1 THEN + CALL util.throw ('This invoice does not allow different types of transactions'); + END IF; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn ENGINE = MEMORY From e1b6ba4276dff0aa80476c9dfc33e33dfcd5b8d1 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 2 Jul 2024 12:03:21 +0200 Subject: [PATCH 20/23] feat roadmap refs #7195 --- .../back/methods/roadmapStop/getPalletMatchState.js | 10 +++++----- .../roadmapStop/specs/getPalletMatchState.spec.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/route/back/methods/roadmapStop/getPalletMatchState.js b/modules/route/back/methods/roadmapStop/getPalletMatchState.js index 138d62411..828dbb689 100644 --- a/modules/route/back/methods/roadmapStop/getPalletMatchState.js +++ b/modules/route/back/methods/roadmapStop/getPalletMatchState.js @@ -1,12 +1,12 @@ module.exports = Self => { Self.remoteMethod('getPalletMatchState', { - description: 'Get list of pallet from roadMapStop with true or false if state is matched', + description: 'Get list of pallet from truckFk with true or false if state is matched', accessType: 'WRITE', accepts: [{ - arg: 'roadMapStopFk', + arg: 'truckFk', type: 'number', required: true, - description: 'The roadmapFk id' + description: 'The truckFk id' }, { arg: 'state', @@ -24,7 +24,7 @@ module.exports = Self => { } }); - Self.getPalletMatchState = async(roadMapStopFk, state, options) => { + Self.getPalletMatchState = async(truckFk, state, options) => { const myOptions = {}; if (typeof options == 'object') @@ -54,7 +54,7 @@ module.exports = Self => { LEFT JOIN totalPalletExpedition tpe ON tpe.expedition = t.expedition LEFT JOIN totalPalletExpeditionCode tpec ON tpec.expedition = t.expedition GROUP BY t.pallet;`, - [roadMapStopFk, state], + [truckFk, state], myOptions); return result; diff --git a/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js index 3e89bd528..4a79b589e 100644 --- a/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js +++ b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js @@ -3,9 +3,9 @@ const {models} = require('vn-loopback/server/server'); describe('roadMapStop getPalletMatchState()', () => { it('should return list of pallet with true or false if state is matched', async() => { - const roadmapStopFk = 1; + const truckFk = 1; const state = 'ON DELIVERY'; - const result = await models.RoadmapStop.getPalletMatchState(roadmapStopFk, state); + const result = await models.RoadmapStop.getPalletMatchState(truckFk, state); expect(result[0].hasMatchStateCode).toBe(1); }); From 9708e79e5518addc77a0e447c65744d96a48a149 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 2 Jul 2024 12:41:51 +0200 Subject: [PATCH 21/23] build: increase version 2430 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 95d696fc3..ea126bce3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.28.0", + "version": "24.30.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 0bb4439f85d07c6765d2873c0ca82f1b42a25358 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 2 Jul 2024 14:37:22 +0200 Subject: [PATCH 22/23] refs #7443 Deleted ekt barcode --- db/routines/edi/procedures/ekt_refresh.sql | 19 +++---------------- db/routines/edi/views/ektRecent.sql | 1 - db/routines/vn2008/views/buy_edi.sql | 1 - 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/db/routines/edi/procedures/ekt_refresh.sql b/db/routines/edi/procedures/ekt_refresh.sql index 0e9ed7d3c..8ba438c0a 100644 --- a/db/routines/edi/procedures/ekt_refresh.sql +++ b/db/routines/edi/procedures/ekt_refresh.sql @@ -7,7 +7,6 @@ BEGIN */ DECLARE vRewriteKop INT DEFAULT NULL; DECLARE vTruncatePutOrder INT DEFAULT NULL; - DECLARE vBarcode CHAR(15) DEFAULT NULL; DECLARE vKop INT; DECLARE vPutOrderFk BIGINT; @@ -16,17 +15,6 @@ BEGIN FROM ekt WHERE id = vSelf; - -- Generates the barcode - - SELECT CONCAT( - LPAD(IFNULL(auction,0), 3, 0), - LPAD(IFNULL(klo, 99), 2, 0), - LPAD(DAYOFYEAR(fec), 3, 0), - COALESCE(agj, RIGHT(batchNumber,7), id)) - INTO vBarcode - FROM ekt - WHERE id = vSelf; - -- Rewrites the kop parameter IF vKop IS NULL THEN @@ -46,10 +34,9 @@ BEGIN -- Refresh EKT - UPDATE ekt SET - barcode = vBarcode - ,kop = vKop - ,putOrderFk = vTruncatePutOrder + UPDATE ekt + SET kop = vKop, + putOrderFk = vTruncatePutOrder WHERE id = vSelf; END$$ DELIMITER ; diff --git a/db/routines/edi/views/ektRecent.sql b/db/routines/edi/views/ektRecent.sql index 3e41490ab..66ff7875e 100644 --- a/db/routines/edi/views/ektRecent.sql +++ b/db/routines/edi/views/ektRecent.sql @@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `edi`.`ektRecent` AS SELECT `e`.`id` AS `id`, - `e`.`barcode` AS `barcode`, `e`.`entryYear` AS `entryYear`, `e`.`batchNumber` AS `batchNumber`, `e`.`deliveryNumber` AS `deliveryNumber`, diff --git a/db/routines/vn2008/views/buy_edi.sql b/db/routines/vn2008/views/buy_edi.sql index 0d194c89e..d00196e95 100644 --- a/db/routines/vn2008/views/buy_edi.sql +++ b/db/routines/vn2008/views/buy_edi.sql @@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`buy_edi` AS SELECT `t`.`id` AS `id`, - `t`.`barcode` AS `barcode`, `t`.`entryYear` AS `entry_year`, `t`.`deliveryNumber` AS `delivery_number`, `t`.`fec` AS `fec`, From 0d70cb892909348e98086e07d564ea3df8f5fa0c Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 2 Jul 2024 17:39:46 +0200 Subject: [PATCH 23/23] fix: informatica no necesita este correo --- db/routines/vn/procedures/XDiario_check.sql | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/db/routines/vn/procedures/XDiario_check.sql b/db/routines/vn/procedures/XDiario_check.sql index 0fb1c410d..ef969924b 100644 --- a/db/routines/vn/procedures/XDiario_check.sql +++ b/db/routines/vn/procedures/XDiario_check.sql @@ -6,19 +6,6 @@ BEGIN * identificando y notificando los asientos descuadrados * y ajustando los saldos en caso necesario. */ - INSERT INTO mail (receiver, subject, body) - SELECT 'cau@verdnatura.es', - 'Asientos descuadrados', - GROUP_CONCAT(CONCAT(' Asiento: ', ASIEN, ' - Importe:', recon) SEPARATOR ' | \n') - FROM ( - SELECT ASIEN, - SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) recon - FROM XDiario - WHERE NOT enlazado - GROUP BY ASIEN - HAVING ABS(SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0))) > 0.01 - ) sub - HAVING COUNT(*); UPDATE XDiario xd JOIN (