public void RemoveCarryOver(string fundingLineCode) { Guard.IsNullOrWhiteSpace(fundingLineCode, nameof(fundingLineCode), "Funding Line Id cannot be missing"); CarryOvers ??= new List <ProfilingCarryOver>(); CarryOvers = CarryOvers.Except(CarryOvers.Where(_ => _.FundingLineCode == fundingLineCode)) .ToList(); }
public void AddCarryOver(string fundingLineCode, ProfilingCarryOverType type, decimal amount) { Guard.IsNullOrWhiteSpace(fundingLineCode, nameof(fundingLineCode), "Funding Line Id cannot be missing"); Guard.Ensure(type != ProfilingCarryOverType.Undefined, $"Unsupported {nameof(ProfilingCarryOverType)}"); Guard.Ensure(amount > 0, "Carry overs must be greater than zero"); CarryOvers ??= new List <ProfilingCarryOver>(); CarryOvers.Add(new ProfilingCarryOver { FundingLineCode = fundingLineCode, Type = type, Amount = amount }); }
public decimal?GetCarryOverTotalForFundingLine(string fundingLineCode) => CarryOvers?.Where(_ => _.FundingLineCode == fundingLineCode).Sum(_ => _.Amount);