feat: update session payment logic to ensure accurate payable amounts and reflect consumables in cost breakdown

- Adjusted the calculation of payable amounts in PaymentStep to align with server logic, ensuring overpayments are handled correctly.
- Enhanced DetailsStep to include consumables in the itemized cost breakdown, ensuring consistency with patient share calculations.
- Updated tests for SessionPaymentPage to validate new behavior regarding overpayments and consumable listings.
- Modified PatientController to register SessionPayment correctly when settling sessions via wallet, preventing double charges.
- Refactored WalletService to remove outdated methods and ensure wallet transactions reflect the correct amounts after discounts.
- Improved accessibility in SearchableSelect component by adding aria labels and ensuring proper role attributes for screen readers.
- Updated styles to ensure minimum touch targets meet WCAG guidelines for mobile usability.
This commit is contained in:
hamed
2026-07-19 13:29:46 +03:30
parent 0d9784b03a
commit 773f9d4d16
22 changed files with 251 additions and 70 deletions
+13 -8
View File
@@ -1073,15 +1073,20 @@ class PatientController extends BaseController
if (isset($data['payment_method'])) {
$method = (string) $data['payment_method'];
// پرداخت از کیف پول: سهمِ بیمار را از موجودی کسر کن (فقط یک‌بار، اگر
// مراجعه هنوز تسویه نشده). موجودیِ ناکافی → AppException (۴۲۲).
if ($method === 'wallet'
&& $session->getPaymentMethod() === 'pending'
&& $session->getFinalPriceRials() > 0
) {
$this->walletService->settleSessionFromWallet($session, $user);
// پرداخت از کیف پول: مانده را از موجودی کسر کن و همزمان SessionPayment ثبت کن.
// از addSessionPayment استفاده می‌شود تا مبلغ = مانده (پس از تخفیف و پرداخت‌های
// قبلی) باشد و is_paid/paid_at درست ست شود؛ موجودی ناکافی → AppException (۴۲۲).
if ($method === 'wallet' && $session->getRemainingRials() > 0) {
$this->patientService->addSessionPayment(
$session,
'wallet',
$session->getRemainingRials(),
isset($data['paid_at']) ? (int) $data['paid_at'] : null,
$user,
);
} else {
$session->setPaymentMethod($method);
}
$session->setPaymentMethod($method);
}
$this->sessionRepo->save($session);