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;