*/ use HasFactory; /** * Get the period that owns the service entry. * * @return BelongsTo */ public function reportPeriod(): BelongsTo { return $this->belongsTo(ReportPeriod::class); } /** * Get the service definition for the entry. * * @return BelongsTo */ public function serviceCatalog(): BelongsTo { return $this->belongsTo(ServiceCatalog::class); } /** * Get the provider department. * * @return BelongsTo */ public function providerDepartment(): BelongsTo { return $this->belongsTo(Department::class, 'provider_department_id'); } /** * Get the recipient department. * * @return BelongsTo */ public function recipientDepartment(): BelongsTo { return $this->belongsTo(Department::class, 'recipient_department_id'); } /** * Get the total amount for the entry. */ public function totalAmount(): float { return round((float) $this->quantity * (float) $this->unit_price, 2); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'quantity' => 'decimal:2', 'unit_price' => 'decimal:2', ]; } }