From 772483817e76b47909b61383e2b874889222e53e Mon Sep 17 00:00:00 2001 From: RageLtMan Date: Tue, 3 Jan 2017 04:32:04 -0500 Subject: [PATCH] Prevent billing if issue has no customer assigned --- app/controllers/qbo_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/qbo_controller.rb b/app/controllers/qbo_controller.rb index 2c91e92..22abf7a 100644 --- a/app/controllers/qbo_controller.rb +++ b/app/controllers/qbo_controller.rb @@ -66,8 +66,12 @@ class QboController < ApplicationController # Manual Billing def bill i = Issue.find_by_id params[:id] - i.bill_time - redirect_to i, :flash => { :notice => "Successfully Billed #{i.customer.name}" } + if i.customer + i.bill_time + redirect_to i, :flash => { :notice => "Successfully Billed #{i.customer.name}" } + else + redirect_to i, :flash => { :error => "Cannot bill without a customer assigned" } + end end # Quickbooks Webhook Callback