Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy branch tests for 2024-09-19 #153

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions app/models/insurance_policies/aca_individuals/enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,10 @@ def enrollment_end_on
end_on.present? ? end_on : insurance_policy.start_on.end_of_year
end

def mid_month_end?(end_on, month)
ends_this_month = end_on.month == month
last_day_of_month = Date.new(end_on.year, month, -1)
(end_on.day != last_day_of_month.day) && ends_this_month
end

def eom_end?(end_on, month)
ends_this_month = end_on.month == month
last_day_of_month = Date.new(end_on.year, month, -1)
(end_on == last_day_of_month) && ends_this_month
end

# rubocop:disable Metrics/AbcSize
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 ends mid month on the current month, set to blank
if mid_month_end?(end_on, calendar_month)
nil
# if ends EOM current month OR ends mid month next month, set to 0
elsif eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month)
format('%.2f', 0.0)
end
if insurance_policy.term_for_np && insurance_policy.policy_end_on.month == calendar_month
format('%.2f', 0.0)
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)
Expand Down Expand Up @@ -118,6 +99,7 @@ def pediatric_dental_premium(enrollments_for_month, tax_household_members, calen
health_enrolled_people: eligible_enrollees,
month: calendar_month }).value!.to_f
end
# rubocop:enable Metrics/AbcSize

def enrolled_member_by_hbx_id(hbx_id)
[[subscriber] + dependents].flatten.detect do |enrollee|
Expand Down
32 changes: 2 additions & 30 deletions app/models/insurance_policies/aca_individuals/insurance_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,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 nil 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|
valid_enrollment_tax_household?(enr_thh, tax_household) && enr_thh.tax_household.is_aqhp
Expand Down Expand Up @@ -156,10 +154,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 nil 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 @@ -190,32 +185,9 @@ def fetch_enrollments_tax_households(enrs_for_month)
.where(:enrollment_id.in => enrs_for_month.pluck(:id))
end

def mid_month_end?(end_on, month)
ends_this_month = end_on.month == month
last_day_of_month = Date.new(end_on.year, month, -1)
(end_on.day != last_day_of_month.day) && ends_this_month
end

def eom_end?(end_on, month)
ends_this_month = end_on.month == month
last_day_of_month = Date.new(end_on.year, month, -1)
(end_on == last_day_of_month) && ends_this_month
end

def fetch_slcsp_premium(enrs_for_month, calendar_month, tax_household = nil, aptc_tax_credit = nil)
return format('%.2f', 0.0) if aptc_tax_credit.blank? || aptc_tax_credit.to_f.zero?

if term_for_np
end_on = policy_end_on
next_month = calendar_month == 12 ? 1 : calendar_month + 1
# if ends mid month on the current month, set to blank
if mid_month_end?(end_on, calendar_month)
return nil
# if ends EOM current month OR ends mid month next month, set to 0
elsif eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month)
return format('%.2f', 0.0)
end
end
return format('%.2f', 0.0) if term_for_np && policy_end_on.month == calendar_month

enr_thhs = fetch_enrollments_tax_households(enrs_for_month)
slcsp_premium = enr_thhs.map(&:household_benchmark_ehb_premium).compact.sum
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 @@ -453,31 +453,8 @@ def construct_coverage_information(insurance_policy, covered_individuals, tax_ho
end
end

def mid_month_end?(end_on, month)
ends_this_month = end_on.month == month
last_day_of_month = Date.new(end_on.year, month, -1)
(end_on.day != last_day_of_month.day) && ends_this_month
end

def eom_end?(end_on, month)
ends_this_month = end_on.month == month
last_day_of_month = Date.new(end_on.year, month, -1)
(end_on == last_day_of_month) && ends_this_month
end

def calculate_ehb_premium_for(insurance_policy, tax_household, enrollments_for_month, calendar_month)

if insurance_policy.term_for_np
end_on = insurance_policy.end_on
next_month = calendar_month == 12 ? 1 : calendar_month + 1
# if ends mid month on the current month, set to blank
if mid_month_end?(end_on, calendar_month)
return nil
# if ends EOM current month OR ends mid month next month, set to 0
elsif eom_end?(end_on, calendar_month) || mid_month_end?(end_on, next_month)
return format('%.2f', 0.0)
end
end
return format('%.2f', 0.0) if insurance_policy.term_for_np && insurance_policy.policy_end_on.month == calendar_month

calender_month_begin = Date.new(insurance_policy.start_on.year, calendar_month, 1)
calender_month_end = calender_month_begin.end_of_month
Expand Down
48 changes: 0 additions & 48 deletions spec/models/insurance_policies/aca_individuals/enrollment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@
let(:insurance_policy) do
FactoryBot.create(:insurance_policy, start_on: Date.new(year, 1, 1), end_on: Date.new(year, 12, 31))
end
let(:insurance_policy_npt_eom) do
FactoryBot.create(:insurance_policy, start_on: Date.new(year, 1, 1),
end_on: Date.new(year, 5, 31),
term_for_np: true)
end
let(:insurance_policy_npt_mid_month) 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(:subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) }
let(:dependents) do
[
Expand All @@ -39,24 +29,6 @@
dependents: dependents)
end

