Adding
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class AccountingSummary
|
||||
{
|
||||
public IReadOnlyCollection<DepartmentLineItem> DepartmentPayouts { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
public DateTime PayoutPeriod { get; }
|
||||
|
||||
public AccountingSummary(DateTime payoutPeriod)
|
||||
{
|
||||
PayoutPeriod = payoutPeriod;
|
||||
DepartmentPayouts = new List<DepartmentLineItem>();
|
||||
Total = 0;
|
||||
}
|
||||
|
||||
public void Apply(List<PayoutLineItem> allNewPayouts, Dictionary<int, string> deptNames)
|
||||
{
|
||||
var departmentSet = new Dictionary<int, DepartmentLineItem>();
|
||||
foreach (var payoutLineItem in allNewPayouts)
|
||||
{
|
||||
if (!departmentSet.ContainsKey(payoutLineItem.DepartmentId))
|
||||
{
|
||||
departmentSet.Add(payoutLineItem.DepartmentId,
|
||||
new DepartmentLineItem(payoutLineItem.DepartmentId, deptNames[payoutLineItem.DepartmentId],
|
||||
PayoutPeriod));
|
||||
}
|
||||
|
||||
departmentSet[payoutLineItem.DepartmentId].Apply(payoutLineItem);
|
||||
Total += payoutLineItem.PayoutTotal;
|
||||
}
|
||||
|
||||
foreach (var accountingSummaryLineItem in departmentSet.Values)
|
||||
{
|
||||
accountingSummaryLineItem.CalculatePercentage(Total);
|
||||
}
|
||||
|
||||
DepartmentPayouts = departmentSet.Values;
|
||||
}
|
||||
}
|
||||
}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Activity : Auditable, IViewTransformable<Activity>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid AppUserId { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public Product Product { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ActivityType Type { get; set; } = ActivityType.Sale;
|
||||
|
||||
[Required]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public SystemType SourceSystem { get; set; }
|
||||
|
||||
public string? SourceId { get; set; }
|
||||
public DateTime SourceCreated { get; set; }
|
||||
|
||||
[Required]
|
||||
public ActivityDetail Detail { get; set; }
|
||||
|
||||
public List<ActivityMetaData> MetaData { get; set; }
|
||||
|
||||
[Required]
|
||||
public int DepartmentId { get; set; }
|
||||
|
||||
[Required]
|
||||
public string EmployeeId { get; set; }
|
||||
|
||||
public string? EmployeeEmail { get; set; }
|
||||
|
||||
public int MatchingActivityId { get; set; }
|
||||
|
||||
public int MatchingDpAccessoryActivityId { get; set; }
|
||||
|
||||
public DateTime Accepted { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ActivityState State { get; set; } = ActivityState.Created;
|
||||
|
||||
public virtual IList<ActivityPayoutLineItem> ActivityPayouts { get; set; }
|
||||
|
||||
public int MatchingGapInsuranceActivityId { get; set; }
|
||||
|
||||
public static Activity CopyActivityForTransfer(
|
||||
Activity activity,
|
||||
ActivityTransferAction activityTransferAction,
|
||||
string employeeEmail
|
||||
)
|
||||
{
|
||||
return new Activity
|
||||
{
|
||||
Accepted = activity.Accepted,
|
||||
DepartmentId = activityTransferAction.NewActivityDepartmentId,
|
||||
Detail = new ActivityDetail
|
||||
{
|
||||
AccountBalance = activity.Detail.AccountBalance,
|
||||
AccountNewBalance = activity.Detail.AccountNewBalance,
|
||||
AccountNumber = activity.Detail.AccountNumber,
|
||||
AccountStatus = activity.Detail.AccountStatus,
|
||||
AgreementNumber = activity.Detail.AgreementNumber,
|
||||
BranchOrgName = activity.Detail.BranchOrgName,
|
||||
BranchOrgNbr = activity.Detail.BranchOrgNbr,
|
||||
DnaPersonNbr = activity.Detail.DnaPersonNbr,
|
||||
DebtProtectionAddDate = activity.Detail.DebtProtectionAddDate,
|
||||
DebtProtectionRemoveDate = activity.Detail.DebtProtectionRemoveDate,
|
||||
GapInsuranceAddDate = activity.Detail.GapInsuranceAddDate,
|
||||
GapInsuranceRemoveDate = activity.Detail.GapInsuranceRemoveDate,
|
||||
IsDebtProtectionEligible = activity.Detail.IsDebtProtectionEligible,
|
||||
IsGapInsuranceEligible = activity.Detail.IsGapInsuranceEligible,
|
||||
MemberName = activity.Detail.MemberName,
|
||||
StationName = activity.Detail.StationName,
|
||||
SubAccountNumber = activity.Detail.SubAccountNumber,
|
||||
SubjectOrgNbr = activity.Detail.SubjectOrgNbr,
|
||||
SubjectPersonNbr = activity.Detail.SubjectPersonNbr,
|
||||
},
|
||||
EmployeeEmail = employeeEmail,
|
||||
EmployeeId = activityTransferAction.NewActivityEmployeeId,
|
||||
MatchingActivityId = activity.MatchingActivityId,
|
||||
MatchingDpAccessoryActivityId = activity.MatchingDpAccessoryActivityId,
|
||||
MatchingGapInsuranceActivityId = activity.MatchingGapInsuranceActivityId,
|
||||
MetaData = activity.MetaData,
|
||||
Product = activity.Product,
|
||||
SourceCreated = activity.SourceCreated,
|
||||
SourceId = activity.SourceId,
|
||||
SourceSystem = activity.SourceSystem,
|
||||
State = activityTransferAction.ActivityStateBeforeTransfer,
|
||||
Type = activity.Type
|
||||
};
|
||||
}
|
||||
|
||||
public static Activity CopyActivityForDpAccessory(Activity activity)
|
||||
{
|
||||
return new Activity
|
||||
{
|
||||
Accepted = activity.Detail.DebtProtectionAddDate ?? activity.Accepted,
|
||||
DepartmentId = activity.DepartmentId,
|
||||
Detail = new ActivityDetail
|
||||
{
|
||||
AccountBalance = activity.Detail.AccountBalance,
|
||||
AccountNewBalance = activity.Detail.AccountNewBalance,
|
||||
AccountNumber = activity.Detail.AccountNumber,
|
||||
AccountStatus = activity.Detail.AccountStatus,
|
||||
AgreementNumber = activity.Detail.AgreementNumber,
|
||||
BranchOrgName = activity.Detail.BranchOrgName,
|
||||
BranchOrgNbr = activity.Detail.BranchOrgNbr,
|
||||
DnaPersonNbr = activity.Detail.DnaPersonNbr,
|
||||
DebtProtectionAddDate = activity.Detail.DebtProtectionAddDate,
|
||||
DebtProtectionRemoveDate = activity.Detail.DebtProtectionRemoveDate,
|
||||
GapInsuranceAddDate = activity.Detail.GapInsuranceAddDate,
|
||||
GapInsuranceRemoveDate = activity.Detail.GapInsuranceRemoveDate,
|
||||
IsDebtProtectionEligible = activity.Detail.IsDebtProtectionEligible,
|
||||
IsGapInsuranceEligible = activity.Detail.IsGapInsuranceEligible,
|
||||
MemberName = activity.Detail.MemberName,
|
||||
StationName = activity.Detail.StationName,
|
||||
SubAccountNumber = activity.Detail.SubAccountNumber,
|
||||
SubjectOrgNbr = activity.Detail.SubjectOrgNbr,
|
||||
SubjectPersonNbr = activity.Detail.SubjectPersonNbr
|
||||
},
|
||||
EmployeeEmail = activity.EmployeeEmail,
|
||||
EmployeeId = activity.EmployeeId,
|
||||
MatchingActivityId = activity.MatchingActivityId,
|
||||
MatchingDpAccessoryActivityId = activity.Id,
|
||||
MatchingGapInsuranceActivityId = activity.MatchingGapInsuranceActivityId,
|
||||
MetaData = activity.MetaData,
|
||||
Product = Product.DebtProtection,
|
||||
SourceCreated = activity.Detail.DebtProtectionAddDate ?? activity.SourceCreated,
|
||||
SourceId = activity.SourceId,
|
||||
SourceSystem = activity.SourceSystem,
|
||||
State = ActivityState.Created,
|
||||
Type = activity.Type
|
||||
};
|
||||
}
|
||||
|
||||
public bool CanAutoDecision()
|
||||
{
|
||||
return State != ActivityState.Rejected;
|
||||
}
|
||||
|
||||
public double CalculatedValueTowardsGoal(Product countsForProduct)
|
||||
{
|
||||
if (Type == ActivityType.Other
|
||||
|| State != ActivityState.Accepted && State != ActivityState.PendingTransfer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var details = ProductDetail.DetailsForProduct(Product);
|
||||
if (countsForProduct == Product.DebtProtectionEligibleLoan && Detail != null)
|
||||
{
|
||||
return Detail.IsDebtProtectionEligible && Detail.DebtProtectionAddDate != null && Detail.DebtProtectionRemoveDate == null ? 1 : 0;
|
||||
}
|
||||
|
||||
if (countsForProduct == Product && details.ValueType == ProductValue.Numeric)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (countsForProduct == Product && Detail is { AccountBalance: { } })
|
||||
{
|
||||
return Detail.AccountBalance.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int CalculatedValueTowardsOther(Product countsForProduct)
|
||||
{
|
||||
if (Detail != null && countsForProduct == Product.DebtProtectionEligibleLoan && Detail.IsDebtProtectionEligible)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int CalculatedValueTowardsGapInsurance() =>
|
||||
Detail?.IsGapInsuranceEligible ?? false ? 1 : 0;
|
||||
|
||||
public bool HasDpAccessory()
|
||||
{
|
||||
return Type == ActivityType.Sale
|
||||
&& Detail.IsDebtProtectionEligible
|
||||
&& (
|
||||
MatchingDpAccessoryActivityId != 0
|
||||
|| Detail.DebtProtectionAddDate?.Date != null
|
||||
|| Detail.DebtProtectionRemoveDate?.Date != null
|
||||
);
|
||||
}
|
||||
|
||||
public bool HasActiveGapAccessory()
|
||||
{
|
||||
return Type == ActivityType.Sale
|
||||
&& MatchingGapInsuranceActivityId != 0
|
||||
&& Detail.IsGapInsuranceEligible
|
||||
&& Detail.GapInsuranceAddDate != null
|
||||
&& Detail.GapInsuranceRemoveDate?.Date == null;
|
||||
}
|
||||
|
||||
public Activity TransformForView()
|
||||
{
|
||||
Detail?.TransformForView();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ActivityDetail : IViewTransformable<ActivityDetail>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? DnaPersonNbr { get; set; }
|
||||
public string? AccountNumber { get; set; }
|
||||
[UpdateAllowed]
|
||||
public string? SubAccountNumber { get; set; }
|
||||
[UpdateAllowed]
|
||||
public string? AccountStatus { get; set; }
|
||||
public string? AgreementNumber { get; set; }
|
||||
public string? SubjectPersonNbr { get; set; }
|
||||
public string? SubjectOrgNbr { get; set; }
|
||||
public string? MemberName { get; set; }
|
||||
[UpdateAllowed]
|
||||
public string? StationName { get; set; }
|
||||
public string? BranchOrgNbr { get; set; }
|
||||
public string? BranchOrgName { get; set; }
|
||||
public double? AccountBalance { get; set; }
|
||||
public double? AccountNewBalance { get; set; }
|
||||
public int ActivityRef { get; set; }
|
||||
[JsonIgnore]
|
||||
public Activity Activity { get; set; }
|
||||
[UpdateAllowed]
|
||||
public DateTime? DebtProtectionAddDate { get; set; }
|
||||
[UpdateAllowed]
|
||||
public DateTime? DebtProtectionRemoveDate { get; set; }
|
||||
public bool IsDebtProtectionEligible { get; set; }
|
||||
public bool IsGapInsuranceEligible { get; set; }
|
||||
public DateTime? GapInsuranceAddDate { get; set; }
|
||||
public DateTime? GapInsuranceRemoveDate { get; set; }
|
||||
|
||||
public ActivityDetail TransformForView()
|
||||
{
|
||||
if ((Activity?.Product == Product.CreditCard || Activity?.Product == Product.CreditCardBalanceTransfer)
|
||||
&& Activity?.Type == ActivityType.Referral)
|
||||
{
|
||||
AccountNumber = GetAccountNumber();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private string GetAccountNumber()
|
||||
{
|
||||
if (string.IsNullOrEmpty(AccountNumber) || AccountNumber.Length <= 4) return AccountNumber;
|
||||
|
||||
var lastDigits = AccountNumber.Substring(AccountNumber.Length - 4, 4);
|
||||
var maskDigits = new string('X', AccountNumber.Length - 4);
|
||||
return string.Concat(maskDigits, lastDigits);
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ActivityDetailUpdate : AuditCreate
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int ActivityDetailId { get; set; }
|
||||
public string Note { get; set; }
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ActivityMetaData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string MetaData { get; set; }
|
||||
[Required]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public MetaDataType MetaDataType { get; set; }
|
||||
public int ActivityRef { get; set; }
|
||||
[JsonIgnore]
|
||||
public Activity Activity { get; set; }
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ActivityPayoutLineItem
|
||||
{
|
||||
public int ActivityId { get; set; }
|
||||
public int PayoutLineItemId { get; set; }
|
||||
public virtual Activity Activity { get; set; }
|
||||
public virtual PayoutLineItem PayoutLineItem { get; set; }
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ActivityStateChange : AuditCreate
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int ActivityId { get; set; }
|
||||
[Required]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ActivityState State { get; set; }
|
||||
public DateTime? AcceptedDate { get; set; }
|
||||
public int ActivityMatchId { get; set; }
|
||||
public string? Note { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ActivityStateDetail
|
||||
{
|
||||
private ActivityStateDetail(ActivityState state)
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
|
||||
public ActivityState State { get; }
|
||||
|
||||
public static readonly ActivityStateDetail Created = new ActivityStateDetail(ActivityState.Created);
|
||||
public static readonly ActivityStateDetail Accepted = new ActivityStateDetail(ActivityState.Accepted);
|
||||
public static readonly ActivityStateDetail Rejected = new ActivityStateDetail(ActivityState.Rejected);
|
||||
public static readonly ActivityStateDetail Transferred = new ActivityStateDetail(ActivityState.Transferred);
|
||||
public static readonly ActivityStateDetail ManualReview = new ActivityStateDetail(ActivityState.ManualReview);
|
||||
public static readonly ActivityStateDetail PendingReferral = new ActivityStateDetail(ActivityState.PendingReferral);
|
||||
public static readonly ActivityStateDetail PendingTransfer = new ActivityStateDetail(ActivityState.PendingTransfer);
|
||||
|
||||
public static readonly List<ActivityStateDetail> ActivityStateDetails = new List<ActivityStateDetail>()
|
||||
{
|
||||
Created,
|
||||
Accepted,
|
||||
Rejected,
|
||||
Transferred,
|
||||
ManualReview,
|
||||
PendingReferral,
|
||||
PendingTransfer
|
||||
};
|
||||
|
||||
public static readonly List<ActivityStateDetail> ActivityStatesEligibleForTransfer = new List<ActivityStateDetail>()
|
||||
{
|
||||
Accepted,
|
||||
ManualReview,
|
||||
PendingReferral
|
||||
};
|
||||
|
||||
public static ActivityStateDetail DetailsForActivityState(ActivityState state)
|
||||
{
|
||||
return ActivityStateDetails.Find(x => x.State == state);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ActivityTransferAction : Auditable, IViewTransformable<ActivityTransferAction>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ActivityState ActivityStateBeforeTransfer { get; set; }
|
||||
public int RequestedActivityId { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ActivityTransferState State { get; set; }
|
||||
public int? NewActivityId { get; set; }
|
||||
public int NewActivityDepartmentId { get; set; }
|
||||
public string NewActivityEmployeeId { get; set; }
|
||||
public Guid NewAppUserId { get; set; }
|
||||
public string? RequestedDepartmentApprover { get; set; }
|
||||
public DateTime? RequestedDepartmentApproved { get; set; }
|
||||
public string? NewDepartmentApprover { get; set; }
|
||||
public DateTime? NewDepartmentApproved { get; set; }
|
||||
public Activity RequestedActivity { get; set; }
|
||||
public Activity NewActivity { get; set; }
|
||||
|
||||
public static bool IsEligibleForTransfer(ActivityState activityState)
|
||||
{
|
||||
return ActivityStateDetail.ActivityStatesEligibleForTransfer
|
||||
.Select(x => x.State).Contains(activityState);
|
||||
}
|
||||
|
||||
public ActivityTransferAction TransformForView()
|
||||
{
|
||||
RequestedActivity?.TransformForView();
|
||||
NewActivity?.TransformForView();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class AppUser : Auditable
|
||||
{
|
||||
public AppUser()
|
||||
{
|
||||
Departments = new List<UserDepartment>();
|
||||
Assignments = new List<UserAssignment>();
|
||||
Terminated = null;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string AdEmail { get; set; }
|
||||
public int PersonId { get; set; }
|
||||
public string EmployeeId { get; set; }
|
||||
public string HomeDepartment { get; set; }
|
||||
public string BaseRole { get; set; }
|
||||
public string? ManagerKey { get; set; }
|
||||
[Obsolete("Start referring to UserDepartment.Role when possible. 09/08/2021")]
|
||||
public Role Role { get; set; }
|
||||
public List<UserPermission> AdditionalPermissions { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public List<UserDepartment> Departments { get; set; }
|
||||
public List<UserAssignment> Assignments { get; set; }
|
||||
public DateTime? Terminated { get; set; }
|
||||
|
||||
public bool UserHasPermission(Permission perm)
|
||||
{
|
||||
var departments = ActiveDepartmentsForRange(new MonthRange());
|
||||
foreach (var userDepartment in departments)
|
||||
{
|
||||
if (userDepartment.Role.Permissions.Any(x => x.Code == perm.Code))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (AdditionalPermissions ?? new List<UserPermission>()).Any(x => x.Permission.Code == perm.Code);
|
||||
}
|
||||
|
||||
public bool UserHasPermission(string permissionCode)
|
||||
{
|
||||
var departments = ActiveDepartmentsForRange(new MonthRange());
|
||||
foreach (var userDepartment in departments)
|
||||
{
|
||||
if (userDepartment.Role.Permissions.Any(x => x.Code == permissionCode))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (AdditionalPermissions ?? new List<UserPermission>()).Any(x => x.Permission.Code == permissionCode);
|
||||
}
|
||||
|
||||
public IEnumerable<UserDepartment> ActiveDepartmentsForRange(MonthRange monthRange)
|
||||
{
|
||||
return Departments.Where(department => department.StartDate.Date <= monthRange.EndTime.Date &&
|
||||
(department.EndDate == null ||
|
||||
monthRange.StartTime.Date <= department.EndDate.Value.Date));
|
||||
}
|
||||
|
||||
public UserDepartment FindDepartmentForRole(Role role)
|
||||
{
|
||||
var departments = ActiveDepartmentsForRange(new MonthRange());
|
||||
return departments.FirstOrDefault(x => x.Role == role);
|
||||
}
|
||||
|
||||
public UserDepartment FindHomeDepartment()
|
||||
{
|
||||
return Departments.FirstOrDefault(x => x.IsHome == true
|
||||
&& x.StartDate.Date <= DateTime.Today.Date &&
|
||||
(x.EndDate == null || DateTime.Today.Date <= x.EndDate.Value.Date));
|
||||
}
|
||||
|
||||
public bool HasDepartment(int departmentId)
|
||||
{
|
||||
return ActiveDepartmentsForRange(new MonthRange()).Any(x => x.DepartmentId == departmentId);
|
||||
}
|
||||
|
||||
public bool HasRoleAnywhere(Role role)
|
||||
{
|
||||
var departments = ActiveDepartmentsForRange(new MonthRange());
|
||||
return departments.Any(userDepartment => userDepartment.Role == role);
|
||||
}
|
||||
|
||||
public bool HasAnyRoleForActiveDepartment(int departmentId, Role[] roles)
|
||||
{
|
||||
var departments = ActiveDepartmentsForRange(new MonthRange());
|
||||
return departments.Any(userDepartment => roles.Contains(userDepartment.Role) && userDepartment.DepartmentId == departmentId);
|
||||
}
|
||||
|
||||
public string AppUserFullNameInFromContextFormat()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(FullName))
|
||||
{
|
||||
var nameParts = FullName.Split(",");
|
||||
return $"{nameParts[1]} {nameParts[0]}";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ApplicationUser
|
||||
{
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string[] Roles { get; set; }
|
||||
public bool IsSystem { get; set; }
|
||||
|
||||
public string UserName()
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(LastName) ? Email : $"{FirstName} {LastName}";
|
||||
}
|
||||
|
||||
public UserType UserType()
|
||||
{
|
||||
return IsSystem ? Library.Internal.IncentiveApiModels.Enums.UserType.System : Library.Internal.IncentiveApiModels.Enums.UserType.Associate;
|
||||
}
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class BusinessLine
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Code { get; }
|
||||
public string OrgCode { get; }
|
||||
|
||||
private const string HeadQuarters = "headquarters";
|
||||
private const string BranchName = "branch";
|
||||
private const string OperationsName = "operations";
|
||||
|
||||
private BusinessLine(string name, string code, string orgcode)
|
||||
{
|
||||
Name = name;
|
||||
Code = code;
|
||||
OrgCode = orgcode;
|
||||
}
|
||||
|
||||
public static BusinessLine BranchOperations = new BusinessLine("Branches", "BCHOPS", Organization.MemberExperience.OrgCode);
|
||||
public static BusinessLine MemberServices = new BusinessLine("Member Services", "MEMSRV", Organization.MemberExperience.OrgCode);
|
||||
public static BusinessLine Operations = new BusinessLine("Operations", "OPS", Organization.MemberExperience.OrgCode);
|
||||
|
||||
public static List<BusinessLine> BusinessLines = new List<BusinessLine>
|
||||
{
|
||||
BranchOperations,
|
||||
MemberServices,
|
||||
Operations
|
||||
};
|
||||
|
||||
public static BusinessLine FindByCode(string code) => BusinessLines.FirstOrDefault(bl => bl.Code == code);
|
||||
|
||||
public static BusinessLine TryLookup(string employeeOrgUnit)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(employeeOrgUnit))
|
||||
{
|
||||
return MemberServices;
|
||||
}
|
||||
|
||||
if (employeeOrgUnit.ToLower().Contains(BranchName))
|
||||
{
|
||||
return BranchOperations;
|
||||
}
|
||||
|
||||
if (employeeOrgUnit.ToLower().Contains(OperationsName))
|
||||
{
|
||||
return Operations;
|
||||
}
|
||||
|
||||
return MemberServices;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Commission : Auditable
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonConverter(typeof(RoleConverter))]
|
||||
public Role Role { get; set; }
|
||||
|
||||
[Required]
|
||||
public int RatePerProduct { get; set; }
|
||||
|
||||
[Required]
|
||||
public Product Product { get; set; }
|
||||
|
||||
public bool HasSameRoleAndProduct(Commission commission)
|
||||
{
|
||||
return Role == commission.Role && Product == commission.Product;
|
||||
}
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class DeadActivity : Auditable, IViewTransformable<DeadActivity>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid AppUserId { get; set; }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public DeadActivityReason Reason { get; set; }
|
||||
public string ReasonNote { get; set; }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public Product? Product { get; set; }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ActivityType? Type { get; set; }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public SystemType? SourceSystem { get; set; }
|
||||
public string? SourceId { get; set; }
|
||||
public DateTime? SourceCreated { get; set; }
|
||||
public DeadActivityDetail DeadDetail { get; set; }
|
||||
public int? DepartmentId { get; set; }
|
||||
public string? EmployeeId { get; set; }
|
||||
public string? EmployeeEmail { get; set; }
|
||||
public DateTime? Accepted { get; set; }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ActivityState? State { get; set; }
|
||||
public int? LivingActivityId { get; set; }
|
||||
|
||||
public DeadActivity(Activity activity, DeadActivityReason reason, string note)
|
||||
{
|
||||
Accepted = activity.Accepted;
|
||||
AppUserId = activity.AppUserId;
|
||||
DeadDetail = new DeadActivityDetail
|
||||
{
|
||||
AccountBalance = activity.Detail.AccountBalance,
|
||||
AccountNewBalance = activity.Detail.AccountNewBalance,
|
||||
AccountNumber = activity.Detail.AccountNumber,
|
||||
AccountStatus = activity.Detail.AccountStatus,
|
||||
AgreementNumber = activity.Detail.AgreementNumber,
|
||||
BranchOrgName = activity.Detail.BranchOrgName,
|
||||
BranchOrgNbr = activity.Detail.BranchOrgNbr,
|
||||
DnaPersonNbr = activity.Detail.DnaPersonNbr,
|
||||
DebtProtectionAddDate = activity.Detail.DebtProtectionAddDate,
|
||||
DebtProtectionRemoveDate = activity.Detail.DebtProtectionRemoveDate,
|
||||
GapInsuranceAddDate = activity.Detail.GapInsuranceAddDate,
|
||||
GapInsuranceRemoveDate = activity.Detail.GapInsuranceRemoveDate,
|
||||
IsDebtProtectionEligible = activity.Detail.IsDebtProtectionEligible,
|
||||
IsGapInsuranceEligible = activity.Detail.IsGapInsuranceEligible,
|
||||
MemberName = activity.Detail.MemberName,
|
||||
StationName = activity.Detail.StationName,
|
||||
SubAccountNumber = activity.Detail.SubAccountNumber,
|
||||
SubjectOrgNbr = activity.Detail.SubjectOrgNbr,
|
||||
SubjectPersonNbr = activity.Detail.SubjectPersonNbr
|
||||
};
|
||||
DepartmentId = activity.DepartmentId < 0 ? null : activity.DepartmentId;
|
||||
EmployeeId = activity.EmployeeId;
|
||||
EmployeeEmail = activity.EmployeeEmail;
|
||||
Product = activity.Product;
|
||||
Reason = reason;
|
||||
ReasonNote = note;
|
||||
SourceCreated = activity.SourceCreated;
|
||||
SourceId = activity.SourceId;
|
||||
SourceSystem = activity.SourceSystem;
|
||||
State = activity.State;
|
||||
Type = activity.Type;
|
||||
}
|
||||
|
||||
public DeadActivity(string sourceId, SystemType systemType, DeadActivityReason reason, string note)
|
||||
{
|
||||
Reason = reason;
|
||||
ReasonNote = note;
|
||||
SourceId = sourceId;
|
||||
SourceSystem = systemType;
|
||||
DeadDetail = new DeadActivityDetail()
|
||||
{
|
||||
DeadActivity = this
|
||||
};
|
||||
}
|
||||
|
||||
private DeadActivity()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DeadActivity TransformForView()
|
||||
{
|
||||
DeadDetail?.TransformForView();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class DeadActivityDetail : IViewTransformable<DeadActivityDetail>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? DnaPersonNbr { get; set; }
|
||||
public string? AccountNumber { get; set; }
|
||||
public string? SubAccountNumber { get; set; }
|
||||
public string? AccountStatus { get; set; }
|
||||
public string? AgreementNumber { get; set; }
|
||||
public string? SubjectPersonNbr { get; set; }
|
||||
public string? SubjectOrgNbr { get; set; }
|
||||
public string? MemberName { get; set; }
|
||||
public string? StationName { get; set; }
|
||||
public string? BranchOrgNbr { get; set; }
|
||||
public string? BranchOrgName { get; set; }
|
||||
public double? AccountBalance { get; set; }
|
||||
public double? AccountNewBalance { get; set; }
|
||||
public int DeadActivityRef { get; set; }
|
||||
[JsonIgnore]
|
||||
public DeadActivity DeadActivity { get; set; }
|
||||
public DateTime? DebtProtectionAddDate { get; set; }
|
||||
public DateTime? DebtProtectionRemoveDate { get; set; }
|
||||
public bool? IsDebtProtectionEligible { get; set; }
|
||||
public bool IsGapInsuranceEligible { get; set; }
|
||||
public DateTime? GapInsuranceAddDate { get; set; }
|
||||
public DateTime? GapInsuranceRemoveDate { get; set; }
|
||||
|
||||
public DeadActivityDetail TransformForView()
|
||||
{
|
||||
if (DeadActivity == null || DeadActivity.Product == null || DeadActivity.Type == null)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if ((DeadActivity?.Product == Product.CreditCard || DeadActivity?.Product == Product.CreditCardBalanceTransfer)
|
||||
&& DeadActivity?.Type == ActivityType.Referral)
|
||||
{
|
||||
AccountNumber = GetAccountNumber();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private string GetAccountNumber()
|
||||
{
|
||||
if (string.IsNullOrEmpty(AccountNumber) || AccountNumber.Length <= 4) return AccountNumber;
|
||||
|
||||
var lastDigits = AccountNumber.Substring(AccountNumber.Length - 4, 4);
|
||||
var maskDigits = new string('X', AccountNumber.Length - 4);
|
||||
return string.Concat(maskDigits, lastDigits);
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Department : Auditable, IValidatableObject
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(255, MinimumLength = 3)]
|
||||
public string DepartmentName { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(255, MinimumLength = 3)]
|
||||
public string DayforceDepartmentName { get; set; }
|
||||
|
||||
public string? DnaOrgNbr { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? DayForceGlCode { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? BusinessLineCode { get; set; }
|
||||
|
||||
public string? RegionCode { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public DepartmentState State { get; set; }
|
||||
|
||||
public List<UserDepartment> Assignments { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var results = new List<ValidationResult>();
|
||||
|
||||
if (!typeof(BusinessLine).GetFields(BindingFlags.Static | BindingFlags.Public)
|
||||
.Where(x => x.FieldType == typeof(BusinessLine))
|
||||
.Select(x => (x.GetValue(x.Name) as BusinessLine)?.Code).Contains(BusinessLineCode))
|
||||
{
|
||||
results.Add(new ValidationResult("The supplied BusinessLineCode is not associated with any known BusinessLine", new[] { "BusinessLine" }));
|
||||
}
|
||||
|
||||
if (RegionCode != null && Region.FindByCode(RegionCode) == null)
|
||||
{
|
||||
results.Add(new ValidationResult("The supplied RegionCode is not associated with any known Region", new[] { "Region" }));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class DepartmentLineItem : Auditable
|
||||
{
|
||||
public DepartmentLineItem()
|
||||
{
|
||||
PayoutPercentage = 0;
|
||||
PayoutTotal = 0;
|
||||
}
|
||||
|
||||
public DepartmentLineItem(int departmentId, string departmentName, DateTime payoutMonth) : this()
|
||||
{
|
||||
DepartmentId = departmentId;
|
||||
DepartmentName = departmentName;
|
||||
PayoutMonth = payoutMonth;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public int DepartmentId { get; set; }
|
||||
public string DepartmentName { get; set; }
|
||||
public decimal PayoutTotal { get; set; }
|
||||
public decimal PayoutPercentage { get; private set; }
|
||||
public DateTime PayoutMonth { get; set; }
|
||||
public void Apply(PayoutLineItem payoutLineItem)
|
||||
{
|
||||
PayoutTotal += payoutLineItem.PayoutTotal;
|
||||
}
|
||||
|
||||
public void CalculatePercentage(decimal total)
|
||||
{
|
||||
PayoutPercentage = total == 0 ? 0 : Math.Round(PayoutTotal / total * 100, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class EStatementDeliveryMethod
|
||||
{
|
||||
public long AccountNumber { get; set; }
|
||||
public long ActivityNumber { get; set; }
|
||||
public DateTime ActivityDateTime { get; set; }
|
||||
public string MinorAccountType { get; set; }
|
||||
public string PersonNumber { get; set; }
|
||||
public string OrganizationNumber { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string PhoneNumbers { get; set; }
|
||||
public string EmailAddresses { get; set; }
|
||||
public List<ActivityMetaData> MetaData { get; set; }
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Goal : Auditable
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid AppUserId { get; set; }
|
||||
public int DepartmentId { get; set; }
|
||||
public string? EmployeeId { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
public Product Product { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public int Value { get; set; }
|
||||
|
||||
public bool IsDepartmentGoal()
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(EmployeeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class GoalChange : AuditCreate
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public Guid AppUserId { get; set; }
|
||||
public int DepartmentId { get; set; }
|
||||
public DateTime EndDate { set; get; }
|
||||
public string? PersonId { get; set; }
|
||||
public Product Product { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public int Value { get; set; }
|
||||
|
||||
public bool IsDepartmentGoalChange()
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(PersonId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Organization
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string OrgCode { get; set; }
|
||||
|
||||
private Organization(string name, string code)
|
||||
{
|
||||
Name = name;
|
||||
OrgCode = code;
|
||||
}
|
||||
|
||||
public static Organization MemberExperience = new Organization("Member Experience", "MEMEXP");
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class PayoutLineItem : AuditCreate
|
||||
{
|
||||
public PayoutLineItem()
|
||||
{
|
||||
}
|
||||
|
||||
public PayoutLineItem(Product product, PayoutProfile profile, int goalValue, decimal slidingPayout, IEnumerable<Activity> activities)
|
||||
{
|
||||
Product = product;
|
||||
PayoutProfileId = profile.Id;
|
||||
GoalValue = goalValue;
|
||||
SlidingPayout = slidingPayout;
|
||||
ApplyActivity(activities);
|
||||
}
|
||||
|
||||
public PayoutLineItem(Product product, PayoutProfile profile, Goal goal, decimal slidingPayout, IEnumerable<Activity> activities, DateTime runDate)
|
||||
{
|
||||
Product = product;
|
||||
PayoutProfileId = profile.Id;
|
||||
GoalId = goal.Id;
|
||||
GoalValue = goal.Value;
|
||||
SlidingPayout = slidingPayout;
|
||||
ApplyActivity(activities);
|
||||
PayoutTotal = profile.CalculateLineItemPayout(GoalValue, ActivityTotal, runDate, SlidingPayout);
|
||||
}
|
||||
|
||||
public PayoutLineItem(Product product, Commission commission, IEnumerable<Activity> activities)
|
||||
{
|
||||
Product = product;
|
||||
CommissionId = commission.Id;
|
||||
CommissionValue = commission.RatePerProduct;
|
||||
ApplyActivity(activities);
|
||||
PayoutTotal = ActivityTotal * CommissionValue;
|
||||
SlidingPayout = 100;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public Guid AppUserId { get; set; }
|
||||
public string EmployeeId { get; set; }
|
||||
public int DepartmentId { get; set; }
|
||||
public decimal SlidingPayout { get; set; }
|
||||
public Role Role { get; set; }
|
||||
public Product Product { get; set; }
|
||||
public DateTime ActivityPeriod { get; set; }
|
||||
public int GoalId { get; set; }
|
||||
public int GoalValue { get; set; }
|
||||
public int CommissionId { get; set; }
|
||||
public int CommissionValue { get; set; }
|
||||
public int PayoutProfileId { get; set; }
|
||||
public virtual IList<ActivityPayoutLineItem> ActivityPayouts { get; set; }
|
||||
public decimal ActivityTotal { get; set; }
|
||||
public decimal PayoutTotal { get; set; }
|
||||
|
||||
private void ApplyActivity(IEnumerable<Activity> activities)
|
||||
{
|
||||
ActivityPayouts = new List<ActivityPayoutLineItem>();
|
||||
foreach (var activity in activities)
|
||||
{
|
||||
var payoutActivity = new ActivityPayoutLineItem
|
||||
{
|
||||
Activity = activity,
|
||||
PayoutLineItem = this
|
||||
};
|
||||
|
||||
ActivityPayouts.Add(payoutActivity);
|
||||
if (activity.Product == Product)
|
||||
{
|
||||
if (PayoutProfileId != 0)
|
||||
{
|
||||
ActivityTotal += Convert.ToDecimal(activity.CalculatedValueTowardsGoal(activity.Product));
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivityTotal++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+363
@@ -0,0 +1,363 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class PayoutProfile
|
||||
{
|
||||
public int Id { get; }
|
||||
public Product Product { get; }
|
||||
public Role[] Roles { get; }
|
||||
public Dictionary<DateTime, PayoutRange[]> Payouts { get; }
|
||||
public PayoutType Type { get; }
|
||||
public bool PayEach { get; }
|
||||
public bool IsEnabled { get; }
|
||||
private const bool PayForEach = true;
|
||||
|
||||
private PayoutProfile(
|
||||
int id,
|
||||
Product product,
|
||||
Role[] roles,
|
||||
PayoutRange[] defaultPayout,
|
||||
PayoutType type = PayoutType.Personal,
|
||||
bool payEach = false,
|
||||
bool isEnabled = true
|
||||
)
|
||||
{
|
||||
Id = id;
|
||||
Product = product;
|
||||
Roles = roles;
|
||||
Payouts = new Dictionary<DateTime, PayoutRange[]>
|
||||
{
|
||||
{ DateTime.MinValue, defaultPayout }
|
||||
};
|
||||
Type = type;
|
||||
PayEach = payEach;
|
||||
IsEnabled = isEnabled;
|
||||
}
|
||||
|
||||
private PayoutProfile(
|
||||
int id,
|
||||
Product product,
|
||||
Role[] roles,
|
||||
Dictionary<DateTime, PayoutRange[]> payouts,
|
||||
PayoutType type = PayoutType.Personal,
|
||||
bool payEach = false,
|
||||
bool isEnabled = true
|
||||
)
|
||||
{
|
||||
Id = id;
|
||||
Product = product;
|
||||
Roles = roles;
|
||||
Payouts = payouts;
|
||||
Type = type;
|
||||
PayEach = payEach;
|
||||
IsEnabled = isEnabled;
|
||||
}
|
||||
|
||||
public static readonly PayoutProfile BMMortgage = new PayoutProfile(1,
|
||||
Product.Mortgage, new[] { Role.BM },
|
||||
new Dictionary<DateTime, PayoutRange[]>
|
||||
{
|
||||
{
|
||||
DateTime.MinValue, new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 200),
|
||||
new PayoutRange(1.25, 1.49, 250),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 325)
|
||||
}
|
||||
},
|
||||
{
|
||||
DateTime.ParseExact("2021-11-01", "yyyy-MM-dd", CultureInfo.InvariantCulture), new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 250),
|
||||
new PayoutRange(1.25, 1.49, 325),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 425)
|
||||
}
|
||||
}
|
||||
},
|
||||
PayoutType.Department
|
||||
);
|
||||
|
||||
public static readonly PayoutProfile ABMMortgage = new PayoutProfile(2,
|
||||
Product.Mortgage, new[] { Role.ABM, Role.ManagementTrainee },
|
||||
new Dictionary<DateTime, PayoutRange[]>
|
||||
{
|
||||
{
|
||||
DateTime.MinValue, new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 125),
|
||||
new PayoutRange(1.25, 1.49, 175),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 250)
|
||||
}
|
||||
},
|
||||
{
|
||||
DateTime.ParseExact("2021-11-01", "yyyy-MM-dd", CultureInfo.InvariantCulture), new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 175),
|
||||
new PayoutRange(1.25, 1.49, 250),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 350)
|
||||
}
|
||||
}
|
||||
},
|
||||
PayoutType.Department
|
||||
);
|
||||
|
||||
public static readonly PayoutProfile PFOMSLOMortgage = new PayoutProfile(3,
|
||||
Product.Mortgage, new[] { Role.PFO, Role.MSLO },
|
||||
new Dictionary<DateTime, PayoutRange[]>
|
||||
{
|
||||
{
|
||||
DateTime.MinValue, new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 50),
|
||||
new PayoutRange(1.0, 1.24, 100),
|
||||
new PayoutRange(1.25, 1.49, 150),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 200)
|
||||
}
|
||||
},
|
||||
{
|
||||
DateTime.ParseExact("2021-11-01", "yyyy-MM-dd", CultureInfo.InvariantCulture), new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 75),
|
||||
new PayoutRange(1.0, 1.24, 150),
|
||||
new PayoutRange(1.25, 1.49, 225),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 300)
|
||||
}
|
||||
}
|
||||
},
|
||||
PayoutType.Personal
|
||||
);
|
||||
|
||||
public static readonly PayoutProfile MSCPersonalMortgage = new PayoutProfile(4,
|
||||
Product.Mortgage, new[] { Role.MSCTeamLead },
|
||||
new Dictionary<DateTime, PayoutRange[]>
|
||||
{
|
||||
{
|
||||
DateTime.MinValue, new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 50),
|
||||
new PayoutRange(1.0, 1.24, 100),
|
||||
new PayoutRange(1.25, 1.49, 150),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 200)
|
||||
}
|
||||
},
|
||||
{
|
||||
DateTime.ParseExact("2021-11-01", "yyyy-MM-dd", CultureInfo.InvariantCulture), new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 75),
|
||||
new PayoutRange(1.0, 1.24, 150),
|
||||
new PayoutRange(1.25, 1.49, 225),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 300)
|
||||
}
|
||||
}
|
||||
},
|
||||
PayoutType.Personal
|
||||
);
|
||||
|
||||
public static readonly PayoutProfile MSCMortgage = new PayoutProfile(5,
|
||||
Product.Mortgage, new[] { Role.MSCTeamLead },
|
||||
new Dictionary<DateTime, PayoutRange[]>
|
||||
{
|
||||
{
|
||||
DateTime.MinValue, new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 50),
|
||||
new PayoutRange(1.25, 1.49, 75),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 100)
|
||||
}
|
||||
},
|
||||
{
|
||||
DateTime.ParseExact("2021-11-01", "yyyy-MM-dd", CultureInfo.InvariantCulture), new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 100),
|
||||
new PayoutRange(1.25, 1.49, 150),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 200)
|
||||
}
|
||||
}
|
||||
},
|
||||
PayoutType.Department
|
||||
);
|
||||
|
||||
public static readonly PayoutProfile BMVehicle = new PayoutProfile(6,
|
||||
Product.Vehicle, new[] { Role.BM },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 125),
|
||||
new PayoutRange(1.25, 1.49, 175),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 225)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile ABMVehicle = new PayoutProfile(7,
|
||||
Product.Vehicle, new[] { Role.ABM, Role.ManagementTrainee },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 50),
|
||||
new PayoutRange(1.25, 1.49, 100),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 125)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile PFOMSLOVehicle = new PayoutProfile(8,
|
||||
Product.Vehicle, new[] { Role.PFO, Role.MSLO },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 25),
|
||||
new PayoutRange(1.0, 1.24, 50),
|
||||
new PayoutRange(1.25, 1.49, 75),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 100)
|
||||
},
|
||||
PayoutType.Personal);
|
||||
|
||||
public static readonly PayoutProfile MSCPersonalVehicle = new PayoutProfile(9,
|
||||
Product.Vehicle, new[] { Role.MSCTeamLead },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 25),
|
||||
new PayoutRange(1.0, 1.24, 50),
|
||||
new PayoutRange(1.25, 1.49, 75),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 100)
|
||||
},
|
||||
PayoutType.Personal);
|
||||
|
||||
public static readonly PayoutProfile BMNewChecking = new PayoutProfile(10,
|
||||
Product.NewChecking, new[] { Role.BM },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 200),
|
||||
new PayoutRange(1.25, 1.49, 250),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 325)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile ABMBOMNewChecking = new PayoutProfile(11,
|
||||
Product.NewChecking, new[] { Role.ABM, Role.BOM, Role.ManagementTrainee },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 125),
|
||||
new PayoutRange(1.25, 1.49, 175),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 250)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile PFOMSLONewChecking = new PayoutProfile(12,
|
||||
Product.NewChecking, new[] { Role.PFO, Role.UniversalSpecialistPFO },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 50),
|
||||
new PayoutRange(1.0, 1.24, 100),
|
||||
new PayoutRange(1.25, 1.49, 150),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 200)
|
||||
},
|
||||
PayoutType.Personal);
|
||||
|
||||
public static readonly PayoutProfile MSCNewChecking = new PayoutProfile(13,
|
||||
Product.NewChecking, new[] { Role.MSCTeamLead },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 50),
|
||||
new PayoutRange(1.25, 1.49, 75),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 100)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile MSCPersonalNewChecking = new PayoutProfile(14,
|
||||
Product.NewChecking, new[] { Role.MSCTeamLead },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(0.74, 0.99, 50),
|
||||
new PayoutRange(1.0, 1.24, 100),
|
||||
new PayoutRange(1.25, 1.49, 150),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 200)
|
||||
},
|
||||
PayoutType.Personal);
|
||||
|
||||
public static readonly PayoutProfile BMCreditCard = new PayoutProfile(15,
|
||||
Product.CreditCard, new[] { Role.BM },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 125),
|
||||
new PayoutRange(1.25, 1.49, 175),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 225)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile ABMBOMCreditCardPayout = new PayoutProfile(16,
|
||||
Product.CreditCard, new[] { Role.ABM, Role.BOM, Role.ManagementTrainee },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 50),
|
||||
new PayoutRange(1.25, 1.49, 100),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 125)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile MSCCreditCardPayout = new PayoutProfile(17,
|
||||
Product.CreditCard, new[] { Role.MSCTeamLead },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(1.0, 1.24, 50),
|
||||
new PayoutRange(1.25, 1.49, 75),
|
||||
new PayoutRange(1.5, PayoutRange.NOLIMIT, 100)
|
||||
},
|
||||
PayoutType.Department);
|
||||
|
||||
public static readonly PayoutProfile BMABMPFOGAPPayout = new PayoutProfile(18,
|
||||
Product.GAPInsurance,
|
||||
new[] { Role.BM, Role.ABM, Role.PFO, Role.ManagementTrainee, Role.MSCTeamLead, Role.MSLO, Role.UniversalSpecialistPFO },
|
||||
new[]
|
||||
{
|
||||
new PayoutRange(0.3, 0.39, 30),
|
||||
new PayoutRange(0.4, 0.49, 40),
|
||||
new PayoutRange(0.5, 0.59, 50),
|
||||
new PayoutRange(0.6, PayoutRange.NOLIMIT, 60)
|
||||
},
|
||||
PayoutType.Personal, PayForEach, false);
|
||||
|
||||
public static readonly List<PayoutProfile> PayoutProfiles = new List<PayoutProfile>
|
||||
{
|
||||
ABMBOMCreditCardPayout,
|
||||
ABMBOMNewChecking,
|
||||
ABMMortgage,
|
||||
ABMVehicle,
|
||||
BMABMPFOGAPPayout,
|
||||
BMCreditCard,
|
||||
BMMortgage,
|
||||
BMNewChecking,
|
||||
BMVehicle,
|
||||
MSCCreditCardPayout,
|
||||
MSCMortgage,
|
||||
MSCNewChecking,
|
||||
MSCPersonalMortgage,
|
||||
MSCPersonalNewChecking,
|
||||
MSCPersonalVehicle,
|
||||
PFOMSLOMortgage,
|
||||
PFOMSLONewChecking,
|
||||
PFOMSLOVehicle,
|
||||
};
|
||||
|
||||
public static readonly List<PayoutProfile> ActivePayoutProfiles = PayoutProfiles.Where(x => x.IsEnabled).ToList();
|
||||
|
||||
public static IEnumerable<PayoutProfile> FindForRole(Role employeeRole)
|
||||
{
|
||||
return ActivePayoutProfiles.Where(profile => profile.Roles.Contains(employeeRole));
|
||||
}
|
||||
|
||||
public static PayoutProfile FindById(int id)
|
||||
{
|
||||
return PayoutProfiles.First(profile => profile.Id == id);
|
||||
}
|
||||
|
||||
public static PayoutProfile LookupProfile(Product product, Role role, PayoutType type)
|
||||
{
|
||||
return ActivePayoutProfiles
|
||||
.Find(profile => profile.Product == product
|
||||
&& profile.Roles.Contains(role)
|
||||
&& profile.Type == type);
|
||||
}
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public static class PayoutProfileExtensions
|
||||
{
|
||||
public static PayoutRange FindPayoutRange(this PayoutProfile profile, double percentage, DateTime runDate)
|
||||
{
|
||||
var percentageToHundreds = Math.Truncate(100 * percentage) / 100;
|
||||
var defaultPayout = profile.Payouts.First(defaultPayout => defaultPayout.Key == DateTime.MinValue).Value;
|
||||
if (profile.Payouts.Count == 1)
|
||||
{
|
||||
return defaultPayout.FirstOrDefault(payoutRange => payoutRange.IsInRange(percentageToHundreds));
|
||||
}
|
||||
|
||||
var payout = profile.Payouts.FirstOrDefault(payout =>
|
||||
{
|
||||
var dateTimeOfPayout = payout.Key;
|
||||
return dateTimeOfPayout.Month == runDate.Month && dateTimeOfPayout.Year == runDate.Year;
|
||||
}).Value;
|
||||
|
||||
var t = payout == null ? defaultPayout.FirstOrDefault(payoutRange => payoutRange.IsInRange(percentageToHundreds)) : payout.FirstOrDefault(payoutRange => payoutRange.IsInRange(percentageToHundreds));
|
||||
return t;
|
||||
}
|
||||
|
||||
public static decimal CalculateLineItemPayout(this PayoutProfile profile, int goal, decimal actual, DateTime runDate, decimal payoutPercent = 100)
|
||||
{
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception("Attempt to calculate payout with null profile");
|
||||
}
|
||||
|
||||
if (goal == 0) return 0;
|
||||
|
||||
var goalPercentage = (double)actual / goal;
|
||||
var payoutRange = profile.FindPayoutRange(goalPercentage, runDate);
|
||||
|
||||
if (payoutRange == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
decimal payoutAmt = payoutRange.Payout;
|
||||
if (profile.PayEach)
|
||||
{
|
||||
payoutAmt *= actual;
|
||||
}
|
||||
|
||||
double payoutPercentage = (double)payoutPercent / 100;
|
||||
double finalPayout = (double)payoutAmt * payoutPercentage;
|
||||
payoutAmt = (decimal)Math.Round(finalPayout, 2);
|
||||
|
||||
return payoutAmt;
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class PayoutRange
|
||||
{
|
||||
public const double NOLIMIT = -1.0;
|
||||
public double MinimumPercentage { get; }
|
||||
public double MaximumPercentage { get; }
|
||||
public int Payout { get; }
|
||||
|
||||
public PayoutRange(double minimumPercentage, double maximumPercentage, int payout)
|
||||
{
|
||||
MinimumPercentage = minimumPercentage;
|
||||
MaximumPercentage = maximumPercentage;
|
||||
Payout = payout;
|
||||
}
|
||||
|
||||
public bool IsInRange(double percentage)
|
||||
{
|
||||
return percentage >= MinimumPercentage && (percentage <= MaximumPercentage || MaximumPercentage == NOLIMIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Permission
|
||||
{
|
||||
public string Code { get; }
|
||||
public string Description { get; }
|
||||
|
||||
private Permission(string code, string description)
|
||||
{
|
||||
Code = code;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public static Permission LookupPermissionFromCode(string code)
|
||||
{
|
||||
var foundPermissions = GetAllPermissions().Where(x => x.Code == code).ToList();
|
||||
if (foundPermissions.Count != 1)
|
||||
{
|
||||
throw new Exception($"{foundPermissions.Count} found using Code: {code}");
|
||||
}
|
||||
|
||||
return foundPermissions.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static readonly Permission AccessTestEnvironments = new Permission("ACCESS_TEST_ENVIRONMENT", "User can access the test environments");
|
||||
|
||||
public static readonly Permission AssignAssociatesToDepartment =
|
||||
new Permission("ASSIGN_ASSOCIATES_TO_DEPARTMENT", "User can assign associates to additional departments");
|
||||
|
||||
public static readonly Permission AssignPermissionsToAssociates =
|
||||
new Permission("ASSIGN_PERMISSIONS_TO_ASSOCIATES", "User can add permissions to an associate's user role");
|
||||
|
||||
public static readonly Permission AssignRegionalManager = new Permission("ASSIGN_REGIONAL_MANAGER", "User can set the regional manager for a region");
|
||||
public static readonly Permission CreateActivity = new Permission("CREATE_ACTIVITY", "User can create manual activity");
|
||||
public static readonly Permission EligibleForReferrals = new Permission("ELIGIBLE_FOR_REFERRALS", "User is eligible for referrals");
|
||||
public static readonly Permission GeneratePayoutFiles = new Permission("GENERATE_PAYOUT_FILES", "User can generate payout files for HR");
|
||||
public static readonly Permission HaveSalesGoals = new Permission("HAVE_SALES_GOALS", "User can have sales goals");
|
||||
public static readonly Permission ManageCommissions = new Permission("MANAGE_COMMISSIONS", "User can manage the commission table");
|
||||
public static readonly Permission ManageDepartments = new Permission("MANAGE_DEPARTMENTS", "User can manage departments");
|
||||
public static readonly Permission ManageDepartmentGoals = new Permission("MANAGE_DEPARTMENT_GOALS", "User can manage their department goals");
|
||||
public static readonly Permission ManageEmployeeDetails = new Permission("MANAGE_EMPLOYEE_DETAILS", "User can manage employee details");
|
||||
public static readonly Permission ManagePersonnelGoals = new Permission("MANAGE_PERSONNEL_GOALS", "User can manage personnel goals");
|
||||
|
||||
public static readonly Permission ManageRoleMappings =
|
||||
new Permission("MANAGE_ROLE_MAPPINGS", "User can manage the business to application role mappings");
|
||||
|
||||
public static readonly Permission SetActivityAcceptedDate = new Permission("SET_ACTIVITY_ACCEPTED_DATE", "User can set activity accepted date");
|
||||
|
||||
public static readonly Permission SetActivityToAcceptedFromManualReview =
|
||||
new Permission("SET_ACTIVITY_TO_ACCEPTED_FROM_MANUAL_REVIEW", "User can set activity to Accepted from ManualReview");
|
||||
|
||||
public static readonly Permission SetActivityToAcceptedFromPendingReferral = new Permission("SET_ACTIVITY_TO_ACCEPTED_FROM_PENDING_REFERRAL",
|
||||
"User can set activity to Accepted from PendingReferral");
|
||||
|
||||
public static readonly Permission SetActivityToAcceptedFromPendingTransfer = new Permission("SET_ACTIVITY_TO_ACCEPTED_FROM_PENDING_TRANSFER",
|
||||
"User can set activity to Accepted from PendingTransfer");
|
||||
|
||||
public static readonly Permission SetActivityToAcceptedFromRejected =
|
||||
new Permission("SET_ACTIVITY_TO_ACCEPTED_FROM_REJECTED", "User can set activity to Accepted from Rejected");
|
||||
|
||||
public static readonly Permission SetActivityToManualReviewFromAccepted =
|
||||
new Permission("SET_ACTIVITY_TO_MANUAL_REVIEW_FROM_ACCEPTED", "User can set activity to ManualReview from Accepted");
|
||||
|
||||
public static readonly Permission SetActivityToManualReviewFromRejected =
|
||||
new Permission("SET_ACTIVITY_TO_MANUAL_REVIEW_FROM_REJECTED", "User can set activity to ManualReview from Rejected");
|
||||
|
||||
public static readonly Permission SetActivityToPendingReferralFromAccepted = new Permission("SET_ACTIVITY_TO_PENDING_REFERRAL_FROM_ACCEPTED",
|
||||
"User can set activity to PendingReferral from Accepted");
|
||||
|
||||
public static readonly Permission SetActivityToPendingReferralFromRejected = new Permission("SET_ACTIVITY_TO_PENDING_REFERRAL_FROM_REJECTED",
|
||||
"User can set activity to PendingReferral from Rejected");
|
||||
|
||||
public static readonly Permission SetActivityToPendingTransferFromAccepted = new Permission("SET_ACTIVITY_TO_PENDING_TRANSFER_FROM_ACCEPTED",
|
||||
"User can set activity to PendingTransfer from Accepted");
|
||||
|
||||
public static readonly Permission SetActivityToRejectedFromAccepted =
|
||||
new Permission("SET_ACTIVITY_TO_REJECTED_FROM_ACCEPTED", "User can set activity to Rejected from Accepted");
|
||||
|
||||
public static readonly Permission SetActivityToRejectedFromManualReview =
|
||||
new Permission("SET_ACTIVITY_TO_REJECTED_FROM_MANUAL_REVIEW", "User can set activity to Rejected from ManualReview");
|
||||
|
||||
public static readonly Permission SetActivityToTransferredFromPendingTransfer = new Permission("SET_ACTIVITY_TO_TRANSFERRED_FROM_PENDING_TRANSFER",
|
||||
"User can set activity to Transferred from PendingTransfer");
|
||||
|
||||
public static readonly Permission TransferActivitiesBetweenAssociates =
|
||||
new Permission("TRANSFER_ACTIVITIES_BETWEEN_ASSOCIATES", "User can transfer activities between associates");
|
||||
|
||||
public static readonly Permission TransferActivitiesBetweenDepartments =
|
||||
new Permission("TRANSFER_ACTIVITIES_BETWEEN_DEPARTMENTS", "User can transfer activities between departments");
|
||||
|
||||
public static readonly Permission Unknown = new Permission("UNKNOWN", "A Permission Could Not Be Parsed By The System. Possibly Removed.");
|
||||
public static readonly Permission ViewActivityAudit = new Permission("VIEW_ACTIVITY_AUDIT", "User can view the activity audit page");
|
||||
public static readonly Permission ViewActivityReport = new Permission("VIEW_ACTIVITY_REPORT", "User can view the activity report");
|
||||
public static readonly Permission ViewAuditReport = new Permission("VIEW_AUDIT_REPORT", "User can view the audit report");
|
||||
public static readonly Permission ViewAssociateRecordReport = new Permission("VIEW_ASSOCIATE_RECORD_REPORT", "User can view the associate record report");
|
||||
|
||||
public static readonly Permission ViewDashboard = new Permission("VIEW_DASHBOARD",
|
||||
"User can see a dashboard showing their referral totals and their sales totals compared to goal");
|
||||
|
||||
public static readonly Permission ViewDeadActivityQueue = new Permission("VIEW_DEAD_ACTIVITY_QUEUE", "User can see the dead activity queue");
|
||||
public static readonly Permission ViewGoalProgressReport = new Permission("VIEW_GOAL_PROGRESS_REPORT", "User can view the goal progress report");
|
||||
public static readonly Permission ViewPayoutReport = new Permission("VIEW_PAYOUT_REPORT", "User can view the payout report");
|
||||
|
||||
public static readonly Permission ViewPerformanceForBusinessLine =
|
||||
new Permission("VIEW_PERFORMANCE_FOR_BUSINESS_LINE", "User can see performance for their business line");
|
||||
|
||||
public static readonly Permission ViewPerformanceForDepartment =
|
||||
new Permission("VIEW_PERFORMANCE_FOR_DEPARTMENT", "User can see performance for their department");
|
||||
|
||||
public static readonly Permission ViewPerformanceForRegion = new Permission("VIEW_PERFORMANCE_FOR_REGION", "User can see performance for their region");
|
||||
public static readonly Permission ViewReports = new Permission("VIEW_REPORTS", "User can access the reports landing page");
|
||||
|
||||
public static List<Permission> GetAllPermissions(bool excludeUnknown = false)
|
||||
{
|
||||
var foundInstances = new List<Permission>();
|
||||
|
||||
foreach (var field in typeof(Permission).GetFields(BindingFlags.Static | BindingFlags.Public))
|
||||
{
|
||||
if (field.FieldType != typeof(Permission))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (field.GetValue(field.Name) is Permission instance)
|
||||
{
|
||||
foundInstances.Add(instance);
|
||||
}
|
||||
}
|
||||
|
||||
return excludeUnknown ? foundInstances.Where(x => x.Code != Unknown.Code).ToList() : foundInstances;
|
||||
}
|
||||
|
||||
/** Collection of permissions needed for minimal application access */
|
||||
public static List<Permission> BaselinePermissions()
|
||||
{
|
||||
return new List<Permission>
|
||||
{
|
||||
ViewActivityAudit,
|
||||
ViewDashboard
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Permission> DepartmentManagerPermissions()
|
||||
{
|
||||
return new List<Permission>
|
||||
{
|
||||
AssignAssociatesToDepartment,
|
||||
SetActivityToRejectedFromManualReview,
|
||||
TransferActivitiesBetweenAssociates,
|
||||
TransferActivitiesBetweenDepartments,
|
||||
ViewReports,
|
||||
ViewActivityReport,
|
||||
ViewGoalProgressReport,
|
||||
ViewPerformanceForDepartment
|
||||
}
|
||||
.Concat(TransferApprovalPermissions())
|
||||
.Concat(TransferRejectionPermissions())
|
||||
.Concat(TransferRequestPermissions())
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static List<Permission> TransferApprovalPermissions()
|
||||
{
|
||||
return new List<Permission>
|
||||
{
|
||||
SetActivityToTransferredFromPendingTransfer
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Permission> TransferRejectionPermissions()
|
||||
{
|
||||
return new List<Permission>
|
||||
{
|
||||
SetActivityToAcceptedFromPendingTransfer
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Permission> TransferRequestPermissions()
|
||||
{
|
||||
return new List<Permission>
|
||||
{
|
||||
SetActivityToPendingTransferFromAccepted
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ProcessorHistoryRecord
|
||||
{
|
||||
public Process Process { get; set; }
|
||||
public DateTime LastSuccessfulRunTime { get; set; }
|
||||
public long LastProcessedRecordId { get; set; }
|
||||
public DateTime LastProcessedRecordTimestamp { get; set; }
|
||||
}
|
||||
}
|
||||
+277
@@ -0,0 +1,277 @@
|
||||
using System.Collections.Generic;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class ProductDetail
|
||||
{
|
||||
private ProductDetail(
|
||||
Product product,
|
||||
string title,
|
||||
ProductValue valueType,
|
||||
int minValue,
|
||||
int maxValue,
|
||||
bool hasGoals,
|
||||
bool hasCommissions,
|
||||
bool isSellable,
|
||||
bool isReferrable,
|
||||
bool isNonPaying
|
||||
)
|
||||
{
|
||||
Product = product;
|
||||
Title = title;
|
||||
ValueType = valueType;
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
HasGoals = hasGoals;
|
||||
HasCommissions = hasCommissions;
|
||||
IsSellable = isSellable;
|
||||
IsReferrable = isReferrable;
|
||||
IsNonPaying = isNonPaying;
|
||||
}
|
||||
|
||||
public Product Product { get; }
|
||||
public string Title { get; }
|
||||
public ProductValue ValueType { get; }
|
||||
public int MinValue { get; }
|
||||
public int MaxValue { get; }
|
||||
public bool HasGoals { get; }
|
||||
public bool HasCommissions { get; }
|
||||
public bool IsSellable { get; }
|
||||
public bool IsReferrable { get; }
|
||||
public bool IsNonPaying { get; }
|
||||
|
||||
public static readonly ProductDetail ATMCard = new(
|
||||
Product.ATMCard,
|
||||
"ATM Card",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly ProductDetail CheckCard = new(
|
||||
Product.CheckCard,
|
||||
"Check Card",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly ProductDetail CreditCard = new(
|
||||
Product.CreditCard,
|
||||
"Credit Card",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail CreditCardBalanceTransfer = new(
|
||||
Product.CreditCardBalanceTransfer,
|
||||
"CCBT",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail DebtProtection = new(
|
||||
Product.DebtProtection,
|
||||
"Debt Protection",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail DebtProtectionEligibleLoan = new(
|
||||
Product.DebtProtectionEligibleLoan,
|
||||
"DP Eligible Loan",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly ProductDetail DirectDeposit = new(
|
||||
Product.DirectDeposit,
|
||||
"Direct Deposit",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail eStatement = new(
|
||||
Product.eStatement,
|
||||
"eStatement",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail FirstMortgageReferral = new(
|
||||
Product.FirstMortgageReferral,
|
||||
"First Mortgage Referral",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail GAPInsurance = new(
|
||||
Product.GAPInsurance,
|
||||
"GAPInsurance",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail LIC = new(
|
||||
Product.LIC,
|
||||
"LIC",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail MechanicalBreakdownProtection = new(
|
||||
Product.MechanicalBreakdownProtection,
|
||||
"MBP",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail Mortgage = new(
|
||||
Product.Mortgage,
|
||||
"Mortgage",
|
||||
ProductValue.Monetary,
|
||||
1,
|
||||
99999999,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail NewChecking = new(
|
||||
Product.NewChecking,
|
||||
"New Checking",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail Unknown = new(
|
||||
Product.Unknown,
|
||||
"Unknown",
|
||||
ProductValue.Unknown,
|
||||
1,
|
||||
99,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly ProductDetail Vehicle = new(
|
||||
Product.Vehicle,
|
||||
"Vehicle",
|
||||
ProductValue.Numeric,
|
||||
1,
|
||||
99,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly List<ProductDetail> ProductDetails = new()
|
||||
{
|
||||
ATMCard,
|
||||
CheckCard,
|
||||
CreditCard,
|
||||
CreditCardBalanceTransfer,
|
||||
DebtProtection,
|
||||
DebtProtectionEligibleLoan,
|
||||
DirectDeposit,
|
||||
eStatement,
|
||||
FirstMortgageReferral,
|
||||
GAPInsurance,
|
||||
LIC,
|
||||
MechanicalBreakdownProtection,
|
||||
Mortgage,
|
||||
NewChecking,
|
||||
Unknown,
|
||||
Vehicle
|
||||
};
|
||||
|
||||
public static ProductDetail DetailsForProduct(Product product)
|
||||
{
|
||||
return ProductDetails.Find(x => x.Product == product);
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Region
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Code { get; }
|
||||
public string BusinessLineCode { get; }
|
||||
|
||||
private Region(string name, string code, string businessLineCode)
|
||||
{
|
||||
Name = name;
|
||||
Code = code;
|
||||
BusinessLineCode = businessLineCode;
|
||||
}
|
||||
|
||||
public static Region East = new Region("East", "EAST", BusinessLine.BranchOperations.Code);
|
||||
public static Region North = new Region("North", "NORTH", BusinessLine.BranchOperations.Code);
|
||||
public static Region South = new Region("South", "SOUTH", BusinessLine.BranchOperations.Code);
|
||||
public static Region West = new Region("West", "WEST", BusinessLine.BranchOperations.Code);
|
||||
|
||||
public static List<Region> Regions = new List<Region>
|
||||
{
|
||||
East,
|
||||
North,
|
||||
South,
|
||||
West
|
||||
};
|
||||
|
||||
public static Region FindByCode(string code) => Regions.FirstOrDefault(region => region.Code == code);
|
||||
}
|
||||
}
|
||||
+458
@@ -0,0 +1,458 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Role
|
||||
{
|
||||
[Required]
|
||||
[StringLength(255, MinimumLength = 2)]
|
||||
public string Name { get; }
|
||||
|
||||
public string Description { get; }
|
||||
public IReadOnlyCollection<Permission> Permissions { get; }
|
||||
public bool HasCommissions { get; }
|
||||
public int Rank { get; }
|
||||
public bool CanBeAssigned { get; }
|
||||
|
||||
private Role(
|
||||
string name,
|
||||
string description,
|
||||
List<Permission> permissions,
|
||||
bool hasCommissions,
|
||||
int rank = 1,
|
||||
bool canBeAssigned = true
|
||||
)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
Permissions = permissions;
|
||||
HasCommissions = hasCommissions;
|
||||
Rank = rank;
|
||||
CanBeAssigned = canBeAssigned;
|
||||
}
|
||||
|
||||
public static List<Role> GetRolesList()
|
||||
{
|
||||
return typeof(Role).GetFields(BindingFlags.Public | BindingFlags.Static)
|
||||
.Where(field => field.FieldType == typeof(Role))
|
||||
.Select(field => (Role)field.GetValue(field))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static List<Role> SearchRoles(string term)
|
||||
{
|
||||
term = term.ToLower().Trim();
|
||||
return GetRolesList()
|
||||
.Where(role => role.Name.ToLower().Contains(term) ||
|
||||
role.Description.ToLower().Contains(term))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static Role DetermineRoleOrDefault(string role)
|
||||
{
|
||||
return GetRolesList().FirstOrDefault(r => r.Name.Equals(role)) ?? UNKNOWN_ROLE;
|
||||
}
|
||||
|
||||
public static readonly Role SystemAppUser = new(
|
||||
"SystemAppUser",
|
||||
"System App User", new List<Permission>(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role Admin = new(
|
||||
"Admin",
|
||||
"Admin",
|
||||
Permission.GetAllPermissions(true),
|
||||
false,
|
||||
99
|
||||
);
|
||||
|
||||
public static readonly Role BusinessLineManager = new(
|
||||
"BusinessLineManager",
|
||||
"Business Line Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManageDepartmentGoals,
|
||||
Permission.ManagePersonnelGoals,
|
||||
Permission.ViewPerformanceForBusinessLine,
|
||||
Permission.ViewPerformanceForRegion
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
98
|
||||
);
|
||||
|
||||
public static readonly Role RegionalManager = new(
|
||||
"RegionalManager",
|
||||
"Regional Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManageDepartmentGoals,
|
||||
Permission.ViewPerformanceForRegion
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
97
|
||||
);
|
||||
|
||||
public static readonly Role Manager = new(
|
||||
"Manager",
|
||||
"Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role MortgageManager = new(
|
||||
"MortgageManager",
|
||||
"Mortgage Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManagePersonnelGoals,
|
||||
Permission.EligibleForReferrals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role BM = new(
|
||||
"BM",
|
||||
"Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role InStoreBranchManager = new(
|
||||
"InStoreBranchManager",
|
||||
"In-Store Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role ABM = new(
|
||||
"ABM",
|
||||
"Assistant Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role InStoreAssistantBranchManager = new(
|
||||
"InStoreAssistantBranchManager",
|
||||
"In-Store Assistant Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role ManagementTrainee = new(
|
||||
"ManagementTrainee",
|
||||
"Management Trainee",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role MSCTeamLead = new(
|
||||
"MSCTeamLead",
|
||||
"Member Service Center Team Lead",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.AssignAssociatesToDepartment,
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ViewReports,
|
||||
Permission.ViewActivityReport,
|
||||
Permission.ViewGoalProgressReport,
|
||||
Permission.ViewPerformanceForDepartment
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role BOM = new(
|
||||
"BOM",
|
||||
"Branch Operations Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.AssignAssociatesToDepartment,
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ViewReports,
|
||||
Permission.ViewActivityReport,
|
||||
Permission.ViewGoalProgressReport,
|
||||
Permission.ViewPerformanceForDepartment,
|
||||
Permission.TransferActivitiesBetweenAssociates,
|
||||
Permission.TransferActivitiesBetweenDepartments
|
||||
}
|
||||
.Concat(Permission.BaselinePermissions())
|
||||
.Concat(Permission.TransferApprovalPermissions())
|
||||
.Concat(Permission.TransferRejectionPermissions())
|
||||
.Concat(Permission.TransferRequestPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
94
|
||||
);
|
||||
|
||||
public static readonly Role MSLO = new(
|
||||
"MSLO",
|
||||
"Member Services Loan Officer",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role PFO = new(
|
||||
"PFO",
|
||||
"PERS FIN OFFICER",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role UniversalSpecialistPFO = new(
|
||||
"UniversalSpecialist-PFO",
|
||||
"Universal Specialist - PFO",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role UniversalSpecialistTeller = new(
|
||||
"UniversalSpecialist-Teller",
|
||||
"Universal Specialist - Teller",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role LIC = new(
|
||||
"LIC",
|
||||
"Landmark Investment Center",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ViewPerformanceForDepartment,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role Mortgage = new(
|
||||
"Mortgage",
|
||||
"Mortgage",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role Teller = new(
|
||||
"Teller",
|
||||
"Teller",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role ConsumerLoanCoordinator = new(
|
||||
"ConsumerLoanCoordinator",
|
||||
"Consumer Loan Coordinator",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role LicAdmin = new(
|
||||
"LicAdmin",
|
||||
"LIC Admin",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.SetActivityToAcceptedFromRejected,
|
||||
Permission.SetActivityToManualReviewFromRejected,
|
||||
Permission.SetActivityToRejectedFromAccepted,
|
||||
Permission.SetActivityToRejectedFromManualReview,
|
||||
Permission.TransferActivitiesBetweenAssociates,
|
||||
Permission.TransferActivitiesBetweenDepartments
|
||||
}
|
||||
.Concat(Permission.BaselinePermissions())
|
||||
.Concat(Permission.TransferApprovalPermissions())
|
||||
.Concat(Permission.TransferRejectionPermissions())
|
||||
.Concat(Permission.TransferRequestPermissions())
|
||||
.ToList(),
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role MSR = new(
|
||||
"MSR",
|
||||
"Member Services Representative",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role OpsHelpDesk = new(
|
||||
"OpsHelpDesk",
|
||||
"Ops Help Desk",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role ManagementTraineePFO = new(
|
||||
"ManagementTrainee-PFO",
|
||||
"Management Trainee - PFO",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
-1,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role UNKNOWN_ROLE = new(
|
||||
"UNKNOWN",
|
||||
"Base role has no access",
|
||||
new List<Permission>(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role MISSING_ROLE = new(
|
||||
"MISSING",
|
||||
"User base role unknown.",
|
||||
new List<Permission>(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role Developer = new(
|
||||
"Developer",
|
||||
"Developer",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.AccessTestEnvironments
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static List<Role> DepartmentManagerRoles => new()
|
||||
{
|
||||
ABM,
|
||||
BOM,
|
||||
BM,
|
||||
BusinessLineManager,
|
||||
InStoreAssistantBranchManager,
|
||||
InStoreBranchManager,
|
||||
ManagementTrainee,
|
||||
Manager,
|
||||
MortgageManager,
|
||||
RegionalManager
|
||||
};
|
||||
|
||||
public static List<Role> LeadershipRoles => new()
|
||||
{
|
||||
BusinessLineManager,
|
||||
RegionalManager
|
||||
};
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class RoleMapping : Auditable
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
[JsonConverter(typeof(RoleConverter))]
|
||||
public Role ApplicationRole { get; set; }
|
||||
[Required]
|
||||
public string BusinessRole { get; set; }
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class UserAssignment
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public AssignmentType Type { get; set; }
|
||||
public string Key { get; set; }
|
||||
public AppUser AppUser { get; set; }
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class UserDepartment : Auditable
|
||||
{
|
||||
public const int PayoutMax = 100;
|
||||
public int Id { get; set; }
|
||||
public Guid AppUserId { get; set; }
|
||||
public int DepartmentId { get; set; }
|
||||
public Role Role { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime? EndDate { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public bool IsHome { get; set; }
|
||||
public decimal SlidingPayout { get; set; }
|
||||
public AppUser Employee { get; set; }
|
||||
public Department Department { get; set; }
|
||||
|
||||
public int SafeGetDepartmentId()
|
||||
{
|
||||
return Department?.Id ?? DepartmentId;
|
||||
}
|
||||
|
||||
public bool IsConflictingAssignment(UserDepartment newAssignment, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
if (newAssignment.Employee.EmployeeId != Employee.EmployeeId || newAssignment.Department.Id != DepartmentId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (EndDate == null)
|
||||
{
|
||||
message = $"Current assignment to department: {newAssignment.Department.DepartmentName} exists.";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newAssignment.EndDate == null)
|
||||
{
|
||||
var startsBeforeEndDate = newAssignment.StartDate.Date <= EndDate.Value.Date;
|
||||
message = startsBeforeEndDate ? $"Assignment would overlap existing assignment to department: {newAssignment.Department.DepartmentName}" : string.Empty;
|
||||
return startsBeforeEndDate;
|
||||
}
|
||||
|
||||
if (newAssignment.StartDate.Date > EndDate.Value.Date || newAssignment.EndDate.Value.Date < StartDate.Date)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
message = $"Assignment would overlap existing assignment to department: {newAssignment.Department.DepartmentName}";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class UserDepartmentHistory : AuditCreate
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserDepartmentId { get; set; }
|
||||
public string FieldName { get; set; }
|
||||
public string OldValue { get; set; }
|
||||
public string NewValue { get; set; }
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class UserPermission : AuditCreate
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid AppUserId { get; set; }
|
||||
public Permission Permission { get; set; }
|
||||
[JsonIgnore]
|
||||
public AppUser AppUser { get; set; }
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Common;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class UserPermissionHistory : AuditCreate
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid AppUserId { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string Permission { get; set; }
|
||||
public bool PermissionAdded { get; set; }
|
||||
public bool PermissionRemoved { get; set; }
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class UserSummary
|
||||
{
|
||||
public UserSummary()
|
||||
{
|
||||
AssociatedPayouts = new List<PayoutLineItem>();
|
||||
}
|
||||
public string AdEmail { get; set; }
|
||||
public string EmployeeId { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string? ManagerKey { get; set; }
|
||||
public DateTime? Terminated { get; set; }
|
||||
public IList<PayoutLineItem> AssociatedPayouts { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user