Skip to content

[ON-HOLD] Fix for inaccurate holiday entitlement calculations #6690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/smart_answer/calculators/holiday_entitlement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def fraction_of_year
days_in_year = leave_year_range.leap? ? DAYS_PER_LEAP_YEAR : DAYS_PER_YEAR

if started_after_year_began?
months_worked / MONTHS_PER_YEAR
days_worked / days_in_year
elsif worked_partial_year?
BigDecimal(leaving_date - start_date + 1.0, 10) / days_in_year
elsif left_before_year_end?
Expand Down Expand Up @@ -203,10 +203,8 @@ def worked_partial_year?
start_date.present? && leaving_date.present?
end

def months_worked
year_difference = BigDecimal(leave_year_range.ends_on.year - start_date.year, 10)
month_difference = MONTHS_PER_YEAR * year_difference + leave_year_range.ends_on.month - start_date.month
leave_year_range.ends_on.day >= start_date.day ? month_difference + 1 : month_difference
def days_worked
BigDecimal(leave_year_range.ends_on - start_date, 10)
end

def leave_year_range
Expand Down
Loading