added tahesab options 2
This commit is contained in:
@@ -22,6 +22,21 @@ class TahesabController extends Controller
|
|||||||
return app(TahesabSyncService::class);
|
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)
|
public function table(Request $request)
|
||||||
{
|
{
|
||||||
$query = Tahesab::with('customer')->orderByDesc('id');
|
$query = Tahesab::with('customer')->orderByDesc('id');
|
||||||
@@ -478,8 +493,7 @@ class TahesabController extends Controller
|
|||||||
"data" => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
"data" => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$pricesResponse = app(ReportController::class)->lastPrice(request());
|
$prices = $this->lastPriceData();
|
||||||
$prices = method_exists($pricesResponse, 'getData') ? (array) $pricesResponse->getData(true) : (array) $pricesResponse;
|
|
||||||
|
|
||||||
$mazaneh = $isDeposit ? (int) ($prices['buy'] ?? 0) : (int) ($prices['sell'] ?? 0);
|
$mazaneh = $isDeposit ? (int) ($prices['buy'] ?? 0) : (int) ($prices['sell'] ?? 0);
|
||||||
$mablaghKol = (int) round($mazaneh * $amount);
|
$mablaghKol = (int) round($mazaneh * $amount);
|
||||||
|
|||||||
Reference in New Issue
Block a user