<?php

declare(strict_types=1);

/**
 * 本文件属于 DBErp 进销存系统。
 *
 * 版权所有 © 2026 北京珑大钜商科技有限公司。保留所有权利。
 *
 * 未经官方授权，不得删除、篡改或隐藏本文件中的版权声明、产品标识与来源信息。
 * 商业授权、官方更新与技术支持服务，请以珑大官方支持中心记录为准。
 *
 * @link https://support.loongdom.cn
 * @see  https://www.dberp.com.cn
 */

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');
    }
}