mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 16:21:58 -04:00
Added support for adding other QBO entities from othe plugins
This commit is contained in:
14
README.md
14
README.md
@@ -117,12 +117,14 @@ Adds support for tracking **customer vehicles** associated with Issues.
|
|||||||
|
|
||||||
Available hooks:
|
Available hooks:
|
||||||
|
|
||||||
|Type|Hook|
|
|Type|Hook|Note
|
||||||
|--|---|
|
|--|--|--|
|
||||||
View Hook|:pdf\_left, { issue: issue }
|
View Hook|:pdf_left, { issue: issue } | Used to add text to left side of PDF
|
||||||
View Hook|:pdf\_right, { issue: issue }
|
View Hook|:pdf_right, { issue: issue } | Used to add text to right side of PDF
|
||||||
Hook|process\_invoice\_custom\_fields, { issue: issue, invoice: invoice }
|
Hook|process_invoice_custom_fields, { issue: issue, invoice: invoice } | Used to process invoice custom fields
|
||||||
View Hook|:show\_customer\_view\_right, { customer: customer }
|
View Hook|:show_customer_view_right, { customer: customer } | Used to show partials on right side of customer view
|
||||||
|
Hook| :qbo_additional_entities | Used to add additional entites to be processed by the WebhookProcessJob
|
||||||
|
Hook| :qbo_full_sync | Used to add a Class to be called by the QboSyncDispatcher
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
# 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!
|
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
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def self.log(msg)
|
||||||
|
Rails.logger.info "[QboSyncDispatcher] #{msg}"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -43,7 +43,14 @@ class WebhookProcessJob < ActiveJob::Base
|
|||||||
name = entity['name']
|
name = entity['name']
|
||||||
id = entity['id']&.to_i
|
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
|
model = name.safe_constantize
|
||||||
return unless model
|
return unless model
|
||||||
|
|||||||
Reference in New Issue
Block a user