public void ExtendCoverage(DateTime effectiveDateOfChange, CoverPrice newCover) { //preconditions if (Terminated()) { throw new ApplicationException("Cannot annex terminated policy"); } var versionAtEffectiveDate = versions.EffectiveAtDate(effectiveDateOfChange); if (versionAtEffectiveDate == null) { throw new ApplicationException("No active version at given date"); } //create new version starting since effectiveDateOfChange based on versionAtEffectiveDate var annexVer = AddNewVersionBasedOn ( versionAtEffectiveDate, effectiveDateOfChange ); //add new cover annexVer.AddCover(newCover, effectiveDateOfChange, annexVer.CoverPeriod.ValidTo); }
public void AddCover(CoverPrice coverPrice, DateTime coverStart, DateTime coverEnd) { if (!IsDraft()) { throw new ApplicationException("Only draft versions can be altered"); } var cover = new PolicyCover ( Guid.NewGuid(), coverPrice.Cover, ValidityPeriod.Between(coverStart, coverEnd), coverPrice.Price, coverPrice.CoverPeriod ); covers.Add(cover); TotalPremium = RecalculateTotal(); }