feat(client): add financial reports and ledger management

- Add trial balance and general ledger pages to client resource with interactive tables
- Implement sales and expenses relation managers for client-specific transactions
- Enhance transaction handling with proper tax and withholding calculations
- Add date casting to Transaction model and define client relationships
- Configure super admin role bypass in AppServiceProvider
- Update Filament components and fix JavaScript formatting issues
This commit is contained in:
Jp
2026-02-09 16:20:55 +08:00
parent 91eb1fbe63
commit 207f4c1609
43 changed files with 3412 additions and 2967 deletions

View File

@@ -47,6 +47,16 @@ class Account extends Model
return $this->hasMany(Balance::class);
}
public function latestBalance(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Balance::class)->latestOfMany();
}
public function ledgers(): HasMany
{
return $this->hasMany(Ledger::class);
}
public function getCurrentBalanceAttribute()
{
if ($this->balances()->exists()) {

View File

@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
#[ObservedBy([ClientObserver::class])]
class Client extends Model
@@ -62,4 +63,14 @@ class Client extends Model
{
return $this->hasMany(Transmittal::class);
}
public function sales(): HasManyThrough
{
return $this->hasManyThrough(Sale::class, Branch::class);
}
public function expenses(): HasManyThrough
{
return $this->hasManyThrough(Expense::class, Branch::class);
}
}

View File

@@ -7,7 +7,7 @@ use App\Traits\HasUser;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Journal extends Model
{
@@ -17,9 +17,9 @@ class Journal extends Model
protected $casts = ['happened_on' => 'date'];
public function ledger(): HasOne
public function ledgers(): HasMany
{
return $this->hasOne(Ledger::class);
return $this->hasMany(Ledger::class);
}
public function scopeDateCreatedFilter(Builder $query, $date) : Builder

View File

@@ -15,6 +15,10 @@ class Transaction extends Model
protected $guarded = [];
protected $casts = [
'happened_on' => 'date',
];
public function transactionable(): MorphTo
{
return $this->morphTo();