public void ExtendCoverage(DateTime effectiveDateOfChange, CoverPrice newCover) { if (Terminated()) { throw new ApplicationException("Cannot annex terminated policy"); } var versionAtDate = versions.EffectiveAt(effectiveDateOfChange); if (versionAtDate == null || !versionAtDate.CoversDate(effectiveDateOfChange)) { throw new ApplicationException("Policy does not cover annex date"); } if (versionAtDate.ContainsCover(newCover.CoverCode)) { throw new ApplicationException("This cover is already present"); } var newVersionNumber = versions.Count + 1; var versionPeriod = ValidityPeriod.Between(effectiveDateOfChange, versionAtDate.CoverPeriod.ValidTo); var newCoverage = PolicyCover.ForPrice(newCover, versionPeriod); ApplyChange ( new CoverageExtendedPolicyVersionCreated ( newVersionNumber, versionAtDate.VersionNumber, versionPeriod, newCoverage ) ); }
public static PolicyCover ForPrice(CoverPrice coverPrice, ValidityPeriod coverPeriod) { return(new PolicyCover ( coverPrice.CoverCode, coverPeriod, new UnitPrice(coverPrice.Price, coverPrice.CoverPeriod) )); }