Skip to content

Commit

Permalink
updating to remove mid month from aptc csr houshold
Browse files Browse the repository at this point in the history
  • Loading branch information
erubinst committed Dec 31, 2024
1 parent 31e0494 commit 59111c1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 47 deletions.
13 changes: 6 additions & 7 deletions app/models/insurance_policies/aca_individuals/enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('%<val>.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|
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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?
Expand Down
6 changes: 3 additions & 3 deletions app/operations/generators/reports/irs_monthly_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) }
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 59111c1

Please sign in to comment.