From 42b634a25e789c6d3854dc00f57d288a49001eb1 Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 29 Jun 2026 22:15:48 +0330 Subject: [PATCH] fix transaction --- .../Controllers/Customer/WalletController.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Customer/WalletController.php b/app/Http/Controllers/Customer/WalletController.php index 883b825..27ef281 100644 --- a/app/Http/Controllers/Customer/WalletController.php +++ b/app/Http/Controllers/Customer/WalletController.php @@ -405,7 +405,7 @@ class WalletController extends Controller return; } - $product = $this->resolveTransactionProduct($record); + $product = $this->resolveTransactionProductForLedgerTitle($record); if (!$product || trim((string) $product->title) === '') { return; } @@ -525,7 +525,7 @@ class WalletController extends Controller return; } - $product = $this->resolveTransactionProduct($record); + $product = $this->resolveTransactionProductForLedgerTitle($record); if (!$product || trim((string) $product->title) === '') { return; } @@ -633,6 +633,19 @@ class WalletController extends Controller return Wallet::with('product')->find($walletId); } + /** + * عنوان هر سطر دفترکل — محصول همان کیف پول (مثلاً کاتد در سطر برداشت کاتد برای خرید مفتول). + */ + private function resolveTransactionProductForLedgerTitle($record): ?Product + { + $wallet = $this->resolveTransactionWallet($record); + if ($wallet?->product instanceof Product && trim((string) $wallet->product->title) !== '') { + return $wallet->product; + } + + return $this->resolveTransactionProduct($record); + } + private function resolveTransactionProduct($record): ?Product { $productId = $this->resolveAbshodeProductId($record) ?? 0;