using Jiaowu.Api.Domain.Academic;

namespace Jiaowu.Api.Infrastructure.Graduation;

public static class GraduationAuditRules
{
    public static GraduationAuditConclusion Evaluate(
        bool hasPublishedPlan,
        StudentStatus studentStatus,
        decimal requiredCredits,
        decimal earnedCredits,
        int requiredCourseCount,
        int passedRequiredCourseCount,
        int failedCourseCount)
    {
        if (!hasPublishedPlan || studentStatus != StudentStatus.Active)
            return GraduationAuditConclusion.Ineligible;
        if (earnedCredits < requiredCredits ||
            passedRequiredCourseCount < requiredCourseCount ||
            failedCourseCount > 0)
            return GraduationAuditConclusion.Ineligible;
        return GraduationAuditConclusion.Eligible;
    }
}
