KatjaGlassConsulting / ApprovalBundle

A Kimai Plugin to manage weekly approval workflow
MIT License
12 stars 16 forks source link

Error 500 - getWorkingTimeForDate return vale must be type int, none returned #64

Closed empx92 closed 4 days ago

empx92 commented 4 days ago

Hi, after adding the Workinghours in a Userprofile i get an error when clicking on the "Approval" Link in the mainmenu.

It is a Freshinstall with Kimai 2.24.0 for testing purposes.

The log says:

[request] CRITICAL: Uncaught PHP Exception TypeError: "KimaiPlugin\ApprovalBundle\Settings\MetaFieldSettings::getWorkingTimeForDate(): 
Return value must be of type int, none returned" at MetaFieldSettings.php line 40 {"exception":"[object] (TypeError(code: 0): KimaiPlugin\\ApprovalBundle\\Settings\\MetaFieldSettings::getWorkingTimeForDate(): 
Return value must be of type int, none returned at /data/web/****/html/****/kimai/var/plugins/ApprovalBundle/Settings/MetaFieldSettings.php:40)"} []

Which is related to that line (40):

public function getWorkingTimeForDate(User $user, \DateTimeInterface $dateTime): int
    {
        $this->workingTimeService->getContractMode($user)->getCalculator($user)->getWorkHoursForDay($dateTime);
    }

Additional Info: There are no working hours until 21.11.2024 for that the "Working Contract" says -176:00 for the previous weeks, i don't know if that can be set to the registration date of the user which would be the correct behavior.

kevinpapst commented 4 days ago

Share a screenshot of your settings for that user please

empx92 commented 4 days ago

image And as in desc.: image

kevinpapst commented 4 days ago

Weird. Can you check if setting 0:01 for saturday and sunday fixes it? If so, revert to 0:00 => what happens now.

empx92 commented 4 days ago

No Sadly that doesn't do the trick. I currently try to fill up the months with time, to see what happens.

Error log stays the same

kevinpapst commented 4 days ago

Ah, I found the issue. There is a return statement missing. I wonder why nobody hit that bug before... See #65

empx92 commented 4 days ago

Thanks, just tried the change and everything is working now ;)