'decimal:2', 'actual_amount' => 'decimal:2', ]; // Relationships public function budget(): BelongsTo { return $this->belongsTo(Budget::class); } public function chartOfAccount(): BelongsTo { return $this->belongsTo(ChartOfAccount::class); } public function transactions(): HasMany { return $this->hasMany(Transaction::class); } // Helper methods public function getVarianceAttribute(): float { return $this->actual_amount - $this->budgeted_amount; } public function getVariancePercentageAttribute(): float { if ($this->budgeted_amount == 0) { return 0; } return ($this->variance / $this->budgeted_amount) * 100; } public function getRemainingBudgetAttribute(): float { return $this->budgeted_amount - $this->actual_amount; } public function isOverBudget(): bool { return $this->actual_amount > $this->budgeted_amount; } public function getUtilizationPercentageAttribute(): float { if ($this->budgeted_amount == 0) { return 0; } return ($this->actual_amount / $this->budgeted_amount) * 100; } }