2026-03-06 10:56:20 -05:00
|
|
|
module IdCard
|
2026-03-13 08:47:13 -04:00
|
|
|
class Configuration < ApplicationRecord
|
2026-03-06 10:56:20 -05:00
|
|
|
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
|
2026-03-05 11:30:24 -05:00
|
|
|
|
2026-03-06 10:56:20 -05:00
|
|
|
has_many :plans, dependent: :destroy
|
2026-03-13 08:47:13 -04:00
|
|
|
has_many :field_exceptions, dependent: :destroy
|
2026-03-05 11:30:24 -05:00
|
|
|
|
2026-03-13 08:47:13 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
attribute :queued_card_count, :integer, default: 0
|
|
|
|
|
|
|
|
|
|
scope :active, -> { where(active: true) }
|
|
|
|
|
|
|
|
|
|
FORM_COLORS = ['atmosphere', 'verdigris', 'bluemana', 'cobalt']
|
|
|
|
|
MODULE_COLOR = 'atmosphere'
|
2026-03-05 11:30:24 -05:00
|
|
|
|
2026-03-06 10:56:20 -05:00
|
|
|
# def employer_logo_filename
|
|
|
|
|
# self.employer_logo.filename
|
|
|
|
|
# end
|
2026-03-05 11:30:24 -05:00
|
|
|
|
2026-03-06 10:56:20 -05:00
|
|
|
# def network_logo_filename
|
|
|
|
|
# self.network_logo.filename
|
|
|
|
|
# end
|
|
|
|
|
|
2026-03-13 08:47:13 -04:00
|
|
|
def build_plan_with_default_benefits(attributes = {})
|
|
|
|
|
plan = plans.new(attributes)
|
|
|
|
|
benefits = IdCardBenefitsTemplate.find_by(title: "BLANK").id_card_benefits.sort_by(&:sequence)
|
|
|
|
|
benefits.each do |ben|
|
|
|
|
|
plan.plan_benefits.new(benefit_desc: ben.benefit_desc, sequence: ben.sequence)
|
|
|
|
|
end
|
|
|
|
|
plan
|
|
|
|
|
end
|
|
|
|
|
|
2026-03-06 10:56:20 -05:00
|
|
|
def self.permitted_params(params)
|
2026-03-13 08:47:13 -04:00
|
|
|
params.require(:id_card_configuration).permit(
|
2026-03-06 10:56:20 -05:00
|
|
|
:print_name,
|
|
|
|
|
:network_provider,
|
|
|
|
|
:card_template,
|
|
|
|
|
:rx_group_number,
|
2026-03-13 08:47:13 -04:00
|
|
|
:employer_logo_id,
|
|
|
|
|
:network_logo_id,
|
|
|
|
|
:rx_section_id,
|
|
|
|
|
:provider_section_id
|
2026-03-06 10:56:20 -05:00
|
|
|
)
|
|
|
|
|
end
|
2026-03-05 11:30:24 -05:00
|
|
|
end
|
|
|
|
|
end
|