Beispiel #1
0
        private void Calculate(MotorInsurancePolicy policy, MotorProductMaster product)
        {
            Age = Utility.CalculateAgeCorrect(policy.DOB, DateTime.Now);

            ProductMinimumPremium = product.MinimumPremium;
            PolicyExpireDate      = policy.PolicyCommencementDate.AddYears(1).AddDays(-1);
            ExcessDiscountPercent = product.MotorOptionalBenefits.Find(c => c.Value == policy.ExcessType).Percentage;
            ExcessAmount          = GetExcess(policy, product, Age);
            BasePremium           = product.Rate * (policy.VehicleValue / 100);

            if (Age < product.UnderAge && policy.Agency == "TISCO")
            {
                BasePremium = product.UnderAgeRate * (policy.VehicleValue / 100);
                if (BasePremium < product.UnderAgeminPremium)
                {
                    BasePremium = product.UnderAgeminPremium;
                }
            }

            ExcessDiscountAmount   = GetExcessDiscount(policy.ExcessType, BasePremium);
            ExcessAdditionalAmount = GetExcessAdditional(policy.ExcessType, BasePremium);
            AgeLoadingAmount       = GetAgeLoading(product.AgeLoadingPercent, BasePremium, product);

            TotalPremium = BasePremium - ExcessDiscountAmount + AgeLoadingAmount + ExcessAdditionalAmount + policy.OptionalCoverAmount + policy.LoadAmount;

            if (TotalPremium < ProductMinimumPremium)
            {
                TotalPremium = ProductMinimumPremium + AgeLoadingAmount + policy.OptionalCoverAmount + policy.LoadAmount;
            }
            AdditionalDaysAmount     = GetAdditionalDays(policy, product, TotalPremium);
            RenewalDelayedDaysAmount = GetRenewalDelayedDaysAmount(policy, product, TotalPremium);
            TotalPremium             = Math.Round(TotalPremium + AdditionalDaysAmount - RenewalDelayedDaysAmount, 3, MidpointRounding.AwayFromZero);
            ClaimLoadingAmount       = GetClaimLoading(policy.ClaimAmount, TotalPremium, product);
            TotalPremium             = Math.Round(TotalPremium + ClaimLoadingAmount, 3, MidpointRounding.AwayFromZero);
            PremiumBeforeDiscount    = TotalPremium;
            DeductableCommission     = GetCommision(policy, TotalPremium, true);
            NonDeductableCommission  = GetCommision(policy, TotalPremium, false);
            CommissionBeforeDiscount = DeductableCommission + NonDeductableCommission;
            if (!policy.UserChangedPremium)
            {
                PremiumAfterDiscount    = PremiumBeforeDiscount;
                CommissionAfterDiscount = CommissionBeforeDiscount;
            }
            else
            {
                PremiumAfterDiscount = policy.PremiumAfterDiscount;
                if (policy.Agency == "TISCO")
                {
                    NonDeductableCommission = GetCommision(policy, PremiumAfterDiscount, false);
                }
                CommissionAfterDiscount = policy.CommissionAfterDiscount + NonDeductableCommission;
            }
            TaxOnPremiumBeforeDiscount    = GetTax(PremiumBeforeDiscount, product.TaxRate);
            TaxOnPremiumAfterDiscount     = GetTax(PremiumAfterDiscount, product.TaxRate);
            TaxOnCommissionBeforeDiscount = GetTax(CommissionBeforeDiscount, product.TaxRate);
            TaxOnCommissionAfterDiscount  = GetTax(CommissionAfterDiscount, product.TaxRate);
            Discount = PremiumBeforeDiscount - PremiumAfterDiscount;
            SetHIR(product, policy);
        }
