mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 09:24:23 -05:00
Update customer.rb
This commit is contained in:
@@ -101,14 +101,14 @@ class Customer < ActiveRecord::Base
|
|||||||
# proforms a bruteforce sync operation
|
# proforms a bruteforce sync operation
|
||||||
# This needs to be simplified
|
# This needs to be simplified
|
||||||
def update_all
|
def update_all
|
||||||
customers = get_base.service.all
|
customers = get_base.service.query("SELECT Id, DisplayName FROM Customer WHERE Metadata.LastUpdatedTime>'#{Qbo.first.last_sync}' ")
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
# Update the customer table
|
# Update the customer table
|
||||||
customers.each { |customer|
|
customers.each { |customer|
|
||||||
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
||||||
# only update if diffrent
|
# only update if diffrent
|
||||||
if not qbo_customer.name == customer.display_name
|
if qbo_customer.new_record?
|
||||||
qbo_customer.name = customer.display_name
|
qbo_customer.name = customer.display_name
|
||||||
qbo_customer.id = customer.id
|
qbo_customer.id = customer.id
|
||||||
qbo_customer.save!
|
qbo_customer.save!
|
||||||
|
|||||||
Reference in New Issue
Block a user