using LCU.Library.Internal.IncentiveApiModels.Entities; using LCU.Library.Internal.IncentiveApiModels.Common; namespace LCU.API.Internal.Operations.IncentiveApi.Models.Payout; public class DepartmentPayout: IViewTransformable { public DepartmentPayout(AppUser employee, UserDepartment assignment, MonthRange monthRange, IReadOnlyCollection departmentRules, IReadOnlyCollection personalRules) { Employee = employee; MonthRange = monthRange; DepartmentRules = departmentRules; PersonalRules = personalRules; Department = assignment; EligibleCommissions = new List(); EligiblePayouts = PayoutProfile.FindForRole(assignment.Role); PersonalActivity = new List(); PersonalGoals = new List(); DepartmentActivity = new List(); DepartmentGoals = new List(); CommissionPayouts = new List(); GoalPayouts = new List(); } public AppUser Employee { get; } public MonthRange MonthRange { get; } public UserDepartment Department { get; } public IEnumerable EligibleCommissions { get; set; } public IEnumerable EligiblePayouts { get; } public IEnumerable PersonalActivity { get; set; } public IEnumerable PersonalGoals { get; set; } public IEnumerable DepartmentActivity { get; set; } public IEnumerable DepartmentGoals { get; set; } public IEnumerable CommissionPayouts { get; set; } public IEnumerable GoalPayouts { get; set; } public IReadOnlyCollection DepartmentRules { get; } public IReadOnlyCollection PersonalRules { get; } public bool HasEligibleIncentives() { return HasEligibleCommissions() || HasEligibleGoalPayouts(); } public DepartmentPayout TransformForView() { foreach(var activity in DepartmentActivity) { activity?.TransformForView(); } foreach(var activity in PersonalActivity) { activity?.TransformForView(); } return this; } public bool HasEligibleActivity() { return PersonalActivity != null && PersonalActivity.Any() || DepartmentActivity != null && DepartmentActivity.Any(); } public bool HasEligibleCommissions() { return EligibleCommissions != null && EligibleCommissions.Any(); } public bool HasEligibleGoalPayouts() { return EligiblePayouts != null && EligiblePayouts.Any(); } }