fix: business overlapping #2631
|
@ -12,23 +12,21 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN
|
||||
|
||||
SELECT COUNT(*) > 0 INTO isOverlapping
|
||||
FROM business b
|
||||
WHERE (util.hasDateOverlapped(
|
||||
SELECT util.hasDateOverlapped(
|
||||
started,
|
||||
ended,
|
||||
NEW.started,
|
||||
IFNULL(NEW.ended, b.started),
|
||||
b.started,
|
||||
IFNULL(b.ended, NEW.started))
|
||||
OR (NEW.ended <=> NULL AND b.ended <=> NULL))
|
||||
AND b.id <> OLD.id
|
||||
AND workerFk = OLD.workerFk;
|
||||
IFNULL(NEW.ended, b.started)
|
||||
) isOverlapped INTO isOverlapping
|
||||
FROM vn.business b
|
||||
WHERE workerFk = NEW.workerFK
|
||||
AND b.id <> NEW.id
|
||||
ORDER BY isOverlapped DESC
|
||||
LIMIT 1;
|
||||
|
||||
IF isOverlapping THEN
|
||||
CALL util.throw ('IS_OVERLAPPING');
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue