Skip to content

Commit

Permalink
updating to include uqhp second gpm
Browse files Browse the repository at this point in the history
  • Loading branch information
erubinst committed Jan 2, 2025
1 parent 13865e6 commit 2221a24
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 14 deletions.
5 changes: 3 additions & 2 deletions app/models/insurance_policies/aca_individuals/enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def pre_amt_tot_values(enrolled_thh_people, calendar_month)
end_on = insurance_policy.end_on
next_month = calendar_month == 12 ? 1 : calendar_month + 1
# if npt policy ends on the last day of the month or mid month next month
# set to 0 as we are in the first grace period month
return format('%.2f', 0.0) if eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month)
# set to 0 as we are in the first or second (for uqhp) grace period month
gpm = eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month) || mid_month_end?(end_on, calendar_month)
return format('%.2f', 0.0) if gpm
end
pre_amt_tot_month = enrolled_thh_people.sum { |mem| mem.premium_schedule.premium_amount.to_f }
pre_amt_tot_month = (pre_amt_tot_month * insurance_policy.insurance_product.ehb).to_f.round(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ def fetch_slcsp_premium(enrs_for_month, calendar_month, tax_household = nil, apt
end_on = policy_end_on
next_month = calendar_month == 12 ? 1 : calendar_month + 1
# if npt policy ends on the last day of the month or mid month next month
# set to 0 as we are in the first grace period month
return format('%.2f', 0.0) if eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month)
# set to 0 as we are in the first or second (for uqhp) grace period month
gpm = eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month) || mid_month_end?(end_on, calendar_month)
return format('%.2f', 0.0) if gpm
end

return format('%.2f', 0.0) if aptc_tax_credit.blank? || aptc_tax_credit.to_f.zero?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ def construct_coverage_information(insurance_policy, covered_individuals, tax_ho
next unless any_thh_members_enrolled?(tax_household, enrollments_for_month)
next if enrollments_tax_household_for_month_empty?(enrollments_for_month, tax_household)

# if npt and mid month end date, do not include that month
next if insurance_policy.term_for_np && mid_month_end?(insurance_policy.end_on, month)
# if npt and mid month end date, do not include that month if aqhp
next if insurance_policy.term_for_np && mid_month_end?(insurance_policy.end_on, month) && tax_household.is_aqhp

if tax_household.is_aqhp && covered_individuals.present?
update_covered_individuals_end_date(covered_individuals, enrollments_for_month, tax_household)
Expand Down Expand Up @@ -464,8 +464,9 @@ def calculate_ehb_premium_for(insurance_policy, tax_household, enrollments_for_m
end_on = insurance_policy.end_on
next_month = calendar_month == 12 ? 1 : calendar_month + 1
# if npt policy ends on the last day of the month or mid month next month
# set to 0 as we are in the first grace period month
return format('%.2f', 0.0) if eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month)
# set to 0 as we are in the first or second (for uqhp) grace period month
gpm = eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month) || mid_month_end?(end_on, calendar_month)
return format('%.2f', 0.0) if gpm
end

calender_month_begin = Date.new(insurance_policy.start_on.year, calendar_month, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,11 @@
expect(enrollment_npt_mid_month.pre_amt_tot_values([subscriber], 2)).to eq('0.00')
end
end

context 'insurance_policy term_for_np is true and mid month end date' do
it 'returns 0.00' do
expect(enrollment_npt_mid_month.pre_amt_tot_values([subscriber], 3)).to eq('0.00')
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,13 @@
aqhp_enrollment_tax_household.applied_aptc)).to eq "0.00"
end

