private PolicyVersion AddNewVersionBasedOn(PolicyVersion versionAtEffectiveDate, DateTime effectiveDateOfChange) { var newVersion = new PolicyVersion ( versionAtEffectiveDate, versions.MaxVersionNumber() + 1, effectiveDateOfChange ); versions.Add(newVersion); return(newVersion); }
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(); }
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(); }
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); }
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(); }
public static PolicyVersionComparer Of(PolicyVersion newVersion, PolicyVersion oldVersion) { return(new PolicyVersionComparer(newVersion, oldVersion)); }
public PolicyVersionComparer(PolicyVersion newVersion, PolicyVersion oldVersion) { this.newVersion = newVersion; this.oldVersion = oldVersion; }