fix transaction

This commit is contained in:
2026-06-29 22:15:48 +03:30
parent b0ac2c7862
commit 42b634a25e
@@ -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;