74 lines
2.6 KiB
C#
74 lines
2.6 KiB
C#
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
|
using LCU.Library.Internal.IncentiveApiModels.Common;
|
|
|
|
namespace LCU.API.Internal.Operations.IncentiveApi.Models.Payout;
|
|
|
|
public class DepartmentPayout: IViewTransformable<DepartmentPayout>
|
|
{
|
|
public DepartmentPayout(AppUser employee, UserDepartment assignment, MonthRange monthRange, IReadOnlyCollection<IPayoutRule> departmentRules, IReadOnlyCollection<IPayoutRule> personalRules)
|
|
{
|
|
Employee = employee;
|
|
MonthRange = monthRange;
|
|
DepartmentRules = departmentRules;
|
|
PersonalRules = personalRules;
|
|
Department = assignment;
|
|
|
|
EligibleCommissions = new List<Commission>();
|
|
EligiblePayouts = PayoutProfile.FindForRole(assignment.Role);
|
|
PersonalActivity = new List<Activity>();
|
|
PersonalGoals = new List<Goal>();
|
|
DepartmentActivity = new List<Activity>();
|
|
DepartmentGoals = new List<Goal>();
|
|
CommissionPayouts = new List<PayoutLineItem>();
|
|
GoalPayouts = new List<PayoutLineItem>();
|
|
}
|
|
|
|
public AppUser Employee { get; }
|
|
public MonthRange MonthRange { get; }
|
|
public UserDepartment Department { get; }
|
|
public IEnumerable<Commission> EligibleCommissions { get; set; }
|
|
public IEnumerable<PayoutProfile> EligiblePayouts { get; }
|
|
public IEnumerable<Activity> PersonalActivity { get; set; }
|
|
public IEnumerable<Goal> PersonalGoals { get; set; }
|
|
public IEnumerable<Activity> DepartmentActivity { get; set; }
|
|
public IEnumerable<Goal> DepartmentGoals { get; set; }
|
|
public IEnumerable<PayoutLineItem> CommissionPayouts { get; set; }
|
|
public IEnumerable<PayoutLineItem> GoalPayouts { get; set; }
|
|
public IReadOnlyCollection<IPayoutRule> DepartmentRules { get; }
|
|
public IReadOnlyCollection<IPayoutRule> 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();
|
|
}
|
|
}
|