From 59111c178ba3fc413d1178c3903e7d88bd42aa33 Mon Sep 17 00:00:00 2001 From: Esme Rubinstein Date: Tue, 31 Dec 2024 11:24:48 -0500 Subject: [PATCH] updating to remove mid month from aptc csr houshold --- .../aca_individuals/enrollment.rb | 13 ++++++------ .../aca_individuals/insurance_policy.rb | 11 ++++------ .../generators/reports/irs_monthly_xml.rb | 6 +++--- .../construct_cv3_payload.rb | 9 +++++--- .../aca_individuals/enrollment_spec.rb | 6 ------ .../aca_individuals/insurance_policy_spec.rb | 21 ------------------- .../construct_cv3_payload_spec.rb | 5 +++++ 7 files changed, 24 insertions(+), 47 deletions(-) diff --git a/app/models/insurance_policies/aca_individuals/enrollment.rb b/app/models/insurance_policies/aca_individuals/enrollment.rb index 271132e4..7ee5c80f 100644 --- a/app/models/insurance_policies/aca_individuals/enrollment.rb +++ b/app/models/insurance_policies/aca_individuals/enrollment.rb @@ -75,14 +75,13 @@ def pre_amt_tot_values(enrolled_thh_people, calendar_month) if insurance_policy.term_for_np end_on = insurance_policy.end_on next_month = calendar_month == 12 ? 1 : calendar_month + 1 - if eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month) || mid_month_end?(end_on, calendar_month) - format('%.2f', 0.0) - end - else - pre_amt_tot_month = enrolled_thh_people.map { |mem| mem.premium_schedule.premium_amount.to_f }.sum - pre_amt_tot_month = (pre_amt_tot_month * insurance_policy.insurance_product.ehb).to_f.round(2) - format('%.2f', pre_amt_tot_month) + # 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) 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) + format('%.2f', pre_amt_tot_month) end # Fetch eligible enrollees based on tax household members. diff --git a/app/models/insurance_policies/aca_individuals/insurance_policy.rb b/app/models/insurance_policies/aca_individuals/insurance_policy.rb index 96e5a3cc..3614d96a 100644 --- a/app/models/insurance_policies/aca_individuals/insurance_policy.rb +++ b/app/models/insurance_policies/aca_individuals/insurance_policy.rb @@ -121,7 +121,6 @@ def valid_enrollment_tax_household?(enr_thh, tax_household) # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity def applied_aptc_amount_for(enrollments_for_month, calender_month, tax_household) - return format('%.2f', val: 0.0) if term_for_np && mid_month_end?(policy_end_on, calender_month) en_tax_households = enrollments_tax_households(enrollments_for_month) enr_thhs_for_month = en_tax_households.select do |enr_thh| @@ -157,9 +156,7 @@ def applied_aptc_amount_for(enrollments_for_month, calender_month, tax_household # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - def fetch_aptc_tax_credit(enrs_for_month, calendar_month, tax_household = nil) - - return format('%.2f', 0.0) if term_for_np && mid_month_end?(policy_end_on, calendar_month) + def fetch_aptc_tax_credit(enrs_for_month, tax_household = nil) applied_aptc = enrs_for_month.map(&:total_premium_adjustment_amount).max return format('%.2f', (applied_aptc || 0.0)) if tax_household.blank? @@ -207,9 +204,9 @@ def fetch_slcsp_premium(enrs_for_month, calendar_month, tax_household = nil, apt if term_for_np end_on = policy_end_on next_month = calendar_month == 12 ? 1 : calendar_month + 1 - if 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) - end + # 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) end return format('%.2f', 0.0) if aptc_tax_credit.blank? || aptc_tax_credit.to_f.zero? diff --git a/app/operations/generators/reports/irs_monthly_xml.rb b/app/operations/generators/reports/irs_monthly_xml.rb index 759dfd0a..1a56d3be 100644 --- a/app/operations/generators/reports/irs_monthly_xml.rb +++ b/app/operations/generators/reports/irs_monthly_xml.rb @@ -103,7 +103,7 @@ def thh_to_pick(_tax_household, calendar_month) enrs_for_month = ::InsurancePolicies::AcaIndividuals::InsurancePolicy .enrollments_for_month(calendar_month, calendar_year, policies) enrs_for_month.each do |enrollment| - aptc = enrollment.insurance_policy.fetch_aptc_tax_credit([enrollment], calendar_month) + aptc = enrollment.insurance_policy.fetch_aptc_tax_credit([enrollment]) aptc_to_pick << aptc.to_f end @@ -189,7 +189,7 @@ def serialize_address(person_xml, address) def serialize_associated_policy(hh_xml, tax_household, calendar_month, enrollment) enrolled_thh_members = enrollment.enrolled_members_from_tax_household(tax_household) pre_amt_tot = enrollment.pre_amt_tot_values(enrolled_thh_members, calendar_month) - aptc_tax_credit = enrollment.insurance_policy.fetch_aptc_tax_credit([enrollment], calendar_month, tax_household) + aptc_tax_credit = enrollment.insurance_policy.fetch_aptc_tax_credit([enrollment], tax_household) slcsp = enrollment.insurance_policy.fetch_slcsp_premium([enrollment], calendar_month, tax_household) pediatric_dental_pre = enrollment.pediatric_dental_premium(tax_household.tax_household_members, calendar_month) total_premium = pre_amt_tot.to_f + pediatric_dental_pre @@ -237,7 +237,7 @@ def serialize_insurance_coverages(insured_pol_xml, policy) enrolled_members_for_month = [[sorted_enrollments.map(&:subscriber)] + sorted_enrollments.map(&:dependents)].flatten.uniq(&:person_id) pre_amt_tot = sorted_enrollments.first.pre_amt_tot_values(enrolled_members_for_month, calendar_month) - aptc_tax_credit = policy.fetch_aptc_tax_credit(sorted_enrollments, calendar_month) + aptc_tax_credit = policy.fetch_aptc_tax_credit(sorted_enrollments) slcsp = sorted_enrollments.first.insurance_policy.fetch_slcsp_premium(sorted_enrollments, calendar_month) pediatric_dental_pre = sorted_enrollments.first.pediatric_dental_premium(thh_members, calendar_month) 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 9a31a0b2..043a6f7b 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 @@ -430,6 +430,9 @@ 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 tax_household.is_aqhp && covered_individuals.present? update_covered_individuals_end_date(covered_individuals, enrollments_for_month, tax_household) end @@ -471,9 +474,9 @@ def calculate_ehb_premium_for(insurance_policy, tax_household, enrollments_for_m if insurance_policy.term_for_np end_on = insurance_policy.end_on next_month = calendar_month == 12 ? 1 : calendar_month + 1 - if 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) - end + # 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) 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 8b99104e..a5f7223f 100644 --- a/spec/models/insurance_policies/aca_individuals/enrollment_spec.rb +++ b/spec/models/insurance_policies/aca_individuals/enrollment_spec.rb @@ -127,12 +127,6 @@ 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 - context 'insurance_policy term_for_np is true and next month mid month end date' do it 'returns 0.00' do expect(enrollment_npt_mid_month.pre_amt_tot_values([subscriber], 2)).to eq('0.00') 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 c1603b85..3ea1d0bb 100644 --- a/spec/models/insurance_policies/aca_individuals/insurance_policy_spec.rb +++ b/spec/models/insurance_policies/aca_individuals/insurance_policy_spec.rb @@ -324,13 +324,6 @@ expect(result).to eq "0.00" end - it "should return 0 if on second grace period month" do - calendar_month = 3 - enrollments_for_month = insurance_policy_npt_mid_month.enrollments_for_month(calendar_month, year) - result = insurance_policy_npt_mid_month.applied_aptc_amount_for(enrollments_for_month, calendar_month, aqhp_tax_household_3) - expect(result).to eq "0.00" - end - it "should return a value if on first grace period month with EOM end date" do calendar_month = 5 enrollments_for_month = insurance_policy_npt_eom.enrollments_for_month(calendar_month, year) @@ -346,15 +339,6 @@ end end - context "#fetch_aptc_tax_credit" do - context "when in second grace period month" do - let(:tax_household) { FactoryBot.create(:tax_household, is_aqhp: false) } - it "should return 0" do - expect(insurance_policy_npt_mid_month.fetch_aptc_tax_credit([enrollment_1], 3, tax_household)).to eq "0.00" - end - end - end - context "#fetch_slcsp_premium" do context "when aptc is zero" do let(:enrollment_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) } @@ -387,11 +371,6 @@ expect(result_eom).to eq "0.00" expect(result_next_month_mid_month).to eq "0.00" end - - it "should return 0 if in second grace period month" do - result_mid_month = insurance_policy_npt_mid_month.fetch_slcsp_premium([enrollment], 3, aqhp_tax_household, 4.0) - expect(result_mid_month).to eq "0.00" - end end context "when aptc is non zero" do 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 9c191775..83485f73 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 @@ -566,6 +566,11 @@ expect(result.success?).to be_truthy end + it "should not return aptc_csr_household for month after GPM for mid month 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 + end + it "should return success on mid month npt polcies" do result = subject.call({ insurance_policy: npt_mid_month_insurance_policy }) expect(result.success?).to be_truthy