fixed kilo in metals 2
This commit is contained in:
@@ -20,6 +20,7 @@ use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
use App\Http\Controllers\Admin\TahesabController;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Services\BalanceReportService;
|
||||
use App\Services\WalletBalanceService;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
|
||||
@@ -219,35 +220,28 @@ class WalletController extends Controller
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$records = Transaction::with(['customer'])->whereNull('fund_id');
|
||||
$balanceReport = app(BalanceReportService::class);
|
||||
$balanceService = app(WalletBalanceService::class);
|
||||
$catalogMetalIds = $balanceService->catalogMetalIds();
|
||||
|
||||
$records = Transaction::with([
|
||||
'customer',
|
||||
'product:id,title,metal_id,group_type,unit,amount,trade_by_quantity,direct_price',
|
||||
])->whereNull('fund_id');
|
||||
TableEngine::create($records, $request->all())
|
||||
->initSearch(['order_id', 'customer.name'])
|
||||
->select([
|
||||
'*', Transaction::$SELECT_CAJ, Transaction::$SELECT_TYPE_STR, Transaction::$SELECT_SAJ, Transaction::$SELECT_EAJ
|
||||
])->export($records);
|
||||
// foreach ($records['rows'] as &$record) {
|
||||
// if (empty($record->title) or $record->title == "تعریف نشده"){
|
||||
// $record->title = $record->type_str ;
|
||||
// $record->unit = "گرم";
|
||||
// if (isset($record->wallet)) {
|
||||
// $wallet = Wallet::with('product')->where('id',$record->wallet)->first();
|
||||
// if (isset($wallet->product)) {
|
||||
// if ($record->gold > 0){
|
||||
// $record->title = " خرید " ;
|
||||
//
|
||||
// }else{
|
||||
// $record->title = " فروش " ;
|
||||
//
|
||||
// }
|
||||
// $record->title .= $wallet->product->title ;
|
||||
// $record->unit = "عدد";
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// $record->save();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
if (isset($records['rows'])) {
|
||||
foreach ($records['rows'] as &$row) {
|
||||
$balanceReport->enrichTransactionTableRow($row, $catalogMetalIds);
|
||||
}
|
||||
unset($row);
|
||||
}
|
||||
|
||||
$records['catalogMetals'] = $balanceReport->catalogMetalsMeta();
|
||||
|
||||
return response()->json($records);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user