Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
78.57% covered (warning)
78.57%
11 / 14
40.00% covered (danger)
40.00%
2 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
MonthlySettlement
78.57% covered (warning)
78.57%
11 / 14
40.00% covered (danger)
40.00%
2 / 5
5.25
0.00% covered (danger)
0.00%
0 / 1
 casts
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
 tenant
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 store
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 items
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 commissions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Models;
4
5use App\Enums\SettlementStatus;
6use Illuminate\Database\Eloquent\Factories\HasFactory;
7use Illuminate\Database\Eloquent\Model;
8use Illuminate\Database\Eloquent\Relations\BelongsTo;
9use Illuminate\Database\Eloquent\Relations\HasMany;
10
11class MonthlySettlement extends Model
12{
13    use HasFactory;
14
15    protected $fillable = [
16        'tenant_id', 'store_id', 'period_year', 'period_month', 'period_start', 'period_end',
17        'status', 'gross_amount', 'adjustments_amount', 'net_amount', 'generated_by', 'closed_by',
18        'closed_at', 'metadata',
19    ];
20
21    protected function casts(): array
22    {
23        return [
24            'period_start' => 'date',
25            'period_end' => 'date',
26            'gross_amount' => 'decimal:2',
27            'adjustments_amount' => 'decimal:2',
28            'net_amount' => 'decimal:2',
29            'status' => SettlementStatus::class,
30            'closed_at' => 'datetime',
31            'metadata' => 'array',
32        ];
33    }
34
35    public function tenant(): BelongsTo { return $this->belongsTo(Tenant::class); }
36    public function store(): BelongsTo { return $this->belongsTo(Store::class); }
37    public function items(): HasMany { return $this->hasMany(SettlementItem::class, 'settlement_id'); }
38    public function commissions(): HasMany { return $this->hasMany(Commission::class, 'settlement_id'); }
39}