Added sanity checks for QBO info

This commit is contained in:
2016-01-11 23:24:35 -05:00
parent 2ec9e43951
commit f9e271cbcb

View File

@@ -15,6 +15,9 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
issue = context[:issue] issue = context[:issue]
cf_estimate = CustomField.find_by_name("Estimate") cf_estimate = CustomField.find_by_name("Estimate")
# Check to see if we have registered with QBO
unless Qbo.first.nil? and issue.qbo_customer_id.nil? and issue.qbo_item_id.nil? and employee_id.nil? then
# if this is a quote, lets create a new estimate based off estimated hours # if this is a quote, lets create a new estimate based off estimated hours
if issue.tracker.name = "Quote" and issue.status.name = "New" and cf_estimate.nil? then if issue.tracker.name = "Quote" and issue.status.name = "New" and cf_estimate.nil? then
@@ -43,7 +46,7 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
issue.custom_field_values = {CustomField.find_by_name("Estimate").id => created_estimate.doc_number} issue.custom_field_values = {CustomField.find_by_name("Estimate").id => created_estimate.doc_number}
issue.save! issue.save!
end end
end
end end
# After Issue Saved # After Issue Saved