Prod build process
This commit is contained in:
+40
-23
@@ -1,14 +1,21 @@
|
||||
module IdCard
|
||||
class Setup < ApplicationRecord
|
||||
belongs_to :employer, class_name: 'Employer'
|
||||
belongs_to :employer_logo, optional: true
|
||||
belongs_to :network_logo, optional: true
|
||||
belongs_to :provider_section, optional: true
|
||||
belongs_to :rx_section, optional: true
|
||||
has_one :employer_logo, dependent: :destroy
|
||||
|
||||
has_many :plans, dependent: :destroy
|
||||
has_many :field_exceptions, dependent: :destroy
|
||||
|
||||
validates :print_name, :network_provider, :card_template, :employer_logo, :network_logo_id,
|
||||
:provider_section_id, :rx_section_id, presence: true, unless: :new_record?
|
||||
validates :pl_plan_key, :rx_group_number, presence: true, if: -> { initialized }
|
||||
validate :validate_print_name_fits_on_card
|
||||
|
||||
attr_accessor :print_name_pixel_width
|
||||
|
||||
accepts_nested_attributes_for :plans, allow_destroy: true, reject_if: :all_blank
|
||||
accepts_nested_attributes_for :field_exceptions, allow_destroy: true, reject_if: :all_blank
|
||||
|
||||
@@ -16,7 +23,7 @@ module IdCard
|
||||
|
||||
scope :active, -> { where(active: true) }
|
||||
|
||||
FORM_COLORS = ['atmosphere', 'verdigris', 'bluemana', 'cobalt']
|
||||
FORM_COLORS = ['atmosphere', 'verdigris-vivid', 'cobalt-vivid', 'bluemana']
|
||||
MODULE_COLOR = 'atmosphere'
|
||||
|
||||
before_save :active_initialized_check, if: :will_save_change_to_active?
|
||||
@@ -27,14 +34,6 @@ module IdCard
|
||||
end
|
||||
end
|
||||
|
||||
# def employer_logo_filename
|
||||
# self.employer_logo.filename
|
||||
# end
|
||||
|
||||
# def network_logo_filename
|
||||
# self.network_logo.filename
|
||||
# end
|
||||
|
||||
def build_plan_with_default_benefits(attributes = {})
|
||||
plan = plans.new(attributes)
|
||||
benefits = IdCardBenefitsTemplate.find_by(title: "BLANK").id_card_benefits.sort_by(&:sequence)
|
||||
@@ -45,7 +44,28 @@ module IdCard
|
||||
end
|
||||
|
||||
def has_field_exceptions?
|
||||
self.field_exceptions.present?
|
||||
field_exceptions.present?
|
||||
end
|
||||
|
||||
def sample_card_print_ready?
|
||||
print_name.present? &&
|
||||
card_template.present? &&
|
||||
employer_logo.present? &&
|
||||
network_logo_id.present? &&
|
||||
provider_section_id.present? &&
|
||||
rx_section_id.present? &&
|
||||
plans.present?
|
||||
end
|
||||
|
||||
def member_cards_print_ready?
|
||||
sample_card_print_ready? &&
|
||||
plans.present? &&
|
||||
plans.all? { |plan| plan.pb_product_key.present? } &&
|
||||
employer.members.present?
|
||||
end
|
||||
|
||||
def activation_ready?
|
||||
member_cards_print_ready? && !active
|
||||
end
|
||||
|
||||
def field_exceptions_card_attributes_by_member_id(member_array = nil)
|
||||
@@ -54,17 +74,6 @@ module IdCard
|
||||
end
|
||||
|
||||
card_fes = self.field_exceptions.includes(:field_exception_items).in_order_of(:exception_type, IdCard::FieldException::VALID_TYPES)
|
||||
# fe_by_value = card_fes.in_order_of(:exception_type, IdCard::FieldException::VALID_TYPES).group_by(&:exception_type)
|
||||
# .transform_values { |fes| fes.map { |fe| [fe.id, fe.exception_values] }.to_h }
|
||||
# .compact_blank
|
||||
|
||||
# field_exception_types = card_fes.pluck(:exception_type).uniq
|
||||
# if field_exception_types.include?("family_id")
|
||||
# members = Member.where(pb_entity_key: member_array)
|
||||
# end
|
||||
# if field_exception_types.intersect?(["state", "zipcode"])
|
||||
# member_addresses = Vhcs::PbEntityAddress.where(pb_entity_key: member_array)
|
||||
# end
|
||||
card_exceptions_map = {}
|
||||
card_fes.each do |fe|
|
||||
if fe.exception_type == "family_id"
|
||||
@@ -90,14 +99,22 @@ module IdCard
|
||||
def self.permitted_params(params)
|
||||
params.require(:id_card_setup).permit(
|
||||
:print_name,
|
||||
:print_name_pixel_width,
|
||||
:network_provider,
|
||||
:card_template,
|
||||
:rx_group_number,
|
||||
:employer_logo_id,
|
||||
:network_logo_id,
|
||||
:rx_section_id,
|
||||
:provider_section_id
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_print_name_fits_on_card
|
||||
if print_name_pixel_width.to_i > 100
|
||||
errors.add(:print_name, "Too Long For Card")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user