From 627de9339faa0341beacee387bf17a828988e78d Mon Sep 17 00:00:00 2001 From: Saipraveen Gudimetla Date: Wed, 11 Dec 2024 15:32:05 -0500 Subject: [PATCH 1/2] round down member premiums and sum up the total --- .../construct_cv3_payload.rb | 22 ++++--- .../construct_cv3_payload_spec.rb | 66 +++++++++++++++++-- 2 files changed, 76 insertions(+), 12 deletions(-) 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 7904d020..348afe42 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 @@ -472,12 +472,8 @@ def calculate_ehb_premium_for(insurance_policy, tax_household, enrollments_for_m member_start_on = [enrollment.start_on, calender_month_begin].max member_end_on = [enrollment.end_on || end_of_year, calender_month_end].min coverage_days = (member_start_on..member_end_on).count - premium_rate = - if enrolled_member.tobacco_use == 'Y' - premium_schedule.non_tobacco_use_premium - else - premium_schedule.premium_amount - end + member_ehb_premium = fetch_member_ehb_premium(enrolled_member, premium_schedule, insurance_policy) + premium_rate = round_down_float_two_decimals(member_ehb_premium) if calender_month_days == coverage_days premium_rate @@ -486,8 +482,18 @@ def calculate_ehb_premium_for(insurance_policy, tax_household, enrollments_for_m end end .round(2) - total_ehb_premium = round_down_float_two_decimals(premium_amount.to_f * insurance_policy.insurance_product.ehb) - format('%.2f', total_ehb_premium) + + format('%.2f', premium_amount) + end + + def fetch_member_ehb_premium(enrolled_member, premium_schedule, insurance_policy) + tobacco_premium = premium_schedule.non_tobacco_use_premium.to_f + non_tobacco_premium = premium_schedule.premium_amount.to_f + member_premium = enrolled_member.tobacco_use == 'Y' ? tobacco_premium : non_tobacco_premium + return member_premium if member_premium.to_d == 0.00.to_d + + result = member_premium * insurance_policy.insurance_product.ehb + member_premium - result >= 1 ? result : (member_premium - 1) end def get_enrolled_members_by_tax_household_for(enrollments_for_month, tax_household) 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 b8fe844d..5e0dc6ff 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 @@ -516,8 +516,11 @@ context 'rounding down total_ehb_premium' do let(:subscriber_person) { FactoryBot.create(:people_person) } + let(:dependent_person) { FactoryBot.create(:people_person) } let!(:glue_subscriber_person) { FactoryBot.create(:person, authority_member_id: subscriber_person.hbx_id) } + let!(:glue_dependent_person) { FactoryBot.create(:person, authority_member_id: dependent_person.hbx_id) } let(:enrollment_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) } + let(:enrollment_dependents) { FactoryBot.build(:enrolled_member, person: dependent_person) } let(:product) do FactoryBot.create(:insurance_product, ehb: 0.9959) end @@ -533,17 +536,26 @@ effectuated_on: Date.new(year, 1, 1), created_at: Time.now, insurance_policy: insurance_policy, - subscriber: enrollment_subscriber) + subscriber: enrollment_subscriber, + dependents: [enrollment_dependents]) end let!(:premium_schedule_enrollment) do FactoryBot.create(:premium_schedule, enrolled_member: enrollment.subscriber, premium_amount: 1710.26, benchmark_ehb_premium_amount: 1710.26) end + let!(:premium_schedule_2_enrollment) do + FactoryBot.create(:premium_schedule, enrolled_member: enrollment.dependents.first, + premium_amount: 1710.26, benchmark_ehb_premium_amount: 1710.26) + end let!(:aqhp_tax_household) { FactoryBot.create(:tax_household, is_aqhp: true) } - let!(:aqhp_thh_2_sub_tax_household_member) do + let!(:aqhp_thh_sub_tax_household_member) do FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household, person: subscriber_person, is_tax_filer: true) end + let!(:aqhp_thh_dep_tax_household_member) do + FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household, person: dependent_person, + is_tax_filer: false) + end let!(:aqhp_enrollment_tax_household) do FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment.id, tax_household_id: aqhp_tax_household.id) end @@ -555,13 +567,59 @@ it "should should publish the event" do expect(@result_call.success?).to be_truthy - expect(@result[:aptc_csr_tax_households].first[:covered_individuals].count).to eq 1 + expect(@result[:aptc_csr_tax_households].first[:covered_individuals].count).to eq 2 end it "should round down ehb premium value" do coverage_info = @result[:aptc_csr_tax_households].first[:months_of_year][0][:coverage_information] premium = coverage_info.dig(:total_premium, :cents) - expect(Money.new(premium).to_f).to eq 1703.24 + expect(Money.new(premium).to_f).to eq 3406.48 + end + end + + context 'rounding down member premiums' do + let(:subscriber_person) { FactoryBot.create(:people_person) } + let!(:glue_subscriber_person) { FactoryBot.create(:person, authority_member_id: subscriber_person.hbx_id) } + let(:enrollment_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) } + let(:product) do + FactoryBot.create(:insurance_product, ehb: 0.997604973763239) + end + let(:insurance_policy) do + FactoryBot.create(:insurance_policy, + insurance_product: product, + start_on: Date.new(year, 1, 1), + end_on: Date.new(year, 12, 31)) + end + + let!(:enrollment) do + FactoryBot.create(:enrollment, start_on: Date.new(year, 1, 1), + effectuated_on: Date.new(year, 1, 1), + created_at: Time.now, + insurance_policy: insurance_policy, + subscriber: enrollment_subscriber) + end + let!(:premium_schedule_enrollment) do + FactoryBot.create(:premium_schedule, enrolled_member: enrollment.subscriber, + premium_amount: 319.76, benchmark_ehb_premium_amount: 319.76) + end + let!(:aqhp_tax_household) { FactoryBot.create(:tax_household, is_aqhp: true) } + let!(:aqhp_thh_sub_tax_household_member) do + FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household, person: subscriber_person, + is_tax_filer: true) + end + let!(:aqhp_enrollment_tax_household) do + FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment.id, tax_household_id: aqhp_tax_household.id) + end + + before :each do + @result_call = subject.call({ insurance_policy: insurance_policy }) + @result = @result_call.value! + end + + it "adjusts the calculated EHB portion to ensure the remaining premium" do + coverage_info = @result[:aptc_csr_tax_households].first[:months_of_year][0][:coverage_information] + premium = coverage_info.dig(:total_premium, :cents) + expect(Money.new(premium).to_f).to eq 318.76 end end end From 60a78a38e4e490ed16fc65fa50ba737d27355538 Mon Sep 17 00:00:00 2001 From: Saipraveen Gudimetla Date: Wed, 11 Dec 2024 15:57:55 -0500 Subject: [PATCH 2/2] update rails to 7.0.8.7 to fix bundler-audit issue --- Gemfile | 2 +- Gemfile.lock | 138 +++++++++++++++++++++++++-------------------------- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Gemfile b/Gemfile index fdf62709..d0067695 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem 'pg' gem 'puma', '~> 6.4.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' -gem 'rails', '~> 7.0.8.5' +gem 'rails', '~> 7.0.8.7' gem 'rbnacl' diff --git a/Gemfile.lock b/Gemfile.lock index 60e80390..8ac78e1e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,67 +80,67 @@ GEM remote: https://rubygems.org/ specs: abbrev (0.1.2) - actioncable (7.0.8.5) - actionpack (= 7.0.8.5) - activesupport (= 7.0.8.5) + actioncable (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.5) - actionpack (= 7.0.8.5) - activejob (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + actionmailbox (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.5) - actionpack (= 7.0.8.5) - actionview (= 7.0.8.5) - activejob (= 7.0.8.5) - activesupport (= 7.0.8.5) + actionmailer (7.0.8.7) + actionpack (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8.5) - actionview (= 7.0.8.5) - activesupport (= 7.0.8.5) + actionpack (7.0.8.7) + actionview (= 7.0.8.7) + activesupport (= 7.0.8.7) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.5) - actionpack (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + actiontext (7.0.8.7) + actionpack (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.5) - activesupport (= 7.0.8.5) + actionview (7.0.8.7) + activesupport (= 7.0.8.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.5) - activesupport (= 7.0.8.5) + activejob (7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.3.6) - activemodel (7.0.8.5) - activesupport (= 7.0.8.5) - activerecord (7.0.8.5) - activemodel (= 7.0.8.5) - activesupport (= 7.0.8.5) - activestorage (7.0.8.5) - actionpack (= 7.0.8.5) - activejob (= 7.0.8.5) - activerecord (= 7.0.8.5) - activesupport (= 7.0.8.5) + activemodel (7.0.8.7) + activesupport (= 7.0.8.7) + activerecord (7.0.8.7) + activemodel (= 7.0.8.7) + activesupport (= 7.0.8.7) + activestorage (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activesupport (= 7.0.8.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8.5) + activesupport (7.0.8.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -156,7 +156,7 @@ GEM bootsnap (1.18.3) msgpack (~> 1.2) bson (4.15.0) - builder (3.2.4) + builder (3.3.0) bunny (2.22.0) amq-protocol (~> 2.3, >= 2.3.1) sorted_set (~> 1, >= 1.0.2) @@ -183,7 +183,7 @@ GEM mongoid (>= 3.0, < 9.0) mongoid-grid_fs (>= 1.3, < 3.0) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) crass (1.0.6) database_cleaner-active_record (2.1.0) activerecord (>= 5.a) @@ -192,7 +192,7 @@ GEM database_cleaner-mongoid (2.0.1) database_cleaner-core (~> 2.0.0) mongoid - date (3.3.4) + date (3.4.1) datev (0.11.0) deep_merge (1.2.2) diff-lcs (1.5.1) @@ -251,7 +251,7 @@ GEM dry-initializer (~> 3.0) dry-schema (~> 1.11, >= 1.11.0) zeitwerk (~> 2.6) - erubi (1.12.0) + erubi (1.13.0) ethon (0.16.0) ffi (>= 1.15.0) factory_bot (6.4.6) @@ -281,7 +281,7 @@ GEM temple (>= 0.8.2) thor tilt - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) ice_nine (0.11.2) image_processing (1.12.2) @@ -308,16 +308,16 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) mime-types-data (3.2024.0206) mini_magick (4.12.0) mini_mime (1.1.5) mini_portile2 (2.8.8) - minitest (5.22.2) + minitest (5.25.4) monetize (1.13.0) money (~> 6.12) money (6.16.0) @@ -349,7 +349,7 @@ GEM msgpack (1.7.2) multi_json (1.15.0) multipart-post (2.4.0) - net-imap (0.5.0) + net-imap (0.5.1) date net-protocol net-pop (0.1.2) @@ -358,7 +358,7 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.0) + nio4r (2.7.4) nokogiri (1.16.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) @@ -389,23 +389,23 @@ GEM puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.8.1) + rack (2.2.10) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.5) - actioncable (= 7.0.8.5) - actionmailbox (= 7.0.8.5) - actionmailer (= 7.0.8.5) - actionpack (= 7.0.8.5) - actiontext (= 7.0.8.5) - actionview (= 7.0.8.5) - activejob (= 7.0.8.5) - activemodel (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + rails (7.0.8.7) + actioncable (= 7.0.8.7) + actionmailbox (= 7.0.8.7) + actionmailer (= 7.0.8.7) + actionpack (= 7.0.8.7) + actiontext (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activemodel (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) bundler (>= 1.15.0) - railties (= 7.0.8.5) + railties (= 7.0.8.7) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -413,15 +413,15 @@ GEM rails-html-sanitizer (1.6.1) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.0.8.5) - actionpack (= 7.0.8.5) - activesupport (= 7.0.8.5) + railties (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rbnacl (7.1.1) ffi rbs (3.4.4) @@ -505,9 +505,9 @@ GEM rbs syntax_tree (>= 2.0.1) temple (0.10.3) - thor (1.3.1) + thor (1.3.2) tilt (2.3.0) - timeout (0.4.1) + timeout (0.4.2) turbo-rails (2.0.4) actionpack (>= 6.0.0) activejob (>= 6.0.0) @@ -535,7 +535,7 @@ GEM yard (0.9.36) yard-mongoid (0.1.0) yard (>= 0.8.4) - zeitwerk (2.6.13) + zeitwerk (2.7.1) PLATFORMS arm64-darwin-21 @@ -566,7 +566,7 @@ DEPENDENCIES prettier pry-byebug puma (~> 6.4.3) - rails (~> 7.0.8.5) + rails (~> 7.0.8.7) rbnacl redcarpet resource_registry!