public RiskData(Risk risk, DateTime validFrom, DateTime validTill, decimal price)
 {
     Risk      = risk;
     ValidFrom = validFrom;
     ValidTill = validTill;
     Price     = price;
 }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 private RiskData CreateRiskData(Risk risk, DateTime from, DateTime till)
 {
     return(new RiskData(risk, from, till, _premiumCalculator.Calculate(risk, from, till)));
 }