<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class CustomerLedgerEntry extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $casts = [
        'order_receipt_id' => 'integer',
        'order_id' => 'integer',
        'user_id' => 'integer',
        'debit' => 'float',
        'credit' => 'float',
        'balance_after' => 'float',
        'entry_date' => 'datetime',
        'voided_at' => 'datetime',
    ];

    public function order()
    {
        return $this->belongsTo(Order::class);
    }

    public function receipt()
    {
        return $this->belongsTo(OrderReceipt::class, 'order_receipt_id');
    }

    public function customer()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}
