mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 08:54:23 -05:00
It's in Production!
Made some tweaks and error checks
This commit is contained in:
2
init.rb
2
init.rb
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,6 @@ 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])
|
||||
@@ -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
|
||||
|
||||
@@ -22,10 +22,14 @@ 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
|
||||
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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user