コード例 #1
0
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value is string)
            {
                string        policyVersion = (string)value;
                PolicyVersion retval        = null;
                switch (policyVersion)
                {
                case ConfigurationStrings.Policy12:
                    retval = PolicyVersion.Policy12;
                    break;

                case ConfigurationStrings.Policy15:
                    retval = PolicyVersion.Policy15;
                    break;

                case ConfigurationStrings.Default:
                    retval = PolicyVersion.Default;
                    break;

                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value",
                                                                                                              SR.GetString(SR.ConfigInvalidClassFactoryValue, policyVersion, typeof(PolicyVersion).FullName)));
                }
                return(retval);
            }
            return(base.ConvertFrom(context, culture, value));
        }
コード例 #2
0
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (typeof(string) == destinationType && value is PolicyVersion)
     {
         string        retval        = null;
         PolicyVersion policyVersion = (PolicyVersion)value;
         if (policyVersion == PolicyVersion.Default)
         {
             retval = ConfigurationStrings.Default;
         }
         else if (policyVersion == PolicyVersion.Policy12)
         {
             retval = ConfigurationStrings.Policy12;
         }
         else if (policyVersion == PolicyVersion.Policy15)
         {
             retval = ConfigurationStrings.Policy15;
         }
         else
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value",
                                                                                                       SR.GetString(SR.ConfigInvalidClassInstanceValue, typeof(PolicyVersion).FullName)));
         }
         return(retval);
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
コード例 #3
0
        public PolicyTerminationResult Terminate(Policy policy, DateTime terminationDate)
        {
            //ensure is not already terminated
            if (policy.PolicyStatusId != (int)Enum.PolicyStatus.Active)
            {
                throw new ApplicationException($"Policy {policy.Number} is already terminated");
            }

            //get version valid at term date
            PolicyVersion versionAtTerminationDate = EffectiveOn(policy.PolicyVersions, terminationDate);

            if (versionAtTerminationDate == null)
            {
                throw new ApplicationException($"No valid policy {policy.Number} version exists at {terminationDate}. Policy cannot be terminated.");
            }

            if (!versionAtTerminationDate.CoverPeriodPolicyValidityPeriod.Contains(terminationDate))
            {
                throw new ApplicationException($"Policy {policy.Number} does not cover {terminationDate}. Policy cannot be terminated at this date.");
            }

            //create terminal version
            policy.PolicyVersions.Add(PolicyVersionEndOn(versionAtTerminationDate, terminationDate));

            //change status
            policy.PolicyStatusId = (int)Enum.PolicyStatus.Terminated;

            //return term version
            var terminalVersion = LastVersion(policy.PolicyVersions);

            return(new PolicyTerminationResult(terminalVersion, versionAtTerminationDate.TotalPremiumAmount - terminalVersion.TotalPremiumAmount));
        }
コード例 #4
0
        private void UpdatePolicyVersionDefaultValues(LocalPluginContext context)
        {
            var target           = context.PluginExecutionContext.InputParameters["Target"] as Entity;
            var policyVersion    = new PolicyVersion(context.OrganizationService, context.TracingService, target);
            var excess           = policyVersion.Excess;
            var limitOfIndemnity = policyVersion.LimitOfIndemnity;
            var product          = policyVersion.Product;

            if (product != null)
            {
                var limitOfIndemnityProduct = product.ProductDefaultLOI;
                var excessProduct           = product.ProductDefaultExcess;
                var updatePolicyVersion     = new Entity(policyVersion.LogicalName);
                updatePolicyVersion.Id = policyVersion.Id;
                if (limitOfIndemnity == null)
                {
                    updatePolicyVersion["new_limitofindemnity"] = limitOfIndemnityProduct;
                }
                if (excess == null)
                {
                    updatePolicyVersion["new_excess"] = excessProduct;
                }
                context.OrganizationService.Update(updatePolicyVersion);
            }
        }
