Example #1
0
        private PolicyVersion AddNewVersionBasedOn(PolicyVersion versionAtEffectiveDate, DateTime effectiveDateOfChange)
        {
            var newVersion = new PolicyVersion
                             (
                versionAtEffectiveDate,
                versions.MaxVersionNumber() + 1,
                effectiveDateOfChange
                             );

            versions.Add(newVersion);
            return(newVersion);
        }
Example #2
0
        public void CancelLastAnnex()
        {
            var lastActiveVer = versions.LatestActive();

            if (lastActiveVer.VersionNumber == 1)
            {
                throw new ApplicationException("There are no annexed left to cancel");
            }

            lastActiveVer.Cancel();

            //WARNING: Added to support queries
            CurrentVersion = Versions.LatestActive();
        }
Example #3
0
        public void ConfirmChanges(int versionToConfirmNumber)
        {
            //ensure version with number is draft and there are no drafts
            var versionToConfirm = versions.WithNumber(versionToConfirmNumber);

            if (versionToConfirm == null)
            {
                throw new ApplicationException("Version not found");
            }

            versionToConfirm.Confirm();

            //WARNING: Added to support queries
            CurrentVersion = Versions.LatestActive();
        }
Example #4
0
        private void AddFirstVersion(Offer offer, DateTime purchaseDate, DateTime policyStartDate)
        {
            var ver = new PolicyVersion
                      (
                Guid.NewGuid(),
                1,
                ValidityPeriod.Between(policyStartDate, policyStartDate.Add(offer.CoverPeriod)),
                PolicyStatus.Active,
                ValidityPeriod.Between(policyStartDate, policyStartDate.Add(offer.CoverPeriod)),
                offer.Customer.Copy(),
                offer.Driver.Copy(),
                offer.Car.Copy(),
                offer.TotalCost,
                offer.Covers
                      );

            versions.Add(ver);
        }
Example #5
0
        public PolicyVersion
        (
            PolicyVersion baseVersion,
            int versionNumber,
            DateTime startDate
        )
        {
            Id                    = Guid.NewGuid();
            VersionNumber         = versionNumber;
            BaseVersionNumber     = baseVersion.VersionNumber;
            VersionValidityPeriod = ValidityPeriod.Between(startDate, baseVersion.CoverPeriod.ValidTo);
            PolicyStatus          = baseVersion.PolicyStatus;
            CoverPeriod           = ValidityPeriod.Between(baseVersion.CoverPeriod.ValidFrom, baseVersion.CoverPeriod.ValidTo);
            PolicyHolder          = baseVersion.PolicyHolder.Copy();
            Driver                = baseVersion.Driver.Copy();
            Car                   = baseVersion.Car.Copy();
            foreach (var oldCover in baseVersion.covers)
            {
                covers.Add(oldCover);
            }

            TotalPremium = RecalculateTotal();
        }
Example #6
0
 public static PolicyVersionComparer Of(PolicyVersion newVersion, PolicyVersion oldVersion)
 {
     return(new PolicyVersionComparer(newVersion, oldVersion));
 }
Example #7
0
 public PolicyVersionComparer(PolicyVersion newVersion, PolicyVersion oldVersion)
 {
     this.newVersion = newVersion;
     this.oldVersion = oldVersion;
 }