AdjustmentStatus::class, 'category' => AdjustmentCategory::class, 'type' => AdjustmentType::class, 'recoverable' => 'boolean', 'rate' => RateCast::class, 'computation' => AdjustmentComputation::class, 'scope' => AdjustmentScope::class, 'start_date' => 'datetime', 'end_date' => 'datetime', ]; public function account(): BelongsTo { return $this->belongsTo(Account::class, 'account_id'); } public function offerings(): MorphToMany { return $this->morphedByMany(Offering::class, 'adjustmentable', 'adjustmentables'); } public function isSalesTax(): bool { return $this->category->isTax() && $this->type->isSales(); } public function isNonRecoverablePurchaseTax(): bool { return $this->category->isTax() && $this->type->isPurchase() && $this->recoverable === false; } public function isRecoverablePurchaseTax(): bool { return $this->category->isTax() && $this->type->isPurchase() && $this->recoverable === true; } public function isSalesDiscount(): bool { return $this->category->isDiscount() && $this->type->isSales(); } public function isPurchaseDiscount(): bool { return $this->category->isDiscount() && $this->type->isPurchase(); } public function calculateStatus(): AdjustmentStatus { if ($this->status === AdjustmentStatus::Archived) { return AdjustmentStatus::Archived; } if ($this->start_date?->isFuture()) { return AdjustmentStatus::Upcoming; } if ($this->end_date?->isPast()) { return AdjustmentStatus::Expired; } return AdjustmentStatus::Active; } protected static function newFactory(): Factory { return AdjustmentFactory::new(); } }