5 Commits

Author SHA1 Message Date
9736f1ac96 Added settings page for Item stats 2026-03-09 00:00:46 -04:00
3463698f8d Use self.page_size instead of a constant 2026-03-08 23:29:16 -04:00
3b51c961e3 2026.3.3 2026-03-08 22:00:47 -04:00
1780896e84 Set page size to 10 2026-03-08 21:48:03 -04:00
91cdd86c12 Add logging 2026-03-08 20:10:14 -04:00
5 changed files with 24 additions and 2 deletions

View File

@@ -15,6 +15,12 @@ class Item < ApplicationRecord
validates :unit_price, numericality: { greater_than_or_equal_to: 0 }
self.primary_key = :id
# Returns the last sync time formatted for display. If no sync has occurred, returns a default message.
def self.last_sync
return I18n.t(:label_qbo_never_synced) unless maximum(:updated_at)
format_time(maximum(:updated_at))
end
# Sync all items, typically triggered by a scheduled task or manual sync request
def self.sync
ItemSyncJob.perform_later(full_sync: true)

View File

@@ -17,12 +17,22 @@ class ItemSyncService < SyncServiceBase
Item
end
# Specify a page size of 20, as the API only returns 20 items at a time.
def self.page_size
20
end
# Map relevant attributes from the QBO Employee to the local Employee model
def process_attributes(local, remote)
log "Processing Item ##{remote.id}"
local.id = remote.id
local.description = remote.description
local.unit_price = remote.unit_price
local.active = remote.active?
end
def log(msg)
Rails.logger.info "[ItemSyncService] #{msg}"
end
end

View File

@@ -0,0 +1,5 @@
<div>
<b><%=t(:label_item_count)%></b> <%= Item.count %> @ <%= Item.last_sync %>
<br/>
<%=t(:label_last_sync)%> </b> <%= Qbo.last_sync if Qbo.exists? %>
</div>

View File

@@ -13,6 +13,7 @@
en:
label_description: "Description"
label_item: "Item"
label_item_count: "Item Count:"
label_line_items: "Line Items"
label_price: "Unit Price"
label_qty: "Quantity"

View File

@@ -14,10 +14,11 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
name 'Redmine QBO Line Items plugin'
author 'Rick Barrette'
description 'A plugin for Redmine to extend the capabilitys of the Redmine QuickBooks Online plugin to attach billable line items to an isuue'
version '2026.3.2'
version '2026.3.3'
url 'https://github.com/rickbarrette/redmine_qbo'
author_url 'https://barrettefabrication.com'
requires_redmine version_or_higher: '6.1.0'
settings partial: 'line_items/settings'
# Ensure redmine_qbo is installed
begin
@@ -28,7 +29,6 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
# Add safe attributes for core models
Issue.safe_attributes :line_items_attributes
end
# Dynamically load all Hooks & Patches recursively