Update qbo_item.rb

This commit is contained in:
2016-05-02 14:06:44 -04:00
parent 98bbad8471
commit a1530fb952

View File

@@ -19,8 +19,13 @@ class QboItem < ActiveRecord::Base
end end
def self.sync def self.sync
items = get_base.service.find_by(:type, "Service") #items = get_base.service.find_by(:type, "Service")
last = Qbo.first.last_sync
query = "SELECT Id, Name FROM Item"
query << " WHERE Metadata.LastUpdatedTime>'#{last}' " if last
items = get_base.service.query()
transaction do transaction do
# Update the item table # Update the item table
items.each { |item| items.each { |item|
@@ -32,6 +37,6 @@ class QboItem < ActiveRecord::Base
end end
#remove deleted items #remove deleted items
where.not(items.map(&:id)).destroy_all #where.not(items.map(&:id)).destroy_all
end end
end end