/// <summary>
        /// Validates the policy data items.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <returns>Process Results Collection</returns>
        private ProcessResultsCollection ValidatePolicyDataItems(Header header)
        {
            var processResultsCollection = new ProcessResultsCollection();
            // Get the latest version of the UW Header
            var headerVersion = (HeaderVersion)header.GetLatestVersion();
            // Validate the Generic Data Items
            this.ValidateGenericDataItems(processResultsCollection, headerVersion, this.ExtractGenericDataItems(headerVersion), headerVersion);
            
            var sectionDetails = from s in header.Sections
                                 from sd in s.SectionDetails
                                 select sd;
            // Cycle through all Section Details on the Header
            foreach (var sectionDetail in sectionDetails)
            {
                // Get the latest version
                var sectionDetailVersion = (SectionDetailVersion)sectionDetail.GetLatestVersion();
                // Validate all the generic data items are correct on this Section detail.
                this.ValidateGenericDataItems(processResultsCollection, sectionDetailVersion, this.ExtractGenericDataItems(sectionDetailVersion), headerVersion);

                // Cycle through all the coverages on this Section Detail
                foreach (var coverage in sectionDetail.Coverages)
                {
                    // Get latest version and validate the Generic data items
                    var coverageVersion = (CoverageVersion)coverage.GetLatestVersion();
                    this.ValidateGenericDataItems(processResultsCollection, coverageVersion, this.ExtractGenericDataItems(coverageVersion), headerVersion);
                }
            }

            return processResultsCollection;
        }
        /// <summary>
        /// Process runs on Create or Copy of a name.
        /// </summary>
        /// <param name="component">The component.</param>
        /// <param name="point">The point.</param>
        /// <param name="pluginId">The plugin identifier.</param>
        /// <returns>Process Results Collection</returns>
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId)
        {
            ProcessResultsCollection results = new ProcessResultsCollection();
            TransactionContext transactionContext = component.Context;
            switch (point)
            {
                case ProcessInvocationPoint.Created:
                    {
                        // Run for create or copy of any name usage that is defined as controlled in GeniusX
                        if ((transactionContext.TransactionType == TransactionProcessConstants.CreateName || transactionContext.TransactionType == TransactionProcessConstants.CopyName)
                            && (component as NameUsage).GetDefinitionComponent().CustomCode01 == IDConstants.NAME_CONTROLLED_IN_GENIUSX)
                        {
                            Name name = component.Parent as Name;
                            this.DefaultNameRefrence(results, component, point, name);
                        }

                        break;
                    }

                case ProcessInvocationPoint.Copy:
                    {
                        // Run for copy of any name usage that is defined as controlled in GeniusX
                        if ((transactionContext.TransactionType == TransactionProcessConstants.CopyName)
                            && (component as NameUsage).GetDefinitionComponent().CustomCode01 == IDConstants.NAME_CONTROLLED_IN_GENIUSX)
                        {
                            Name name = component.Context.CopyDictionary[component.Parent.DataId] as Name;
                            this.DefaultNameRefrence(results, component, point, name);
                        }

                        break;
                    }
            }

            return results;
        }
