feat(patient): services tab with billing (services, debt, pay, invoice)

Expose session services + per-session billing summary (invoice_uuid,
invoice_status, patient_debt_rials, is_paid) on the sessions endpoint.
Add 'سرویس‌ها' card tab in my-patients: cost, remaining debt, complete
payment (PATCH session), and invoice view modal. Grant secretary access
in BillingController.resolveEntity. Update patient.md + billing.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-12 22:13:14 +03:30
co-authored by Claude Opus 4.8
parent f15c57d73c
commit a954a0389d
3 changed files with 45 additions and 1 deletions
@@ -36,6 +36,8 @@ class BillingController extends BaseController
private readonly DoctorRepository $doctorRepo,
private readonly ClinicRepository $clinicRepo,
private readonly InsuranceRepository $insuranceRepo,
private readonly \App\Secretary\Repository\DoctorSecretaryRepository $secretaryRepo,
private readonly \App\Auth\Repository\UserActiveContextRepository $contextRepo,
) {}
/**
@@ -290,6 +292,19 @@ class BillingController extends BaseController
$clinic = $this->clinicRepo->findByUser($user);
return $clinic !== null ? ['clinic', $clinic->getId()] : ['clinic', null];
}
if ($user->hasRole('ROLE_SECRETARY')) {
$dbUuid = $this->contextRepo->findByUser($user)?->getDbUuid();
if ($dbUuid !== null) {
$clinic = $this->clinicRepo->findByUuid($dbUuid);
if ($clinic !== null && $this->secretaryRepo->findActiveBySecretaryForClinic($user, $clinic) !== null) {
return ['clinic', $clinic->getId()];
}
$doctor = $this->doctorRepo->findByUuid($dbUuid);
if ($doctor !== null && $this->secretaryRepo->findActiveBySecretaryForDoctor($user, $doctor) !== null) {
return ['doctor', $doctor->getId()];
}
}
}
return ['unknown', null];
}
}