<?php



namespace Daniv04\HaciendaPackage\Models;


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


class Receipt extends Model
{

    use HasFactory;

     /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'receipts';

    protected $fillable = [
        'receipt_type',
        'ui_key', 
        'consecutive_number',
        'emission_date',
        'sent_to_hacienda_at',
        'receipt_status',
        'signed_xml',
        'hacienda_status',

        'sell_condition',
        'total_amount', 
        'tax_amount',
        'total_discount',
        'total_voucher',
        'currency',
        'exchange_rate',

        'emissor_name',
        'emissor_number',
        'emissor_type_identification',
        'receiver_name',
        'receiver_number',
        'receiver_type_identification',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'emission_date' => 'datetime',
        'sent_to_hacienda_at' => 'datetime',
    ];

    public function payload()
    {
        return $this->hasOne(ReceiptPayload::class, 'receipt_id');
    }

    public function haciendaResponse()
    {
        return $this->hasOne(HaciendaResponse::class, 'receipt_id');
    }

    
}