Ejemplo n.º 3
0
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId, ProcessParameters processParameters)
        {
            ProcessResultsCollection processResults = new ProcessResultsCollection();
            Header header = (Header)component;
            // Get the header status code that matches Policy Verified from the Application Configuration
            string verifiedHeaderStatus = UWBusinessLogicHelper.ResolveMandatoryConfig<string>("PolicyVerifiedHeaderStatus");
            // If the header status code has been changed and now matches the verified header status code retried, process
            if (header.HeaderStatusCode == verifiedHeaderStatus && header.HeaderStatusCode != header.OriginalTransitionStatus)
            {
                // Retrieve the Policy Verify Permission Token and the Submitted for verification Event codes from the Application Configuration
                string policyVerifyPermissionToken = UWBusinessLogicHelper.ResolveMandatoryConfig<string>("PolicyVerificationPermissionToken");
                string submittedForVerificationEventTypeCode = UWBusinessLogicHelper.ResolveMandatoryConfig<string>("SubmittedForVerificationEventTypeCode");
                
                // Check if this user has Policy Verify in their permission tokens. This method throws a SecurityException if this fails
                XiapSecurity.Assert(policyVerifyPermissionToken);
                // Check in tasks for a 'submitted for verification' task and make sure it wasn't entered by the user who is now trying to
                // verify the policy. Throw an error if so.
                var eventType = header.UwEvents.Where(e => e.EventTypeCode == submittedForVerificationEventTypeCode).OrderByDescending(e => e.EventDate).FirstOrDefault();
                if (eventType != null && eventType.CreatedByUserID == XiapSecurity.GetUser().UserID)
                {
                    UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.POLICY_CANNOT_BE_VERIFIED_BY_PERSON_SUBMITTED, ProcessInvocationPoint.Virtual, component);
                }
            }

            return processResults;
        }
 public void AreVehicleTypeAndGeniusVehicleCategory_Mismatch_True()
 {
     string[] list = new string[5] { "T1", StaticValues.PolicyLinkLevel.Coverage.ToString(), "DummyCode", "InvalidCode", "ExternalCovRef" };
     this.claimHeader.ClaimHeaderAnalysisCode09 = "ValidCode";
     this.target = new PolicyAttachmentAndVehicleTypeValidationPlugin();
     this.processResultsCollection = this.target.ProcessComponent(this.claimHeader, Xiap.Framework.ProcessInvocationPoint.Virtual, 0, new ProcessParameters { Parameters = list });
     Assert.AreEqual(this.processResultsCollection.Count, 1);
     AssertEx.ContainsMessage(this.processResultsCollection, ClaimConstants.VEHICLE_TYPE_AND_GENIUS_VEHICLE_TYPE_MISMATCH);
 }
        /// <summary>
        /// This method assigns next transaction reference to Claim Transaction Reference (ClaimTransactionHeaderReference of ClaimTransactionHeader) 
        /// </summary>
        /// <param name="component">Claim Transaction Header</param>
        /// <param name="point">Process Invocation Point</param>
        /// <param name="pluginId">plugin Id</param>
        /// <returns>Process Results Collection</returns>
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId)
        {
            PluginHelper<ClaimTransactionHeader> pluginHelper = new PluginHelper<ClaimTransactionHeader>(point, (ClaimTransactionHeader)component, new ProcessResultsCollection());
            ProcessResultsCollection processResults = new ProcessResultsCollection();

            if (point == ProcessInvocationPoint.Virtual)
            {
                ClaimTransactionHeaderReferenceDefaulting(pluginHelper);
            }

            return processResults;
        }
        public void ValidateMigrationStatus_MigrationStatusIsNull_ClaimReopenNotAllowed()
        {
            string[] parameters = { this.claimHeader.ClaimHeaderID.ToString() };
            Xiap.Testing.Utils.Mocks.MockBusinessTransaction mockBT = new Xiap.Testing.Utils.Mocks.MockBusinessTransaction("ReopenClaim", parameters, "Claims", new ClaimsTransactionContext(Guid.NewGuid().ToString(), "Claims", "ReopenClaim"));
            this.claimHeader.ClaimHeaderID = 1;
            this.claimHeader.CustomCode18 = null;
            this.claimHeader.CustomCode19 = "C";
            mockBT.Component = this.claimHeader;
            ReopenClaimTransactionPlugin transaction = new ReopenClaimTransactionPlugin();
            this.results = transaction.ProcessTransaction(mockBT, TransactionInvocationPoint.PreCreate, 1, parameters);

            Assert.AreEqual(1, this.results.Count);
            Assert.AreEqual("REOPENING_OF_UNPROCESSED_CLAIM_NOT_ALLOWED", this.results.Results.First().MessageId);
        }
        public void ClaimReopenNotAllowedErrorTest()
        {
            string[] parameters = { this.claimHeader.ClaimHeaderID.ToString() };
            Xiap.Testing.Utils.Mocks.MockBusinessTransaction mockBT = new Xiap.Testing.Utils.Mocks.MockBusinessTransaction("ReopenClaim", parameters, "Claims", new ClaimsTransactionContext(Guid.NewGuid().ToString(), "Claims", "ReopenClaim"));
            this.claimHeader.ClaimHeaderID = 1;
            this.claimHeader.CustomCode18 = "F01"; // ClaimWakeUp Validation error check
            this.claimHeader.CustomCode19 = "C";
            mockBT.Component = this.claimHeader;
            ReopenClaimTransactionPlugin transaction = new ReopenClaimTransactionPlugin();
            this.results = transaction.ProcessTransaction(mockBT, TransactionInvocationPoint.PreCreate, 1, parameters);

            Assert.AreEqual(1, this.results.Count);
            Assert.AreEqual(ClaimConstants.REOPENING_OF_CLAIM_NOT_ALLOWED_WITHOUT_POLICY, this.results.Results.First().MessageId);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Processes the component in the Virtual Invocation Point
        /// </summary>
        /// <param name="component">The component.</param>
        /// <param name="point">The point.</param>
        /// <param name="pluginId">The plugin identifier.</param>
        /// <returns>Process Results Collection</returns>
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId)
        {
            ProcessResultsCollection results = new ProcessResultsCollection();
            Header header = (Header)component;
            if (point == ProcessInvocationPoint.Virtual)
            {
                if (this.ValidateXiapHeader(header, results).Count == 0)
                {
                    // Count is 0, i.e. no errors added to the ProcessResultsCollection 'results' in the Validation the GeniusX policy, so update
                    this.UpdateFromGenius(header, results);
                }
            }

            return results;
        }
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId)
        {
            // Plugin is configured to run after core HeaderReferenceDefaulter
            ProcessResultsCollection results = new ProcessResultsCollection();
            Header header = (Header)component;
            if (point == ProcessInvocationPoint.Created)
            {
                if (!string.IsNullOrEmpty(header.GetProduct().Product.ExternalDataSource))
                {
                    // Reset to blank, header ref will be entered manually
                    header.HeaderReference = string.Empty;
                }
            }

            return results;
        }
