-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3042 from bitzesty/staging
Production < staging
- Loading branch information
Showing
1 changed file
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
module LatestYearGenerator | ||
def calculate_last_year(form_answer, day, month) | ||
# Conditional latest year | ||
# If from 7th of September to December -> then previous year | ||
# If from January to 6th of September -> then current year | ||
# | ||
|
||
@form_answer_award_year = form_answer.award_year.year if @form_answer_award_year.blank? | ||
|
||
if form_answer.financial_year_changeable? || (month.to_i == 9 && day.to_i > 6) || month.to_i > 9 | ||
@form_answer_award_year - 2 | ||
if form_answer.document["most_recent_financial_year"] | ||
@form_answer_award_year = form_answer.document["most_recent_financial_year"].to_i | ||
else | ||
@form_answer_award_year - 1 | ||
# Conditional latest year | ||
# If from 7th of September to December -> then previous year | ||
# If from January to 6th of September -> then current year | ||
# | ||
@form_answer_award_year = form_answer.award_year.year if @form_answer_award_year.blank? | ||
|
||
if form_answer.financial_year_changeable? || (month.to_i == 9 && day.to_i > 6) || month.to_i > 9 | ||
@form_answer_award_year - 2 | ||
else | ||
@form_answer_award_year - 1 | ||
end | ||
end | ||
end | ||
end |