<?php

namespace App\Models\Finance;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class CustomerSettlement extends Model
{
    use SoftDeletes;

    protected $table = 'customer_settlements';

    protected $fillable = [
        'tenant_id', 'period', 'customer', 'total_sales', 'commission',
        'expense', 'net_amount', 'status', 'settled_date', 'memo',
    ];

    protected $casts = [
        'total_sales' => 'integer',
        'commission' => 'integer',
        'expense' => 'integer',
        'net_amount' => 'integer',
        'settled_date' => 'date',
    ];

    public function scopeForTenant($query, $tenantId)
    {
        return $query->where('tenant_id', $tenantId);
    }
}