Beispiel #2
0
 public static string GetEndorsementType(string endorsementName, MotorInsurancePolicy motorInsurancePolicy)
 {
     if (endorsementName == Constants.MotorEndorsementTypesNames.AddRemoveBank)
     {
         if (string.IsNullOrEmpty(motorInsurancePolicy.FinancierCompanyCode))
         {
             return("Remove-Bank");
         }
         else
         {
             return("Add-Bank");
         }
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.AddCover)
     {
         return("Add-Cover");
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.CancelPolicy)
     {
         return("Cancel-Policy");
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.ChangeExess)
     {
         return("Change-Excess");
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.ChangePremium)
     {
         return("Change-Premium");
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.ChangeRegistration)
     {
         return("Change-Registration");
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.ChangeSumInsured)
     {
         return("Change-Suminsured");
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.Extended)
     {
         return("Extension");
     }
     else if (endorsementName == Constants.MotorEndorsementTypesNames.InternalEndorsement)
     {
         return("Internal");
     }
     return(String.Empty);
 }
Beispiel #3
0
 private void InsertCategory(MotorInsurancePolicy policy, List <PolicyCategory> policyCategories)
 {
     if (policyCategories != null && policyCategories.Count > 0)
     {
         foreach (var dr in policyCategories)
         {
             SqlParameter[] paras = new SqlParameter[]
             {
                 new SqlParameter("@DocumentID", dr.DocumentID),
                 new SqlParameter("@InsuredCode", policy.InsuredCode),
                 new SqlParameter("@LinkID", dr.LinkID),
                 new SqlParameter("@DocumentNo", dr.DocumentNo),
                 new SqlParameter("@EndorsementNo", dr.EndorsementNo ?? string.Empty),
                 new SqlParameter("@EndorsementCount", dr.EndorsementCount),
                 new SqlParameter("@AgentCode", dr.AgentCode),
                 new SqlParameter("@LineNo", dr.LineNo),
                 new SqlParameter("@Category", dr.Category),
                 new SqlParameter("@Code", dr.Code),
                 new SqlParameter("@ValueType", dr.ValueType),
                 new SqlParameter("@Value", dr.Value),
                 new SqlParameter("@PremiumBeforeDiscount", dr.PremiumBeforeDiscount),
                 new SqlParameter("@PremiumAfterDiscount", dr.PremiumAfterDiscount),
                 new SqlParameter("@CommissionBeforeDiscount", dr.CommissionBeforeDiscount),
                 new SqlParameter("@CommissionAfterDiscount", dr.CommissionAfterDiscount),
                 new SqlParameter("@TaxOnPremiumBeforeDiscount", dr.TaxOnPremiumBeforeDiscount),
                 new SqlParameter("@TaxOnPremiumAfterDiscount", dr.TaxOnPremiumAfterDiscount),
                 new SqlParameter("@TaxOnCommissionBeforeDiscount", dr.TaxOnCommissionBeforeDiscount),
                 new SqlParameter("@TaxOnCommissionAfterDiscount", dr.TaxOnCommissionAfterDiscount),
                 new SqlParameter("@IsDeductable", dr.IsDeductable),
                 new SqlParameter("@RenewalCount", dr.RenewalCount),
                 new SqlParameter("@DomesticID", DBNull.Value),
                 new SqlParameter("@TravelID", DBNull.Value),
                 new SqlParameter("@HomeID", DBNull.Value),
                 new SqlParameter("@MotorID", dr.MotorID),
                 new SqlParameter("@MotorEndorsementID", DBNull.Value),
                 new SqlParameter("@TravelEndorsementID", DBNull.Value),
                 new SqlParameter("@HomeEndorsementID", DBNull.Value),
             };
             BKICSQL.edt(MotorInsuranceSP.PolicyCategoryInsert, paras);
         }
     }
 }
        /// <summary>
        /// Get motor proposal.
        /// </summary>
        /// <param name="motordetails">motor policy properties.</param>
        /// <param name="isMailSend">Mail send to the client or not.</param>
        /// <returns>Schedule file path.</returns>
        public string CreateMotorProposal(MotorInsurancePolicy motordetails, bool isMailSend = true)
        {
            try
            {
                string FileName     = motordetails.DocumentNo + ".pdf";
                string FileSavePath = AppDomain.CurrentDomain.BaseDirectory + "/ScheduleDocuments/" + motordetails.InsuredCode + "/" + motordetails.DocumentNo + "/";

                if (!System.IO.Directory.Exists(FileSavePath))
                {
                    System.IO.Directory.CreateDirectory(FileSavePath);
                }

                string   FullPath        = FileSavePath + FileName;
                Document document        = new Document();
                var      applicationPath = AppDomain.CurrentDomain.BaseDirectory + "/Templates/";

                if (motordetails.Agency == "BBK")
                {
                    document.LoadFromFile(ExtensionMethods.CopyFile(applicationPath + "MotorProposal-Secura.docx", FileSavePath + "MotorProposal-Secura.docx"));
                }
                else
                {
                    document.LoadFromFile(ExtensionMethods.CopyFile(applicationPath + "MotorProposal-Tisco.docx", FileSavePath + "MotorProposal-Tisco.docx"));
                }


                var InsuredName = motordetails.IsUnderBCFC ? "BAHRAIN COMMERCIAL FACILITIE COMPANY" : motordetails.InsuredName;

                var proposalName = motordetails.RenewalCount > 0 ? "Motor Renewal Proposal" : "Motor Proposal";

                document.Replace("{{Motor Proposal}}", proposalName, false, true);
                document.Replace("{{PolicyNo}}", motordetails.DocumentNo, false, true);
                document.Replace("{{InsuredName}}", InsuredName, false, true);
                document.Replace("{{RegistrationNo}}", Convert.ToString(motordetails.RegistrationNumber), false, true);
                document.Replace("{{ChasisNo}}", motordetails.ChassisNo, false, true);
                document.Replace("{{VehicleMake}}", motordetails.VehicleMake, false, true);
                document.Replace("{{VehicleModel}}", motordetails.VehicleModel, false, true);
                document.Replace("{{EngineCapacity}}", Convert.ToString(motordetails.EngineCC), false, true);
                document.Replace("{{YearOfMake}}", Convert.ToString(motordetails.YearOfMake), false, true);
                document.Replace("{{StartDate}}", motordetails.PolicyCommencementDate.CovertToLocalFormat(), false, true);
                document.Replace("{{ExpiryDate}}", motordetails.ExpiryDate.CovertToLocalFormat(), false, true);
                document.Replace("{{Product}}", string.IsNullOrEmpty(motordetails.Subclass) ? "" : motordetails.Subclass, false, true);
                document.Replace("{{VehicleValue}}", Convert.ToString(motordetails.VehicleValue), false, true);
                document.Replace("{{Premium}}", Convert.ToString(motordetails.PremiumAfterDiscount), false, true);
                document.Replace("{{ExcessValue}}", Convert.ToString(motordetails.ExcessAmount), false, true);
                document.Replace("{{ExcessType}}", motordetails.ExcessType, false, true);
                document.Replace("{{CurrentDateTime}}", Convert.ToString(DateTime.Now), false, true);
                document.Replace("{{Vat}}", Convert.ToString(motordetails.TaxOnPremium), false, true);
                document.Replace("{{Total}}", Convert.ToString(motordetails.PremiumAfterDiscount + motordetails.TaxOnPremium), false, true);

                if (string.IsNullOrEmpty(motordetails.FinancierCompanyCode))
                {
                    document.Replace("{{FinancierType}}", "Privately owned", false, true);
                }
                else
                {
                    document.Replace("{{FinancierType}}", motordetails.FinancierCompanyCode, false, true);
                }

                string coverCodes = string.Empty;
                if (motordetails.Covers != null)
                {
                    for (int i = 0; i < motordetails.Covers.Count; i++)
                    {
                        coverCodes += motordetails.Covers[i].CoverCode.ToLower() + ", ";
                    }
                    //Optional covers.
                    if (motordetails.OptionalCovers != null && motordetails.OptionalCovers.Count > 0)
                    {
                        for (int i = 0; i < motordetails.OptionalCovers.Count; i++)
                        {
                            coverCodes += motordetails.OptionalCovers[i].CoverCode.ToLower() + ", ";
                        }
                    }
                    coverCodes = coverCodes.TrimStart(' ').TrimEnd(' ').TrimStart(',').Trim(',');
                    document.Replace("{{Covers}}", coverCodes, false, true);
                }
                else
                {
                    document.Replace("{{Covers}}", "", false, true);
                }
                if (System.IO.File.Exists(FullPath))
                {
                    System.IO.File.Delete(FullPath);
                }
                document.SaveToFile(FileSavePath + FileName, Spire.Doc.FileFormat.PDF);
                return(FullPath);
            }
            catch (Exception ex)
            {
                return("");
            }
        }
