From 2221a245da89159945214886a631255d08f4856e Mon Sep 17 00:00:00 2001 From: Esme Rubinstein Date: Thu, 2 Jan 2025 12:15:49 -0500 Subject: [PATCH] updating to include uqhp second gpm --- .../aca_individuals/enrollment.rb | 5 ++- .../aca_individuals/insurance_policy.rb | 5 ++- .../construct_cv3_payload.rb | 9 +++-- .../aca_individuals/enrollment_spec.rb | 6 +++ .../aca_individuals/insurance_policy_spec.rb | 4 +- .../construct_cv3_payload_spec.rb | 39 ++++++++++++++++--- 6 files changed, 54 insertions(+), 14 deletions(-) diff --git a/app/models/insurance_policies/aca_individuals/enrollment.rb b/app/models/insurance_policies/aca_individuals/enrollment.rb index cc6baf77..284019be 100644 --- a/app/models/insurance_policies/aca_individuals/enrollment.rb +++ b/app/models/insurance_policies/aca_individuals/enrollment.rb @@ -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) diff --git a/app/models/insurance_policies/aca_individuals/insurance_policy.rb b/app/models/insurance_policies/aca_individuals/insurance_policy.rb index 2c68040c..532767d0 100644 --- a/app/models/insurance_policies/aca_individuals/insurance_policy.rb +++ b/app/models/insurance_policies/aca_individuals/insurance_policy.rb @@ -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? diff --git a/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb b/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb index d05ec38f..29c3c610 100644 --- a/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb +++ b/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb @@ -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) @@ -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) diff --git a/spec/models/insurance_policies/aca_individuals/enrollment_spec.rb b/spec/models/insurance_policies/aca_individuals/enrollment_spec.rb index a5f7223f..7a0ee634 100644 --- a/spec/models/insurance_policies/aca_individuals/enrollment_spec.rb +++ b/spec/models/insurance_policies/aca_individuals/enrollment_spec.rb @@ -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 diff --git a/spec/models/insurance_policies/aca_individuals/insurance_policy_spec.rb b/spec/models/insurance_policies/aca_individuals/insurance_policy_spec.rb index 3ea1d0bb..f6132657 100644 --- a/spec/models/insurance_policies/aca_individuals/insurance_policy_spec.rb +++ b/spec/models/insurance_policies/aca_individuals/insurance_policy_spec.rb @@ -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 diff --git a/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb b/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb index 83485f73..37ffafcb 100644 --- a/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb +++ b/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb @@ -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 @@ -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, @@ -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