using Jiaowu.Api.Domain.Academic;

namespace Jiaowu.Api.Infrastructure.Graduation;

public static class GraduationClearanceRules
{
    public static bool CanClose(
        IEnumerable<(bool IsRequired, GraduationClearanceRecordStatus Status)> records)
    {
        var snapshot = records.ToArray();
        return snapshot.Length > 0 && snapshot
            .Where(x => x.IsRequired)
            .All(x => x.Status is GraduationClearanceRecordStatus.Completed or
                GraduationClearanceRecordStatus.Waived);
    }
}
