Major features finished
This commit is contained in:
@@ -1,12 +1,36 @@
|
||||
module EmployerAutomation
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# included do
|
||||
# # Code in this block becomes instance methods or class macros (like scopes, validations, associations) in the including class.
|
||||
# scope :visible, -> { where(visible: true) }
|
||||
# scope :invisible, -> { where(visible: false) }
|
||||
# validates :status, inclusion: { in: %w(visible invisible), message: "%{value} is not a valid status" }
|
||||
# end
|
||||
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
|
||||
|
||||
# class_methods do
|
||||
# # Methods in this block become class methods of the including class.
|
||||
@@ -16,16 +40,20 @@ module EmployerAutomation
|
||||
# end
|
||||
|
||||
# Any other methods defined here become instance methods automatically.
|
||||
def up_to_date?
|
||||
self.pl_plan_key.present? &&
|
||||
self.company_pb_entity_key.present? &&
|
||||
self.plan_id.present? &&
|
||||
self.group_number.present? &&
|
||||
self.effect_date.present?
|
||||
# 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
|
||||
end
|
||||
|
||||
|
||||
def sync_with_vhcs
|
||||
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader WHERE ActiveInactive = 'Active' And PLPlanKey = 57"
|
||||
plan_header = VhcsRecord.connection.select_all(sql_query).first
|
||||
AutomationService::EmployerUpdate.new(self.pl_plan_key).call
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user