Major features finished

This commit is contained in:
Jason Jordan
2026-04-15 08:12:47 -04:00
parent 9f306d3150
commit 247a075c9c
112 changed files with 3700 additions and 379 deletions
+28 -14
View File
@@ -1,7 +1,10 @@
class Employer < ApplicationRecord
has_many :members
include EmployerAutomation
has_many :members, dependent: :destroy
accepts_nested_attributes_for :members, allow_destroy: true, reject_if: :all_blank
has_one :id_card_setup, class_name: 'IdCard::Setup', dependent: :destroy
scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) }
@@ -9,7 +12,9 @@ class Employer < ApplicationRecord
# before_save :process_employer_logo
# before_save :process_employer_logo, if: :employer_logo_filename_changed?
before_save :create_slug, if: :new_record?
# before_save :create_slug, if: :new_record?
before_save :create_slug, if: :will_save_change_to_name?
# before_save :set_active_status, unless: :will_save_change_to_active?
# after_save :process_employer_logo, if: :saved_change_to_employer_logo_filename?
# def process_employer_logo
@@ -35,7 +40,17 @@ class Employer < ApplicationRecord
# end
def create_slug
self.slug = employer_trim_name(self.name).parameterize
self.slug = Employer.employer_trim_name(self.name).parameterize
end
def set_active_status
self.active = (
self.pl_plan_key.present? &&
self.company_pb_entity_key.present? &&
self.plan_id.present? &&
self.group_number.present? &&
self.effective_date.present?
)
end
def id_card_enabled?
@@ -54,12 +69,12 @@ class Employer < ApplicationRecord
end
def name_to_logo_filename(extension)
self.employer_trim_name(self.name).titleize.gsub(/[^a-zA-Z]/, '').concat('Logo').concat(extension.downcase)
Employer.employer_trim_name(self.name).titleize.gsub(/[^a-zA-Z]/, '').concat('Logo').concat(extension.downcase)
end
def employer_trim_name(name = nil)
employer_name = name.present? ? name : self.name
regex_source = Regexp.union(["health ", "plan", "the", "inc", "llc"]).source
def self.employer_trim_name(employer_name)
# employer_name = name.present? ? name : self.name
regex_source = Regexp.union(["health ", "plan", "the", "inc", "llc", "group"]).source
case_insensitive_regex = Regexp.new(regex_source, "i")
employer_name.gsub(case_insensitive_regex, "").gsub(/[^[:alpha:][:space:]]/, "").squish
end
@@ -82,21 +97,20 @@ class Employer < ApplicationRecord
medical_number: self.group_number,
dental_number: '',
plan_key: self.pl_plan_key,
effect_date: self.effective_date
effect_date: DateTime.strptime(self.effective_date, "%m/%d/%y")
)
# Replace fairos_info with template like for benefits
fairos_info = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
rx_info = self.id_card_setup.rx_section
Vhcs::HlrxCrosRef.create!(
group_no: self.group_number,
rx_group_id: self.group_number,
help_desk: fairos_info.help_desk,
customer_service: fairos_info.customer_service,
web_url: fairos_info.web_url,
help_desk: rx_info.help_desk,
customer_service: rx_info.customer_service,
web_url: rx_info.web_url,
pl_plan_key: self.pl_plan_key
)
self.plans.each_with_index do |plan, i|
self.id_card_setup.plans.each_with_index do |plan, i|
plan.plan_benefits.each do |bene|
Vhcs::HlEgglestonCardBenefit.create!(
plan_id: plan.pb_product_key,