/// <summary> /// Amends the Claim Transaction Header's transaction source where necessary. /// </summary> /// <param name="cth">Claim Transaction Header Type</param> /// <param name="isReservesWithNonZeroMovementsPresent">vool value</param> /// <returns>short value</returns> private static short GetTransactionSource(XiapClaim.ClaimTransactionHeader cth, bool isReservesWithNonZeroMovementsPresent) { short transSource = (short)cth.ClaimTransactionSource; // If we we have Reserves with Non-Zero Movements on them, return the transaction source as 'Reserve'. if (isReservesWithNonZeroMovementsPresent) { return transSource = (short)StaticValues.ClaimTransactionSource.Reserve; } // If the ClaimTransactionHeader is a payment but now only contains reserves, change it to a reserve transaction if (cth.ClaimTransactionSource == (short)StaticValues.ClaimTransactionSource.Payment) { var hasPayments = (from ctg in cth.ClaimTransactionGroups where ctg.ClaimTransactionDetails != null from ctd in ctg.ClaimTransactionDetails where ctd.AmountType == (short)StaticValues.AmountType.Payment select ctd.AmountType) .Any(); if (!hasPayments) { transSource = (short)StaticValues.ClaimTransactionSource.Reserve; } } // If the ClaimTransactionHeader is a RecoveryReceipt but now only conatans Recovery Reserves, set to a Recovery Reserve type. if (cth.ClaimTransactionSource == (short)StaticValues.ClaimTransactionSource.RecoveryReceipt) { var hasReceipts = (from ctg in cth.ClaimTransactionGroups where ctg.ClaimTransactionDetails != null from ctd in ctg.ClaimTransactionDetails where ctd.AmountType == (short)StaticValues.AmountType.RecoveryReceipt select ctd.AmountType) .Any(); if (!hasReceipts) { transSource = (short)StaticValues.ClaimTransactionSource.RecoveryReserve; } } return transSource; }
/// <summary> /// method used to get funded deductible movement types. /// </summary> /// <param name="entities">Metadata Entity</param> /// <param name="productVersion">long value</param> /// <param name="riskProductCode">string value</param> /// <param name="attachedPolicyRef">string value</param> /// <param name="fundedDeductiblePolicies">Dictionary collection</param> /// <param name="cth">Claim Transaction Header</param> /// <returns>Dictionary collection</returns> private static Dictionary<string, string> GetFundedDeductibleMovementTypes(MetadataEntities entities, long productVersion, string riskProductCode, string attachedPolicyRef, Dictionary<string, string> fundedDeductiblePolicies, XiapClaim.ClaimTransactionHeader cth) { string reserveMovementType; var movementTypes = new Dictionary<string, string>(); // Get the claim definition from the Product Version passed in. ProductClaimDefinition pcd = (from claimDefinition in entities.ProductClaimDefinition where claimDefinition.ProductVersionID == productVersion select claimDefinition).FirstOrDefault(); // Add funded deductible movement types for Reserve, Payment and RecoveryReceipt, if this isn't a Recovery Reserve Claim Transaction Header if (cth.ClaimTransactionSource != (short)StaticValues.ClaimTransactionSource.RecoveryReserve) { GetFundedDeductibleMovementTypes(entities, productVersion, attachedPolicyRef, fundedDeductiblePolicies, pcd, null, null, false, ref movementTypes); } // Add funded deductible movement types for recovery reserve if the CTH is a RecoveryReserve or Recovery Receipt if (cth.ClaimTransactionSource == (short)StaticValues.ClaimTransactionSource.RecoveryReserve || cth.ClaimTransactionSource == (short)StaticValues.ClaimTransactionSource.RecoveryReceipt) { // Cycle through all Claim Transaction Groups foreach (XiapClaim.ClaimTransactionGroup ctg in cth.ClaimTransactionGroups) { // Cycle through each Claim Transaction Detail on each group foreach (XiapClaim.ClaimTransactionDetail ctd in ctg.ClaimTransactionDetails) { // For any Recovery Reserve type amounts if (ctd.AmountType == (short)StaticValues.AmountType.RecoveryReserve) { // Retrieve funded deductible reserve movement type on the basis of recovery reserve movement type ClaimsBusinessLogicHelper.TryGetReserveMovementType(ctd.MovementType, riskProductCode, out reserveMovementType); // Add to the list of types if we get a value. if (!string.IsNullOrWhiteSpace(reserveMovementType)) { GetFundedDeductibleMovementTypes(entities, productVersion, attachedPolicyRef, fundedDeductiblePolicies, pcd, ctd.MovementType, reserveMovementType, true, ref movementTypes); } } } } } return movementTypes; }
/// <summary> /// Method used to remove Funded and net zero transaction from claim transaction. /// </summary> /// <param name="fundedDeductibles">dictionary collection</param> /// <param name="cth">Claim Transaction Header Type</param> /// <returns>Claim Transaction Header</returns> private static XiapClaim.ClaimTransactionHeader RemoveFundedAndNetZeroTransactions(Dictionary<string, string> fundedDeductibles, XiapClaim.ClaimTransactionHeader cth) { bool isReservesWithNonZeroMovementsPresent = false; foreach (XiapClaim.ClaimTransactionGroup ctg in cth.ClaimTransactionGroups) { // Find all claim transaction details in each claim transaction group, where there the movement type ISN'T in the list of funded deductibles passed in. ctg.ClaimTransactionDetails = ctg.ClaimTransactionDetails.Where(a => !fundedDeductibles.ContainsKey(a.MovementType)).ToArray(); // Find out if there are any resereves with non-zero movments in this filtered list of claim transaction details isReservesWithNonZeroMovementsPresent = ClaimTransferDataTransform.IsReserveWithNonZeroMovementsPresent(ctg.ClaimTransactionDetails.ToList()); // if the claimtransaction header isn't a Payment Cancellation, process for zero movement amounts if (cth.ClaimTransactionSource != (short)StaticValues.ClaimTransactionSource.PaymentCancellation) { // Remove all ClaimTransactionDetails which have zero movement amounts ctg.ClaimTransactionDetails = ctg.ClaimTransactionDetails.Where(a => !(a.MovementAmountOriginal == 0 && a.TransactionAmountOriginal == 0)).ToArray(); } else if (!isReservesWithNonZeroMovementsPresent) { // Payment cancellation can occur with only reserves. We need to check for this and then change the transaction source appropriately. isReservesWithNonZeroMovementsPresent = ClaimTransferDataTransform.AreThereOnlyReservesOnClaimTransactionDetails(ctg.ClaimTransactionDetails.ToList()); } } // Possibly amend the claim transaction source to reflect the presence of reserves with non-zero movements present cth.ClaimTransactionSource = GetTransactionSource(cth, isReservesWithNonZeroMovementsPresent); // Remove any claim transaction group with no remaining claim transaction details cth.ClaimTransactionGroups = cth.ClaimTransactionGroups.Where(a => a.ClaimTransactionDetails.Any()).ToArray(); return cth; }