diff --git a/lib/issues_form_hook_listener.rb b/lib/issues_form_hook_listener.rb index d992eda..600e9e3 100644 --- a/lib/issues_form_hook_listener.rb +++ b/lib/issues_form_hook_listener.rb @@ -22,8 +22,8 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener # Check to see if there is a quickbooks user attached to the issue @selected_customer = context[:issue].qbo_customer.id if context[:issue].qbo_customer @selected_item = context[:issue].qbo_item.id if context[:issue].qbo_item - @selected_invoice = context[:issue].qbo_invoice.id if context[:issue].qbo_invoice - @selected_estimate = context[:issue].qbo_estimate.id if context[:issue].qbo_estimate + @selected_invoice = context[:issue].qbo_invoice ? context[:issue].qbo_invoice.id : nil + @selected_estimate = context[:issue].qbo_estimate ? context[:issue].qbo_estimate.id : nil # Generate the drop down list of quickbooks customers @select_customer = context[:form].select :qbo_customer_id, QboCustomer.all.pluck(:name, :id), :selected => @selected_customer, include_blank: true diff --git a/lib/issues_show_hook_listener.rb b/lib/issues_show_hook_listener.rb index 921eae1..1a45245 100644 --- a/lib/issues_show_hook_listener.rb +++ b/lib/issues_show_hook_listener.rb @@ -21,11 +21,13 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener issue = context[:issue] # Check to see if there is a quickbooks user attached to the issue - @customer = issue.qbo_customer.name if issue.qbo_customer + @customer = issue.qbo_customer ? issue.qbo_customer.name : nil # Check to see if there is a quickbooks item attached to the issue - @item = issue.qbo_item.name if issue.qbo_item + @item = issue.qbo_item ? issue.qbo_item.name : nil + @estimate = nil + @estimate_link = nil # Estimate Number if issue.qbo_estimate QboEstimate.update(issue.qbo_estimate.id) @@ -33,6 +35,8 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener @estimate_link = link_to @estimate, "#{Redmine::Utils::relative_url_root }/qbo/estimate/#{issue.qbo_estimate.id}", :target => "_blank" end + @invoice = nil + @invo = nil # Invoice Number if issue.qbo_invoice QboInvoice.update(issue.qbo_invoice.id)