let(:enrollment_npt_eom) do
FactoryBot.create(:enrollment, start_on: Date.new(year, 1, 1),
effectuated_on: Date.new(year, 1, 1),
end_on: Date.new(year, 5, 31),
insurance_policy: insurance_policy_npt_eom,
subscriber: subscriber,
dependents: dependents)
end

let(:enrollment_npt_mid_month) do
FactoryBot.create(:enrollment, start_on: Date.new(year, 1, 1),
effectuated_on: Date.new(year, 1, 1),
end_on: Date.new(year, 5, 31),
insurance_policy: insurance_policy_npt_mid_month,
subscriber: subscriber,
dependents: dependents)
end

let(:tax_household_members) do
[
double('InsurancePolicies::AcaIndividuals::TaxHouseholdMember', is_medicaid_chip_eligible: true, person: subscriber_person),
Expand Down Expand Up @@ -119,24 +91,4 @@
end
end
end

describe '#pre_amt_tot_values' do
context 'insurance_policy term_for_np is true and eom end date' do
it 'returns 0.00' do
expect(enrollment_npt_eom.pre_amt_tot_values([subscriber], 5)).to eq('0.00')
end
end

context 'insurance_policy term_for_np is true and mid month end date' do
it 'returns nil' do
expect(enrollment_npt_mid_month.pre_amt_tot_values([subscriber], 3)).to eq(nil)
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')
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@

let(:year) { Date.today.year }
let(:insurance_policy) { FactoryBot.create(:insurance_policy, start_on: Date.new(year, 1, 1), end_on: Date.new(year, 12, 31)) }
let(:insurance_policy_npt_eom) do
FactoryBot.create(:insurance_policy, start_on: Date.new(year, 1, 1),
end_on: Date.new(year, 5, 31),
term_for_np: true)
end
let(:insurance_policy_npt_mid_month) 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(:subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) }
let(:dependents) { FactoryBot.build(:enrolled_member, person: dependent_person) }
let!(:enrollment_1) do
Expand Down Expand Up @@ -298,36 +288,6 @@
result = insurance_policy.applied_aptc_amount_for(enrollments_for_month, calendar_month, aqhp_tax_household_3)
expect(result).to eq "0.00"
end

it "should return nil 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 nil
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)
result = insurance_policy_npt_eom.applied_aptc_amount_for(enrollments_for_month, calendar_month, aqhp_tax_household_3)
expect(result).not_to eq nil
end

it "should return a value if on first grace period month with next month mid month end date" do
calendar_month = 2
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).not_to eq nil
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 nil" do
expect(insurance_policy_npt_mid_month.fetch_aptc_tax_credit([enrollment_1], 3, tax_household)).to eq nil
end
end
end

context "#fetch_slcsp_premium" do
Expand Down Expand Up @@ -355,18 +315,6 @@
expect(insurance_policy.fetch_slcsp_premium([enrollment], 1, aqhp_tax_household,
aqhp_enrollment_tax_household.applied_aptc)).to eq "0.00"
end

it "should return 0 if in first 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)
expect(result_eom).to eq "0.00"
expect(result_next_month_mid_month).to eq "0.00"
end

it "should return nil 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 nil
end
end

context "when aptc is non zero" do
Expand Down
Loading