Beispiel #5
0
        private PolicyRecord InsertMotorMain(MotorInsurancePolicy policy, string spName)
        {
            DataTable optionalCovers = new DataTable();

            optionalCovers.Columns.Add("CoverCode", typeof(string));
            optionalCovers.Columns.Add("CoverDescription", typeof(string));
            optionalCovers.Columns.Add("CoverAmount", typeof(decimal));
            optionalCovers.Columns.Add("IsOptionalCover", typeof(bool));

            if (policy.OptionalCovers != null && policy.OptionalCovers.Count > 0)
            {
                foreach (var cover in policy.OptionalCovers)
                {
                    optionalCovers.Rows.Add(cover.CoverCode, cover.CoverDescription,
                                            cover.CoverAmount, 1);
                }
            }
            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@MotorID", policy.MotorID),
                new SqlParameter("@InsuredCode", policy.InsuredCode),
                new SqlParameter("@DOB", policy.DOB),
                new SqlParameter("@YearOfMake", policy.YearOfMake),
                new SqlParameter("@VehicleMake", policy.VehicleMake),
                new SqlParameter("@VehicleModel", policy.VehicleModel),
                new SqlParameter("@vehicleTypeCode", policy.vehicleTypeCode),
                new SqlParameter("@vehicleBodyType", policy.vehicleBodyType),
                new SqlParameter("@VehicleSumInsured", policy.VehicleValue),
                new SqlParameter("@BasePremium", policy.PremiumAmount),
                new SqlParameter("@PolicyCommenceDate", policy.PolicyCommencementDate),
                new SqlParameter("@PolicyEndDate", policy.PolicyEndDate),
                new SqlParameter("@RegistrationNumber", policy.RegistrationNumber ?? ""),
                new SqlParameter("@ChassisNo", policy.ChassisNo),
                new SqlParameter("@EngineCC", policy.EngineCC),
                new SqlParameter("@FinancierCompanyCode", !string.IsNullOrEmpty(policy.FinancierCompanyCode) ? policy.FinancierCompanyCode : ""),
                new SqlParameter("@ExcessType", !string.IsNullOrEmpty(policy.ExcessType) ? policy.ExcessType : ""),
                new SqlParameter("@dt", optionalCovers),
                new SqlParameter("OptionalCoverAmount", policy.OptionalCoverAmount),
                new SqlParameter("@IsUnderBCFC", policy.IsUnderBCFC),
                new SqlParameter("@SeatingCapacity", policy.SeatingCapacity),
                new SqlParameter("@Createdby", policy.CreatedBy),
                new SqlParameter("@AuthorizedBy", policy.AuthorizedBy),
                new SqlParameter("@IsSaved", policy.IsSaved),
                new SqlParameter("@IsActive", policy.IsActivePolicy),
                new SqlParameter("@PaymentAuthorization", policy.PaymentAuthorizationCode ?? ""),
                new SqlParameter("@TransactionNo", policy.TransactionNo ?? ""),
                new SqlParameter("@PaymentType", policy.PaymentType ?? ""),
                new SqlParameter("@AccountNumber", policy.AccountNumber ?? ""),
                new SqlParameter("@Remarks", policy.Remarks ?? ""),
                new SqlParameter("@MainClass", policy.Mainclass ?? ""),
                new SqlParameter("@SubClass", policy.Subclass ?? ""),
                new SqlParameter("@Agency", policy.Agency),
                new SqlParameter("@AgentCode", policy.AgencyCode),
                new SqlParameter("@AgentBranch", policy.AgentBranch),
                new SqlParameter("ExcessAmount", ExcessAmount),
                new SqlParameter("@PremiumBeforeDiscount", PremiumBeforeDiscount),
                new SqlParameter("@PremiumAfterDiscount", PremiumAfterDiscount),
                new SqlParameter("@CommissionBeforeDiscount", CommissionBeforeDiscount),
                new SqlParameter("@CommissionAfterDiscount", CommissionAfterDiscount),
                new SqlParameter("@TaxOnPremiumBeforeDiscount", TaxOnPremiumBeforeDiscount),
                new SqlParameter("@TaxOnPremiumAfterDiscount", TaxOnPremiumAfterDiscount),
                new SqlParameter("@TaxOnCommissionBeforeDiscount", TaxOnCommissionBeforeDiscount),
                new SqlParameter("@TaxOnCommissionAfterDiscount", TaxOnCommissionAfterDiscount),
                new SqlParameter("@Discount", Discount),
                new SqlParameter("@IsHIR", IsHIR),
                new SqlParameter("@HIRReason", HIRReason ?? string.Empty),
                new SqlParameter("@HIRStatus", HIRStatus),
                new SqlParameter("@UserChangedPremium", policy.UserChangedPremium),
                new SqlParameter("@AgeLoadingAmount", AgeLoadingAmount),
                new SqlParameter("@ExcessDiscountPercent", ExcessDiscountPercent),
                new SqlParameter("@ExcessAdditionalAmount", ExcessAdditionalAmount),
                new SqlParameter("@ClaimLoadingPercent", ClaimLoadPercent),
                new SqlParameter("@ClaimLoadingAmount", ClaimLoadingAmount),
                new SqlParameter("@ClaimAmount", policy.ClaimAmount),
                new SqlParameter("@OtherLoadingAmount", policy.LoadAmount),
                new SqlParameter("@OldDocumentNumber", policy.OldDocumentNumber ?? string.Empty),
                new SqlParameter("@RenewalDocumentNumber", policy.DocumentNo ?? string.Empty),
                new SqlParameter("@OldRenewalCount", policy.RenewalCount),
                new SqlParameter("@RenewalDelayedDays", policy.RenewalDelayedDays),
                new SqlParameter("@ActualRenewalStartDate", policy.ActualRenewalStartDate.HasValue ? policy.ActualRenewalStartDate : (object)DBNull.Value)
            };
            List <SPOut> outParams = new List <SPOut>()
            {
                new SPOut()
                {
                    OutPutType = SqlDbType.BigInt, ParameterName = "@NewMotorID"
                },
                new SPOut()
                {
                    OutPutType = SqlDbType.NVarChar, ParameterName = "@DocumentNumber", Size = 100
                },
                new SPOut()
                {
                    OutPutType = SqlDbType.NVarChar, ParameterName = "@LinkIDNew", Size = 100
                },
                new SPOut()
                {
                    OutPutType = SqlDbType.Int, ParameterName = "@RenewalCount"
                },
            };

            object[] dataSet      = BKICSQL.GetValues(spName, paras, outParams);
            var      MotorID      = Convert.ToInt64(dataSet[0] != null ? dataSet[0] : 0);
            var      DocNo        = Convert.ToString(dataSet[1]);
            var      LinkID       = Convert.ToString(dataSet[2]);
            var      RenewalCount = Convert.ToInt32(dataSet[3]);

            return(new PolicyRecord
            {
                IsInserted = true,
                DocumentNumber = DocNo,
                LinkID = LinkID,
                NewMotorID = MotorID,
                RenewalCount = RenewalCount
            });
        }