Skip to content

Commit 768bcbd

Browse files
authored
Merge dependent drop APTC changes to DC. (#190)
1 parent 995083f commit 768bcbd

File tree

8 files changed

+778
-60
lines changed

8 files changed

+778
-60
lines changed

.docker/development/Dockerfile

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,88 @@
1-
FROM --platform=linux/amd64 ruby:2.1.7 AS base
1+
FROM --platform=linux/amd64 buildpack-deps:bionic as ruby-2.1.10-bionic
2+
3+
# skip installing gem documentation
4+
RUN mkdir -p /usr/local/etc \
5+
&& { \
6+
echo 'install: --no-document'; \
7+
echo 'update: --no-document'; \
8+
} >> /usr/local/etc/gemrc
9+
10+
ENV RUBY_MAJOR 2.1
11+
ENV RUBY_VERSION 2.1.10
12+
ENV RUBY_DOWNLOAD_SHA256 5be9f8d5d29d252cd7f969ab7550e31bbb001feb4a83532301c0dd3b5006e148
13+
ENV RUBYGEMS_VERSION 2.6.12
14+
15+
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
16+
RUN apt update && apt-cache policy libssl1.0-dev
17+
RUN apt-get -y install libssl1.0-dev
18+
19+
# some of ruby's build scripts are written in ruby
20+
# we purge system ruby later to make sure our final image uses what we just built
21+
RUN set -ex \
22+
\
23+
&& buildDeps=' \
24+
bison \
25+
libgdbm-dev \
26+
ruby \
27+
' \
28+
&& apt-get update \
29+
&& apt-get install -y --no-install-recommends $buildDeps \
30+
&& rm -rf /var/lib/apt/lists/* \
31+
\
32+
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
33+
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
34+
\
35+
&& mkdir -p /usr/src/ruby \
36+
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
37+
&& rm ruby.tar.xz \
38+
\
39+
&& cd /usr/src/ruby \
40+
\
41+
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
42+
# warning: Insecure world writable dir
43+
&& { \
44+
echo '#define ENABLE_PATH_CHECK 0'; \
45+
echo; \
46+
cat file.c; \
47+
} > file.c.new \
48+
&& mv file.c.new file.c \
49+
\
50+
&& autoconf \
51+
&& ./configure --disable-install-doc --enable-shared \
52+
&& make -j"$(nproc)" \
53+
&& make install \
54+
\
55+
&& apt-get purge -y --auto-remove $buildDeps \
56+
&& cd / \
57+
&& rm -r /usr/src/ruby \
58+
\
59+
&& gem update --system "$RUBYGEMS_VERSION"
60+
61+
ENV BUNDLER_VERSION 1.14.6
62+
63+
RUN gem install bundler --version "$BUNDLER_VERSION"
64+
65+
# install things globally, for great justice
66+
# and don't create ".bundle" in all our apps
67+
ENV GEM_HOME /usr/local/bundle
68+
ENV BUNDLE_PATH="$GEM_HOME" \
69+
BUNDLE_BIN="$GEM_HOME/bin" \
70+
BUNDLE_SILENCE_ROOT_WARNING=1 \
71+
BUNDLE_APP_CONFIG="$GEM_HOME"
72+
ENV PATH $BUNDLE_BIN:$PATH
73+
RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
74+
&& chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
75+
76+
CMD [ "irb" ]
77+
78+
FROM --platform=linux/amd64 ruby-2.1.10-bionic AS base
279

380
LABEL author="IdeaCrew"
481

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

2299
# Setting env up
23100
ARG GEM_OAUTH_TOKEN
24-
ENV BUNDLE_GITHUB__COM=x-access-token:"$GEM_OAUTH_TOKEN"
101+
ENV BUNDLE_GITHUB__COM=$GEM_OAUTH_TOKEN:x-oauth-basic
25102

26103
RUN bundle install --jobs 20 --retry 5
27104

.github/workflows/push_checks.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ jobs:
55
rspec:
66
runs-on: ubuntu-22.04
77
steps:
8+
- uses: actions/checkout@v3
89
- name: Get Packages for Ruby Prerequisites
910
run: |
1011
sudo apt-get -y update
@@ -15,11 +16,26 @@ jobs:
1516
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
1617
sudo apt update && apt-cache policy libssl1.0-dev
1718
sudo apt-get -y install libssl1.0-dev
18-
- name: Install Ruby
19+
- uses: actions/checkout@v3
20+
- name: Download Ruby
1921
run: |
2022
curl -O https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.10.tar.bz2
23+
- name: Cache Ruby
24+
id: cache-ruby
25+
uses: actions/cache@v3
26+
with:
27+
path: ruby-2.1.10
28+
key: ${{ runner.os }}-gluedb-ruby-${{ hashFiles('**/Gemfile.lock', 'ruby-2.1.10.tar.bz2', '/usr/local/bin/ruby') }}
29+
restore-keys: |
30+
${{ runner.os }}-gluedb-ruby-${{ hashFiles('**/Gemfile.lock', 'ruby-2.1.10.tar.bz2', '/usr/local/bin/ruby') }}
31+
- name: Build Ruby
32+
if: steps.cache-ruby.outputs.cache-hit != 'true'
33+
run: |
2134
tar xjf ruby-2.1.10.tar.bz2
22-
cd ruby-2.1.10 && ./configure && make -j 2
35+
cd ruby-2.1.10 && ./configure --disable-install-doc && make -j 2
36+
- name: Install Ruby
37+
run: |
38+
cd ruby-2.1.10
2339
sudo make install
2440
- name: Launch MongoDB
2541
uses: wbari/[email protected]
@@ -30,7 +46,6 @@ jobs:
3046
with:
3147
# Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0, lts
3248
node-version: 9.11.1
33-
- uses: actions/checkout@v3
3449
- name: Cache Gems
3550
uses: actions/cache@v3
3651
with:

app/models/enrollment_action/dependent_drop.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class DependentDrop < Base
33
extend PlanComparisonHelper
44
extend DependentComparisonHelper
55
include RenewalComparisonHelper
6+
include TerminationDateHelper
67

78
attr_accessor :dep_drop_from_renewal
89

@@ -35,6 +36,8 @@ def persist
3536
policy_to_change.save
3637
pol_updater = ExternalEvents::ExternalPolicyMemberDrop.new(policy_to_change, termination.policy_cv, dropped_dependents)
3738
pol_updater.use_totals_from(action.policy_cv)
39+
pol_updater.subscriber_start(action.subscriber_start)
40+
pol_updater.member_drop_date(select_termination_date)
3841
pol_updater.persist
3942
true
4043
end
@@ -50,21 +53,25 @@ def renewal_candidate
5053

5154
def publish
5255
amqp_connection = termination.event_responder.connection
56+
existing_policy = termination.existing_policy
57+
existing_policy.reload
5358
if @dep_drop_from_renewal
5459
action_helper = ActionPublishHelper.new(action.event_xml)
5560
action_helper.set_event_action("urn:openhbx:terms:v1:enrollment#auto_renew")
5661
action_helper.keep_member_ends([])
5762
publish_edi(amqp_connection, action_helper.to_xml, action.hbx_enrollment_id, action.employer_hbx_id)
5863
else
59-
existing_policy = termination.existing_policy
6064
termination_helper = ActionPublishHelper.new(termination.event_xml)
6165
member_date_map = {}
66+
member_end_date_map = {}
6267
existing_policy.enrollees.each do |en|
6368
member_date_map[en.m_id] = en.coverage_start
69+
member_end_date_map[en.m_id] = en.coverage_end
6470
end
6571
termination_helper.set_event_action("urn:openhbx:terms:v1:enrollment#change_member_terminate")
6672
termination_helper.set_policy_id(existing_policy.eg_id)
6773
termination_helper.set_member_starts(member_date_map)
74+
termination_helper.set_member_end_date(member_end_date_map)
6875
termination_helper.filter_affected_members(dropped_dependents)
6976
termination_helper.replace_premium_totals(action.event_xml)
7077
termination_helper.keep_member_ends(dropped_dependents)

app/models/external_events/external_policy_member_drop.rb

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def use_totals_from(other_policy_cv)
2424
@total_source = other_policy_cv
2525
end
2626

27+
def subscriber_start(subscriber_start_date)
28+
@subscriber_start_date = subscriber_start_date
29+
end
30+
31+
def member_drop_date(member_end_date)
32+
@member_end_date = member_end_date
33+
end
34+
2735
def extract_pre_amt_tot
2836
@pre_amt_tot_val ||= begin
2937
p_enrollment = Maybe.new(@total_source).policy_enrollment.value
@@ -94,6 +102,12 @@ def extract_other_financials
94102
end
95103
end
96104

105+
def is_shop?
106+
p_enrollment = Maybe.new(@policy_node).policy_enrollment.value
107+
return false if p_enrollment.blank?
108+
p_enrollment.shop_market
109+
end
110+
97111
def extract_rel_from_me(rel)
98112
simple_relationship = Maybe.new(rel).relationship_uri.strip.split("#").last.downcase.value
99113
case simple_relationship
@@ -142,9 +156,9 @@ def extract_rel_code(enrollee)
142156
def term_enrollee(policy, enrollee_node)
143157
member_id = extract_member_id(enrollee_node)
144158
enrollee = policy.enrollees.detect { |en| en.m_id == member_id }
145-
if enrollee
159+
if enrollee
146160
if @dropped_member_ids.include?(member_id)
147-
enrollee.coverage_end = extract_enrollee_end(enrollee_node)
161+
enrollee.coverage_end = @member_end_date
148162
enrollee.coverage_status = "inactive"
149163
enrollee.employment_status_code = "terminated"
150164
end
@@ -161,8 +175,27 @@ def subscriber_id
161175
end
162176
end
163177

178+
def build_aptc_credits(pol)
179+
unless is_shop?
180+
tot_res_amt = extract_tot_res_amt.to_f
181+
pre_amt_tot = extract_pre_amt_tot.to_f
182+
aptc_amt = extract_other_financials[:applied_aptc].present? ? extract_other_financials[:applied_aptc].to_f : "0.0"
183+
pol.set_aptc_effective_on(@subscriber_start_date, aptc_amt, pre_amt_tot, tot_res_amt)
184+
pol.save!
185+
end
186+
end
187+
164188
def persist
165189
pol = policy_to_update
190+
unless is_shop?
191+
if pol.multi_aptc? || extract_other_financials[:applied_aptc].present?
192+
tot_res_amt = extract_tot_res_amt.to_f
193+
pre_amt_tot = extract_pre_amt_tot.to_f
194+
aptc_amt = extract_other_financials[:applied_aptc].present? ? extract_other_financials[:applied_aptc].to_f : "0.0"
195+
pol.set_aptc_effective_on(@subscriber_start_date, aptc_amt, pre_amt_tot, tot_res_amt)
196+
pol.save!
197+
end
198+
end
166199
pol.update_attributes!({
167200
:pre_amt_tot => extract_pre_amt_tot,
168201
:tot_res_amt => extract_tot_res_amt
@@ -172,6 +205,9 @@ def persist
172205
@policy_node.enrollees.each do |en|
173206
term_enrollee(pol, en)
174207
end
208+
209+
build_aptc_credits(pol)
210+
175211
unless all_terminations_exempt?(pol, @policy_node)
176212
Observers::PolicyUpdated.notify(pol)
177213
end

0 commit comments

Comments
 (0)