feat: refs #8190 entry_getCommission #3207

Open
robert wants to merge 4 commits from 8190-entry_getCommission into dev
1 changed files with 8 additions and 5 deletions

View File

@ -11,6 +11,7 @@ BEGIN
DECLARE vCurrentCommission INT;
DECLARE vIsNotEUR INT;
DECLARE vLastEntryFk INT;
DECLARE vTravelFkLanded INT;
Review

vLanded

vLanded
SELECT count(*) INTO vIsNotEUR
FROM currency c
@ -26,23 +27,25 @@ BEGIN
RETURN IFNULL(vCommission, 0);
ELSE
SELECT landed INTO vTravelFkLanded
FROM travel
WHERE id = vTravelFk;
SELECT e.id INTO vLastEntryFk
FROM `entry` e
JOIN travel tr ON tr.id = e.travelFk
WHERE e.supplierFk = vSupplierFk
ORDER BY tr.landed DESC
ORDER BY (vTravelFkLanded <= tr.landed) ASC, tr.landed DESC
Review

per defecte ja es ASC

per defecte ja es ASC
LIMIT 1;
IF vLastEntryFk THEN
SELECT commission INTO vCurrentCommission
FROM `entry`
WHERE id = vLastEntryFk;
ELSE
SELECT commission INTO vCurrentCommission
FROM supplier s
WHERE s.id = vSupplierFk;
END IF;
RETURN vCurrentCommission;