<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class CashRegister extends Model
{
    use HasUlids, SoftDeletes;

    protected $fillable = [
        'user_id', 'store_id', 'local_id', 'opening_balance', 'closing_balance',
        'expected_balance', 'difference', 'total_sales', 'total_returns',
        'total_expenses', 'status', 'notes', 'opened_at', 'closed_at',
        'device_id', 'sync_version', 'is_deleted',
    ];

    protected $casts = [
        'opening_balance' => 'float',
        'closing_balance' => 'float',
        'expected_balance' => 'float',
        'difference' => 'float',
        'total_sales' => 'float',
        'total_returns' => 'float',
        'total_expenses' => 'float',
        'is_deleted' => 'boolean',
        'sync_version' => 'integer',
        'opened_at' => 'datetime',
        'closed_at' => 'datetime',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
