diff --git a/app/models/item.rb b/app/models/item.rb index 85cce09..15087ef 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -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) diff --git a/app/views/line_items/_settings.html.erb b/app/views/line_items/_settings.html.erb new file mode 100644 index 0000000..645a755 --- /dev/null +++ b/app/views/line_items/_settings.html.erb @@ -0,0 +1,5 @@ +
+ <%=t(:label_item_count)%> <%= Item.count %> @ <%= Item.last_sync %> +
+ <%=t(:label_last_sync)%> <%= Qbo.last_sync if Qbo.exists? %> +
\ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index d5a3fcf..90bf982 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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" diff --git a/init.rb b/init.rb index a79c733..d37e392 100644 --- a/init.rb +++ b/init.rb @@ -18,6 +18,7 @@ Redmine::Plugin.register :redmine_qbo_lineitems do 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