feat(invoice): implement recorder identity resolution for payments and update related tests
This commit is contained in:
@@ -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). */
|
||||
|
||||
Reference in New Issue
Block a user