Skip to content

Commit

Permalink
Dry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
javier-npq committed Jul 14, 2023
1 parent ce0feaf commit f3c3e97
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/lib/forms/choose_your_npq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def next_step
elsif wizard.query_store.works_in_other?
if lead_mentor?
:ineligible_for_funding
elsif wizard.query_store.employment_type_other? || (wizard.query_store.teacher_catchment_england? && !wizard.query_store.employment_type_other?)
elsif wizard.query_store.employment_type_other? || wizard.query_store.valid_employent_type_for_england?
:possible_funding
else
:choose_your_provider
Expand Down
6 changes: 5 additions & 1 deletion app/lib/forms/possible_funding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def after_save
def message_template
return "private_childcare_provider" if institution.is_a?(PrivateChildcareProvider)
return "lead_mentor" if Course.npqltd.include?(course)
return "funding_eligibility_unclear" if (works_in_other? && employment_type_other?) || (works_in_other? && !employment_type_other? && teacher_catchment_england?)
return "funding_eligibility_unclear" if works_in_other? && (employment_type_other? || valid_employent_type_for_england?)

if targeted_delivery_funding_eligibility?
"eligible_for_scholarship_funding"
Expand All @@ -48,6 +48,10 @@ def teacher_catchment_england?
wizard.query_store.teacher_catchment_england?
end

def valid_employent_type_for_england?
wizard.query_store.valid_employent_type_for_england?
end

def targeted_delivery_funding_eligibility?
wizard.query_store.targeted_delivery_funding_eligibility?
end
Expand Down
4 changes: 4 additions & 0 deletions app/lib/services/query_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def teacher_catchment_england?
store["teacher_catchment"] == "england"
end

def valid_employent_type_for_england?
teacher_catchment_england? && !employment_type_other?
end

def works_in_school?
store["works_in_school"] == "yes"
end
Expand Down

0 comments on commit f3c3e97

Please sign in to comment.