Compare commits

..

2 Commits

Author SHA1 Message Date
cd88ce6217 2026.3.5 2026-03-09 08:22:26 -04:00
b10665355d Allow Subclasses to override the page size 2026-03-08 23:34:37 -04:00
2 changed files with 11 additions and 4 deletions

View File

@@ -16,6 +16,12 @@ class SyncServiceBase
raise "No QBO configuration found" unless qbo raise "No QBO configuration found" unless qbo
@qbo = qbo @qbo = qbo
@entity = self.class.model_class @entity = self.class.model_class
@page_size = self.class.page_size
end
# Subclasses can implement this to overide the default page size
def self.page_size
@page_size = PAGE_SIZE
end end
# Subclasses must implement this to specify which local model they sync (e.g. Customer, Invoice) # Subclasses must implement this to specify which local model they sync (e.g. Customer, Invoice)
@@ -25,7 +31,7 @@ class SyncServiceBase
# Sync all entities, or only those updated since the last sync # Sync all entities, or only those updated since the last sync
def sync(full_sync: false) def sync(full_sync: false)
log "Starting #{full_sync ? 'full' : 'incremental'} #{@entity.name} sync" log "Starting #{full_sync ? 'full' : 'incremental'} #{@entity.name} sync with page size of: #{@page_size}"
@qbo.perform_authenticated_request do |access_token| @qbo.perform_authenticated_request do |access_token|
service_class = "Quickbooks::Service::#{@entity.name}".constantize service_class = "Quickbooks::Service::#{@entity.name}".constantize
@@ -33,7 +39,7 @@ class SyncServiceBase
query = build_query(full_sync) query = build_query(full_sync)
service.query_in_batches(query, per_page: self.class::PAGE_SIZE) do |batch| service.query_in_batches(query, per_page: @page_size) do |batch|
entries = Array(batch) entries = Array(batch)
log "Processing batch of #{entries.size} #{@entity.name}" log "Processing batch of #{entries.size} #{@entity.name}"
@@ -61,6 +67,7 @@ class SyncServiceBase
private private
# Builds a QBO query for retrieving entities
def build_query(full_sync) def build_query(full_sync)
if full_sync if full_sync
"SELECT * FROM #{@entity.name} ORDER BY Id" "SELECT * FROM #{@entity.name} ORDER BY Id"

View File

@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo do
name 'Redmine QBO plugin' name 'Redmine QBO plugin'
author 'Rick Barrette' author 'Rick Barrette'
description 'A pluging for Redmine to connect with QuickBooks Online to create Time Activity Entries for billable hours logged when an Issue is closed' description 'A pluging for Redmine to connect with QuickBooks Online to create Time Activity Entries for billable hours logged when an Issue is closed'
version '2026.3.4' version '2026.3.5'
url 'https://github.com/rickbarrette/redmine_qbo' url 'https://github.com/rickbarrette/redmine_qbo'
author_url 'https://barrettefabrication.com' author_url 'https://barrettefabrication.com'
settings default: {empty: true}, partial: 'qbo/settings' settings default: {empty: true}, partial: 'qbo/settings'