コード例 #5
0
        public override PolicyConfigBase ConvertFromStorage(ExPolicyConfigProvider provider, UnifiedPolicyStorageBase storageObject)
        {
            ArgumentValidator.ThrowIfNull("provider", provider);
            ArgumentValidator.ThrowIfNull("storageObject", storageObject);
            PolicyConfigBase policyConfigBase = provider.NewBlankConfigInstance <TPolicyConfig>();

            if (!provider.ReadOnly)
            {
                policyConfigBase.RawObject = storageObject;
            }
            Guid identity = storageObject.Guid;

            if (!ExPolicyConfigProvider.IsFFOOnline)
            {
                identity = storageObject.MasterIdentity;
            }
            policyConfigBase.Identity       = identity;
            policyConfigBase.Name           = storageObject.Name;
            policyConfigBase.Version        = PolicyVersion.Create(storageObject.PolicyVersion);
            policyConfigBase.Workload       = storageObject.Workload;
            policyConfigBase.WhenChangedUTC = storageObject.WhenChangedUTC;
            policyConfigBase.WhenCreatedUTC = storageObject.WhenChangedUTC;
            this.copyPropertiesToPolicyConfigDelegate((TPolicyStorage)((object)storageObject), (TPolicyConfig)((object)policyConfigBase));
            policyConfigBase.ResetChangeTracking();
            return(policyConfigBase);
        }
コード例 #6
0
        public void UpdatePolicyInfoDto(Policy policy, PolicyVersion currentVersion)
        {
            using (var cn = new NpgsqlConnection(cnString))
            {
                var policyInfo = new PolicyInfoDto
                {
                    PolicyId           = policy.Id,
                    CoverFrom          = currentVersion.CoverPeriod.ValidFrom,
                    CoverTo            = currentVersion.CoverPeriod.ValidTo,
                    PolicyHolder       = $"{currentVersion.PolicyHolder.LastName} {currentVersion.PolicyHolder.FirstName}",
                    Vehicle            = $"{currentVersion.Car.PlateNumber} {currentVersion.Car.Make}",
                    TotalPremiumAmount = currentVersion.TotalPremium.Amount
                };


                cn.Open();
                cn.Execute(
                    "UPDATE public.policy_info_view " +
                    "SET " +
                    "cover_from = @CoverFrom, " +
                    "cover_to = @CoverTo, " +
                    "vehicle = @Vehicle, " +
                    "policy_holder = @PolicyHolder, " +
                    "total_premium = @TotalPremiumAmount " +
                    "WHERE policy_id = @PolicyId ",
                    policyInfo);
            }
        }
コード例 #7
0
        /// <summary>
        /// Checks if policy version needs to get insured risks created.
        /// </summary>
        /// <param name="policyVersion"></param>
        /// <returns></returns>
        private bool CheckIfCreatingInsuredRisks(PolicyVersion policyVersion)
        {
            ThrowIf.Argument.IsNull(policyVersion, "policyVersion");

            // all initialization of policies created by portal is managed by portal itself
            if (policyVersion.InputChannel == PolicyInputChannel.Portal)
            {
                return(false);
            }

            // all new policies and renewals need to get insured risks created
            if (policyVersion.TransactionType == PolicyVersionTransactionType.NewPolicy ||
                policyVersion.TransactionType == PolicyVersionTransactionType.Renewal)
            {
                return(true);
            }

            // cancellations for Bordereau are a special case, which needs same initialization as in new policy versions
            if (policyVersion.TransactionType == PolicyVersionTransactionType.Cancellation &&
                policyVersion.InputChannel == PolicyInputChannel.Import)
            {
                return(true);
            }

            return(false);
        }
