<?php

namespace App\Support;

class SalePaymentStatus
{
    public const OPEN = 'open';

    public const PARTIAL = 'partial';

    public const PAID = 'paid';

    /**
     * @return list<string>
     */
    public static function values(): array
    {
        return [
            self::OPEN,
            self::PARTIAL,
            self::PAID,
        ];
    }

    public static function resolve(float $netAmount, float $paidAmount): string
    {
        if ($paidAmount <= 0) {
            return self::OPEN;
        }

        if ($paidAmount + 0.001 < $netAmount) {
            return self::PARTIAL;
        }

        return self::PAID;
    }
}
