feat(insurance): add insurance coverage flag to selected services and update coverage logic

This commit is contained in:
hamed
2026-06-24 06:09:05 +03:30
parent 17f41117f1
commit 69beb7b944
3 changed files with 13 additions and 3 deletions
@@ -2,6 +2,7 @@
namespace App\Insurance\Service;
use App\ClinicService\Repository\ServiceItemRepository;
use App\Insurance\Entity\TenantInsurance;
use App\Insurance\Repository\InsuranceRepository;
use App\Insurance\Repository\TenantInsuranceRepository;
@@ -16,6 +17,7 @@ class TenantInsuranceService
private readonly TenantInsuranceRepository $repo,
private readonly InsuranceRepository $insuranceRepo,
private readonly TenantServiceCoverageRepository $coverageRepo,
private readonly ServiceItemRepository $serviceItemRepo,
) {}
/**
@@ -101,6 +103,12 @@ class TenantInsuranceService
return CoverageRule::notCovered();
}
// پرچم سرویس gate نهایی است: اگر «این خدمت شامل بیمه می‌شود» غیرفعال باشد، هیچ پوششی محاسبه نمی‌شود.
$service = $this->serviceItemRepo->find($serviceItemId);
if ($service === null || !$service->isInsuranceCovered()) {
return CoverageRule::notCovered();
}
$contract = $this->repo->findActiveContract($entityType, $entityId, $insuranceId);
if ($contract === null) {
return CoverageRule::notCovered();