Last active
August 29, 2015 14:08
-
-
Save dustyhoppe/266822492187c902e653 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static decimal AdjustedFee(this Entities.Placement p, AccountFeeCalculation feeCalculations) | |
| { | |
| if (p.PlacementType == Contracts.PlacementType.Permanent.ToString() || p.RateType == FeeRateType.FixedFee.ToString()) | |
| { | |
| return p.PermanentFee; | |
| } | |
| else | |
| { | |
| decimal timeUnit = p.ContractTimePerWeek; | |
| decimal marginRate = 0.0m; | |
| MarginType marginType = MarginType.NetMargin; | |
| PeriodLengthType lengthType = PeriodLengthType.LengthOfPlacement; | |
| if (p.RateType == Contracts.ContractPlacementRateType.Daily.ToString()) | |
| { | |
| marginType = feeCalculations.DailyMarginType; | |
| lengthType = feeCalculations.DailyPeriodLength; | |
| } | |
| else if (p.RateType == Contracts.ContractPlacementRateType.Hourly.ToString()) | |
| { | |
| marginType = feeCalculations.HourlyMarginType; | |
| lengthType = feeCalculations.HourlyPeriodLength; | |
| } | |
| switch (marginType) | |
| { | |
| case MarginType.NetMargin: | |
| marginRate = p.ContractNetMargin; | |
| break; | |
| case MarginType.ClientRate: | |
| marginRate = p.ContractClientRate; | |
| break; | |
| case MarginType.CandidateRate: | |
| marginRate = p.ContractCandidateRate; | |
| break; | |
| } | |
| switch (lengthType) | |
| { | |
| case PeriodLengthType.Week: | |
| return marginRate * timeUnit; | |
| case PeriodLengthType.Month: | |
| return marginRate * timeUnit * (decimal)(DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) / 7); | |
| case PeriodLengthType.LengthOfPlacement: | |
| return (p.EndDate.HasValue && p.StartDate.HasValue ? marginRate * timeUnit * (decimal)((p.EndDate.Value - p.StartDate.Value).TotalDays / 7) : 0); | |
| } | |
| return 0.0m; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment