update revenue chart
All checks were successful
All checks were successful
This commit is contained in:
@@ -196,17 +196,17 @@ public function revenue()
|
|||||||
$data['loss'] = Sale::where('business_id', auth()->user()->business_id)
|
$data['loss'] = Sale::where('business_id', auth()->user()->business_id)
|
||||||
->whereYear('created_at', request('year') ?? date('Y'))
|
->whereYear('created_at', request('year') ?? date('Y'))
|
||||||
->where('lossProfit', '<', 0)
|
->where('lossProfit', '<', 0)
|
||||||
->selectRaw("TO_CHAR(created_at, 'Month') as month, SUM(ABS(lossProfit)) as total")
|
->selectRaw("TO_CHAR(created_at, 'FMMonth') as month, SUM(ABS(lossProfit)) as total")
|
||||||
->orderBy('created_at')
|
->groupByRaw("TO_CHAR(created_at, 'FMMonth'), DATE_TRUNC('month', created_at)")
|
||||||
->groupBy('created_at')
|
->orderByRaw("DATE_TRUNC('month', created_at)")
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$data['profit'] = Sale::where('business_id', auth()->user()->business_id)
|
$data['profit'] = Sale::where('business_id', auth()->user()->business_id)
|
||||||
->whereYear('created_at', request('year') ?? date('Y'))
|
->whereYear('created_at', request('year') ?? date('Y'))
|
||||||
->where('lossProfit', '>=', 0)
|
->where('lossProfit', '>=', 0)
|
||||||
->selectRaw("TO_CHAR(created_at, 'Month') as month, SUM(ABS(lossProfit)) as total")
|
->selectRaw("TO_CHAR(created_at, 'FMMonth') as month, SUM(ABS(lossProfit)) as total")
|
||||||
->orderBy('created_at')
|
->groupByRaw("TO_CHAR(created_at, 'FMMonth'), DATE_TRUNC('month', created_at)")
|
||||||
->groupBy('created_at')
|
->orderByRaw("DATE_TRUNC('month', created_at)")
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
|
|||||||
Reference in New Issue
Block a user