Fix BadMethodCallException and remaining PostgreSQL issues
This commit is contained in:
@@ -34,8 +34,9 @@ public function getDashboardData()
|
||||
public function yearlySubscriptions()
|
||||
{
|
||||
$subscriptions = PlanSubscribe::whereYear('created_at', request('year') ?? date('Y'))
|
||||
->selectRaw("TO_CHAR(created_at, 'Month') as month, SUM(price) as total_amount")
|
||||
->groupBy('month')
|
||||
->selectRaw("TO_CHAR(created_at, 'FMMonth') as month, SUM(price) as total_amount")
|
||||
->groupBy(DB::raw("TO_CHAR(created_at, 'FMMonth')"))
|
||||
->orderBy(DB::raw("MIN(created_at)"))
|
||||
->get();
|
||||
|
||||
return response()->json($subscriptions);
|
||||
|
||||
@@ -118,7 +118,7 @@ public function dashboard()
|
||||
$sales_data = Sale::selectRaw("TO_CHAR(created_at, '$dateFormatSQL') as date, SUM(\"totalAmount\") as amount")
|
||||
->where('business_id', $business_id)
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->groupBy('date')
|
||||
->groupBy(DB::raw("TO_CHAR(created_at, '$dateFormatSQL')"))
|
||||
->orderBy('date')
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
@@ -131,7 +131,7 @@ public function dashboard()
|
||||
$purchase_data = Purchase::selectRaw("TO_CHAR(created_at, '$dateFormatSQL') as date, SUM(\"totalAmount\") as amount")
|
||||
->where('business_id', $business_id)
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->groupBy('date')
|
||||
->groupBy(DB::raw("TO_CHAR(created_at, '$dateFormatSQL')"))
|
||||
->orderBy('date')
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
|
||||
@@ -84,6 +84,17 @@ public function dueCollect()
|
||||
{
|
||||
return $this->hasOne(DueCollect::class);
|
||||
}
|
||||
public function dueForBranch($branchId = null)
|
||||
{
|
||||
$query = $this->type === 'Supplier' ? $this->purchases_dues() : $this->sales_dues();
|
||||
|
||||
if ($branchId) {
|
||||
$query->where('branch_id', $branchId);
|
||||
}
|
||||
|
||||
return $query->sum('dueAmount');
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user