public PolicyVersion ( Guid id, int versionNumber, ValidityPeriod versionValidityPeriod, PolicyStatus policyStatus, ValidityPeriod coverPeriod, Person policyHolder, Person driver, Car car, Money totalPremium, IEnumerable <CoverPrice> coverPrices ) { Id = id; VersionNumber = versionNumber; BaseVersionNumber = null; VersionStatus = PolicyVersionStatus.Draft; VersionValidityPeriod = versionValidityPeriod; PolicyStatus = policyStatus; CoverPeriod = coverPeriod; PolicyHolder = policyHolder; Driver = driver; Car = car; TotalPremium = totalPremium; //TODO: check against covers? foreach (var coverPrice in coverPrices) { AddCover(coverPrice, versionValidityPeriod.ValidFrom, versionValidityPeriod.ValidTo); } }
public PolicyCover(Guid id, Cover cover, ValidityPeriod coverPeriod, Money price, TimeSpan pricePeriod) { Id = id; Cover = cover; CoverPeriod = coverPeriod; Price = price; PricePeriod = pricePeriod; Amount = CalculateAmount(); }
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 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(); }
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(); }