<?php

namespace App\Models\Transaction;

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

class Invoice extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'company_id',
        'order_id',
        'machine_id',
        'flow_id',
        'invoice_no',
        'amount',
        'carrier_id',
        'invoice_date',
        'machine_time',
        'random_number',
        'love_code',
        'rtn_code',
        'rtn_msg',
        'metadata',
    ];

    protected $casts = [
        'total_amount' => 'decimal:2',
        'tax_amount' => 'decimal:2',
        'machine_time' => 'datetime',
        'metadata' => 'array',
    ];

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

    public function machine()
    {
        return $this->belongsTo(\App\Models\Machine\Machine::class);
    }
}
