<?php

namespace App\Models\Barobill;

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

/**
 * 카드 거래 금액 수정 이력 모델
 */
class CardTransactionAmountLog extends Model
{
    protected $table = 'barobill_card_transaction_amount_logs';

    public $timestamps = false;

    protected $fillable = [
        'card_transaction_id',
        'original_unique_key',
        'before_supply_amount',
        'before_tax',
        'after_supply_amount',
        'after_tax',
        'modified_by',
        'modified_by_name',
        'ip_address',
    ];

    protected $casts = [
        'before_supply_amount' => 'decimal:2',
        'before_tax' => 'decimal:2',
        'after_supply_amount' => 'decimal:2',
        'after_tax' => 'decimal:2',
        'created_at' => 'datetime',
    ];

    /**
     * 카드 거래 관계
     */
    public function cardTransaction(): BelongsTo
    {
        return $this->belongsTo(CardTransaction::class, 'card_transaction_id');
    }
}
