Skip to content

Commit

Permalink
fixes off cycle benefit package display edge case scenario (#2475) (#…
Browse files Browse the repository at this point in the history
…2494)

Co-authored-by: Utkarsh Shukla <utkarsh7989@gmail.com>
  • Loading branch information
sri49 and utkarsh7989 authored Nov 29, 2023
1 parent 7a74ce3 commit 76b8dd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def overlapping_coverage_exists?(benefit_application)
end

def oe_extended_applications
benefit_applications.select do |application|
benefit_applications.select do |application|
application.enrollment_extended? && TimeKeeper.date_of_record > open_enrollment_period_for(application.effective_date).max
end
end
Expand Down Expand Up @@ -501,7 +501,7 @@ def dt_display_benefit_application
end

def off_cycle_benefit_application
recent_bas = benefit_applications.where(:aasm_state.ne => :canceled).order_by(:created_at.asc).to_a.last(3)
recent_bas = benefit_applications.where(:aasm_state.ne => :canceled).order_by(:created_at.asc).to_a.last(4)
termed_or_ineligible_app = recent_bas.select(&:is_termed_or_ineligible?).max_by(&:start_on)
return nil unless termed_or_ineligible_app

Expand Down Expand Up @@ -604,7 +604,7 @@ def carriers_dropped_for(product_kind)
renewal_benefit_application.predecessor.issuers_offered_for(product_kind) - renewal_benefit_application.issuers_offered_for(product_kind) if renewal_benefit_application.present?
late_renewal_benefit_application.predecessor.issuers_offered_for(product_kind) - late_renewal_benefit_application.issuers_offered_for(product_kind) if late_renewal_benefit_application.present?
end

####

# Workflow for self service
Expand All @@ -624,7 +624,7 @@ def carriers_dropped_for(product_kind)
state :suspended # Premium payment is 61-90 days past due and Sponsor's benefit coverage has lapsed
state :terminated # Sponsor's ability to offer benefits under this BenefitSponsorship is permanently terminated
state :ineligible # Sponsor is permanently banned from sponsoring benefits due to regulation or policy

# event :approve_initial_application do
# transitions from: [:applicant, :initial_application_under_review], to: :initial_application_approved
# end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,20 @@ module BenefitSponsors
it_behaves_like "for off-cycle employer", "active", "enrollment_ineligible", nil, false
it_behaves_like "for off-cycle employer", "active", "terminated", "draft", true
it_behaves_like "for off-cycle employer", "active", "termination_pending", "draft", true

context 'employer has 1 draft and 2 expired applications after terminated application' do
let(:start_on) { TimeKeeper.date_of_record.beginning_of_month.prev_month }
let(:termination_date) { TimeKeeper.date_of_record.next_month.end_of_month }
let!(:renewal_effective_period) { termination_date.next_day..termination_date.next_day.next_year.prev_day }
let!(:effective_period) { start_on..termination_date }
let!(:term_application) { create(:benefit_sponsors_benefit_application, aasm_state: :termination_pending, effective_period: effective_period, benefit_sponsorship: active_benefit_sponsorship) }
let!(:canceled_app1) { create(:benefit_sponsors_benefit_application, aasm_state: :expired, effective_period: renewal_effective_period, benefit_sponsorship: active_benefit_sponsorship) }
let!(:canceled_app2) { create(:benefit_sponsors_benefit_application, aasm_state: :expired, effective_period: renewal_effective_period, benefit_sponsorship: active_benefit_sponsorship) }
let!(:draft_app) { create(:benefit_sponsors_benefit_application, aasm_state: :draft, effective_period: renewal_effective_period, benefit_sponsorship: active_benefit_sponsorship) }


it { expect(active_benefit_sponsorship.off_cycle_benefit_application).to eq draft_app }
end
end
end
end

0 comments on commit 76b8dd0

Please sign in to comment.