Added support for adding other QBO entities from othe plugins

This commit is contained in:
2026-03-08 15:04:57 -04:00
parent d8a26f98c0
commit 643b15391b
3 changed files with 34 additions and 8 deletions

View File

@@ -19,6 +19,23 @@ class QboSyncDispatcher
# Dispatches all synchronization jobs to perform a full sync of QuickBooks entities with the local database. Each job is enqueued with the `full_sync` flag set to true.
def self.full_sync!
SYNC_JOBS.each { |job| job.perform_later(full_sync: true) }
jobs = SYNC_JOBS.dup
# Allow other plugins to add addtional sync jobs via Hooks
Redmine::Hook.call_hook( :qbo_full_sync ).each do |context|
next unless context
jobs.push context
log "Added additionals QBO Sync Job for #{contex.to_s}"
end
jobs.each { |job| job.perform_later(full_sync: true) }
end
private
def self.log(msg)
Rails.logger.info "[QboSyncDispatcher] #{msg}"
end
end

View File

@@ -43,7 +43,14 @@ class WebhookProcessJob < ActiveJob::Base
name = entity['name']
id = entity['id']&.to_i
return unless ALLOWED_ENTITIES.include?(name)
entitys = ALLOWED_ENTITIES.dup
# Allow other plugins to add addtional qbo entities via Hooks
Redmine::Hook.call_hook( :qbo_additional_entities ).each do |context|
next unless context
entitys.push context
log "Added additional QBO entities: #{context}"
end
return unless entitys.include?(name)
model = name.safe_constantize
return unless model