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

@@ -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.
*