Refactor: Replace BillingValidator with inline validations in bill method and update error messages in locale

This commit is contained in:
2026-03-01 12:29:20 -05:00
parent 46f06df995
commit ef3f00c445
3 changed files with 5 additions and 22 deletions

View File

@@ -33,7 +33,10 @@ class QboController < ApplicationController
# Manual billing endpoint to trigger the billing process for a specific issue. Validates the issue and its associations, enqueues a job to bill the issue's time entries, and redirects back to the issue with a notice. If validation fails, redirects back with an error message.
def bill
issue = Issue.find_by(id: params[:id])
BillingValidator.validate!(issue)
raise I18n.t(:notice_error_issue_not_found) unless issue
raise I18n.t(:label_billing_error_no_customer) unless issue.customer
raise I18n.t(:label_billing_error_no_employee) unless issue.assigned_to&.employee_id.present?
raise I18n.t(:label_billing_error_no_qbo) unless Qbo.exists?
BillIssueTimeJob.perform_later(issue.id)