'decimal:2', 'belegdatum' => 'date', ]; /* |-------------------------------------------------------------------------- | Relationships |-------------------------------------------------------------------------- */ public function datev_export() { return $this->belongsTo(DatevExport::class, 'datev_export_id'); } /* |-------------------------------------------------------------------------- | Scopes |-------------------------------------------------------------------------- */ public function scopeInvoices($query) { return $query->where('source_type', self::SOURCE_INVOICE); } public function scopeCredits($query) { return $query->where('source_type', self::SOURCE_CREDIT); } public function scopeCancellations($query) { return $query->where('source_type', self::SOURCE_CANCELLATION); } /* |-------------------------------------------------------------------------- | Accessors |-------------------------------------------------------------------------- */ public function getSourceTypeLabelAttribute(): string { return match ($this->source_type) { self::SOURCE_INVOICE => 'Rechnung', self::SOURCE_CREDIT => 'Gutschrift', self::SOURCE_CANCELLATION => 'Storno', default => $this->source_type, }; } public function getFormattedAmountAttribute(): string { $prefix = $this->soll_haben === 'S' ? '-' : ''; return $prefix.number_format(abs($this->amount_gross), 2, ',', '.').' €'; } public function getFormattedBelegdatumAttribute(): string { return $this->belegdatum ? $this->belegdatum->format('d.m.Y') : '-'; } }