コード例 #8
0
        public void CreatePolicyVersionDtoProjection(Policy policy, PolicyVersion policyVersion)
        {
            using (var cn = new NpgsqlConnection(cnString))
            {
                cn.Open();
                using (var tx = cn.BeginTransaction())
                {
                    cn.Execute
                    (
                        "insert into policy_version_view " +
                        "(policy_version_id, policy_id,policy_number,product_code,version_number," +
                        "version_status,policy_status,policy_holder,insured,car," +
                        "cover_from,cover_to,version_from,version_to,total_premium) " +
                        "values (@PolicyVersionId, @PolicyId, @PolicyNumber,@ProductCode,@VersionNumber," +
                        "@VersionStatus,@PolicyStatus,@PolicyHolder,@Insured,@Car," +
                        "@CoverFrom,@CoverTo,@VersionFrom,@VersionTo,@TotalPremium)",
                        new
                    {
                        PolicyVersionId = policyVersion.Id,
                        PolicyId        = policy.Id,
                        PolicyNumber    = policy.Number,
                        ProductCode     = policy.ProductCode,
                        VersionNumber   = policyVersion.VersionNumber,
                        VersionStatus   = policyVersion.VersionStatus.ToString(),
                        PolicyStatus    = policyVersion.PolicyStatus.ToString(),
                        PolicyHolder    = $"{policyVersion.PolicyHolder.LastName} {policyVersion.PolicyHolder.FirstName} {policyVersion.PolicyHolder.TaxId}",
                        Insured         = "",
                        Car             = $"{policyVersion.Car.PlateNumber} {policyVersion.Car.Make} {policyVersion.Car.ProductionYear}",
                        CoverFrom       = policyVersion.CoverPeriod.ValidFrom,
                        CoverTo         = policyVersion.CoverPeriod.ValidTo,
                        VersionFrom     = policyVersion.VersionValidityPeriod.ValidFrom,
                        VersionTo       = policyVersion.VersionValidityPeriod.ValidTo,
                        TotalPremium    = policyVersion.TotalPremium.Amount
                    }
                    );

                    foreach (var cover in policyVersion.Covers)
                    {
                        cn.Execute
                        (
                            "insert into policy_version_cover " +
                            "(policy_version_cover_id,policy_version_id,code,cover_from,cover_to,premium_amount)" +
                            "values " +
                            "(@PolicyVersionCoverId,@PolicyVersionId,@Code,@CoverFrom,@CoverTo,@PremiumAmount)",
                            new
                        {
                            PolicyVersionCoverId = Guid.NewGuid(),
                            PolicyVersionId      = policyVersion.Id,
                            Code          = cover.CoverCode,
                            CoverFrom     = cover.CoverPeriod.ValidFrom,
                            CoverTo       = cover.CoverPeriod.ValidTo,
                            PremiumAmount = cover.Amount.Amount
                        }
                        );
                    }

                    tx.Commit();
                }
            }
        }
コード例 #9
0
        public void Create_Update_Delete_Policy()
        {
            var newPolicy = new PolicyVersion
            {
                name        = testData.Policyname,
                description = testData.Policydescription,
                sca_blacklist_grace_period = testData.Policysca_blacklist_grace_period,
                score_grace_period         = testData.Policyscore_grace_period,
                sev0_grace_period          = testData.Policysev0_grace_period,
                sev1_grace_period          = testData.Policysev1_grace_period,
                sev2_grace_period          = testData.Policysev2_grace_period,
                sev3_grace_period          = testData.Policysev3_grace_period,
                sev4_grace_period          = testData.Policysev4_grace_period,
                sev5_grace_period          = testData.Policysev5_grace_period,
                type                 = testData.Policytype,
                vendor_policy        = testData.Policyvendor_policy,
                scan_frequency_rules = new List <ScanFrequencyRule>(),
                finding_rules        = new List <FindingRule>()
            };

            var policy = _repo.CreatePolicy(newPolicy);

            Assert.IsNotNull(policy);

            policy.name = testData.Policynameupdated;
            _           = _repo.UpdatePolicy(policy, policy.guid);

            var retrievedPolicy = _repo.GetPolicies().SingleOrDefault(x => x.name.Contains(testData.Policynameupdated));

            Assert.AreEqual(testData.Policynameupdated, retrievedPolicy.name);

            var deleted = _repo.DeletePolicy(policy.guid).SingleOrDefault(x => x.name.Contains(testData.Policynameupdated));

            Assert.IsNull(deleted);
        }
コード例 #10
0
        private static XmlElement CreatePolicyElement(PolicyVersion policyVersion, XmlDocument doc)
        {
            string localName    = "Policy";
            string namespaceURI = policyVersion.Namespace;
            string prefix       = "wsp";

            return(doc.CreateElement(prefix, localName, namespaceURI));
        }
コード例 #11
0
        private static XmlElement CreatePolicyElement(PolicyVersion policyVersion, XmlDocument doc)
        {
            string policy       = MetadataStrings.WSPolicy.Elements.Policy;
            string policyNs     = policyVersion.Namespace;
            string policyPrefix = MetadataStrings.WSPolicy.Prefix;

            return(doc.CreateElement(policyPrefix, policy, policyNs));
        }
