Skip to content

Commit

Permalink
handling reterm retro canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
nisanthyaganti9 committed Jun 26, 2024
1 parent 420b336 commit 16bbced
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/models/external_events/enrollment_event_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,12 @@ def is_eligible_term?
return false unless is_termination?
return false unless extract_enrollee_end(subscriber).present?
return false if existing_policy.blank?
return true unless existing_policy.terminated?

existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber)
is_reterm_retro_canceled? || (existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber))
end

def is_reterm_retro_canceled?
extract_enrollee_end(subscriber) == existing_policy.policy_start
end

def enrollment_action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
allow(subject).to receive(:is_termination?).and_return(true)
allow(subject).to receive(:hbx_enrollment_id).and_return(hbx_enrollment_id)
allow(subject).to receive(:enrollment_action).and_return("urn:openhbx:terms:v1:enrollment#terminate_enrollment")
allow(subject).to receive(:is_eligible_term?).and_return(true)
allow(subject).to receive(:is_eligible_term?).and_return(true)
end

it "returns false" do
Expand All @@ -752,4 +752,32 @@
subject.drop_if_already_processed!
end
end

context '#is_reterm_retro_canceled' do
let(:enrollee) { double }
let(:existing_policy) { double(policy_start: start_date)}
let(:start_date) { Date.today.beginning_of_month }

before do
allow(subject).to receive(:subscriber).and_return(enrollee)
allow(subject).to receive(:extract_enrollee_end).with(enrollee).and_return(end_date)
allow(subject).to receive(:existing_policy).and_return(existing_policy)
end

context 'when existing policy start date matches with xml end date' do
let(:end_date) { start_date }

it 'returns true' do
expect(subject.is_reterm_retro_canceled?).to eq true
end
end

context 'when existing policy start date does matches with xml end date' do
let(:end_date) { start_date + 5.days }

it 'returns true' do
expect(subject.is_reterm_retro_canceled?).to eq false
end
end
end
end

0 comments on commit 16bbced

Please sign in to comment.