8355-testToMaster #3336

Merged
alexm merged 241 commits from 8355-testToMaster into master 2025-01-07 06:44:57 +00:00
1 changed files with 8 additions and 5 deletions
Showing only changes of commit 4ba8c91c1e - Show all commits

View File

@ -11,6 +11,7 @@ BEGIN
DECLARE vCurrentCommission INT; DECLARE vCurrentCommission INT;
DECLARE vIsNotEUR INT; DECLARE vIsNotEUR INT;
DECLARE vLastEntryFk INT; DECLARE vLastEntryFk INT;
DECLARE vLanded INT;
SELECT count(*) INTO vIsNotEUR SELECT count(*) INTO vIsNotEUR
FROM currency c FROM currency c
@ -26,23 +27,25 @@ BEGIN
RETURN IFNULL(vCommission, 0); RETURN IFNULL(vCommission, 0);
ELSE ELSE
SELECT landed INTO vLanded
FROM travel
WHERE id = vTravelFk;
SELECT e.id INTO vLastEntryFk SELECT e.id INTO vLastEntryFk
FROM `entry` e FROM `entry` e
JOIN travel tr ON tr.id = e.travelFk JOIN travel tr ON tr.id = e.travelFk
WHERE e.supplierFk = vSupplierFk WHERE e.supplierFk = vSupplierFk
ORDER BY tr.landed DESC ORDER BY (vLanded <= tr.landed), tr.landed DESC
LIMIT 1; LIMIT 1;
IF vLastEntryFk THEN IF vLastEntryFk THEN
SELECT commission INTO vCurrentCommission SELECT commission INTO vCurrentCommission
FROM `entry` FROM `entry`
WHERE id = vLastEntryFk; WHERE id = vLastEntryFk;
ELSE ELSE
SELECT commission INTO vCurrentCommission SELECT commission INTO vCurrentCommission
FROM supplier s FROM supplier s
WHERE s.id = vSupplierFk; WHERE s.id = vSupplierFk;
END IF; END IF;
RETURN vCurrentCommission; RETURN vCurrentCommission;