46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
namespace UtopiaCanteenSystem.Services;
|
|
|
|
/// <summary>
|
|
/// Maps HRMS <c>employee_rfid_tag.grade_type</c> to <c>menu_item.item_for</c>.
|
|
/// Menu rows only use MANAGEMENT / NON_MANAGEMENT; other grades must map to one of those.
|
|
/// Contractual and MTO/TE/Intern use the management menu; Unassigned uses non-management.
|
|
/// </summary>
|
|
public static class HrmsMenuItemForMapping
|
|
{
|
|
/// <summary>
|
|
/// Returns MANAGEMENT or NON_MANAGEMENT for menu queries. Never returns empty.
|
|
/// </summary>
|
|
public static string FromGradeType(string? gradeType)
|
|
{
|
|
var compact = ToCompactAlphaNum(gradeType);
|
|
if (string.IsNullOrEmpty(compact))
|
|
return "NON_MANAGEMENT";
|
|
|
|
if (compact == "management")
|
|
return "MANAGEMENT";
|
|
|
|
if (compact == "nonmanagement")
|
|
return "NON_MANAGEMENT";
|
|
|
|
if (compact == "contractual" || compact == "mtoteintern")
|
|
return "MANAGEMENT";
|
|
|
|
if (compact == "unassigned")
|
|
return "NON_MANAGEMENT";
|
|
|
|
if (compact.StartsWith("non", StringComparison.Ordinal) && compact.Contains("management", StringComparison.Ordinal))
|
|
return "NON_MANAGEMENT";
|
|
|
|
// Any other label (e.g. future grade codes) — use non-management menu so items still resolve.
|
|
return "NON_MANAGEMENT";
|
|
}
|
|
|
|
private static string ToCompactAlphaNum(string? s)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(s))
|
|
return string.Empty;
|
|
var chars = s.Trim().ToLowerInvariant().Where(char.IsLetterOrDigit).ToArray();
|
|
return new string(chars);
|
|
}
|
|
}
|