added tahesab options 2

This commit is contained in:
2026-06-25 22:24:46 +03:30
parent e6e1ff0cc4
commit 1f93408c7b
@@ -22,6 +22,21 @@ class TahesabController extends Controller
return app(TahesabSyncService::class);
}
private function lastPriceData(): array
{
$response = app(ReportController::class)->lastPrice(request());
if (is_array($response)) {
return $response;
}
if (is_object($response) && method_exists($response, 'getData')) {
return (array) $response->getData(true);
}
return (array) $response;
}
public function table(Request $request)
{
$query = Tahesab::with('customer')->orderByDesc('id');
@@ -478,8 +493,7 @@ class TahesabController extends Controller
"data" => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
]);
$pricesResponse = app(ReportController::class)->lastPrice(request());
$prices = method_exists($pricesResponse, 'getData') ? (array) $pricesResponse->getData(true) : (array) $pricesResponse;
$prices = $this->lastPriceData();
$mazaneh = $isDeposit ? (int) ($prices['buy'] ?? 0) : (int) ($prices['sell'] ?? 0);
$mablaghKol = (int) round($mazaneh * $amount);