feat: Enhance insurance billing system to support supplementary insurance
- Updated CoverageRule and related entities to include franchise_percent instead of franchise_rials. - Modified Appointment entity to carry supplementary insurance ID alongside base insurance. - Implemented SessionBillingService to ensure finalized invoices for insured patient sessions. - Created InvoiceFinalized event to trigger claims creation upon invoice finalization. - Added BackfillMissingClaimsCommand to generate claims for finalized invoices without existing claims. - Developed tests to validate the new functionality for supplementary insurance handling in appointments and claims.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Billing\EventSubscriber;
|
||||
|
||||
use App\Billing\Event\InvoiceFinalized;
|
||||
use App\Billing\Service\ClaimService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||
|
||||
/**
|
||||
* هر صورتحساب نهاییشدهی بیمهدار باید مطالبه داشته باشد، از هر مسیری که نهایی شده باشد.
|
||||
* خطا در این مرحله نباید نهاییشدن صورتحساب را برگرداند؛ فقط لاگ میشود.
|
||||
*/
|
||||
#[AsEventListener(event: InvoiceFinalized::class)]
|
||||
class CreateClaimsOnInvoiceFinalized
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ClaimService $claimService,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {}
|
||||
|
||||
public function __invoke(InvoiceFinalized $event): void
|
||||
{
|
||||
try {
|
||||
$this->claimService->syncFromInvoice($event->invoice);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('claim sync failed', [
|
||||
'invoice' => $event->invoice->getUuid(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user