<?php

declare(strict_types=1);

namespace App\Models;

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

class DberpReceiptPaymentQuery extends Model
{
    public $timestamps = false;

    protected $table = 'dberp_receipt_payment_queries';

    protected $primaryKey = 'row_id';

    public $incrementing = false;

    protected $keyType = 'int';

    protected function casts(): array
    {
        return [
            'row_id' => 'integer',
            'business_time' => 'datetime',
            'amount' => 'decimal:4',
            'customer_id' => 'integer',
            'supplier_id' => 'integer',
            'sales_order_id' => 'integer',
            'purchase_order_id' => 'integer',
            'payment_method_item_id' => 'integer',
            'handler_employee_id' => 'integer',
            'effective_at' => 'datetime',
            'voided_at' => 'datetime',
        ];
    }

    public function customer(): BelongsTo
    {
        return $this->belongsTo(DberpCustomer::class, 'customer_id');
    }

    public function supplier(): BelongsTo
    {
        return $this->belongsTo(DberpSupplier::class, 'supplier_id');
    }

    public function handlerEmployee(): BelongsTo
    {
        return $this->belongsTo(DberpEmployee::class, 'handler_employee_id');
    }

    public function paymentMethodItem(): BelongsTo
    {
        return $this->belongsTo(DberpDictionaryItem::class, 'payment_method_item_id');
    }

    public function salesOrder(): BelongsTo
    {
        return $this->belongsTo(DberpSalesOrder::class, 'sales_order_id');
    }

    public function purchaseOrder(): BelongsTo
    {
        return $this->belongsTo(DberpPurchaseOrder::class, 'purchase_order_id');
    }
}