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,6 +118,8 @@ class QboController < ApplicationController
# Synchronizes the QboCustomer table with QBO # Synchronizes the QboCustomer table with QBO
# #
def sync def sync
# Update info in background
Thread.new do
if Qbo.exists? if Qbo.exists?
Customer.sync Customer.sync
QboItem.sync QboItem.sync
@@ -128,6 +130,8 @@ class QboController < ApplicationController
# Record the last sync time # Record the last sync time
Qbo.update_time_stamp Qbo.update_time_stamp
end end
ActiveRecord::Base.connection.close
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" }
end end