It's in Production!

Made some tweaks and error checks
This commit is contained in:
2016-01-09 10:11:13 -05:00
parent ed66b7b7b4
commit 6d357f27f9
4 changed files with 11 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ Redmine::Plugin.register :redmine_qbo do
TimeEntry.safe_attributes 'qbo_billed'
# We are playing in the sandbox
Quickbooks.sandbox_mode = true
#Quickbooks.sandbox_mode = true
# Register QBO top menu item
menu :top_menu, :qbo, { :controller => 'qbo', :action => 'index' }, :caption => 'Quickbooks'

View File

@@ -16,7 +16,7 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
selected = ""
QboCustomers.update_all
QboItem.update_all
#QboItem.update_all
# Check to see if there is a quickbooks user attached to the issue
if not context[:issue].qbo_customer_id.nil? then

View File

@@ -22,8 +22,7 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
time_service = Quickbooks::Service::TimeActivity.new(:company_id => qbo.realmId, :access_token => Qbo.get_auth_token)
item_service = Quickbooks::Service::Item.new(:company_id => qbo.realmId, :access_token => Qbo.get_auth_token)
time_entry = Quickbooks::Model::TimeActivity.new
item = item_service.fetch_by_id issue.qbo_item_id
# Get unbilled time entries
spent_time = issue.time_entries.where(qbo_billed: [false, nil])
spent_hours ||= spent_time.sum(:hours) || 0
@@ -44,6 +43,7 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
# If the issue is closed, then create a new billable time activty for the customer
# TODO Add configuration settings for employee_id, hourly_rate, item_id
if issue.status.is_closed? and not issue.qbo_customer_id.nil? and not issue.qbo_item_id.nil? and not employee_id.nil? and spent_hours > 0 then
item = item_service.fetch_by_id issue.qbo_item_id
time_entry.description = "#{issue.tracker} ##{issue.id}: #{issue.subject}"
time_entry.employee_id = employee_id
time_entry.customer_id = issue.qbo_customer_id

View File

@@ -22,9 +22,13 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
output = content_tag(:div, content_tag(:div, content_tag(:div, content_tag(:span,"Customer") + ":", class:"label") + content_tag(:div, value, class:"value") , class:"qbo_customer_id attribute"), class:"attributes")
# Check to see if there is a quickbooks user attached to the issue
if not context[:issue].qbo_customer_id.nil? then
value = QboItem.find_by_id(context[:issue].qbo_item_id).name
value = ""
# Check to see if there is a quickbooks item attached to the issue
if not context[:issue].qbo_customer_id.nil? then
if not QboItem.find_by_id(context[:issue].qbo_item_id).nil? then
value = QboItem.find_by_id(context[:issue].qbo_item_id).name
end
end
output << content_tag(:div, content_tag(:div, content_tag(:div, content_tag(:span,"Item") + ":", class:"label") + content_tag(:div, value, class:"value") , class:"qbo_item_id attribute"), class:"attributes")