Added time stamps to each qbo entity model

This commit is contained in:
2026-03-02 07:10:13 -05:00
parent 485a977d1a
commit f02b50ae26
5 changed files with 38 additions and 6 deletions

View File

@@ -11,8 +11,9 @@
class Customer < ActiveRecord::Base
include Redmine::Acts::Searchable
include Redmine::Acts::Event
include Redmine::Acts::Event
include Redmine::I18n
has_many :issues
has_many :invoices
has_many :estimates
@@ -49,6 +50,12 @@ class Customer < ActiveRecord::Base
@details.email_address = s
end
# 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
# Convenience Method
# returns the customer's primary phone
def primary_phone

View File

@@ -10,11 +10,19 @@
class Employee < ActiveRecord::Base
include Redmine::I18n
has_many :users
validates_presence_of :id, :name
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 employees, typically triggered by a scheduled task or manual sync request
def self.sync
EmployeeSyncJob.perform_later(full_sync: true)

View File

@@ -10,11 +10,19 @@
class Estimate < ActiveRecord::Base
include Redmine::I18n
has_and_belongs_to_many :issues
belongs_to :customer
validates_presence_of :doc_number, :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
# returns a human readable string
def to_s
return self[:doc_number]

View File

@@ -9,6 +9,9 @@
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class Invoice < ActiveRecord::Base
include Redmine::I18n
has_and_belongs_to_many :issues
belongs_to :customer
@@ -17,6 +20,12 @@ class Invoice < ActiveRecord::Base
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
# Return the invoice's document number as its string representation
def to_s
doc_number

View File

@@ -89,19 +89,19 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
<br/>
<div>
<b><%=t(:label_customer_count)%>:</b> <%= Customer.count%>
<b><%=t(:label_customer_count)%>:</b> <%= Customer.count%> @ <%= Customer.last_sync %>
</div>
<div>
<b><%=t(:label_employee_count)%>:</b> <%= Employee.count %>
<b><%=t(:label_employee_count)%>:</b> <%= Employee.count %> @ <%= Employee.last_sync %>
</div>
<div>
<b><%=t(:label_invoice_count)%>:</b> <%= Invoice.count %>
<b><%=t(:label_invoice_count)%>:</b> <%= Invoice.count %> @ <%= Invoice.last_sync%>
</div>
<div>
<b><%=t(:label_estimate_count)%>:</b> <%= Estimate.count %>
<b><%=t(:label_estimate_count)%>:</b> <%= Estimate.count %> @ <%= Estimate.last_sync %>
</div>
<br/>