<?php

namespace App\Models;

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

class PurchaseItem extends Model
{
    use HasUlids;

    protected $fillable = [
        'purchase_id', 'product_id', 'local_product_id', 'product_name',
        'product_barcode', 'unit_cost', 'quantity',
        'tax_percent', 'tax_id', 'tax_amount', // [INTEGRATION]
        'subtotal',
    ];

    protected $casts = [
        'unit_cost' => 'float',
        'quantity' => 'float',
        'tax_percent' => 'float',
        'tax_amount' => 'float', // [INTEGRATION]
        'subtotal' => 'float',
    ];

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