コード例 #12
0
        private XmlElement CreateReliabilityAssertion(PolicyVersion policyVersion, BindingElementCollection bindingElements)
        {
            string      str;
            string      str2;
            string      str3;
            string      str4;
            XmlDocument doc          = new XmlDocument();
            XmlElement  childElement = null;

            if (this.ReliableMessagingVersion == System.ServiceModel.ReliableMessagingVersion.WSReliableMessagingFebruary2005)
            {
                str  = "wsrm";
                str2 = "http://schemas.xmlsoap.org/ws/2005/02/rm/policy";
                str3 = str;
                str4 = str2;
            }
            else
            {
                str  = "wsrmp";
                str2 = "http://docs.oasis-open.org/ws-rx/wsrmp/200702";
                str3 = "netrmp";
                str4 = "http://schemas.microsoft.com/ws-rx/wsrmp/200702";
            }
            XmlElement element2 = doc.CreateElement(str, "RMAssertion", str2);

            if (this.ReliableMessagingVersion == System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11)
            {
                XmlElement newChild = CreatePolicyElement(policyVersion, doc);
                if (IsSecureConversationEnabled(bindingElements))
                {
                    XmlElement element4 = doc.CreateElement(str, "SequenceSTR", str2);
                    newChild.AppendChild(element4);
                }
                XmlElement element5 = doc.CreateElement(str, "DeliveryAssurance", str2);
                XmlElement element6 = CreatePolicyElement(policyVersion, doc);
                XmlElement element7 = doc.CreateElement(str, "ExactlyOnce", str2);
                element6.AppendChild(element7);
                if (this.ordered)
                {
                    XmlElement element8 = doc.CreateElement(str, "InOrder", str2);
                    element6.AppendChild(element8);
                }
                element5.AppendChild(element6);
                newChild.AppendChild(element5);
                element2.AppendChild(newChild);
            }
            childElement = doc.CreateElement(str3, "InactivityTimeout", str4);
            WriteMillisecondsAttribute(childElement, this.InactivityTimeout);
            element2.AppendChild(childElement);
            childElement = doc.CreateElement(str3, "AcknowledgementInterval", str4);
            WriteMillisecondsAttribute(childElement, this.AcknowledgementInterval);
            element2.AppendChild(childElement);
            return(element2);
        }
コード例 #13
0
        private static PolicyBindingConfig ToBindingScope(ScopeStorage storageScope)
        {
            PolicyBindingConfig policyBindingConfig = new PolicyBindingConfig();

            policyBindingConfig.Identity = (ExPolicyConfigProvider.IsFFOOnline ? storageScope.Guid : storageScope.MasterIdentity);
            policyBindingConfig.Name     = storageScope.Name;
            policyBindingConfig.Mode     = storageScope.Mode;
            policyBindingConfig.Scope    = BindingMetadata.FromStorage(storageScope.Scope);
            policyBindingConfig.Version  = PolicyVersion.Create(storageScope.PolicyVersion);
            policyBindingConfig.ResetChangeTracking();
            return(policyBindingConfig);
        }
コード例 #14
0
 public static PolicyInfoDto AssemblePolicyInfoDto(Policy policy, PolicyVersion policyVersion)
 {
     return(new PolicyInfoDto
     {
         PolicyId = policy.Id,
         PolicyNumber = policy.Number,
         CoverFrom = policyVersion.CoverPeriod.ValidFrom,
         CoverTo = policyVersion.CoverPeriod.ValidTo,
         Vehicle = AssembleVehicleDescription(policyVersion.Car),
         PolicyHolder = AssemblePolicyHolderDescription(policyVersion.PolicyHolder),
         TotalPremiumAmount = policyVersion.TotalPremium.Amount
     });
 }
コード例 #15
0
        protected static string GetClientInfoIdentifier(IEnumerable <SyncChangeInfo> syncChangeInfos)
        {
            Guid guid = Guid.NewGuid();

            if (syncChangeInfos != null && syncChangeInfos.Any <SyncChangeInfo>())
            {
                PolicyVersion version = syncChangeInfos.First <SyncChangeInfo>().Version;
                if (version != null)
                {
                    guid = version.InternalStorage;
                }
            }
            return(string.Format("{0}:{1}", guid.ToString(), CompliancePolicySyncNotificationClient.clientInfo));
        }
コード例 #16
0
        private static List <string> AssembleChanges(Policy policy, PolicyVersion version)
        {
            if (!version.BaseVersionNumber.HasValue)
            {
                return new List <string>()
                       {
                       }
            }
            ;

            var baseVersion = policy.Versions.WithNumber(version.BaseVersionNumber.Value);

            return(PolicyVersionComparer.Of(version, baseVersion).Compare());
        }
    }
