コード例 #1
0
        public decimal GetExcess(BO.MotorInsurancePolicy policy, BO.MotorProductMaster product, int Age)
        {
            decimal excessAmount = decimal.Zero;

            var underAgeLimit = product != null ? product.UnderAge : 25;

            var excessRequest = new BKIC.SellingPoint.DL.BO.ExcessAmountRequest
            {
                VehicleMake  = policy.VehicleMake,
                VehicleModel = policy.VehicleModel,
                ExcessType   = policy.ExcessType,
                Agency       = policy.Agency,
                AgentCode    = policy.AgencyCode,
                MainClass    = policy.Mainclass,
                SubClass     = policy.Subclass,
                IsUnderAge   = Age < underAgeLimit ? true : false
            };

            var excessResponse = _motorInsuranceRepository.GetExcessCalcualtion(excessRequest);

            if (excessResponse.IsTransactionDone)
            {
                excessAmount = excessResponse.ExcessAmount;
                return(excessAmount);
            }
            return(excessAmount);
        }
コード例 #2
0
        public decimal GetRenewalDelayedDaysAmount(BO.MotorInsurancePolicy policy, BO.MotorProductMaster product, decimal netPremium)
        {
            decimal delayedDaysAmount = 0;

            if (policy.RenewalDelayedDays > 0)
            {
                delayedDaysAmount = (netPremium * policy.RenewalDelayedDays) / 365;
            }
            return(delayedDaysAmount);
        }
コード例 #3
0
        public decimal GetCommision(BO.MotorInsurancePolicy policy, decimal totalPremium, bool isDeductable)
        {
            decimal CommissionAmount = 0;

            var commisionRequest = new BO.CommissionRequest
            {
                AgentCode     = policy.AgencyCode,
                Agency        = policy.Agency,
                SubClass      = policy.Subclass,
                PremiumAmount = totalPremium,
                IsDeductable  = isDeductable
            };

            var commissionResponse = _insurancePortalRepository.GetCommission(commisionRequest);

            if (commissionResponse.IsTransactionDone)
            {
                CommissionAmount = commissionResponse.CommissionAmount;
            }
            return(CommissionAmount);
        }
コード例 #4
0
        public decimal GetAdditionalDays(BO.MotorInsurancePolicy policy, BO.MotorProductMaster product, decimal netPremium)
        {
            decimal additionalDaysAmount = 0;

            if (product.HasAdditionalDays)
            {
                if (policy.Agency == "BBK")
                {
                    var actualExpireDate = policy.PolicyCommencementDate.AddYears(1).AddDays(-1);

                    decimal additionalDays = Convert.ToDecimal((policy.PolicyEndDate - actualExpireDate).TotalDays);

                    if (additionalDays > 0)
                    {
                        additionalDaysAmount = netPremium * additionalDays / 365;
                    }
                }
                else
                {
                    DateTime actualExpireDate = DateTime.Now;
                    if (policy.vehicleTypeCode == "Used" || string.IsNullOrEmpty(policy.vehicleTypeCode))
                    {
                        actualExpireDate = policy.PolicyCommencementDate.AddYears(1).AddDays(-1);
                    }
                    else
                    {
                        actualExpireDate = policy.PolicyCommencementDate.AddMonths(13).AddDays(-1);
                    }
                    decimal additionalDays = Convert.ToDecimal((policy.PolicyEndDate - actualExpireDate).TotalDays);
                    if (additionalDays > 0)
                    {
                        additionalDaysAmount = netPremium * additionalDays / 365;
                    }
                }
            }
            return(additionalDaysAmount);
        }
コード例 #5
0
        public void SetHIR(BO.MotorProductMaster product, BO.MotorInsurancePolicy policy)
        {
            bool isAdded = false;

            if (product.MaximumVehicleAge < DateTime.Now.Year - policy.YearOfMake)
            {
                IsHIR     = true;
                HIRReason = "Vehicle year exceed the limit";
                HIRStatus = 1;
                isAdded   = true;
            }
            if (product.MaximumVehicleValue < policy.VehicleValue)
            {
                IsHIR     = true;
                HIRReason = isAdded ? ", " + "Vehicle value exceeds the limit" : "Vehicle value exceeds the limit";
                HIRStatus = 1;
                isAdded   = true;
            }
            if (product.UnderAgeToHIR && Age < product.UnderAge)
            {
                IsHIR     = true;
                HIRReason = isAdded ? ", " + "Insured under age" : "Insured under age";
                HIRStatus = 1;
                isAdded   = true;
            }
            if (policy.ClaimAmount > 0 && product.MotorClaim != null && product.MotorClaim.Count > 0)
            {
                if (policy.ClaimAmount > product.MotorClaim[0].MaximumClaimAmount)
                {
                    IsHIR     = true;
                    HIRReason = isAdded ? ", " + "Claim amount exceed" : "Claim amount exceed";
                    HIRStatus = 1;
                    isAdded   = true;
                }
            }
        }
