Update qbo_controller.rb

This commit is contained in:
2016-08-10 01:24:18 -04:00
committed by GitHub
parent a56c01fe6d
commit a0e9061a8f

View File

@@ -57,7 +57,7 @@ class QboController < ApplicationController
qbo.reconnect_token_at = 5.months.from_now.utc qbo.reconnect_token_at = 5.months.from_now.utc
qbo.company_id = params['realmId'] qbo.company_id = params['realmId']
if qbo.save! if qbo.save!
redirect_to qbo_path, :flash => { :notice => "Successfully connected to Quickbooks" } redirect_to qbo_sync_path, :flash => { :notice => "Successfully connected to Quickbooks" }
else else
redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => "Error" } redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => "Error" }
end end
@@ -118,15 +118,19 @@ class QboController < ApplicationController
# Synchronizes the QboCustomer table with QBO # Synchronizes the QboCustomer table with QBO
# #
def sync def sync
if Qbo.exists? # Update info in background
Customer.sync Thread.new do
QboItem.sync if Qbo.exists?
QboEmployee.sync Customer.sync
QboEstimate.sync QboItem.sync
QboInvoice.sync QboEmployee.sync
QboEstimate.sync
QboInvoice.sync
# Record the last sync time # Record the last sync time
Qbo.update_time_stamp Qbo.update_time_stamp
end
ActiveRecord::Base.connection.close
end end
redirect_to qbo_path(:redmine_qbo), :flash => { :notice => "Successfully synced to Quickbooks" } redirect_to qbo_path(:redmine_qbo), :flash => { :notice => "Successfully synced to Quickbooks" }