feat(invoice): implement recorder identity resolution for payments and update related tests

This commit is contained in:
hamed
2026-08-04 11:19:07 +03:30
parent 2c7b86d917
commit 810e9351a9
7 changed files with 321 additions and 13 deletions
+8 -10
View File
@@ -8,7 +8,7 @@ use App\Settlement\Repository\SettlementRepository;
use App\Settlement\Repository\WalletTransactionRepository;
use App\Shared\Constant\ErrorCodes;
use App\Shared\Exception\AppException;
use App\UserProfile\Repository\UserProfileRepository;
use App\Shared\Service\ActorIdentityResolver;
/**
* منطق کیف پولِ بیمار: موجودی، شارژ (credit)، برداشت (debit) و تسویهٔ سرویس از
@@ -24,7 +24,7 @@ class WalletService
public function __construct(
private readonly WalletTransactionRepository $walletRepo,
private readonly SettlementRepository $settlementRepo,
private readonly UserProfileRepository $profileRepo,
private readonly ActorIdentityResolver $actorIdentity,
) {}
public function balance(User $patient): int
@@ -32,16 +32,14 @@ class WalletService
return $this->settlementRepo->getWalletBalance($patient);
}
/** نامِ نمایشیِ کاربرِ عامل (برای ستون «ثبت‌کننده»)؛ در نبودِ پروفایل، شماره موبایل. */
/**
* نامِ نمایشیِ کاربرِ عامل (برای ستون «ثبت‌کننده»).
* پیاده‌سازی در {@see ActorIdentityResolver} است تا نامِ ذخیره‌شده و نامِ
* نمایش‌داده‌شده از یک قاعده بیایند.
*/
public function resolveActorName(?User $actor): ?string
{
if ($actor === null) {
return null;
}
$profile = $this->profileRepo->findByUser($actor);
$name = trim(($profile?->getLabel() ?? '') . ' ' . ($profile?->getFamily() ?? ''));
return $name !== '' ? $name : $actor->getMobileNumber();
return $this->actorIdentity->name($actor);
}
/** شارژِ کیف پول (credit). فرض بر مثبت بودنِ مبلغ است (اعتبارسنجی در Controller). */