diff --git a/backend/Api/StaffingController/ReadModelFactory.cs b/backend/Api/StaffingController/ReadModelFactory.cs index 3f6414e2..7eb7fa2b 100644 --- a/backend/Api/StaffingController/ReadModelFactory.cs +++ b/backend/Api/StaffingController/ReadModelFactory.cs @@ -103,7 +103,7 @@ private static List DetailedBookings(Consultant consultant, grouping.First().Engagement.Agreements.Select(a => (DateTime?)a.EndDate).DefaultIfEmpty(null).Max()), weekSet.Select(week => new WeeklyHours( - week, grouping + week.ToSortableInt(), grouping .Where(staffing => staffing.Week.Equals(week)) .Sum(staffing => staffing.Hours)) ).ToList() @@ -120,7 +120,7 @@ private static List DetailedBookings(Consultant consultant, grouping.First().Engagement.Agreements.Select(a => (DateTime?)a.EndDate).DefaultIfEmpty(null).Max()), weekSet.Select(week => new WeeklyHours( - week, + week.ToSortableInt(), grouping .Where(staffing => staffing.Week.Equals(week)) @@ -137,7 +137,7 @@ private static List DetailedBookings(Consultant consultant, grouping.First().Absence.ExcludeFromBillRate), weekSet.Select(week => new WeeklyHours( - week, + week.ToSortableInt(), grouping .Where(absence => absence.Week.Equals(week)) @@ -155,7 +155,7 @@ private static List DetailedBookings(Consultant consultant, if (vacationsInSet.Count > 0) { var vacationsPrWeek = weekSet.Select(week => new WeeklyHours( - week, + week.ToSortableInt(), vacationsInSet.Count(vacation => week.ContainsDate(vacation.Date)) * consultant.Department.Organization.HoursPerWorkday )).ToList(); @@ -206,7 +206,7 @@ private static List GetNonEmploymentHoursNotStartedOrQuit(DateOnly : GetNonEmployedHoursForWeekWhenStarting(date, week, isTargetWeek, consultant); return new WeeklyHours( - week, Math.Min(hoursOutsideEmployment, maxWorkHoursForWeek) + week.ToSortableInt(), Math.Min(hoursOutsideEmployment, maxWorkHoursForWeek) ); }) .ToList(); @@ -297,7 +297,9 @@ private static BookedHoursPerWeek GetBookedHours(Week week, IEnumerable weeklySum.Week == week).Sum(weeklyHours => weeklyHours.Hours); + return Hours.Where(weeklySum => weeklySum.Week == week.ToSortableInt()).Sum(weeklyHours => weeklyHours.Hours); } internal static double GetTotalHoursPrBookingTypeAndWeek(IEnumerable list, BookingType type, @@ -98,7 +100,7 @@ public record BookingDetails( bool IsBillable = false, DateTime? EndDateAgreement = null); -public record WeeklyHours(Week Week, double Hours); +public record WeeklyHours(int Week, double Hours); public enum BookingType { diff --git a/backend/Core/Weeks/Week.cs b/backend/Core/Weeks/Week.cs index 46ed521d..e0d99c72 100644 --- a/backend/Core/Weeks/Week.cs +++ b/backend/Core/Weeks/Week.cs @@ -171,6 +171,9 @@ private bool DateIsInWeek(DateOnly day) public static bool operator ==(Week left, Week right) { + if (ReferenceEquals(left, right)) return true; + if (ReferenceEquals(left, null)) return false; + if (ReferenceEquals(right, null)) return false; return left.Year == right.Year && left.WeekNumber == right.WeekNumber; } diff --git a/frontend/mockdata/mockData.ts b/frontend/mockdata/mockData.ts index 51dc3aef..bac4ca8c 100644 --- a/frontend/mockdata/mockData.ts +++ b/frontend/mockdata/mockData.ts @@ -16,7 +16,7 @@ const MockWeeklyBookingReadModel: WeeklyBookingReadModel = { totalBillable: 0, totalOffered: 0, totalVacationHours: 0, - totalExludableAbsence: 0, + totalExcludableAbsence: 0, totalNotStartedOrQuit: 0, }; diff --git a/frontend/src/api-types.ts b/frontend/src/api-types.ts index 968e9cb5..b66d8d92 100644 --- a/frontend/src/api-types.ts +++ b/frontend/src/api-types.ts @@ -277,7 +277,7 @@ export interface WeeklyBookingReadModel { /** @format double */ totalOverbooking: number; /** @format double */ - totalExludableAbsence: number; + totalExcludableAbsence: number; /** @format double */ totalNotStartedOrQuit: number; } diff --git a/frontend/src/components/FilteredConsultantsList.tsx b/frontend/src/components/FilteredConsultantsList.tsx index 6a907ee5..9963a37b 100644 --- a/frontend/src/components/FilteredConsultantsList.tsx +++ b/frontend/src/components/FilteredConsultantsList.tsx @@ -18,113 +18,112 @@ export default function StaffingTable() { } = useConsultantsFilter(); const { weekSpan } = useContext(FilteredContext).activeFilters; + console.log(filteredConsultants); return ( - <> - 23 - ? "min-w-[1400px]" - : weekSpan > 11 - ? "min-w-[850px]" - : "min-w-[700px]" - } table-fixed`} - > - - - - {filteredConsultants - .at(0) - ?.bookings.map((_, index) => )} - - - - - {filteredConsultants.at(0)?.bookings?.map((booking) => ( - + + + {filteredConsultants.map((consultant) => ( + + ))} + + +
-
-

Konsulenter

-

- {filteredConsultants?.length} -

-
-
-
- {isCurrentWeek(booking.weekNumber, booking.year) ? ( -
- {booking.bookingModel.totalHolidayHours > 0 && ( - } - colors={"bg-holiday text-holiday_darker w-fit"} - variant={weekSpan < 24 ? "wide" : "medium"} - /> - )} -
- -

- {booking.weekNumber} -

-
- ) : ( -
= 26 - ? "min-h-[30px] flex-col mb-2 gap-[1px] items-end" - : "flex-row gap-2" - }`} - > - {booking.bookingModel.totalHolidayHours > 0 && ( - } - colors={"bg-holiday text-holiday_darker w-fit"} - variant={weekSpan < 24 ? "wide" : "medium"} - /> - )} -

{booking.weekNumber}

-
- )} + 23 + ? "min-w-[1400px]" + : weekSpan > 11 + ? "min-w-[850px]" + : "min-w-[700px]" + } table-fixed`} + > + + + + {filteredConsultants + .at(0) + ?.bookings.map((_, index) => )} + + + + + {filteredConsultants.at(0)?.bookings?.map((booking) => ( + - ))} - - - - {filteredConsultants.map((consultant) => ( - + {booking.bookingModel.totalHolidayHours > 0 && ( + } + colors={"bg-holiday text-holiday_darker w-fit"} + variant={weekSpan < 24 ? "wide" : "medium"} + /> + )} +

{booking.weekNumber}

+ + )} + +

= 26 && "hidden" + }`} + > + {booking.dateString} +

