From 69314171ea7c8425343dca993c2de5b8b79c138d Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 14 Nov 2024 12:11:14 +0100 Subject: [PATCH 1/4] feat: refs #8190 entry_getCommission --- .../vn/functions/entry_getCommission.sql | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 4a19f4e63..0d294fe24 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -7,41 +7,46 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(v NOT DETERMINISTIC READS SQL DATA BEGIN - DECLARE vCommission INT; - DECLARE vCurrentCommission INT; - DECLARE vIsCurrencyUsd INT; - DECLARE vLastEntryFk INT; - - SELECT count(*) INTO vIsCurrencyUsd - FROM currency c - WHERE c.code = 'USD' AND id = vCurrencyFk; - - IF NOT vIsCurrencyUsd THEN - + DECLARE vCommission INT; + DECLARE vCurrentCommission INT; + DECLARE vIsCurrencyUsd INT; + DECLARE vLastEntryFk INT; + DECLARE vTravelFkLanded INT; + + SELECT count(*) INTO vIsCurrencyUsd + FROM currency c + WHERE c.code = 'USD' AND id = vCurrencyFk; + + IF NOT vIsCurrencyUsd THEN + SELECT landed INTO vTravelFkLanded + FROM travel + WHERE id = vTravelFk; + SELECT e.id INTO vLastEntryFk - FROM vn.entry e - JOIN vn.travel tr ON tr.id = e.travelFk - WHERE e.supplierFk = vSupplierFk - ORDER BY tr.landed DESC - LIMIT 1; - - IF vLastEntryFk THEN - + FROM entry e + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed < vTravelFkLanded + AND e.supplierFk = vSupplierFk + ORDER BY (vTravelFkLanded - tr.landed) ASC, tr.landed DESC + LIMIT 1; + + IF vLastEntryFk THEN + SELECT commission INTO vCurrentCommission FROM vn.entry - WHERE id = vLastEntryFk; - - ELSE - + WHERE id = vLastEntryFk; + + ELSE + SELECT commission INTO vCurrentCommission FROM supplier s WHERE s.id = vSupplierFk; - + END IF; - - RETURN vCurrentCommission; - - ELSE + + RETURN vCurrentCommission; + + ELSE SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission FROM travel t @@ -49,10 +54,10 @@ BEGIN WHERE t.id = vTravelFk ORDER BY r.`dated` DESC LIMIT 1; - + RETURN IFNULL(vCommission, 0); - + END IF; - + END$$ DELIMITER ; From 5a92fe16914a906362173f735b01652eece6c395 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 26 Nov 2024 11:57:24 +0100 Subject: [PATCH 2/4] feat: refs #8190 entry_getCommission --- db/routines/vn/functions/entry_getCommission.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 0d550358f..9e2b53e5e 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -34,9 +34,8 @@ BEGIN SELECT e.id INTO vLastEntryFk FROM `entry` e JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed < vTravelFkLanded - AND e.supplierFk = vSupplierFk - ORDER BY (vTravelFkLanded - tr.landed) ASC, tr.landed DESC + WHERE e.supplierFk = vSupplierFk + ORDER BY (vTravelFkLanded <= tr.landed) ASC, tr.landed DESC LIMIT 1; IF vLastEntryFk THEN From d9aa11b3e9c91e8912c8f7ac23f20c9b28b5e01a Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 27 Nov 2024 07:27:47 +0100 Subject: [PATCH 3/4] feat: refs #8190 entry_getCommission change request --- db/routines/vn/functions/entry_getCommission.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 9e2b53e5e..f8c1ce3b4 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -11,7 +11,7 @@ BEGIN DECLARE vCurrentCommission INT; DECLARE vIsNotEUR INT; DECLARE vLastEntryFk INT; - DECLARE vTravelFkLanded INT; + DECLARE vLanded INT; SELECT count(*) INTO vIsNotEUR FROM currency c @@ -27,7 +27,7 @@ BEGIN RETURN IFNULL(vCommission, 0); ELSE - SELECT landed INTO vTravelFkLanded + SELECT landed INTO vLanded FROM travel WHERE id = vTravelFk; @@ -35,7 +35,7 @@ BEGIN FROM `entry` e JOIN travel tr ON tr.id = e.travelFk WHERE e.supplierFk = vSupplierFk - ORDER BY (vTravelFkLanded <= tr.landed) ASC, tr.landed DESC + ORDER BY (vLanded <= tr.landed), tr.landed DESC LIMIT 1; IF vLastEntryFk THEN From 36705a028edda6324e318fec95ccee74eec00553 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 11:33:18 +0100 Subject: [PATCH 4/4] fix: refs #8174 Version --- modules/worker/back/models/device-production-user.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json index a024cc94c..31aaf92d4 100644 --- a/modules/worker/back/models/device-production-user.json +++ b/modules/worker/back/models/device-production-user.json @@ -25,7 +25,7 @@ "userFk": { "type": "number" }, - "simSerialNumber": { + "simFk": { "type": "string" }, "created": {