Ejemplo n.º 10
0
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId)
        {
            // Update header to verified when automatically creating a policy from coverage verification
            ProcessResultsCollection results = new ProcessResultsCollection();
            if (point == ProcessInvocationPoint.Virtual)
            {
                Header header = (Header)component;
                if (header.GetProduct().Product.ExternalDataSource != null)
                {
                    var verifiedHeaderStatus = UWBusinessLogicHelper.ResolveMandatoryConfig<string>("PolicyVerifiedHeaderStatus");
                    header.HeaderStatusCode = verifiedHeaderStatus;
                }
            }

            return results;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Updates the header from genius.
        /// </summary>
        /// <param name="xiapHeader">The xiap header.</param>
        /// <param name="results">The results.</param>
        /// <exception cref="System.ServiceModel.FaultException">new FaultCode(Sender)</exception>
        /// <exception cref="FaultReason"></exception>
        /// <exception cref="FaultCode">Sender</exception>
        private void UpdateFromGenius(Header xiapHeader, ProcessResultsCollection results)
        {
            try
            {
                IUWHeader externalHeader = null;
                IPolicyService riskService = null;
                // Create an external policy service to the external service linked on the Header product.
                // This external service will be Genius.
                riskService = new PolicyService(xiapHeader.GetProduct().Product.ExternalDataSource);
                externalHeader = riskService.GetPolicy(xiapHeader.HeaderReference);
                if (this.ValidateExternalHeader(xiapHeader, externalHeader, results).Count == 0)
                {
                    // Count is 0, i.e. no errors added to the ProcessResultsCollection 'results' in the Validation of External Header
                    this.UpdateHeader(xiapHeader, externalHeader);

                    // Apply the external policy terms to the GeniusX policy.
                    foreach (IUWTerms externalTerm in externalHeader.ITerms)
                    {
                        this.ProcessTerms(xiapHeader, externalTerm);
                    }

                    // Order the external policy sections by the External Reference, which will be a Genius Reference,
                    // thus the sections will be ordered as they are in the Genius policy.
                    // Then apply each to the GeniusX policy in turn.
                    var sections = externalHeader.ISections.OrderBy(x => x.ExternalReference);
                    foreach (IUWSection externalSection in sections)
                    {
                        this.ProcessSection(xiapHeader, externalSection);
                    }

                    // Finally, update NameInvolvements from the external Genius policy
                    this.UpdateNameInvolvement(xiapHeader, externalHeader);
                }
            }
            catch (Exception e)
            {
                if (_logger.IsErrorEnabled)
                {
                    _logger.Error(e);
                }

                throw new FaultException(new FaultReason(e.Message), new FaultCode("Sender"));
            }
        }
        public void TestInitialize()
        {
            this.container = new UnityContainer();
            this.container.RegisterType<IMessageService, MessageService>();
            this.componentMetadata = MockRepository.GenerateStub<IComponentMetadata>();
            this.container.RegisterInstance<IXiapCache>(MockRepository.GenerateStub<IXiapCache>());
            this.container.RegisterInstance<IComponentMetadata>(this.componentMetadata);
            var metadataMock = MockRepository.GenerateStub<IMetadataQuery>();
            container.RegisterInstance<IMetadataQuery>(metadataMock);
            List<ValueSetCacheName> codes = new List<ValueSetCacheName>();
            codes.Add(new ValueSetCacheName() { Code = "DummyCode", LanguageID = 1, LongDescription = "Description", ShortDescription = "Description" });
            IQueryable<ValueSetCacheName> codeNames = codes.AsQueryable<ValueSetCacheName>();
            metadataMock.Stub(md => md.QueryValueSetNames(Arg<SystemValueSetCodeEnum>.Is.Anything, Arg<int>.Is.Equal(1))).Return(codeNames);
            BusinessComponentKey key = new BusinessComponentKey("TEST");
            key.Add(new BusinessComponentKeyMember("TEST", "1"));
            this.componentMetadata.Stub(a => a.FieldExists("ClaimHeaderAnalysisCode02")).Return(true);
            this.componentMetadata.Stub(a => a.GetField("ClaimHeaderAnalysisCode02")).Return(new Field() { Title = "ClaimHeaderAnalysisCode02", LookupDefinitionKey = key, LookupParameters = new LookupParameters { Code = "TEST" } });

            this.decisionTableHelper = MockRepository.GenerateStub<IDecisionTableHelper>();
            this.container.RegisterInstance<IDecisionTableHelper>(this.decisionTableHelper);
            this.decisionTableComponent = new DecisionTableComponent { Context = new TransactionContext(string.Empty, string.Empty, string.Empty) };

            this.decisionTableHelper.Stub(s => s.Call(Arg<string>.Is.Anything, Arg<DateTime>.Is.Anything, Arg<object[]>.Is.Anything)).Return(this.decisionTableComponent);
            this.claimHeader = new ClaimHeader();

            ILookupDefinitionCache lookupDefinitionCache = MockRepository.GenerateStub<ILookupDefinitionCache>();
            ILookupDefinition lookupDefinition = MockRepository.GenerateStub<ILookupDefinition>();
            lookupDefinitionCache.Stub(a => a.GetLookupDefinition(string.Empty, 0)).IgnoreArguments().Return(lookupDefinition);
            this.container.RegisterInstance<ILookupDefinitionCache>(lookupDefinitionCache);
            lookupDefinition.Stub(a => a.RetrieveValues(Arg<LookupParameters>.Is.Anything,
                                  Arg<short>.Is.Equal((short)1),
                                  Arg<int>.Is.Anything,
                                  Arg<int?>.Is.Anything,
                                  Arg<LookupOptions>.Is.Equal(LookupOptions.None),
                                  out Arg<int>.Out(new int()).Dummy)).Return((new CodeRow[] { new CodeRow() { Code = "ClaimHeaderAnalysisCode02", Description = "ClaimHeaderAnalysisCode02", LanguageId = 1 } }));
            this.container.RegisterInstance<ILookupDefinition>(lookupDefinition);

            this.mockIUnderwritingService = MockRepository.GenerateStub<IUnderwritingService>();
            container.RegisterInstance<IUnderwritingService>(this.mockIUnderwritingService);
            ObjectFactory.Instance = new ObjectFactory(this.container);
            this.processResultsCollection = new ProcessResultsCollection();
        }
 /// <summary>
 /// Defaults the name refrence.
 /// </summary>
 /// <param name="results">The results.</param>
 /// <param name="component">The component.</param>
 /// <param name="point">The point.</param>
 /// <param name="name">The name.</param>
 private void DefaultNameRefrence(ProcessResultsCollection results, IBusinessComponent component, ProcessInvocationPoint point, Name name)
 {
     if (name != null)
     {
         // We have a valid name
         if (String.IsNullOrEmpty(name.NameReference))
         {
             // The NameReference is not yet set so first get a Name Code defaulted
             // this should default the name reference.
             this.DefaultNameCode(name);
             // Check the namereference is now set. If not, raise an error to say we couldn't lock the Name Reference and this is why it wasn't updated.
             if (!String.IsNullOrEmpty(name.NameReference))
             {
                 if (!LockManager.UpdateReferenceLocks(component.Context.TransactionId, name.NameReference, LockLevel.NameReference, LockType.Update, LockDurationType.Transaction, LockOrigin.InsuranceDirectory, string.Empty))
                 {
                     InsuranceDirectoryHelper.SetProcessResult(results, component, ProcessInvocationPoint.Instantiation, "CREATE_LOCK_FAILED");
                 }
             }
         }
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Validates the person has a title and then uses this in the list name creation.
 /// Otherwise, list name is just a concatenation of forename and surname.
 /// </summary>
 /// <param name="results">The results.</param>
 /// <param name="personDetailVersion">The person detail version.</param>
 /// <param name="point">The point.</param>
 public void PersonValidation(ProcessResultsCollection results, PersonDetailVersion personDetailVersion, ProcessInvocationPoint point)
 {
     string title = string.Empty;
     if (!string.IsNullOrEmpty(personDetailVersion.TitleCode))
     {
         // Default the title as a string from the selected Title code on the Person detail
         title = FieldsHelper.GetCodeDescription(personDetailVersion.TitleCodeField, personDetailVersion.TitleCode);
     }
     
     if (!string.IsNullOrWhiteSpace(title))
     {
         // We have a title, so format the list name to include the title at the start.
         string listName = String.Format("{0} {1}", title, personDetailVersion.Forename).Trim();
         personDetailVersion.ListName = String.Format("{0} {1}", listName, personDetailVersion.Surname).Trim();
     }
     else 
     {
         // Otherwise, the list name is just forename surname.
         personDetailVersion.ListName = String.Format("{0} {1}", personDetailVersion.Forename, personDetailVersion.Surname).Trim();
     }
 }
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId)
        {
            ProcessResultsCollection processResults = new ProcessResultsCollection();

            if (point == ProcessInvocationPoint.Created)
            {
                bool isClaimDetailDefaulted = false;
                ClaimDetail claimDetail = (ClaimDetail)component;
                bool isUniqueClaimDetail = false;

                // default the Claim Detail Reference with AllocateClaimDetailReference 
                claimDetail.ClaimDetailReference = this.AllocateClaimDetailReference(claimDetail, claimDetail.GetProduct(), ref isClaimDetailDefaulted);

                // Validate that the ClaimDetailRef is unique for this ClaimDetailID 
                isUniqueClaimDetail = ClaimDetailReferenceDefaulterPlugin.IsUniqueClaimDetailReference(claimDetail, point, isClaimDetailDefaulted);
                if (!isUniqueClaimDetail)
                {
                    processResults = ClaimsBusinessLogicHelper.AddError(processResults, MessageConstants.ClaimDetailRefNotUnique, point, component);
                }
            }

            return processResults;
        }
 public void IsExternalPolicyChild_ComponentExists_False()
 {
     this.mockIUnderwritingService.Stub(a => a.GetCoverageIDByExternalReference(Arg<string>.Is.Anything)).Return(0);
     this.decisionTableComponent.IsValid = true;
     this.target = new PolicyAttachmentAndTypeOfLossValidationPlugin();
     this.processResultsCollection = this.target.ProcessComponent(this.claimHeader, Xiap.Framework.ProcessInvocationPoint.Virtual, 0, new ProcessParameters { Parameters = this.list });
     Assert.AreEqual(this.processResultsCollection.Count, 1);
     AssertEx.ContainsMessage(this.processResultsCollection, ClaimConstants.POLICY_ATTACHMENT_NOT_ALLOWED);
 }
 public void ValidateTypeOfLossAndCoverageTypeCombination_Mismatch_True()
 {
     this.mockIUnderwritingService.Stub(a => a.GetCoverageIDByExternalReference(Arg<string>.Is.Anything)).Return(1);
     this.claimHeader.ClaimHeaderAnalysisCode02 = "ClaimHeaderAnalysisCode02";
     this.decisionTableComponent.IsValid = false;
     this.target = new PolicyAttachmentAndTypeOfLossValidationPlugin();
     this.processResultsCollection = this.target.ProcessComponent(this.claimHeader, Xiap.Framework.ProcessInvocationPoint.Virtual, 0, new ProcessParameters { Parameters = this.list });
     Assert.AreEqual(this.processResultsCollection.Count, 1);
     AssertEx.ContainsMessage(this.processResultsCollection, ClaimConstants.TYPE_OF_LOSS_AND_COVERAGE_TYPE_MISMATCH);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Validates GeniusX policy can be updated from Genius.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="results">The results.</param>
        /// <returns>Process Results Collection</returns>
        private ProcessResultsCollection ValidateXiapHeader(Header header, ProcessResultsCollection results)
        {
            // If status is verified, creation of components from Genius not allowed
            if (header.HeaderStatusThreshold >= 30)
            {
                UWBusinessLogicHelper.AddError(results, UwMessageConstants.HEADERSTATUS_VERIFIED_GENIUSUPDATE_NOTALLOWED, ProcessInvocationPoint.Virtual, header);
            }

            // We can't collect from Genius if we haven't defined the product as actually using an external source (which should be Genius).
            if (header.GetProduct().Product.ExternalDataSource == null)
            {
                UWBusinessLogicHelper.AddError(results, UwMessageConstants.EXTERNALDATASOURCE_REQUIRED, ProcessInvocationPoint.Virtual, header);
            }

            // Note that core validation already checks duplicate XIAP header references, so shouldn't have to re-check
            
            return results;
        }
 public void ValidateTypeOfLossAndCoverageTypeCombination_Mismatch_False()
 {
     this.mockIUnderwritingService.Stub(a => a.GetCoverageIDByExternalReference(Arg<string>.Is.Anything)).Return(1);
     this.decisionTableComponent.IsValid = true;
     this.target = new PolicyAttachmentAndTypeOfLossValidationPlugin();
     this.processResultsCollection = this.target.ProcessComponent(this.claimHeader, Xiap.Framework.ProcessInvocationPoint.Virtual, 0, new ProcessParameters { Parameters = this.list });
     Assert.AreEqual(this.processResultsCollection.Count, 0);
 }
        /// <summary>
        /// Setting values when component create, copy and when component changes.
        /// </summary>
        /// <param name="component">Component of Business Type</param>
        /// <param name="point">Process Invocation Point</param>
        /// <param name="pluginId">unique plugin id</param>
        /// <returns>collection of process results</returns>
        public override ProcessResultsCollection ProcessComponent(IBusinessComponent component, ProcessInvocationPoint point, int pluginId)
        {
            ProcessResultsCollection processResults = new ProcessResultsCollection();

            if (point == ProcessInvocationPoint.Created ||  point == ProcessInvocationPoint.Copy || point == ProcessInvocationPoint.ComponentChange)
            {
                try
                {
                    bool IsClaimHeaderDefaulted = false;
                    ClaimHeader claimHeader = (ClaimHeader)component;

                    // if Claim Reference field property gets changes.
                    if (point == ProcessInvocationPoint.ComponentChange && !claimHeader.PropertiesChanged.ContainsKey(ClaimHeader.ClaimReferenceFieldName))
                    {
                        return processResults;
                    }

                    Product product = claimHeader.GetProduct().GetProduct();
                    string createdBy = claimHeader.CustomReference05;   // UI Label = Created By

                    if (point == ProcessInvocationPoint.Copy)
                    {
                        claimHeader = component.Context.CopyDictionary[component.DataId] as ClaimHeader;
                        claimHeader.CustomReference05 = createdBy; // claimHeader.CustomReference05 = Created By
                        product = claimHeader.GetProduct().GetProduct();
                    }

                    if (claimHeader != null)
                    {
                        if (!claimHeader.ClaimStage.HasValue)
                        {
                            claimHeader.ClaimStage = product.ClaimStage;
                        }

                        if (claimHeader.ClaimStage.GetValueOrDefault((short)StaticValues.ClaimStage.Claim) != (short)StaticValues.ClaimStage.Claim)
                        {
                            return processResults;
                        }

                        bool isUniqueClaimRef = false;
                        bool isLockSuccess = false;

                        for (int loopCounter = 0; loopCounter < 5; loopCounter++)
                        {
                            isUniqueClaimRef = false;
                            isLockSuccess = false;

                            if (string.IsNullOrEmpty(claimHeader.ClaimReference))
                            {
                                claimHeader.ClaimReference = this.AllocateClaimReference(claimHeader, product, ref IsClaimHeaderDefaulted);
                            }

                            isUniqueClaimRef = this.IsUniqueClaimReference(claimHeader, point, IsClaimHeaderDefaulted);

                            isLockSuccess = IsCreateLockStatus(claimHeader);

                            if (isUniqueClaimRef && isLockSuccess)
                            {
                                break;
                            }

                            if (!IsClaimHeaderDefaulted || isLockSuccess)
                            {
                                break;
                            }

                            claimHeader.ClaimReference = string.Empty;
                        }

                        // if Claim reference is not unique then add error.
                        if (!isUniqueClaimRef)
                        {
                            ClaimsBusinessLogicHelper.AddError(processResults, MessageConstants.CLAIM_REFERENCE_EXIST, point, component);
                        }

                        if (isUniqueClaimRef && !isLockSuccess)
                        {
                            ClaimsBusinessLogicHelper.AddError(processResults, MessageConstants.ERROR_IN_LOCKING, point, claimHeader);
                        }
                    }
                }
                catch (Exception e)
                {
                    this._Logger.Error(e);
                    this._Logger.Info(e.StackTrace);
                }
            }

            return processResults;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Validates the external Genius Policy can be used to refresh the GeniusX policy.
        /// </summary>
        /// <param name="xiapheader">The xiapheader.</param>
        /// <param name="externalheader">The externalheader.</param>
        /// <param name="results">The results.</param>
        /// <returns>Process Results Collection</returns>
        private ProcessResultsCollection ValidateExternalHeader(Header xiapheader, IUWHeader externalheader, ProcessResultsCollection results)
        {
            // Genius policy not found
            if (externalheader == null)
            {
                UWBusinessLogicHelper.AddError(results, MessageConstants.INVALID_POLICY_REFERENCE, ProcessInvocationPoint.Virtual, xiapheader);
            }
            else
            {
                // Genius policy product must match XIAP product
                if (externalheader.ProductCode != xiapheader.GetProduct().Product.Code)
                {
                    UWBusinessLogicHelper.AddError(results, UwMessageConstants.GENIUS_PRODUCT_DOES_NOT_MATCH, ProcessInvocationPoint.Virtual, xiapheader);
                }
            }

            return results;
        }
        /// <summary>
        /// Validate the Deductible Sequence
        /// </summary>
        /// <param name="processResults">The process results.</param>
        /// <param name="sourceComponent">The source component.</param>
        /// <param name="genericDataItems">The generic data items.</param>
        /// <param name="headerVersion">The header version.</param>
        private void DeductibleSequenceValidation(ProcessResultsCollection processResults, IBusinessComponent sourceComponent, IEnumerable<IGenericDataItem> genericDataItems, HeaderVersion headerVersion)
        {
            // Group by CustomNumeric01 - the Deductible sequence
            var grouping = genericDataItems.ToLookup(a => a.CustomNumeric01);

            // Deductible sequence must be different if subtypes match
            foreach (var group in grouping)
            {
                IGenericDataItem prevGroup = null;

                // Cycle through each entry in the group (of deductibles at a given sequence)
                foreach (IGenericDataItem entry in group)
                {
                    // If we've viewed a group previously, compare the subtypes and throw an error if they match
                    if (prevGroup != null)
                    {
                        // CustomCode01 = Division SubSection, CustomCode02 = Vehicle SubSection, CustomCode03 = DeductibleReasonSubSection
                        if (entry.CustomCode01 == prevGroup.CustomCode01
                            && entry.CustomCode02 == prevGroup.CustomCode02
                            && entry.CustomCode03 == prevGroup.CustomCode03)
                        {
                            UWBusinessLogicHelper.AddError(processResults, "DeductibleSequenceMustBeDistinct", ProcessInvocationPoint.Validation, sourceComponent);
                            break;
                        }
                    }
                    // Assign this current Item to the 'previousGroup' (previous entry in the group) field.
                    prevGroup = entry;
                }
            }

            // Cycle through all Generic Data Items
            foreach (IGenericDataItem genericData in genericDataItems)
            {
                decimal customNumeric03 = genericData.CustomNumeric03.GetValueOrDefault(0); // CustomNumeric03 is Deductible Policy Sequence number
                // Check if this is Funded (CustomBoolean03) AND 
                // - the Deductible Type matches the Deductible Service Generic Data Type in the config
                //  OR 
                // - the Deductible Type matches the Deductible Captive Generic Data Type in the config
                // AND Deductible Policy Sequence number is 0
                if (genericData.CustomBoolean03.GetValueOrDefault(false) == true && (genericData.CustomCode04 == ResolveMandatoryConfig(GenericDataType_Deductible_Service) || genericData.CustomCode04 == ResolveMandatoryConfig(GenericDataType_Deductible_Captive)) && customNumeric03 == 0)
                {
                    // Raise error that the Deductible Policy Sequence must be > 0.
                    string shortDescription = this.GetUWValueSetShortDescription(genericData);
                    UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.DEDUCTIBLE_SEQUENCE_MUST_BE_GREATER_THAN_ZERO, ProcessInvocationPoint.Validation, sourceComponent, shortDescription);
                }
                else if (genericData.CustomCode04 == ResolveMandatoryConfig(GenericDataType_Deductible_Client) && customNumeric03 > 0)
                {
                    // Otherwise, if this is a Client type deductible, and the DEDUCIBLE POLICY sequence is > 0, it should be zero - raise an error.
                    string shortDescription = this.GetUWValueSetShortDescription(genericData);
                    UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.DEDUCTIBLE_POLICY_SEQUENCE_SHOULD_BE_ZERO, ProcessInvocationPoint.Validation, sourceComponent, shortDescription);
                }

                // If we have a HeaderVersion
                if (headerVersion != null)
                {
                    // Raise error if Deductible Policy Sequence == 1 and no Deductible Policy Reference on the UW Header in Custom Reference 01
                    // likewise for Deductible Policy Sequence a value of 2 to 5, with no custom reference02 to 05 set.
                    if (customNumeric03 == 1 && string.IsNullOrWhiteSpace(headerVersion.CustomReference01))
                    {
                        UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.DEDUCTIBLE_POLICY_REFERENCE_SHOULD_NOT_BE_NULL, ProcessInvocationPoint.Validation, sourceComponent, headerVersion.CustomReference01Field.Title);
                    }
                    else if (customNumeric03 == 2 && string.IsNullOrWhiteSpace(headerVersion.CustomReference02))
                    {
                        UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.DEDUCTIBLE_POLICY_REFERENCE_SHOULD_NOT_BE_NULL, ProcessInvocationPoint.Validation, sourceComponent, headerVersion.CustomReference02Field.Title);
                    }
                    else if (customNumeric03 == 3 && string.IsNullOrWhiteSpace(headerVersion.CustomReference03))
                    {
                        UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.DEDUCTIBLE_POLICY_REFERENCE_SHOULD_NOT_BE_NULL, ProcessInvocationPoint.Validation, sourceComponent, headerVersion.CustomReference03Field.Title);
                    }
                    else if (customNumeric03 == 4 && string.IsNullOrWhiteSpace(headerVersion.CustomReference04))
                    {
                        UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.DEDUCTIBLE_POLICY_REFERENCE_SHOULD_NOT_BE_NULL, ProcessInvocationPoint.Validation, sourceComponent, headerVersion.CustomReference04Field.Title);
                    }
                    else if (customNumeric03 == 5 && string.IsNullOrWhiteSpace(headerVersion.CustomReference05))
                    {
                        UWBusinessLogicHelper.AddError(processResults, UwMessageConstants.DEDUCTIBLE_POLICY_REFERENCE_SHOULD_NOT_BE_NULL, ProcessInvocationPoint.Validation, sourceComponent, headerVersion.CustomReference05Field.Title);
                    }
                }
            }
        }
        /// <summary>
        /// Validates the collection of generic data items that is passed in.
        /// </summary>
        /// <param name="processResults">The process results.</param>
        /// <param name="sourceComponent">The source component.</param>
        /// <param name="genericDataItems">The generic data items.</param>
        private void CommonGenericDataItemsValidation(ProcessResultsCollection processResults, IBusinessComponent sourceComponent, IEnumerable<IGenericDataItem> genericDataItems)
        {
            var genericDataItemCount = genericDataItems.Count();
            // Return if there are no items in the collection
            if (genericDataItemCount == 0)
            {
                return;
            }

            // CustomCode01 = Division SubSection, CustomCode02 = Vehicle SubSection, CustomCode03 = DeductibleReasonSubSection
            bool isNotSubSection = genericDataItems.Any(a => a.CustomCode01 == null && a.CustomCode02 == null && a.CustomCode03 == null);
            bool isDivisionSubSection = genericDataItems.Any(a => a.CustomCode01 != null);
            bool isVehicleSubSection = genericDataItems.Any(a => a.CustomCode02 != null);
            bool isDeductibleReasonSubSection = genericDataItems.Any(a => a.CustomCode03 != null);
            var currentlyActiveSubSections = new[] { isDivisionSubSection, isVehicleSubSection, isDeductibleReasonSubSection }.Count(a => a);

            // should only have one or fewer active sub sections AND not mix sub section and top level
            if (genericDataItemCount > 1 && (currentlyActiveSubSections > 1 || (currentlyActiveSubSections > 0 && isNotSubSection)))
            {
                UWBusinessLogicHelper.AddError(processResults, "DataItemsRepresentMultipleSubSections", ProcessInvocationPoint.Validation, sourceComponent);
            }
        }
 /// <summary>
 /// Validates the generic data items and puts data into the ProcessResultsCollection.
 /// All objects are passed by reference so the ProcessResults collection will return the results
 /// </summary>
 /// <param name="processResults">The process results.</param>
 /// <param name="sourceComponent">The source component.</param>
 /// <param name="genericDataItems">The generic data items.</param>
 /// <param name="header">The header.</param>
 private void ValidateGenericDataItems(ProcessResultsCollection processResults, IBusinessComponent sourceComponent, IEnumerable<IGenericDataItem> genericDataItems, HeaderVersion header)
 {
     // Get excess type Data Items then validate
     var excessDataItems = genericDataItems.Where(a => a.GenericDataTypeCode == ResolveMandatoryConfig("GenericDataType.Excess"));
     this.CommonGenericDataItemsValidation(processResults, sourceComponent, excessDataItems);
     // Get deductible data items, then validate
     var deductibleDataItems = genericDataItems.Where(a => a.GenericDataTypeCode == ResolveMandatoryConfig("GenericDataType.Deductible"));
     this.CommonGenericDataItemsValidation(processResults, sourceComponent, deductibleDataItems);
     // Validate deductible sequence
     this.DeductibleSequenceValidation(processResults, sourceComponent, deductibleDataItems, header);
 }