+ + ))} -
- -
+
+

Konsulenter

+

+ {filteredConsultants?.length} +

+
+
+
+ {isCurrentWeek(booking.weekNumber, booking.year) ? ( +
+ {booking.bookingModel.totalHolidayHours > 0 && ( + } + colors={"bg-holiday text-holiday_darker w-fit"} + variant={weekSpan < 24 ? "wide" : "medium"} + /> + )} +
-

= 26 && "hidden" +

+ {booking.weekNumber} +

+
+ ) : ( +
= 26 + ? "min-h-[30px] flex-col mb-2 gap-[1px] items-end" + : "flex-row gap-2" }`} > - {booking.dateString} -

-
-
- +
); } diff --git a/frontend/src/hooks/staffing/useConsultantsFilter.ts b/frontend/src/hooks/staffing/useConsultantsFilter.ts index 2883dcdd..351de4e0 100644 --- a/frontend/src/hooks/staffing/useConsultantsFilter.ts +++ b/frontend/src/hooks/staffing/useConsultantsFilter.ts @@ -283,7 +283,7 @@ function setWeeklyInvoiceRate( let consultantAvailableWeekHours = numWorkHours - booking.bookingModel.totalHolidayHours - - booking.bookingModel.totalExludableAbsence - + booking.bookingModel.totalExcludableAbsence - booking.bookingModel.totalNotStartedOrQuit - booking.bookingModel.totalVacationHours;