fix: if holiday type have bock if negative, it is ignored when balance is 0 (#36817)

* fix: backport of holiday approval if block_if_negative

* fix: backport of holiday approval if block_if_negative
This commit is contained in:
HENRY Florian 2026-01-07 11:08:40 +01:00 committed by GitHub
parent 53b07f760b
commit 2dbc4c5e01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -687,13 +687,13 @@ if (empty($reshook)) {
if (!$error) {
$db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
} else {
$db->rollback();
$action = '';
}
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
}

View file

@ -882,8 +882,9 @@ class Holiday extends CommonObject
if ($checkBalance > 0) {
$balance = $this->getCPforUser($this->fk_user, $this->fk_type);
$daysAsked = num_open_day($this->date_debut, $this->date_fin, 0, 1);
if ($balance < 0) {
if (($balance - $daysAsked) < 0) {
$this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
return -1;
}