コード例 #17
0
 public static PolicyVersionDto MapPolicyVersionToPolicyVersionDto(PolicyVersion policyVersion)
 {
     return(new PolicyVersionDto()
     {
         PolicyNumber = policyVersion.PolicyNumber,
         PolicyHolder = PolicyHolderMapper.MapPolicyHolderToPersonDto(policyVersion.PolicyHolder),
         PolicyFrom = policyVersion.PolicyFrom,
         PolicyStatus = policyVersion.PolicyStatus,
         PolicyTo = policyVersion.PolicyTo,
         ProductCode = policyVersion.ProductCode,
         TotalPremium = policyVersion.TotalPremium,
         VersionFrom = policyVersion.VersionFrom,
         VersionNumber = policyVersion.VersionNumber,
         VersionTo = policyVersion.VersionTo
     });
 }
コード例 #18
0
 public void UpdatePolicyVersionDtoProjection(PolicyVersion policyVersion)
 {
     using (var cn = new NpgsqlConnection(cnString))
     {
         cn.Execute
         (
             "update policy_version_view " +
             "set version_status = @PolicyVersionStatus " +
             "where policy_version_id = @PolicyVersionId",
             new
         {
             PolicyVersionId     = policyVersion.Id,
             PolicyVersionStatus = policyVersion.VersionStatus.ToString()
         }
         );
     }
 }
コード例 #19
0
        /// <summary>
        /// Creates insured risks for new/renewal policy version
        /// </summary>
        /// <param name="context"></param>
        private void CreateInsuredRisksForPolicyVersion(LocalPluginContext context)
        {
            var postImage     = context.PostImage;
            var policyVersion = new PolicyVersion(context.OrganizationService, context.TracingService, postImage);

            // check if policy needs to be initialized with all insured risks and covers
            if (!CheckIfCreatingInsuredRisks(policyVersion))
            {
                return;
            }

            var product    = policyVersion.Product;
            var firstCover = product.Covers.FirstOrDefault();

            foreach (var risk in product.Risks)
            {
                // create only risk objects with minimum > 0
                if (risk.MinimumNumberOfRisks <= 0)
                {
                    continue;
                }

                var insuredRisk = new Entity("new_insuredrisk");
                insuredRisk["new_product"]  = product.EntityReference;
                insuredRisk["new_policyid"] = policyVersion.EntityReference;

                if (risk.RiskClassRef != null)
                {
                    insuredRisk["new_riskclassid"] = risk.RiskClassRef;
                }

                if (risk.RiskSubClassRef != null)
                {
                    insuredRisk["new_secondlevelriskclass"] = risk.RiskSubClassRef;
                }

                insuredRisk["new_riskid"] = risk.EntityReference;

                context.OrganizationService.Create(insuredRisk);
            }

            // trigger recalculation of totals on policy version
            //var triggerPolicy = new Entity(postImage.LogicalName) { Id = postImage.Id };
            //triggerPolicy["new_recalc"] = true;
            //context.OrganizationService.Update(triggerPolicy);
        }
コード例 #20
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            PolicyVersion policy = (PolicyVersion)value;

            if (policy == PolicyVersion.Policy12)
            {
                return("Policy12");
            }
            else if (policy == PolicyVersion.Policy15)
            {
                return("Policy15");
            }
            else
            {
                return("Default");
            }
        }
コード例 #21
0
        public PolicyVersion PolicyVersionEndOn(PolicyVersion policyVersion, DateTime endDate)
        {
            var endedCovers = policyVersion.PolicyCovers.Select(c => PolicyCoverEndOn(c, endDate)).ToList();

            var termVersion = new PolicyVersion
            {
                Policy        = policyVersion.Policy,
                VersionNumber = NextVersionNumber(policyVersion.Policy.PolicyVersions.ToList()),
                PolicyHolder  = new PolicyHolder(policyVersion.PolicyHolder.FirstName, policyVersion.PolicyHolder.LastName, policyVersion.PolicyHolder.Pesel, policyVersion.PolicyHolder.Address),
                CoverPeriodPolicyValidityPeriod           = PolicyValidityPeriodEndOn(policyVersion.CoverPeriodPolicyValidityPeriod, endDate),
                VersionValidityPeriodPolicyValidityPeriod = PolicyValidityPeriodBetween(endDate.AddDays(1), policyVersion.VersionValidityPeriodPolicyValidityPeriod.PolicyTo),
                PolicyCovers       = endedCovers,
                TotalPremiumAmount = endedCovers.Sum(c => c.Premium)
            };

            return(termVersion);
        }
