Пример #1
0
 public PolicyCover EndOn(DateTime lastDateOfCover)
 {
     return(new PolicyCover
            (
                CoverCode,
                CoverPeriod.EndOn(lastDateOfCover),
                Price
            ));
 }
        public virtual PolicyVersion EndOn(DateTime endDate)
        {
            var endedCovers = this.covers.Select(c => c.EndOn(endDate)).ToList();

            var termVersion = new PolicyVersion
            {
                Policy                = this.Policy,
                VersionNumber         = this.Policy.NextVersionNumber(),
                PolicyHolder          = new PolicyHolder(PolicyHolder.FirstName, PolicyHolder.LastName, PolicyHolder.Pesel),
                CoverPeriod           = CoverPeriod.EndOn(endDate),
                VersionValidityPeriod = ValidityPeriod.Between(endDate.AddDays(1), VersionValidityPeriod.ValidTo),
                covers                = endedCovers,
                TotalPremiumAmount    = endedCovers.Sum(c => c.Premium)
            };

            return(termVersion);
        }
Пример #3
0
        public void EndPolicyOn(DateTime lastDayOfCover)
        {
            if (!IsDraft())
            {
                throw new ApplicationException("Only draft versions can be altered");
            }

            CoverPeriod = CoverPeriod.EndOn(lastDayOfCover);

            foreach (var cover in covers)
            {
                cover.EndCoverOn(lastDayOfCover);
            }

            TotalPremium = RecalculateTotal();

            PolicyStatus = PolicyStatus.Terminated;
        }
 public void EndCoverOn(DateTime lastDayOfCover)
 {
     CoverPeriod = CoverPeriod.EndOn(lastDayOfCover);
     Amount      = CalculateAmount();
 }
 public bool CoversDate(DateTime theDate) => CoverPeriod.Contains(theDate);