Fix BadMethodCallException and remaining PostgreSQL issues

This commit is contained in:
2026-05-14 12:24:33 +07:00
parent b76d34cc64
commit ce2b815b07
4 changed files with 18 additions and 6 deletions

View File

@@ -241,7 +241,7 @@ public function incomeExpense(Request $request)
$data['expenses'] = Sale::where('business_id', auth()->user()->business_id)
->whereYear('created_at', request('year') ?? date('Y'))
->where('lossProfit', '<', 0)
->selectRaw("EXTRACT(MONTH FROM created_at) as month_number, TO_CHAR(created_at, 'Month') as month, SUM(ABS(lossProfit)) as total")
->selectRaw("EXTRACT(MONTH FROM created_at) as month_number, TO_CHAR(created_at, 'Month') as month, SUM(ABS(\"lossProfit\")) as total")
->groupBy('month_number', 'month')
->orderBy('month_number')
->get();
@@ -249,7 +249,7 @@ public function incomeExpense(Request $request)
$data['incomes'] = Sale::where('business_id', auth()->user()->business_id)
->whereYear('created_at', request('year') ?? date('Y'))
->where('lossProfit', '>=', 0)
->selectRaw("EXTRACT(MONTH FROM created_at) as month_number, TO_CHAR(created_at, 'Month') as month, SUM(ABS(lossProfit)) as total")
->selectRaw("EXTRACT(MONTH FROM created_at) as month_number, TO_CHAR(created_at, 'Month') as month, SUM(ABS(\"lossProfit\")) as total")
->groupBy('month_number', 'month')
->orderBy('month_number')
->get();