コード例 #22
0
        private static void CopyPropertiesFromStorage <T>(T baseConfiguration, FacadeBase storage) where T : PolicyConfigurationBase
        {
            baseConfiguration.Name           = (string)storage.InnerPropertyBag[ADObjectSchema.Name];
            baseConfiguration.Workload       = (Workload)storage.InnerPropertyBag[UnifiedPolicyStorageBaseSchema.WorkloadProp];
            baseConfiguration.WhenCreatedUTC = (DateTime?)storage.InnerPropertyBag[ADObjectSchema.WhenCreatedUTC];
            baseConfiguration.WhenChangedUTC = (DateTime?)storage.InnerPropertyBag[ADObjectSchema.WhenChangedUTC];
            baseConfiguration.ChangeType     = ((storage.InnerConfigurable.ObjectState == ObjectState.Deleted) ? ChangeType.Delete : ChangeType.Update);
            baseConfiguration.Version        = PolicyVersion.Create((Guid)storage.InnerPropertyBag[UnifiedPolicyStorageBaseSchema.PolicyVersion]);
            IEnumerable <PropertyInfo> reflectedProperties = UnifiedPolicyStorageFactory.GetReflectedProperties <T>();

            UnifiedPolicyStorageFactory.InitializeIncrementalAttributes(baseConfiguration, reflectedProperties);
            IEnumerable <PropertyDefinition> propertyDefinitions = DalHelper.GetPropertyDefinitions(storage, false);

            using (IEnumerator <PropertyDefinition> enumerator = propertyDefinitions.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    PropertyDefinition property = enumerator.Current;
                    object             propertyValue;
                    if (UnifiedPolicyStorageFactory.TryReadPropertyValue(storage, property, out propertyValue))
                    {
                        PropertyInfo propertyInfo = reflectedProperties.FirstOrDefault((PropertyInfo p) => UnifiedPolicyStorageFactory.PropertiesMatch(property, p));
                        if (!(propertyInfo == null) && !UnifiedPolicyStorageFactory.IsIncrementalCollection(propertyInfo))
                        {
                            UnifiedPolicyStorageFactory.CopyPropertyFromStorage(propertyInfo, propertyValue, baseConfiguration);
                        }
                    }
                }
            }
            using (IEnumerator <PropertyInfo> enumerator2 = (from p in reflectedProperties
                                                             where UnifiedPolicyStorageFactory.IsIncrementalCollection(p)
                                                             select p).GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    UnifiedPolicyStorageFactory.< > c__DisplayClassf <T> CS$ < > 8__locals2 = new UnifiedPolicyStorageFactory.< > c__DisplayClassf <T>();
                    CS$ < > 8__locals2.incrementalCollectionProp = enumerator2.Current;
                    PropertyDefinition addedProperty      = propertyDefinitions.FirstOrDefault((PropertyDefinition p) => UnifiedPolicyStorageFactory.PropertiesMatch(p, CS$ < > 8__locals2.incrementalCollectionProp));
                    PropertyDefinition propertyDefinition = propertyDefinitions.FirstOrDefault((PropertyDefinition p) => p.Name == UnifiedPolicyStorageFactory.GetRemovedCollectionPropertyName(addedProperty));
                    if (addedProperty != null && propertyDefinition != null)
                    {
                        UnifiedPolicyStorageFactory.CopyIncrementalCollection(CS$ < > 8__locals2.incrementalCollectionProp, addedProperty, propertyDefinition, storage, baseConfiguration);
                    }
                }
            }
        }