it "should return 0 if in first grace period month" do
it "should return 0 if in first or second (for uqhp) grace period month" do
result_eom = insurance_policy_npt_eom.fetch_slcsp_premium([enrollment], 5, aqhp_tax_household, 4.0)
result_next_month_mid_month = insurance_policy_npt_mid_month.fetch_slcsp_premium([enrollment], 2, aqhp_tax_household, 4.0)
result_mid_month = insurance_policy_npt_mid_month.fetch_slcsp_premium([enrollment], 3, aqhp_tax_household, 4.0)
expect(result_eom).to eq "0.00"
expect(result_next_month_mid_month).to eq "0.00"
expect(result_mid_month).to eq "0.00"
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,23 @@
end
end

context "when on an assisted npt policy" do
context "when on an npt policy" do
let(:enrollment_1_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) }
# create insurance policy copy but set term_for_np to true
let(:enrollment_2_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) }

let!(:aqhp_tax_household_1) { FactoryBot.create(:tax_household, is_aqhp: true) }
let!(:uqhp_tax_household_1) { FactoryBot.create(:tax_household, is_aqhp: false) }

let!(:aqhp_tax_household_member_1) do
FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household_1, person: subscriber_person,
is_tax_filer: true)
end

let!(:uqhp_tax_household_member_1) do
FactoryBot.create(:tax_household_member, tax_household: uqhp_tax_household_1, person: subscriber_person,
is_tax_filer: true)
end

let(:npt_eom_insurance_policy) do
FactoryBot.create(:insurance_policy, start_on: Date.new(year, 1, 1), end_on: Date.new(year, 5, 31), term_for_np: true)
end
Expand All @@ -548,8 +555,22 @@
subscriber: enrollment_1_subscriber)
end

let(:npt_mid_month_uqhp_insurance_policy) do
FactoryBot.create(:insurance_policy, start_on: Date.new(year, 1, 1), end_on: Date.new(year, 3, 3), term_for_np: true)
end

let(:enrollment_npt_mid_month_uqhp) do
FactoryBot.create(:enrollment, start_on: Date.new(year, 1, 1),
effectuated_on: Date.new(year, 1, 1),
end_on: Date.new(year, 3, 3),
created_at: Time.now,
insurance_policy: npt_mid_month_uqhp_insurance_policy,
subscriber: enrollment_2_subscriber)
end

let!(:premium_schedule_1) { FactoryBot.create(:premium_schedule, enrolled_member: enrollment_npt_eom.subscriber) }
let!(:premium_schedule_2) { FactoryBot.create(:premium_schedule, enrolled_member: enrollment_npt_mid_month.subscriber) }
let!(:premium_schedule_3) { FactoryBot.create(:premium_schedule, enrolled_member: enrollment_npt_mid_month_uqhp.subscriber) }

let!(:aqhp_enrollment_tax_household_1) do
FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment_npt_eom.id,
Expand All @@ -561,18 +582,26 @@
tax_household_id: aqhp_tax_household_1.id)
end

let!(:uqhp_enrollment_tax_household_1) do
FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment_npt_mid_month_uqhp.id,
tax_household_id: uqhp_tax_household_1.id)
end

it "should return success on eom npt policies" do
result = subject.call({ insurance_policy: npt_eom_insurance_policy })
expect(result.success?).to be_truthy
end

it "should not return aptc_csr_household for month after GPM for mid month npt policies" do
it "should not return aptc_csr_household for month after GPM for mid month aqhp npt policies" do
result = subject.call({ insurance_policy: npt_mid_month_insurance_policy })
expect(result.value![:aptc_csr_tax_households][0][:months_of_year].count).to eq 2
expect(result.success?).to be_truthy
end

it "should return success on mid month npt polcies" do
result = subject.call({ insurance_policy: npt_mid_month_insurance_policy })
it "should include mid month for uqhp npt policies" do
result = subject.call({ insurance_policy: npt_mid_month_uqhp_insurance_policy })
expect(result.value![:aptc_csr_tax_households][0][:months_of_year].count).to eq 3
print(result.value![:aptc_csr_tax_households][0][:months_of_year])
expect(result.success?).to be_truthy
end
end
Expand Down

0 comments on commit 2221a24

Please sign in to comment.