mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-02-14 09:34:00 -05:00
Fixed partial billing and added flash messages
This commit is contained in:
@@ -64,11 +64,16 @@ class QboController < ApplicationController
|
|||||||
def bill
|
def bill
|
||||||
i = Issue.find_by_id params[:id]
|
i = Issue.find_by_id params[:id]
|
||||||
if i.customer
|
if i.customer
|
||||||
i.bill_time
|
billed = i.bill_time
|
||||||
redirect_to i, flash: { notice: I18n.t(:label_billed_success) + i.customer.name }
|
|
||||||
|
if i.bill_time
|
||||||
|
redirect_to i, flash: { notice: I18n.t( :label_billed_success ) + i.customer.name }
|
||||||
else
|
else
|
||||||
redirect_to i, flash: { error: I18n.t(:label_billing_error) }
|
redirect_to i, flash: { error: I18n.t(:label_billing_error) }
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
redirect_to i, flash: { error: I18n.t(:label_billing_error_no_customer) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Quickbooks Webhook Callback
|
# Quickbooks Webhook Callback
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ en:
|
|||||||
label_connected: "Successfully connected to Quickbooks"
|
label_connected: "Successfully connected to Quickbooks"
|
||||||
label_error: "Error"
|
label_error: "Error"
|
||||||
label_billed_success: "Successfully Billed "
|
label_billed_success: "Successfully Billed "
|
||||||
label_billing_error: "Cannot bill without a customer assigned"
|
label_billing_error: "Customer could not be billed, check for Customer or Assignee and try again"
|
||||||
|
label_billing_error_no_customer: "Cannot bill without a customer assigned"
|
||||||
label_qbo_sync_success: "Successfully synced to Quickbooks"
|
label_qbo_sync_success: "Successfully synced to Quickbooks"
|
||||||
label_hours: "Hours"
|
label_hours: "Hours"
|
||||||
label_oauth2_refresh_token_expires_at: "Refresh Token Expires At"
|
label_oauth2_refresh_token_expires_at: "Refresh Token Expires At"
|
||||||
|
|||||||
@@ -44,10 +44,9 @@ module RedmineQbo
|
|||||||
# Create billable time entries
|
# Create billable time entries
|
||||||
def bill_time
|
def bill_time
|
||||||
logger.debug "QBO: Billing time for issue ##{id}"
|
logger.debug "QBO: Billing time for issue ##{id}"
|
||||||
return unless status.is_closed?
|
return false if assigned_to.nil?
|
||||||
return if assigned_to.nil?
|
return false unless Qbo.first
|
||||||
return unless Qbo.first
|
return false unless customer
|
||||||
return unless customer
|
|
||||||
|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
spent_time = time_entries.where(billed: [false, nil])
|
spent_time = time_entries.where(billed: [false, nil])
|
||||||
@@ -102,6 +101,7 @@ module RedmineQbo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user