public RiskData(Risk risk, DateTime validFrom, DateTime validTill, decimal price) { Risk = risk; ValidFrom = validFrom; ValidTill = validTill; Price = price; }
public decimal Calculate(Risk risk, DateTime validFrom, DateTime validTo) { var riskMonthlyPrice = risk.YearlyPrice / 12; var monthsValid = (validTo.Year - validFrom.Year) * 12 + validTo.Month - validFrom.Month; var riskPriceForPeriod = riskMonthlyPrice * monthsValid; return(Math.Round(riskPriceForPeriod, 2)); }
public void AddRisk(string nameOfInsuredObject, Risk risk, DateTime validFrom) { if (validFrom < DateTime.Now) { throw new TimeNotValidException("Risk starting time cannot be retroactive."); } var policy = GetPolicy(nameOfInsuredObject, validFrom); _policies[policy].Add(CreateRiskData(risk, validFrom, policy.ValidTill)); }
private RiskData CreateRiskData(Risk risk, DateTime from, DateTime till) { return(new RiskData(risk, from, till, _premiumCalculator.Calculate(risk, from, till))); }