Skip to content

Commit

Permalink
plan shopping options (#4255)
Browse files Browse the repository at this point in the history
* 107 plan shopping flow

* missing if

* rubocop

* started fixing cucumbers
  • Loading branch information
kristinmerbach authored and charlienparker committed Sep 16, 2024
1 parent 2ee6626 commit abdde7f
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 117 deletions.
8 changes: 4 additions & 4 deletions app/assets/javascripts/plan_shopping.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ $(function() {
var max = parseFloat($('input#elected_aptc_value').attr('max'));
var elected_pct = $("input[name='elected_aptc_pct']").val() / 100;
var elected_amount = parseFloat($('#max_aptc').attr('value')).toFixed(2) * parseFloat(elected_pct).toFixed(2);
if (elected_amount <= 1) {
elected_amount = 1.00;
if (elected_amount <= 0) {
elected_amount = 0;
}
if (elected_amount > max) {
elected_amount = max;
Expand All @@ -272,13 +272,13 @@ $(function() {
var elected_aptc = $(this).val();
var max = $('input#elected_aptc_value').attr('max');
var max_aptc = $('input#max_aptc').val();
elected_pct = (elected_aptc/max_aptc).toFixed(2) * 100;
elected_pct = (elected_aptc/max_aptc).toFixed(1) * 100;
if (elected_pct <= 0) {
elected_amount = 0;
}
if (elected_pct > 100) {
elected_pct = 100;
$('#elected_aptc_value').val(max);
$('#elected_aptc_value').val(max_aptc);
}
$("input[name='elected_aptc_pct']").val(elected_pct);
});
Expand Down
12 changes: 10 additions & 2 deletions app/controllers/insured/group_selection_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,19 @@ def create
hbx_enrollment.update_osse_childcare_subsidy
redirect_to thankyou_insured_plan_shopping_path(change_plan: @change_plan, market_kind: @market_kind, coverage_kind: @adapter.coverage_kind, id: hbx_enrollment.id, plan_id: @adapter.previous_hbx_enrollment.product_id)
elsif @change_plan.present?
redirect_to insured_plan_shopping_path(:id => hbx_enrollment.id, change_plan: @change_plan, market_kind: @market_kind, coverage_kind: @adapter.coverage_kind, enrollment_kind: @adapter.enrollment_kind)
if EnrollRegistry.feature_enabled?(:choose_shopping_method)
redirect_to choose_shopping_method_insured_plan_shopping_path(:id => hbx_enrollment.id, change_plan: @change_plan, market_kind: @market_kind, coverage_kind: @adapter.coverage_kind, enrollment_kind: @adapter.enrollment_kind)
else
redirect_to insured_plan_shopping_path(:id => hbx_enrollment.id, change_plan: @change_plan, market_kind: @market_kind, coverage_kind: @adapter.coverage_kind, enrollment_kind: @adapter.enrollment_kind)
end
else
# FIXME: models should update relationships, not the controller
hbx_enrollment.benefit_group_assignment.update(hbx_enrollment_id: hbx_enrollment.id) if hbx_enrollment.benefit_group_assignment.present?
redirect_to insured_plan_shopping_path(:id => hbx_enrollment.id, market_kind: @market_kind, coverage_kind: @adapter.coverage_kind, enrollment_kind: @adapter.enrollment_kind)
if EnrollRegistry.feature_enabled?(:choose_shopping_method)
redirect_to choose_shopping_method_insured_plan_shopping_path(:id => hbx_enrollment.id, market_kind: @market_kind, coverage_kind: @adapter.coverage_kind, enrollment_kind: @adapter.enrollment_kind)
else
redirect_to insured_plan_shopping_path(:id => hbx_enrollment.id, market_kind: @market_kind, coverage_kind: @adapter.coverage_kind, enrollment_kind: @adapter.enrollment_kind)
end
end
else
raise "You must select the primary applicant to enroll in the healthcare plan"
Expand Down
54 changes: 36 additions & 18 deletions app/controllers/insured/plan_shoppings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class Insured::PlanShoppingsController < ApplicationController
include L10nHelper

before_action :find_hbx_enrollment
before_action :set_current_person, :only => [:receipt, :thankyou, :waive, :show, :plans, :checkout, :terminate, :plan_selection_callback]
before_action :set_kind_for_market_and_coverage, only: [:thankyou, :show, :plans, :checkout, :receipt, :set_elected_aptc, :plan_selection_callback]
before_action :validate_rating_address, only: [:show]
before_action :check_enrollment_state, only: [:show, :thankyou]
before_action :set_cache_headers, only: [:show, :thankyou]
before_action :enable_bs4_layout, only: [:show, :plans, :receipt, :thankyou] if EnrollRegistry.feature_enabled?(:bs4_consumer_flow)
before_action :set_current_person, :only => [:receipt, :thankyou, :waive, :show, :plans, :checkout, :terminate, :plan_selection_callback, :choose_shopping_method]
before_action :set_kind_for_market_and_coverage, only: [:thankyou, :show, :plans, :checkout, :receipt, :set_elected_aptc, :plan_selection_callback, :choose_shopping_method]
before_action :validate_rating_address, only: [:show, :choose_shopping_method]
before_action :check_enrollment_state, only: [:show, :thankyou, :choose_shopping_method]
before_action :set_cache_headers, only: [:show, :thankyou, :choose_shopping_method]
before_action :enable_bs4_layout, only: [:show, :plans, :receipt, :thankyou, :choose_shopping_method] if EnrollRegistry.feature_enabled?(:bs4_consumer_flow)

layout :resolve_layout

Expand All @@ -37,11 +37,9 @@ def checkout

qle = (plan_selection.hbx_enrollment.enrollment_kind == "special_enrollment")

if !plan_selection.hbx_enrollment.can_select_coverage?(qle: qle)
if plan_selection.hbx_enrollment.errors.present?
flash[:error] = plan_selection.hbx_enrollment.errors.full_messages
end
redirect_back(fallback_location: :back)
unless plan_selection.hbx_enrollment.can_select_coverage?(qle: qle)
flash[:error] = plan_selection.hbx_enrollment.errors.full_messages if plan_selection.hbx_enrollment.errors.present?
redirect_back(fallback_location: :back)
return
end

Expand Down Expand Up @@ -97,7 +95,7 @@ def thankyou
get_aptc_info_from_session(@enrollment)
end

# TODO Fix this stub
# TODO: Fix this stub
if @enrollment.is_shop?
@member_group = HbxEnrollmentSponsoredCostCalculator.new(@enrollment).groups_for_products([@plan]).first
@enrollment.verify_and_reset_osse_subsidy_amount(@member_group)
Expand All @@ -111,7 +109,7 @@ def thankyou

@family = @person.primary_family

#FIXME need to implement can_complete_shopping? for individual
#FIXME: need to implement can_complete_shopping? for individual
@enrollable = @market_kind == 'individual' ? true : @enrollment.can_complete_shopping?(qle: @enrollment.is_special_enrollment?)
@waivable = @enrollment.can_complete_shopping?
@change_plan =
Expand Down Expand Up @@ -293,6 +291,21 @@ def plans
end
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity

def choose_shopping_method
authorize @hbx_enrollment, :show?

set_consumer_bookmark_url(family_account_path)
set_admin_bookmark_url(family_account_path)

hbx_enrollment_id = params.require(:id)
@change_plan = params[:change_plan].present? ? params[:change_plan] : ''
@enrollment_kind = params[:enrollment_kind].present? ? params[:enrollment_kind] : ''

set_plans_by(hbx_enrollment_id: hbx_enrollment_id)
generate_eligibility_data
generate_checkbook_service
end

private


Expand Down Expand Up @@ -363,7 +376,8 @@ def show_ivl(hbx_enrollment_id)
@max_deductible = thousand_ceil(@plans.map(&:deductible).map {|d| d.is_a?(String) ? d.gsub(/[$,]/, '').to_i : 0}.max)
end

def show_shop(hbx_enrollment_id)
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
def show_shop(_hbx_enrollment_id)
set_employee_bookmark_url(family_account_path) if params[:market_kind] == 'shop' || params[:market_kind] == 'fehb'
@hbx_enrollment.update_osse_childcare_subsidy
sponsored_cost_calculator = HbxEnrollmentSponsoredCostCalculator.new(@hbx_enrollment)
Expand Down Expand Up @@ -400,6 +414,7 @@ def show_shop(hbx_enrollment_id)
render "show"
::Caches::CustomCache.release(::BenefitSponsors::Organizations::Organization, :plan_shopping)
end
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity

def fix_member_dates(enrollment, plan)
return if enrollment.parent_enrollment.present? && plan.id == enrollment.parent_enrollment.product_id
Expand Down Expand Up @@ -443,7 +458,7 @@ def generate_eligibility_data
end

def generate_checkbook_service
plan_comparision_obj = ::Services::CheckbookServices::PlanComparision.new(@hbx_enrollment)
plan_comparision_obj = ::Services::CheckbookServices::PlanComparision.new(@hbx_enrollment, @plans)
plan_comparision_obj.elected_aptc = session[:elected_aptc]
@dc_individual_checkbook_url = plan_comparision_obj.generate_url
end
Expand Down Expand Up @@ -514,7 +529,10 @@ def collect_shopping_filters

# no dental as of now
def sort_member_groups(products)
products.select { |prod| prod.group_enrollment.product.id.to_s == @enrolled_hbx_enrollment_plan_ids.first.to_s } + products.select { |prod| prod.group_enrollment.product.id.to_s != @enrolled_hbx_enrollment_plan_ids.first.to_s }.sort_by { |mg| (mg.group_enrollment.product_cost_total - mg.group_enrollment.sponsor_contribution_total) }
unsorted = products.select { |prod| prod.group_enrollment.product.id.to_s == @enrolled_hbx_enrollment_plan_ids.first.to_s } + products.reject do |prod|
prod.group_enrollment.product.id.to_s == @enrolled_hbx_enrollment_plan_ids.first.to_s
end
unsorted.sort_by { |mg| (mg.group_enrollment.product_cost_total - mg.group_enrollment.sponsor_contribution_total) }
end

def sort_by_standard_plans(plans)
Expand Down Expand Up @@ -621,9 +639,9 @@ def build_same_plan_premiums
if @hbx_enrollment.is_shop?
ref_plan = (@hbx_enrollment.coverage_kind == "health" ? @benefit_group.reference_plan : @benefit_group.dental_reference_plan)

@enrolled_plans = enrolled_plans.collect{|plan|
@enrolled_plans = enrolled_plans.collect do |plan|
@benefit_group.decorated_plan(plan, same_plan_enrollment, ref_plan)
}
end
else
@enrolled_plans = same_plan_enrollment.calculate_costs_for_plans(enrolled_plans)
end
Expand Down
14 changes: 6 additions & 8 deletions app/models/services/checkbook_services/plan_comparision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,14 @@ def construct_body_ivl
"enrollmentId": @hbx_enrollment.id.to_s # Host Name will be static as Checkbook suports static URL's and hostname should be changed before going to production.
}
ivl_body.merge!(extra_ivl_body) if EnrollRegistry.feature_enabled?(:send_extra_fields_to_checkbook)
ivl_body
end

def extra_ivl_body
fields = {
"enrollmentDate": @hbx_enrollment.effective_on&.strftime("%m/%d/%Y")
}
current_plan = build_current_plan(@hbx_enrollment)
fields[:currentPlan] = current_plan if current_plan.present?
fields
{
"coverageStartDate": @hbx_enrollment.effective_on.strftime("%m-%d-%Y"),
"currentPlan": current_plan
}
end

def construct_body_congress
Expand Down Expand Up @@ -233,8 +231,8 @@ def build_congress_employee_age
def build_current_plan(enrollment)
return "" unless @plans
available_plans = @plans.map(&:hios_id)
enrolled_plan = enrollment.family.checkbook_enrollments(enrollment)&.map(&:hios_id)&.first
return "" unless enrolled_plan && available_plans&.include?(enrolled_plan)
enrolled_plan = enrollment.family.current_enrolled_or_termed_products_by_subscriber(enrollment)&.map(&:hios_id)&.first
return "" unless available_plans&.include?(enrolled_plan)
enrolled_plan
end

Expand Down
11 changes: 7 additions & 4 deletions app/views/insured/plan_shoppings/_plan_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
<%= plan.standard_plan_label.titleize %>
</span>
<% end %>
<% current_plans = @hbx_enrollment.family.current_enrolled_or_termed_coverages(@hbx_enrollment, true).collect(&:product_id) %>
<% if current_plans.present? && current_plans.include?(plan.id) %>
<% if @person.primary_family.enrolled_hbx_enrollments.map(&:product).map(&:id).include?(plan.id) %>
<span class="badge badge-pill badge-lg badge-current-plan ml-2 d-flex align-items-center">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<title>Star</title>
Expand Down Expand Up @@ -89,7 +88,7 @@
<div class="price-wrapper text-right">
<strong class="text-secondary"><%= l10n("premium") %></strong>
<% if session[:elected_aptc] && session[:elected_aptc] != 0 %>
<% premium = min_premium_with_aptc(plan.total_employee_cost, plan.total_ehb_premium, plan.total_childcare_subsidy_amount, plan.can_use_aptc?) %>
<% premium = shopping_group_premium(plan.total_employee_cost, plan.total_ehb_premium, plan.total_childcare_subsidy_amount, plan.can_use_aptc?) %>
<p class="bold beta m-0"><%= number_to_currency(premium) %></p>
<% else %>
<p class="bold beta m-0"><%= number_to_currency(plan.total_employee_cost - plan.total_childcare_subsidy_amount) %></p>
Expand Down Expand Up @@ -136,6 +135,9 @@
<%= link_to l10n("see_details"), summary_products_plans_path({plan_id: plan.id, :standard_component_id => plan.hios_id, hbx_enrollment_id: @hbx_enrollment.id, market_kind: @market_kind, coverage_kind: @coverage_kind, enrollment_kind: @enrollment_kind, active_year: plan.try(:active_year), bs4: @bs4}), {:class => "primary-text ml-4", :remote => true} %>
<% end %>
</div>
<% if details_page %>
<%= render partial: "shared/plan_shoppings/select_plan_button", locals: { plan: plan } %>
<% else %>
<% if (@tax_household || @aptc_grants) && params[:market_kind]=='individual' && params[:coverage_kind] == 'health' %>
<% if @csr_available && plan.metal_level != "silver" %>
<%= link_to l10n("select_plan"), "javascript:void(0)", class: 'btn btn-default btn-right', data: {'toggle': 'modal', 'target': "#csrEligibleReminder-#{plan.id}"} %>
Expand All @@ -147,6 +149,7 @@
<% else %>
<%= link_to(l10n("select_plan"), "javascript:void(0)", {class: 'btn btn-default btn-right plan-select select', data: {url: thankyou_insured_plan_shopping_path(@hbx_enrollment, plan_id: plan.id, change_plan: @change_plan, market_kind: @market_kind, coverage_kind: @coverage_kind, enrollment_kind: @enrollment_kind)}}) %>
<% end %>
<% end %>
</div>

</div>
Expand All @@ -172,7 +175,7 @@
</div>
<div class="row">
<% if @enrolled_hbx_enrollment_plan_ids.include?(plan.id) %>
<h5 class="col-md-12 current bg-title"><i class="fa fa-star fa-lg enrolling"></i><%= l10n("your_current_plan", year: plan.try(:active_year)).to_s.upcase %></h5>
<h5 class="col-md-12 current bg-title"><i class="fa fa-star fa-lg enrolling"></i><%= l10n("your_current_plan", year: plan.try(:active_year)).to_s.upcase %></h5>
<% end %>
</div>
<div class="row">
Expand Down
26 changes: 15 additions & 11 deletions app/views/insured/plan_shoppings/choose_shopping_method.html.erb
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<%= render partial: 'shared/plan_shopping_progress', locals: { current_page: :choose_plan, nav_options: plan_shopping_progress_hash } %>
<h1 id="chooseShoppingMethod"><%= l10n("plans.plan_shopping_options.header") %></h1>
<h1><%= l10n("plans.plan_shopping_options.header") %></h1>
<p><%= l10n("plans.plan_shopping_options.description") %></p>
<fieldset class="mb-4 d-block">
<legend class="required"><%= l10n("plans.plan_shopping_options.question") %></legend>
<label for="guidance_true" class="radio mt-2">
<%= radio_button_tag :guidance, true, true %>
<%= radio_button_tag :guidance, true %>
<%= l10n("plans.plan_shopping_options.question.compare") %>
</label>
<label for="guidance_false" class="radio mt-2">
<%= radio_button_tag :guidance, false, false %>
<%= radio_button_tag :guidance, false %>
<%= l10n("plans.plan_shopping_options.question.know") %>
</label>
</fieldset>
<!-- logic for the next link: if yes, it should show appropriate modal, if no, go to plan shopping -->
<% content_for :submit_button do %>
<%= link_to(l10n("continue_next"), insured_plan_shopping_path(:id => @hbx_enrollment.id, market_kind: @market_kind, coverage_kind: @hbx_enrollment.coverage_kind, enrollment_kind: @hbx_enrollment.enrollment_kind), class: "button hidden", id: "plan-shopping-link") %>
<%= link_to(l10n("continue_next"), insured_plan_shopping_path(:id => @hbx_enrollment.id, market_kind: @market_kind, coverage_kind: @hbx_enrollment.coverage_kind, enrollment_kind: @hbx_enrollment.enrollment_kind), class: "button disabled hidden", id: "plan-shopping-link") %>
<% if @market_kind == "individual" && @coverage_kind == "health" %>
<%= h(link_to l10n("continue_next"), "", data: {toggle: "modal", target: "#plan_match_redirection"}, class: "button", id: "checkbook-link") %>
<%= h(link_to l10n("continue_next"), "", data: {toggle: "modal", target: "#plan_match_redirection"}, class: "button disabled", disabled: true, id: "checkbook-link") %>
<% end %>
<% if @market_kind == "individual" && @coverage_kind == "dental" %>
<%= h(link_to l10n("continue_next"), '',data: {toggle: "modal", target: "#plan_match_dental_redirection"}, class: "button", id: "checkbook-link") %>
<%= h(link_to l10n("continue_next"), '',data: {toggle: "modal", target: "#plan_match_dental_redirection"}, class: "button disabled", disabled: true, id: "checkbook-link") %>
<% end %>
<% end %>
<div class="my-4">
<%= render partial: "shared/progress_navigation_buttons", locals: {disable_link: false} %>
<%= render partial: "shared/progress_navigation_buttons", locals: {disable_link: true} %>
</div>
<!-- the modals -->
<div id="plan_match_redirection" class="modal fade" role="document" tabindex="-1">
Expand Down Expand Up @@ -78,11 +78,15 @@
<script>
$(document).on('change', 'input[name="guidance"]', function(){
if($(this).val() == "false"){
$('#plan-shopping-link').removeClass('hidden');
$('#checkbook-link').addClass('hidden');
$('#plan-shopping-link').removeClass('hidden disabled');
$('#plan-shopping-link').removeAttr('disabled');
$('#checkbook-link').addClass('hidden disabled');
$('#checkbook-link').attr('disabled', true);
} else {
$('#checkbook-link').removeClass('hidden');
$('#plan-shopping-link').addClass('hidden');
$('#checkbook-link').removeClass('hidden disabled');
$('#plan-shopping-link').addClass('hidden disabled');
$('#checkbook-link').removeAttr('disabled');
$('#plan-shopping-link').attr('disabled', true);
}
});
</script>
7 changes: 4 additions & 3 deletions app/views/insured/plan_shoppings/thankyou.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dd><%= @enrollment.effective_on.strftime("%m/%d/%Y") %></dd>
</dl>

<% if @person.has_active_consumer_role? && (@tax_household.present? || @aptc_grants.present?) && @market_kind == "individual" %>
<% if @person.has_active_consumer_role? && (@tax_household.present? || @aptc_grants.present?) && @market_kind == "individual" && @plan.metal_level != "catastrophic" && @plan.kind&.to_s != "dental" %>
<div class="mb-4">
<% is_ivl_osse_filter_eligible = ivl_osse_filtering_enabled? && @enrollment.ivl_osse_eligible? %>
<h3><%= l10n('insured.plan_shoppings.thankyou.applied_credits') %></h3>
Expand All @@ -32,7 +32,8 @@
<dt><%= l10n('insured.plan_shoppings.thankyou.total_credit') %>:</dt>
<dd><%= number_to_currency(@max_aptc, precision: 2) %></dd>
<dt><%= l10n('insured.plan_shoppings.thankyou.max_credit') %>:</dt>
<% per_plan_max = @plan.total_premium > @max_aptc ? @max_aptc : (@plan.total_premium - 1).round(2) %>
<% shopping_premium = shopping_group_premium(@plan.total_employee_cost, @plan.total_ehb_premium, @plan.total_childcare_subsidy_amount, @plan.can_use_aptc?) %>
<% per_plan_max = shopping_premium > @max_aptc ? @max_aptc : shopping_premium %>
<dd><%= number_to_currency(per_plan_max) %></dd>
</dl>
<p><%= l10n("insured.plan_shoppings.thankyou.aptc_instructions") %></p>
Expand All @@ -48,7 +49,7 @@
<% step = is_ivl_osse_filter_eligible ? 1 : 1 %>
<% pct = @max_aptc > 0 ? (@elected_aptc/@max_aptc).round(2) : 0 %>
<label for="elected_aptc_pct" class="required"><%= l10n('insured.plan_shoppings.thankyou.percent_applied') %></label>
<input max="100" min="<%= min_aptc %>" name="elected_aptc_pct" id="elected_aptc_pct" step="<%= step %>" type="number" value="<%= number_with_precision(pct * 100, precision: 2) %>" class="w-100 thankyou">
<input max="100" min="<%= min_aptc %>" name="elected_aptc_pct" id="elected_aptc_pct" step="<%= step %>" type="number" value="<%= number_with_precision(pct * 100, precision: 0) %>" class="w-100 thankyou">
</div>
<div class="mr-3">
<label for="elected_aptc_value" class="required"><%= l10n('insured.plan_shoppings.thankyou.amount_applied') %></label>
Expand Down
Loading

0 comments on commit abdde7f

Please sign in to comment.