Adding
This commit is contained in:
+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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user