mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 07:01:59 -04:00
Added settings page for Item stats
This commit is contained in:
@@ -15,6 +15,12 @@ class Item < ApplicationRecord
|
|||||||
validates :unit_price, numericality: { greater_than_or_equal_to: 0 }
|
validates :unit_price, numericality: { greater_than_or_equal_to: 0 }
|
||||||
self.primary_key = :id
|
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
|
# Sync all items, typically triggered by a scheduled task or manual sync request
|
||||||
def self.sync
|
def self.sync
|
||||||
ItemSyncJob.perform_later(full_sync: true)
|
ItemSyncJob.perform_later(full_sync: true)
|
||||||
|
|||||||
5
app/views/line_items/_settings.html.erb
Normal file
5
app/views/line_items/_settings.html.erb
Normal 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>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
en:
|
en:
|
||||||
label_description: "Description"
|
label_description: "Description"
|
||||||
label_item: "Item"
|
label_item: "Item"
|
||||||
|
label_item_count: "Item Count:"
|
||||||
label_line_items: "Line Items"
|
label_line_items: "Line Items"
|
||||||
label_price: "Unit Price"
|
label_price: "Unit Price"
|
||||||
label_qty: "Quantity"
|
label_qty: "Quantity"
|
||||||
|
|||||||
2
init.rb
2
init.rb
@@ -18,6 +18,7 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
|
|||||||
url 'https://github.com/rickbarrette/redmine_qbo'
|
url 'https://github.com/rickbarrette/redmine_qbo'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
requires_redmine version_or_higher: '6.1.0'
|
requires_redmine version_or_higher: '6.1.0'
|
||||||
|
settings partial: 'line_items/settings'
|
||||||
|
|
||||||
# Ensure redmine_qbo is installed
|
# Ensure redmine_qbo is installed
|
||||||
begin
|
begin
|
||||||
@@ -28,7 +29,6 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
|
|||||||
|
|
||||||
# Add safe attributes for core models
|
# Add safe attributes for core models
|
||||||
Issue.safe_attributes :line_items_attributes
|
Issue.safe_attributes :line_items_attributes
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dynamically load all Hooks & Patches recursively
|
# Dynamically load all Hooks & Patches recursively
|
||||||
|
|||||||
Reference in New Issue
Block a user