Files
baclight/app/models/concerns/employer_automation.rb
T

59 lines
1.5 KiB
Ruby
Raw Normal View History

2026-03-19 00:42:27 -04:00
module EmployerAutomation
extend ActiveSupport::Concern
2026-04-15 08:12:47 -04:00
included do
scope :new_groups, -> {
where(active: false)
.where.not(pl_plan_key: [nil, ''])
}
scope :with_plans, -> {
joins(id_card_setup: :plans).distinct
}
# scope :with_survey_and_no_questions, -> {
# joins(:survey) # join has_one
# .left_joins(survey: :questions) # join has_many through has_one
# .where(questions: { id: nil }) # filter where has_many is empty
# }
scope :missing_keychain_values, -> {
new_groups
.where(
arel_table[:company_pb_entity_key].in([nil, ''])
.or(arel_table[:plan_id].in([nil, '']))
.or(arel_table[:group_number].in([nil, '']))
.or(arel_table[:effective_date].in([nil, '']))
)
}
scope :missing_initial_members, -> {
new_groups.with_plans
}
end
2026-03-19 00:42:27 -04:00
# class_methods do
# # Methods in this block become class methods of the including class.
# def count_all_visible
# visible.count
# end
# end
# Any other methods defined here become instance methods automatically.
2026-04-15 08:12:47 -04:00
# def up_to_date?
# 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 sync_members_with_vhcs
AutomationService::EmployerMembersUpdate.new(self.pl_plan_key).call
2026-03-19 00:42:27 -04:00
end
2026-04-15 08:12:47 -04:00
2026-03-19 00:42:27 -04:00
def sync_with_vhcs
2026-04-15 08:12:47 -04:00
AutomationService::EmployerUpdate.new(self.pl_plan_key).call
2026-03-19 00:42:27 -04:00
end
end