[#339] Ajout d'une page listant les règles de calcules (#5)
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | #339 | Ajout d'une page listant les règles de calcules | ## Description de la PR [#339] Ajout d'une page listant les règles de calcules ## Modification du .env ## Check list - [ ] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: #5 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #5.
This commit is contained in:
@@ -6,11 +6,16 @@ namespace App\Service\WorkHours;
|
||||
|
||||
use App\Entity\Absence;
|
||||
use App\Enum\TrackingMode;
|
||||
use App\Service\Contracts\EmployeeContractResolver;
|
||||
use DateMalformedStringException;
|
||||
use DateTimeImmutable;
|
||||
|
||||
final class WorkedHoursCreditPolicy
|
||||
final readonly class WorkedHoursCreditPolicy
|
||||
{
|
||||
public function __construct(
|
||||
private EmployeeContractResolver $contractResolver,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws DateMalformedStringException
|
||||
*/
|
||||
@@ -23,14 +28,19 @@ final class WorkedHoursCreditPolicy
|
||||
}
|
||||
|
||||
$employee = $absence->getEmployee();
|
||||
if (null === $employee) {
|
||||
return 0;
|
||||
}
|
||||
$workDate = new DateTimeImmutable($dateYmd);
|
||||
$contract = $this->contractResolver->resolveForEmployeeAndDate($employee, $workDate);
|
||||
// Les contrats suivis en "présence" ne cumulent pas d'heures en minutes.
|
||||
if (TrackingMode::TIME->value !== $employee?->getContract()?->getTrackingMode()) {
|
||||
if (TrackingMode::TIME->value !== $contract?->getTrackingMode()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$weekday = (int) new DateTimeImmutable($dateYmd)->format('N');
|
||||
$weekday = (int) $workDate->format('N');
|
||||
// On applique la règle de crédit dépendante du contrat (35h / 39h / fallback).
|
||||
$dayMinutes = $this->resolveContractDayMinutes($employee->getContract()?->getWeeklyHours(), $weekday);
|
||||
$dayMinutes = $this->resolveContractDayMinutes($contract?->getWeeklyHours(), $weekday);
|
||||
if ($dayMinutes <= 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -41,15 +51,26 @@ final class WorkedHoursCreditPolicy
|
||||
return (int) round(($dayMinutes / 2) * $halfUnits);
|
||||
}
|
||||
|
||||
public function computeCreditedPresenceUnits(Absence $absence, bool $absentMorning, bool $absentAfternoon): float
|
||||
{
|
||||
/**
|
||||
* @throws DateMalformedStringException
|
||||
*/
|
||||
public function computeCreditedPresenceUnits(
|
||||
Absence $absence,
|
||||
string $dateYmd,
|
||||
bool $absentMorning,
|
||||
bool $absentAfternoon
|
||||
): float {
|
||||
$type = $absence->getType();
|
||||
if (!$type?->getCountAsWorkedHours()) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
$employee = $absence->getEmployee();
|
||||
if (TrackingMode::PRESENCE->value !== $employee?->getContract()?->getTrackingMode()) {
|
||||
if (null === $employee) {
|
||||
return 0.0;
|
||||
}
|
||||
$contract = $this->contractResolver->resolveForEmployeeAndDate($employee, new DateTimeImmutable($dateYmd));
|
||||
if (TrackingMode::PRESENCE->value !== $contract?->getTrackingMode()) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user