Wire Care lists into Ladill Queue workflows instead of reception panels.
Deploy Ladill Care / deploy (push) Successful in 1m45s
Deploy Ladill Care / deploy (push) Successful in 1m45s
When Queue integration is on, role pages issue tickets into their own department queues and drive Call next → Serve → Complete on the native lists. Integration off leaves existing UI unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,8 @@ use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Models\Bill;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Care\BillService;
|
||||
use App\Services\Care\CareQueueBridge;
|
||||
use App\Services\Care\CareQueueContexts;
|
||||
use App\Services\Care\OrganizationResolver;
|
||||
use App\Services\Payments\MerchantGatewayService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -21,13 +23,15 @@ class BillController extends Controller
|
||||
public function __construct(
|
||||
protected BillService $bills,
|
||||
protected MerchantGatewayService $gateway,
|
||||
protected CareQueueBridge $queueBridge,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'bills.view');
|
||||
$organization = $this->organization($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($this->member($request));
|
||||
$member = $this->member($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($member);
|
||||
|
||||
$bills = $this->bills->list(
|
||||
$this->ownerRef($request),
|
||||
@@ -36,13 +40,59 @@ class BillController extends Controller
|
||||
$branchScope,
|
||||
);
|
||||
|
||||
$branchId = (int) ($branchScope ?: \App\Models\Branch::owned($this->ownerRef($request))
|
||||
->where('organization_id', $organization->id)
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->value('id'));
|
||||
|
||||
return view('care.bills.index', [
|
||||
'organization' => $organization,
|
||||
'bills' => $bills,
|
||||
'statuses' => config('care.bill_statuses'),
|
||||
'branchId' => $branchId,
|
||||
'queueIntegration' => $branchId
|
||||
? $this->queueBridge->listMeta($organization, CareQueueContexts::BILLING, $branchId)
|
||||
: ['enabled' => false],
|
||||
'canManageQueue' => app(\App\Services\Care\CarePermissions::class)
|
||||
->can($member, 'service_queues.console'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function callNext(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'bills.manage');
|
||||
$organization = $this->organization($request);
|
||||
$member = $this->member($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($member);
|
||||
$branchId = (int) ($request->input('branch_id') ?: $branchScope);
|
||||
abort_unless($branchId > 0, 422);
|
||||
abort_unless($this->queueBridge->isEnabled($organization), 404);
|
||||
|
||||
$result = $this->queueBridge->callNext($organization, CareQueueContexts::BILLING, $branchId);
|
||||
$ticket = $result['ticket'] ?? null;
|
||||
if (! $ticket) {
|
||||
return back()->with('error', 'No bills waiting in the billing queue.');
|
||||
}
|
||||
|
||||
return back()->with('success', 'Called '.$ticket['ticket_number'].'.');
|
||||
}
|
||||
|
||||
public function serve(Request $request, Bill $bill): RedirectResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'bills.manage');
|
||||
$this->authorizeBill($request, $bill);
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($this->queueBridge->isEnabled($organization), 404);
|
||||
|
||||
$ticket = $this->queueBridge->serve($organization, $bill);
|
||||
if (! $ticket) {
|
||||
return back()->with('error', 'Could not serve billing ticket.');
|
||||
}
|
||||
|
||||
return back()->with('success', 'Now serving '.$ticket['ticket_number'].'.');
|
||||
}
|
||||
|
||||
public function generate(Request $request, Visit $visit): RedirectResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'bills.manage');
|
||||
|
||||
Reference in New Issue
Block a user