20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
100
app/Models/DatevExportLine.php
Normal file
100
app/Models/DatevExportLine.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DatevExportLine extends Model
|
||||
{
|
||||
protected $table = 'datev_export_lines';
|
||||
|
||||
// Source Types
|
||||
const SOURCE_INVOICE = 'invoice';
|
||||
|
||||
const SOURCE_CREDIT = 'credit';
|
||||
|
||||
const SOURCE_CANCELLATION = 'cancellation';
|
||||
|
||||
protected $fillable = [
|
||||
'datev_export_id',
|
||||
'source_type',
|
||||
'source_id',
|
||||
'line_number',
|
||||
'amount_gross',
|
||||
'soll_haben',
|
||||
'konto',
|
||||
'gegenkonto',
|
||||
'bu_schluessel',
|
||||
'belegdatum',
|
||||
'belegfeld1',
|
||||
'buchungstext',
|
||||
'eu_ustid',
|
||||
'eu_land',
|
||||
'row_csv',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'amount_gross' => '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') : '-';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue