Skip to content

Commit

Permalink
Merge dependent drop APTC changes to DC. (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
TreyE authored Apr 1, 2024
1 parent 995083f commit 768bcbd
Show file tree
Hide file tree
Showing 8 changed files with 778 additions and 60 deletions.
83 changes: 80 additions & 3 deletions .docker/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,88 @@
FROM --platform=linux/amd64 ruby:2.1.7 AS base
FROM --platform=linux/amd64 buildpack-deps:bionic as ruby-2.1.10-bionic

# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc

ENV RUBY_MAJOR 2.1
ENV RUBY_VERSION 2.1.10
ENV RUBY_DOWNLOAD_SHA256 5be9f8d5d29d252cd7f969ab7550e31bbb001feb4a83532301c0dd3b5006e148
ENV RUBYGEMS_VERSION 2.6.12

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
RUN apt update && apt-cache policy libssl1.0-dev
RUN apt-get -y install libssl1.0-dev

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -ex \
\
&& buildDeps=' \
bison \
libgdbm-dev \
ruby \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
\
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
\
&& mkdir -p /usr/src/ruby \
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
&& rm ruby.tar.xz \
\
&& cd /usr/src/ruby \
\
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
# warning: Insecure world writable dir
&& { \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new \
&& mv file.c.new file.c \
\
&& autoconf \
&& ./configure --disable-install-doc --enable-shared \
&& make -j"$(nproc)" \
&& make install \
\
&& apt-get purge -y --auto-remove $buildDeps \
&& cd / \
&& rm -r /usr/src/ruby \
\
&& gem update --system "$RUBYGEMS_VERSION"

ENV BUNDLER_VERSION 1.14.6

RUN gem install bundler --version "$BUNDLER_VERSION"

# install things globally, for great justice
# and don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_BIN="$GEM_HOME/bin" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $BUNDLE_BIN:$PATH
RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
&& chmod 777 "$GEM_HOME" "$BUNDLE_BIN"

CMD [ "irb" ]

FROM --platform=linux/amd64 ruby-2.1.10-bionic AS base

LABEL author="IdeaCrew"

# Install required packages/libraries
RUN apt-get update && \
apt-get -yq dist-upgrade && \
apt-get install -y git gcc openssl libyaml-dev libyaml-cpp-dev libyaml-cpp0.5 libffi-dev libffi6 libreadline-dev \
apt-get install -y git gcc openssl libyaml-dev libyaml-cpp-dev libyaml-cpp0.5v5 libffi-dev libffi6 libreadline-dev \
zlibc libgdbm-dev libncurses-dev autoconf fontconfig unzip zip sshpass bzip2 libxrender1 libxext6 \
build-essential && \
apt-get autoremove -y
Expand All @@ -21,7 +98,7 @@ RUN gem install bundler --version "1.17.3"

# Setting env up
ARG GEM_OAUTH_TOKEN
ENV BUNDLE_GITHUB__COM=x-access-token:"$GEM_OAUTH_TOKEN"
ENV BUNDLE_GITHUB__COM=$GEM_OAUTH_TOKEN:x-oauth-basic

RUN bundle install --jobs 20 --retry 5

Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/push_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jobs:
rspec:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Get Packages for Ruby Prerequisites
run: |
sudo apt-get -y update
Expand All @@ -15,11 +16,26 @@ jobs:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
sudo apt update && apt-cache policy libssl1.0-dev
sudo apt-get -y install libssl1.0-dev
- name: Install Ruby
- uses: actions/checkout@v3
- name: Download Ruby
run: |
curl -O https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.10.tar.bz2
- name: Cache Ruby
id: cache-ruby
uses: actions/cache@v3
with:
path: ruby-2.1.10
key: ${{ runner.os }}-gluedb-ruby-${{ hashFiles('**/Gemfile.lock', 'ruby-2.1.10.tar.bz2', '/usr/local/bin/ruby') }}
restore-keys: |
${{ runner.os }}-gluedb-ruby-${{ hashFiles('**/Gemfile.lock', 'ruby-2.1.10.tar.bz2', '/usr/local/bin/ruby') }}
- name: Build Ruby
if: steps.cache-ruby.outputs.cache-hit != 'true'
run: |
tar xjf ruby-2.1.10.tar.bz2
cd ruby-2.1.10 && ./configure && make -j 2
cd ruby-2.1.10 && ./configure --disable-install-doc && make -j 2
- name: Install Ruby
run: |
cd ruby-2.1.10
sudo make install
- name: Launch MongoDB
uses: wbari/[email protected]
Expand All @@ -30,7 +46,6 @@ jobs:
with:
# Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0, lts
node-version: 9.11.1
- uses: actions/checkout@v3
- name: Cache Gems
uses: actions/cache@v3
with:
Expand Down
9 changes: 8 additions & 1 deletion app/models/enrollment_action/dependent_drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class DependentDrop < Base
extend PlanComparisonHelper
extend DependentComparisonHelper
include RenewalComparisonHelper
include TerminationDateHelper

attr_accessor :dep_drop_from_renewal

Expand Down Expand Up @@ -35,6 +36,8 @@ def persist
policy_to_change.save
pol_updater = ExternalEvents::ExternalPolicyMemberDrop.new(policy_to_change, termination.policy_cv, dropped_dependents)
pol_updater.use_totals_from(action.policy_cv)
pol_updater.subscriber_start(action.subscriber_start)
pol_updater.member_drop_date(select_termination_date)
pol_updater.persist
true
end
Expand All @@ -50,21 +53,25 @@ def renewal_candidate

def publish
amqp_connection = termination.event_responder.connection
existing_policy = termination.existing_policy
existing_policy.reload
if @dep_drop_from_renewal
action_helper = ActionPublishHelper.new(action.event_xml)
action_helper.set_event_action("urn:openhbx:terms:v1:enrollment#auto_renew")
action_helper.keep_member_ends([])
publish_edi(amqp_connection, action_helper.to_xml, action.hbx_enrollment_id, action.employer_hbx_id)
else
existing_policy = termination.existing_policy
termination_helper = ActionPublishHelper.new(termination.event_xml)
member_date_map = {}
member_end_date_map = {}
existing_policy.enrollees.each do |en|
member_date_map[en.m_id] = en.coverage_start
member_end_date_map[en.m_id] = en.coverage_end
end
termination_helper.set_event_action("urn:openhbx:terms:v1:enrollment#change_member_terminate")
termination_helper.set_policy_id(existing_policy.eg_id)
termination_helper.set_member_starts(member_date_map)
termination_helper.set_member_end_date(member_end_date_map)
termination_helper.filter_affected_members(dropped_dependents)
termination_helper.replace_premium_totals(action.event_xml)
termination_helper.keep_member_ends(dropped_dependents)
Expand Down
40 changes: 38 additions & 2 deletions app/models/external_events/external_policy_member_drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def use_totals_from(other_policy_cv)
@total_source = other_policy_cv
end

def subscriber_start(subscriber_start_date)
@subscriber_start_date = subscriber_start_date
end

def member_drop_date(member_end_date)
@member_end_date = member_end_date
end

def extract_pre_amt_tot
@pre_amt_tot_val ||= begin
p_enrollment = Maybe.new(@total_source).policy_enrollment.value
Expand Down Expand Up @@ -94,6 +102,12 @@ def extract_other_financials
end
end

def is_shop?
p_enrollment = Maybe.new(@policy_node).policy_enrollment.value
return false if p_enrollment.blank?
p_enrollment.shop_market
end

def extract_rel_from_me(rel)
simple_relationship = Maybe.new(rel).relationship_uri.strip.split("#").last.downcase.value
case simple_relationship
Expand Down Expand Up @@ -142,9 +156,9 @@ def extract_rel_code(enrollee)
def term_enrollee(policy, enrollee_node)
member_id = extract_member_id(enrollee_node)
enrollee = policy.enrollees.detect { |en| en.m_id == member_id }
if enrollee
if enrollee
if @dropped_member_ids.include?(member_id)
enrollee.coverage_end = extract_enrollee_end(enrollee_node)
enrollee.coverage_end = @member_end_date
enrollee.coverage_status = "inactive"
enrollee.employment_status_code = "terminated"
end
Expand All @@ -161,8 +175,27 @@ def subscriber_id
end
end

def build_aptc_credits(pol)
unless is_shop?
tot_res_amt = extract_tot_res_amt.to_f
pre_amt_tot = extract_pre_amt_tot.to_f
aptc_amt = extract_other_financials[:applied_aptc].present? ? extract_other_financials[:applied_aptc].to_f : "0.0"
pol.set_aptc_effective_on(@subscriber_start_date, aptc_amt, pre_amt_tot, tot_res_amt)
pol.save!
end
end

def persist
pol = policy_to_update
unless is_shop?
if pol.multi_aptc? || extract_other_financials[:applied_aptc].present?
tot_res_amt = extract_tot_res_amt.to_f
pre_amt_tot = extract_pre_amt_tot.to_f
aptc_amt = extract_other_financials[:applied_aptc].present? ? extract_other_financials[:applied_aptc].to_f : "0.0"
pol.set_aptc_effective_on(@subscriber_start_date, aptc_amt, pre_amt_tot, tot_res_amt)
pol.save!
end
end
pol.update_attributes!({
:pre_amt_tot => extract_pre_amt_tot,
:tot_res_amt => extract_tot_res_amt
Expand All @@ -172,6 +205,9 @@ def persist
@policy_node.enrollees.each do |en|
term_enrollee(pol, en)
end

build_aptc_credits(pol)

unless all_terminations_exempt?(pol, @policy_node)
Observers::PolicyUpdated.notify(pol)
end
Expand Down
Loading

0 comments on commit 768bcbd

Please sign in to comment.