コード例 #23
0
        // Document that this also processes address!
        public void AddRiskToPolicy(Entity policyVersion, Entity riskEntity, string lookupName)
        {
            var policyVersionWrapped = new PolicyVersion(_svc, _trace, policyVersion);
            // == scenarios ==
            // 1. first risk object
            //   - find all insured risks with risk obj. empty, set current risk entity
            // 2. additional risk object - !!!not implemented at the moment !!!
            //   - create insured risk for every risk object of product, add risk entity to them

            var insuredRisks = policyVersionWrapped.InsuredRisks;

            if (insuredRisks.All(ir => ir.RiskEntityRef == null))
            {
                var insuredRiskAddress = _svc.ProcessAddress(_attrs.ForEntity("new_address").ForAddressOf(AddressOf.InsuredRisk), _defaults.Country);

                EntityReference addressRef = null;
                if (insuredRiskAddress != null && insuredRiskAddress.Address != null)
                {
                    // empty GUID -> address record not created yet
                    if (insuredRiskAddress.Address.Id == Guid.Empty)
                    {
                        insuredRiskAddress.Address.Id = _svc.Create(insuredRiskAddress.Address);
                    }

                    addressRef = insuredRiskAddress.Address.ToEntityReference();
                }

                foreach (var ir in insuredRisks)
                {
                    var updatedInsuredRisk = new Entity(ir.LogicalName)
                    {
                        Id = ir.Id
                    };
                    updatedInsuredRisk[lookupName] = riskEntity.ToEntityReference();

                    if (insuredRiskAddress != null)
                    {
                        updatedInsuredRisk["new_country"]    = insuredRiskAddress.Country;
                        updatedInsuredRisk["new_postalcode"] = insuredRiskAddress.PostalCode;
                        updatedInsuredRisk["new_address"]    = addressRef;
                    }

                    _svc.Update(updatedInsuredRisk);
                }
            }
        }
コード例 #24
0
        public void AddPolicies()
        {
            if (!_dbContext.PolicyVersions.Any())
            {
                var policy = new PolicyVersion
                {
                    PolicyId   = 1,
                    PolicyFrom = new DateTime(2019, 1, 1),
                    PolicyTo   = new DateTime(2019, 12, 31),
                    Insureds   = new List <Insured>()
                    {
                        new Insured {
                            InsuredId = 1
                        },
                        new Insured {
                            InsuredId = 2
                        }
                    },
                    CoveredServices = new List <CoveredService>()
                    {
                        new CoveredService
                        {
                            ServiceCode = "KONS_INTERNISTA",
                            CoPayment   = new PercentCoPayment(0.1m),
                            Limit       = new AmountLimit(1000m, new PolicyYearLimitPeriod(), false)
                        },
                        new CoveredService
                        {
                            ServiceCode = "KONS_LARYNGOLOG",
                            CoPayment   = new PercentCoPayment(0.1m),
                            Limit       = new AmountLimit(1200m, new CalendarYearLimitPeriod(), true)
                        },
                        new CoveredService
                        {
                            ServiceCode = "KONS_GASTROLOG",
                            CoPayment   = null,
                            Limit       = new AmountLimit(500m, new PerCaseLimitPeriod(), false)
                        },
                    }
                };

                _dbContext.PolicyVersions.Add(policy);
            }

            _dbContext.SaveChanges();
        }
コード例 #25
0
        /// <summary>
        /// Fixes a missing policy version number on insured risks. Policy version might get auto-numbered after
        /// it's created, then we have to update insured risk name as well.
        /// </summary>
        /// <param name="ctx"></param>
        protected void FixInsuredRiskNameOnChangePolicyVersion(LocalPluginContext context)
        {
            var target    = context.PluginExecutionContext.InputParameters["Target"] as Entity;
            var postImage = context.PostImage;

            // only execute when name changes
            if (!target.Contains("new_name"))
            {
                return;
            }

            var policyNumber = target.GetAttributeValue <string>("new_name");

            // if there's nothing in a name, do nothing
            if (string.IsNullOrWhiteSpace(policyNumber))
            {
                return;
            }

            var policyVersion = new PolicyVersion(context.OrganizationService, context.TracingService, postImage);

            var insuredRisks = policyVersion.InsuredRisks;

            foreach (var insRisk in insuredRisks)
            {
                var insRiskName = insRisk.Entity.GetAttributeValue <string>("new_name");

                // name already starts with policy number, no need to update it
                if (insRiskName.StartsWith(policyNumber))
                {
                    continue;
                }

                // in this case, insured risk is missing policy number
                if (insRiskName.StartsWith(" - "))
                {
                    var updatedInsRisk = new Entity(insRisk.LogicalName)
                    {
                        Id = insRisk.Id
                    };
                    updatedInsRisk["new_name"] = policyNumber + insRiskName;
                    context.OrganizationService.Update(updatedInsRisk);
                }
            }
        }
