feat: refs #8124 Enrutadores nuevos requerimientos
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Andrés 2024-11-25 18:45:37 +01:00
parent b0b64b2630
commit 26406b6fdb
2 changed files with 14 additions and 4 deletions

View File

@ -23,14 +23,15 @@ BEGIN
DELETE FROM routeCommission
WHERE routeFk = vSelf;
SELECT w.isFreelance, v.isKmTruckRate, c.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk
SELECT w.isFreelance, v.isKmTruckRate, p.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk
FROM route r
JOIN worker w ON w.id = r.workerFk
JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN ticket t ON t.routeFk = r.id
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN address a ON a.id = t.addressFk
LEFT JOIN province p ON p.id = a.provinceFk
WHERE r.id = vSelf
GROUP BY c.countryFk
GROUP BY p.countryFk
ORDER BY COUNT(*) DESC
LIMIT 1;
@ -90,7 +91,9 @@ BEGIN
(r.kmEnd - r.kmStart) *
IF(v.isKmTruckRate, rc.kmHeavy, rc.kmLight),
IFNULL(r.m3, 0) *
IF(v.isKmTruckRate, rc.deliveryM3Cat5, rc.deliveryM3Cat4),
IF(v.isKmTruckRate,
IFNULL(wc.deliveryM3Cat5, rc.deliveryM3Cat5),
IFNULL(wc.deliveryM3Cat4, rc.deliveryM3Cat4)),
(r.kmEnd - r.kmStart) * rc.kmYearly,
IFNULL(r.m3, 0) * rc.m3Yearly,
IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),

View File

@ -0,0 +1,7 @@
ALTER TABLE vn.workCenterCommission ADD deliveryM3Cat4 DECIMAL(5,2) DEFAULT NULL NULL;
ALTER TABLE vn.workCenterCommission ADD deliveryM3Cat5 DECIMAL(5,2) DEFAULT NULL NULL;
INSERT INTO vn.workCenterCommission (workCenterFk, deliveryM3Cat4, deliveryM3Cat5)
VALUES (5,8.0,8.0);