<?php

namespace App\Modules\Sales\Services;

use App\Modules\Sales\Support\SalesOrderLifecycleStatus;

final class SalesOrderLifecycleRules
{
    public static function allowsAllocation(SalesOrderLifecycleStatus $s): bool
    {
        return in_array($s, [
            SalesOrderLifecycleStatus::Confirmed,
            SalesOrderLifecycleStatus::PartiallyAllocated,
            SalesOrderLifecycleStatus::Allocated,
            SalesOrderLifecycleStatus::PartiallyFulfilled,
        ], true);
    }

    public static function allowsFulfillment(SalesOrderLifecycleStatus $s): bool
    {
        return in_array($s, [
            SalesOrderLifecycleStatus::PartiallyAllocated,
            SalesOrderLifecycleStatus::Allocated,
            SalesOrderLifecycleStatus::PartiallyFulfilled,
        ], true);
    }

    public static function allowsConfirm(SalesOrderLifecycleStatus $s): bool
    {
        return $s === SalesOrderLifecycleStatus::Draft;
    }

    public static function allowsCancel(SalesOrderLifecycleStatus $s): bool
    {
        return ! in_array($s, [
            SalesOrderLifecycleStatus::Cancelled,
            SalesOrderLifecycleStatus::Fulfilled,
        ], true);
    }
}
