Skip to content

Commit

Permalink
minor holiday bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbjoralt committed Nov 6, 2023
1 parent 3db7148 commit ef4c7a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions backend/Api/Consultants/ConsultantExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,22 +211,23 @@ private static BookedHoursPerWeek GetBookedHours(Week week, IEnumerable<Detailed
BookingType.Vacation,
week);

var bookedTime = totalBillable + totalAbsence + totalVacations + totalHolidayHours;
var hoursPrWorkDay = consultant.Department.Organization.HoursPerWorkday;

var rawSellableTime = consultant.Department.Organization.HoursPerWorkday * 5 - totalBillable -
totalOffered -
totalVacations - totalVacations - totalHolidayHours;
var totalFreeTime =
Math.Max(hoursPrWorkDay * 5 - bookedTime, 0);

var totalSellableTime = Math.Max(rawSellableTime, 0);
var totalOverBooked = Math.Min(rawSellableTime, 0);
var totalOverbooked =
Math.Max(bookedTime - hoursPrWorkDay * 5, 0);

return new BookedHoursPerWeek(
week.Year,
week.WeekNumber,
week.ToSortableInt(),
week.ToString(),
new WeeklyBookingReadModel(totalBillable, totalOffered, totalAbsence, totalSellableTime,
GetDatesForWeek(week),
new WeeklyBookingReadModel(totalBillable, totalOffered, totalAbsence, totalFreeTime,
totalHolidayHours, totalVacations,
totalOverBooked)
totalOverbooked)
);
}
}
4 changes: 2 additions & 2 deletions backend/Api/Organisation/OrganisationHolidayExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static bool IsPublicHoliday(this Organization organization, DateOnly day
{
var publicHoliday = organization.GetPublicHoliday();
var isPublicHoliday = publicHoliday.IsPublicHoliday(day.ToDateTime(TimeOnly.MinValue));
return isPublicHoliday || organization.IsChristmasHoliday(day);
return isPublicHoliday;
}

private static PublicHolidayBase GetPublicHoliday(this Organization organization)
Expand All @@ -44,7 +44,7 @@ private static PublicHolidayBase GetPublicHoliday(this Organization organization

private static bool IsChristmasHoliday(this Organization organization, DateOnly date)
{
if (organization.HasVacationInChristmas) return false;
if (!organization.HasVacationInChristmas) return false;

var startDate = new DateOnly(date.Year, 12, 24);
var endDate = new DateOnly(date.Year, 12, 31);
Expand Down

0 comments on commit ef4c7a0

Please sign in to comment.