コード例 #6
0
        public void CalculateCommission(BO.MotorProduct motorProduct, BO.MotorInsurancePolicy policy,
                                        long motorID, string documentNo, string LinkID, int renewalCount)
        {
            try
            {
                int lineNo = 0;
                if (motorProduct.Category != null && motorProduct.Category.Count > 0)
                {
                    List <PolicyCategory> policyCategories = new List <PolicyCategory>();
                    foreach (var dr in motorProduct.Category)
                    {
                        lineNo++;
                        if (!policy.UserChangedPremium)
                        {
                            if (dr.ValueType == "Percent")
                            {
                                var policyCategory = new PolicyCategory();
                                policyCategory.Agency    = dr.Agency;
                                policyCategory.AgentCode = dr.AgentCode;
                                policyCategory.Code      = dr.Code;
                                policyCategory.Category  = dr.Category;
                                policyCategory.CommissionBeforeDiscount = Math.Round(dr.IsDeductable ?
                                                                                     PremiumBeforeDiscount * dr.Value / 100
                                                                          : PremiumAfterDiscount * dr.Value / 100, 3, MidpointRounding.AwayFromZero);

                                policyCategory.CommissionAfterDiscount = Math.Round(PremiumAfterDiscount * dr.Value / 100, 3, MidpointRounding.AwayFromZero);
                                policyCategory.DocumentNo                    = documentNo;
                                policyCategory.EndorsementCount              = 0;
                                policyCategory.EndorsementNo                 = string.Empty;
                                policyCategory.DocumentID                    = motorID;
                                policyCategory.LineNo                        = lineNo.ToString();
                                policyCategory.LinkID                        = LinkID;
                                policyCategory.PremiumAfterDiscount          = PremiumAfterDiscount;
                                policyCategory.PremiumBeforeDiscount         = PremiumBeforeDiscount;
                                policyCategory.TaxOnCommissionBeforeDiscount = GetTax(policyCategory.CommissionBeforeDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnCommissionAfterDiscount  = GetTax(policyCategory.CommissionAfterDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnPremiumBeforeDiscount    = GetTax(PremiumBeforeDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnPremiumAfterDiscount     = GetTax(PremiumAfterDiscount, motorProduct.TaxRate);
                                policyCategory.Value        = dr.Value;
                                policyCategory.ValueType    = dr.ValueType;
                                policyCategory.IsDeductable = dr.IsDeductable;
                                policyCategory.RenewalCount = renewalCount;
                                policyCategory.MotorID      = motorID;

                                policyCategories.Add(policyCategory);
                            }
                        }
                        else
                        {
                            if (dr.ValueType == "Percent" && dr.IsDeductable)
                            {
                                var policyCategory = new PolicyCategory();
                                policyCategory.Agency    = dr.Agency;
                                policyCategory.AgentCode = dr.AgentCode;
                                policyCategory.Code      = dr.Code;
                                policyCategory.Category  = dr.Category;
                                policyCategory.CommissionBeforeDiscount = Math.Round(PremiumBeforeDiscount * dr.Value / 100, 3, MidpointRounding.AwayFromZero);
                                policyCategory.CommissionAfterDiscount  = CommissionAfterDiscount - NonDeductableCommission;
                                policyCategory.DocumentNo                    = documentNo;
                                policyCategory.EndorsementCount              = 0;
                                policyCategory.EndorsementNo                 = string.Empty;
                                policyCategory.DocumentID                    = motorID;
                                policyCategory.LineNo                        = lineNo.ToString();
                                policyCategory.LinkID                        = LinkID;
                                policyCategory.PremiumAfterDiscount          = PremiumAfterDiscount;
                                policyCategory.PremiumBeforeDiscount         = PremiumBeforeDiscount;
                                policyCategory.TaxOnCommissionBeforeDiscount = GetTax(policyCategory.CommissionBeforeDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnCommissionAfterDiscount  = GetTax(policyCategory.CommissionAfterDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnPremiumBeforeDiscount    = GetTax(PremiumBeforeDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnPremiumAfterDiscount     = GetTax(PremiumAfterDiscount, motorProduct.TaxRate);
                                policyCategory.Value        = dr.Value;
                                policyCategory.ValueType    = dr.ValueType;
                                policyCategory.IsDeductable = dr.IsDeductable;
                                policyCategory.RenewalCount = renewalCount;
                                policyCategory.MotorID      = motorID;

                                policyCategories.Add(policyCategory);
                            }
                            if (dr.ValueType == "Percent" && !dr.IsDeductable)
                            {
                                var policyCategory = new PolicyCategory();
                                policyCategory.Agency    = dr.Agency;
                                policyCategory.AgentCode = dr.AgentCode;
                                policyCategory.Code      = dr.Code;
                                policyCategory.Category  = dr.Category;
                                policyCategory.CommissionBeforeDiscount = Math.Round(PremiumAfterDiscount * dr.Value / 100, 3, MidpointRounding.AwayFromZero);
                                policyCategory.CommissionAfterDiscount  = Math.Round(PremiumAfterDiscount * dr.Value / 100, 3, MidpointRounding.AwayFromZero);
                                policyCategory.DocumentNo                    = documentNo;
                                policyCategory.EndorsementCount              = 0;
                                policyCategory.EndorsementNo                 = string.Empty;
                                policyCategory.DocumentID                    = motorID;
                                policyCategory.LineNo                        = lineNo.ToString();
                                policyCategory.LinkID                        = LinkID;
                                policyCategory.PremiumAfterDiscount          = PremiumAfterDiscount;
                                policyCategory.PremiumBeforeDiscount         = PremiumAfterDiscount;
                                policyCategory.TaxOnCommissionBeforeDiscount = GetTax(policyCategory.CommissionBeforeDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnCommissionAfterDiscount  = GetTax(policyCategory.CommissionAfterDiscount, motorProduct.TaxRate);
                                policyCategory.TaxOnPremiumBeforeDiscount    = GetTax(PremiumAfterDiscount, 5);
                                policyCategory.TaxOnPremiumAfterDiscount     = GetTax(PremiumAfterDiscount, 5);
                                policyCategory.Value        = dr.Value;
                                policyCategory.ValueType    = dr.ValueType;
                                policyCategory.IsDeductable = dr.IsDeductable;
                                policyCategory.RenewalCount = renewalCount;
                                policyCategory.MotorID      = motorID;

                                policyCategories.Add(policyCategory);
                            }
                        }
                    }
                    if (policy.UserChangedPremium)
                    {
                        var commissionDiscount = policy.CommissionAfterDiscount;
                        foreach (var pc in policyCategories)
                        {
                            if (pc.IsDeductable)
                            {
                                if (pc.CommissionBeforeDiscount < commissionDiscount)
                                {
                                    pc.CommissionAfterDiscount      = pc.CommissionBeforeDiscount;
                                    pc.TaxOnCommissionAfterDiscount = GetTax(pc.CommissionBeforeDiscount, motorProduct.TaxRate);
                                    commissionDiscount = commissionDiscount - pc.CommissionBeforeDiscount;
                                }
                                else
                                {
                                    pc.CommissionAfterDiscount      = commissionDiscount;
                                    pc.TaxOnCommissionAfterDiscount = GetTax(commissionDiscount, motorProduct.TaxRate);
                                    commissionDiscount = 0;
                                }
                            }
                        }
                    }
                    InsertCategory(policy, policyCategories);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
        public BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse InsertMotor(BO.MotorInsurancePolicy policy)
        {
            try
            {
                var req = new BO.MotorProductRequest
                {
                    Type      = "fetch",
                    Agency    = policy.Agency,
                    AgentCode = policy.AgencyCode,
                    MainClass = policy.Mainclass,
                    SubClass  = policy.Subclass,
                };
                BO.MotorProductMasterResponse productRes = _adminRepository.GetMotorProduct(req);
                if (productRes != null && productRes.IsTransactionDone && productRes.motorProductMaster.Count > 0)
                {
                    BO.MotorProductMaster product = productRes.motorProductMaster[0];
                    if (product != null)
                    {
                        Calculate(policy, product);
                        var policyRecord = InsertMotorMain(policy, policy.IsRenewal ? MotorInsuranceSP.MotorRenewalInsert : MotorInsuranceSP.MotorInsert);
                        if (policyRecord != null && policyRecord.IsInserted)
                        {
                            CalculateCommission(product, policy, policyRecord.NewMotorID, policyRecord.DocumentNumber,
                                                policyRecord.LinkID, policyRecord.RenewalCount);

                            if (!IsHIR && policy.IsActivePolicy)
                            {
                                try
                                {
                                    new Task(() =>
                                    {
                                        SqlParameter[] para = new SqlParameter[]
                                        {
                                            new SqlParameter("@MotorID", policyRecord.NewMotorID)
                                        };
                                        SellingPointSQL.eds("MIG_IntegrateMotorDetails", para);
                                    }).Start();
                                }
                                catch (AggregateException ex)
                                {
                                    foreach (Exception inner in ex.InnerExceptions)
                                    {
                                        _mail.SendMailLogError(inner.Message, policy.InsuredCode, "MotorInsurance", policy.Agency, true);
                                    }
                                }
                            }
                            return(new BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse()
                            {
                                IsTransactionDone = true,
                                IsHIR = IsHIR,
                                MotorID = policyRecord.NewMotorID,
                                DocumentNo = policyRecord.DocumentNumber,
                                RenewalCount = policyRecord.RenewalCount
                            });
                        }
                    }
                    return(new BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse()
                    {
                        IsTransactionDone = false,
                        TransactionErrorMessage = "Product not found"
                    });
                }
                return(new BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse()
                {
                    IsTransactionDone = false,
                    TransactionErrorMessage = "Product not found"
                });
            }
            catch (Exception ex)
            {
                _mail.SendMailLogError(ex.Message, policy.InsuredCode, "MotorInsurance", policy.Agency, false);
                return(new MotorInsurancePolicyResponse()
                {
                    IsTransactionDone = false,
                    TransactionErrorMessage = ex.ToString()
                });
            }
        }