<?php
declare(strict_types=1);

namespace App\Modules\Sales\Models;

use App\Core\Model;
use App\Core\App;

class SaleRefund extends Model
{
    protected static string $table = 'sale_refunds';
    protected static string $primaryKey = 'id';
    protected static bool $timestamps = false;
    protected static bool $softDelete = false;
    protected static bool $autoTrackAuthor = false;

    protected static array $fillable = [
        'sale_id',
        'refund_number',
        'refund_amount',
        'reason',
        'return_to_stock',
        'warehouse_id',
        'payment_id',
        'refunded_by',
        'refund_date',
        'notes',
        'created_by',
    ];

    public static function getForSale(int $saleId): array
    {
        return static::query()
            ->where('sale_id', '=', $saleId)
            ->orderBy('created_at', 'DESC')
            ->get();
    }
}