コード例 #26
0
        public override void CopyFrom(ServiceModelExtensionElement from)
        {
            base.CopyFrom(from);

            ServiceMetadataPublishingElement source = (ServiceMetadataPublishingElement)from;

#pragma warning suppress 56506 //Microsoft; base.CopyFrom() check for 'from' being null
            this.HttpGetEnabled               = source.HttpGetEnabled;
            this.HttpGetUrl                   = source.HttpGetUrl;
            this.HttpsGetEnabled              = source.HttpsGetEnabled;
            this.HttpsGetUrl                  = source.HttpsGetUrl;
            this.ExternalMetadataLocation     = source.ExternalMetadataLocation;
            this.PolicyVersion                = source.PolicyVersion;
            this.HttpGetBinding               = source.HttpGetBinding;
            this.HttpGetBindingConfiguration  = source.HttpGetBindingConfiguration;
            this.HttpsGetBinding              = source.HttpsGetBinding;
            this.HttpsGetBindingConfiguration = source.HttpsGetBindingConfiguration;
        }
コード例 #27
0
        /// <summary>
        /// Validates policy and modifies field values based on logic for individual transaction types.
        /// </summary>
        /// <param name="context"></param>
        private void CheckPolicyVersionValues(LocalPluginContext context)
        {
            var target        = context.PluginExecutionContext.InputParameters["Target"] as Entity;
            var policyVersion = new PolicyVersion(context.OrganizationService, context.TracingService, target);

            // make sure that policy version contains transaction type
            if (policyVersion.TransactionType == null)
            {
                throw new InvalidPluginExecutionException("Cannot create Policy Version without Transaction type.");
            }

            if (policyVersion.TransactionType == PolicyVersionTransactionType.Cancellation)
            {
                // cancellations have zero-duration, expiry date is always same as effective date - that is the date
                // of policy cancellation
                target["new_endofcover"] = policyVersion.TransactionEffectiveDate;
            }
        }
コード例 #28
0
        public void LeapYear()
        {
            //given
            var policy = new PolicyVersion
            {
                PolicyId   = 1,
                PolicyFrom = new DateTime(2020, 2, 29),
                PolicyTo   = new DateTime(2020, 2, 29).AddYears(1).AddDays(-1)
            };

            var serviceDate = new DateTime(2020, 5, 1);

            //when
            var limitPeriod = new PolicyYearLimitPeriod().Calculate(serviceDate, policy);

            //then
            Assert.Equal(Period.Between(new DateTime(2020, 2, 29), new DateTime(2021, 2, 27)), limitPeriod);
        }
コード例 #29
0
        public void ServiceDateInsideFirstPolicyYear_PeriodStartEqualToPolicyStart_PeriodEndsYearAfterThat()
        {
            //given
            var policy = new PolicyVersion
            {
                PolicyId   = 1,
                PolicyFrom = new DateTime(2019, 1, 1),
                PolicyTo   = new DateTime(2019, 12, 31)
            };

            var serviceDate = new DateTime(2019, 5, 1);

            //when
            var limitPeriod = new PolicyYearLimitPeriod().Calculate(serviceDate, policy);

            //then
            Assert.Equal(Period.Between(new DateTime(2019, 1, 1), new DateTime(2019, 12, 31)), limitPeriod);
        }
コード例 #30
0
 public static PolicyVersionDto AssemblePolicyVersionDto(Policy policy, PolicyVersion version)
 {
     return(new PolicyVersionDto
     {
         VersionNumber = version.VersionNumber,
         VersionStatus = version.VersionStatus.ToString(),
         PolicyStatus = version.PolicyStatus.ToString(),
         PolicyHolder = $"{version.PolicyHolder.LastName} {version.PolicyHolder.FirstName}",
         Insured = null,
         Car = $"{version.Car.PlateNumber} {version.Car.Make} {version.Car.ProductionYear}",
         CoverFrom = version.CoverPeriod.ValidFrom,
         CoverTo = version.CoverPeriod.ValidTo,
         VersionFrom = version.VersionValidityPeriod.ValidFrom,
         VersionTo = version.VersionValidityPeriod.ValidTo,
         TotalPremium = version.TotalPremium.Amount,
         Covers = version.Covers.Select(CoverDtoAssembler.AssembleCoverDto).ToList(),
         Changes = AssembleChanges(policy, version)
     });
 }
コード例 #31
0
 static PolicyVersion()
 {
     s_policyVersion12 = new PolicyVersion(MetadataStrings.WSPolicy.NamespaceUri);
     s_policyVersion15 = new PolicyVersion(MetadataStrings.WSPolicy.NamespaceUri15);
 }