Skip to content

Commit

Permalink
Fix error where started and quit had switched day difference logic (#522
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sigridge authored Aug 30, 2024
1 parent 34b9613 commit 7bd9048
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/Api/StaffingController/ReadModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private static double GetNonEmployedHoursForWeekWhenStarting(DateOnly? startDate
Consultant consultant)
{
var hasStarted = startDate < week.FirstDayOfWorkWeek();
var dayDifference = Math.Max((week.LastWorkDayOfWeek().ToDateTime(new TimeOnly()) - startDate.Value.ToDateTime(new TimeOnly())).Days, 0);
var dayDifference = Math.Max((startDate.Value.ToDateTime(new TimeOnly()) - week.FirstDayOfWorkWeek().ToDateTime(new TimeOnly())).Days, 0);

Check warning on line 218 in backend/Api/StaffingController/ReadModelFactory.cs

View workflow job for this annotation

GitHub Actions / dotnet_core_project_tests (7.x.x)

Nullable value type may be null.

Check warning on line 218 in backend/Api/StaffingController/ReadModelFactory.cs

View workflow job for this annotation

GitHub Actions / Build and deploy Backend

Nullable value type may be null.

Check warning on line 218 in backend/Api/StaffingController/ReadModelFactory.cs

View workflow job for this annotation

GitHub Actions / Build and deploy Backend

Nullable value type may be null.

return isStartWeek ? dayDifference * consultant.Department.Organization.HoursPerWorkday :
hasStarted ? 0 : consultant.Department.Organization.HoursPerWorkday * 5 ;
Expand All @@ -225,7 +225,7 @@ private static double GetNonEmployedHoursForWeekWhenQuitting(DateOnly? endDate,
Consultant consultant)
{
var hasQuit = endDate < week.FirstDayOfWorkWeek();
var dayDifference = Math.Max((endDate.Value.ToDateTime(new TimeOnly()) - week.FirstDayOfWorkWeek().ToDateTime(new TimeOnly())).Days, 0);
var dayDifference = Math.Max((week.LastWorkDayOfWeek().ToDateTime(new TimeOnly()) - endDate.Value.ToDateTime(new TimeOnly())).Days, 0);

Check warning on line 228 in backend/Api/StaffingController/ReadModelFactory.cs

View workflow job for this annotation

GitHub Actions / dotnet_core_project_tests (7.x.x)

Nullable value type may be null.

Check warning on line 228 in backend/Api/StaffingController/ReadModelFactory.cs

View workflow job for this annotation

GitHub Actions / Build and deploy Backend

Nullable value type may be null.

return isFinalWeek ? dayDifference * consultant.Department.Organization.HoursPerWorkday :
hasQuit ? consultant.Department.Organization.HoursPerWorkday * 5 : 0;
Expand Down

0 comments on commit 7bd9048

Please sign in to comment.