public void CalculateEndorsementQuote(bool showPremium)
        {
            master.IsSessionAvailable();
            var userInfo = CommonMethods.GetUserDetails();
            var service  = CommonMethods.GetLogedInService();

            var motorEndorementQuote = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote
            {
                Agency            = userInfo.Agency,
                AgentCode         = userInfo.AgentCode,
                MainClass         = MainClass,
                SubClass          = SubClass,
                EffectiveFromDate = txtEffectiveFromDate.Text.CovertToCustomDateTime(),
                EffectiveToDate   = txtEffectiveToDate.Text.CovertToCustomDateTime(),
                PaidPremium       = string.IsNullOrEmpty(paidPremium.Value) ? decimal.Zero : Convert.ToDecimal(paidPremium.Value),
                EndorsementType   = "AddRemoveBank",
                CancelationDate   = DateTime.Now,
                NewInsuredCode    = string.Empty
            };

            //Calculate the motor endorsement premium.
            var motorEndoQuoteResult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuoteResult>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote>
                                           (BKIC.SellingPoint.DTO.Constants.MotorEndorsementURI.GetMotorEndorsementQuote, motorEndorementQuote);

            if (motorEndoQuoteResult.StatusCode == 200 && motorEndoQuoteResult.Result.IsTransactionDone)
            {
                var endoresementPremium = motorEndoQuoteResult.Result.EndorsementPremium;
                calculatedPremium.Value = endoresementPremium.ToString();

                var commisionRequest = new BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionRequest();
                commisionRequest.AgentCode     = userInfo.AgentCode;
                commisionRequest.Agency        = userInfo.Agency;
                commisionRequest.SubClass      = subClass.Value;
                commisionRequest.PremiumAmount = endoresementPremium;

                //Get commision for the endorsement premium.
                var commissionresult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionResponse>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionRequest>("api/insurance/Commission", commisionRequest);

                if (commissionresult.StatusCode == 200 && commissionresult.Result.IsTransactionDone && commissionresult.Result.CommissionAmount > 0)
                {
                    //commission.Text = Convert.ToString(commissionresult.Result.CommissionAmount);
                    calculatedCommision.Value = Convert.ToString(commissionresult.Result.CommissionAmount);
                    //ShowPremium(userInfo, endoresementPremium, commissionresult.Result.CommissionAmount);
                }
            }
        }
 public RR.MotorEndorsementQuoteResult GetQuote(RR.MotorEndorsementQuote motorEndorsementQuote)
 {
     try
     {
         BLO.MotorEndorsementQuote       details = _mapper.Map <RR.MotorEndorsementQuote, BLO.MotorEndorsementQuote>(motorEndorsementQuote);
         BLO.MotorEndorsementQuoteResult result  = _motorEndorsementRepository.GetMotorEndorsementQuote(details);
         return(_mapper.Map <BLO.MotorEndorsementQuoteResult, RR.MotorEndorsementQuoteResult>(result));
     }
     catch (Exception ex)
     {
         return(new RR.MotorEndorsementQuoteResult
         {
             IsTransactionDone = false,
             TransactionErrorMessage = ex.Message
         });
     }
 }
Esempio n. 3
0
        public void CalculateEndorsementQuote(bool showPremium)
        {
            master.IsSessionAvailable();
            var userInfo = CommonMethods.GetUserDetails();
            var service  = CommonMethods.GetLogedInService();

            var motorEndorementQuote = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote
            {
                Agency            = userInfo.Agency,
                AgentCode         = userInfo.AgentCode,
                MainClass         = MainClass,
                SubClass          = SubClass,
                EffectiveFromDate = txtEffectiveFromDate.Text.CovertToCustomDateTime(),
                EffectiveToDate   = expireDate.Value.CovertToCustomDateTime(),
                PaidPremium       = string.IsNullOrEmpty(paidPremium.Value) ? decimal.Zero : Convert.ToDecimal(paidPremium.Value),
                EndorsementType   = "CancelPolicy",
                CancelationDate   = txtEffectiveToDate.Text.CovertToCustomDateTime(),
                NewInsuredCode    = string.Empty,
                RefundType        = ddlRefundType.SelectedItem.Value,
                DocumentNo        = ddlMotorPolicies.SelectedItem.Text.Trim()
            };
            var daysDiff = (txtEffectiveToDate.Text.CovertToCustomDateTime() - expireDate.Value.CovertToCustomDateTime()).TotalDays;

            motorEndorementQuote.ExtendedDays = Convert.ToInt32(daysDiff);

            //Calculate the motor endorsement premium.
            var motorEndoQuoteResult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuoteResult>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote>
                                           (BKIC.SellingPoint.DTO.Constants.MotorEndorsementURI.GetMotorEndorsementQuote,
                                           motorEndorementQuote);

            if (motorEndoQuoteResult.StatusCode == 200 && motorEndoQuoteResult.Result.IsTransactionDone)
            {
                var refundPremium = Math.Abs(motorEndoQuoteResult.Result.EndorsementPremium);
                calculatedPremium.Value    = Convert.ToString(refundPremium * -1);
                adjustedPremium.Value      = Convert.ToString(refundPremium * -1);
                calculatedCommission.Value = Convert.ToString(motorEndoQuoteResult.Result.Commision * -1);
                adjustedCommission.Value   = Convert.ToString(motorEndoQuoteResult.Result.Commision * -1);
                ShowPremium(userInfo, refundPremium * -1, motorEndoQuoteResult.Result.Commision * -1);


                decimal TotalPremium    = (motorEndoQuoteResult.Result.EndorsementPremium + motorEndoQuoteResult.Result.RefundVat) * -1;
                decimal TotalCommission = (motorEndoQuoteResult.Result.Commision + 0) * -1;
                ShowVAT(userInfo, motorEndoQuoteResult.Result.RefundVat * -1, 0, TotalPremium, TotalCommission);
            }
            else
            {
                master.ShowLoading = false;
                master.ShowErrorPopup(motorEndoQuoteResult.Result.TransactionErrorMessage, "Request Failed !");
                return;
            }
            //Calculate VAT.
            //var vatResponse = master.GetVat(motorEndoQuoteResult.Result.EndorsementPremium, motorEndoQuoteResult.Result.Commision);
            //if (vatResponse != null && vatResponse.IsTransactionDone)
            //{
            //    decimal TotalPremium = (motorEndoQuoteResult.Result.EndorsementPremium + vatResponse.VatAmount) * -1;
            //    decimal TotalCommission = (motorEndoQuoteResult.Result.Commision + vatResponse.VatCommissionAmount) * -1;
            //    ShowVAT(userInfo, vatResponse.VatAmount * -1, vatResponse.VatCommissionAmount * -1, TotalPremium, TotalCommission);
            //}
            btnSubmit.Visible = true;
        }
        public void CalculateEndorsementQuote(bool showPremium)
        {
            master.IsSessionAvailable();
            var userInfo = CommonMethods.GetUserDetails();
            var service  = CommonMethods.GetLogedInService();

            var motorEndorementQuote = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote
            {
                Agency            = userInfo.Agency,
                AgentCode         = userInfo.AgentCode,
                MainClass         = MainClass,
                SubClass          = SubClass,
                EffectiveFromDate = txtEffectiveFromDate.Text.CovertToCustomDateTime(),
                EffectiveToDate   = txtEffectiveToDate.Text.CovertToCustomDateTime(),
                PaidPremium       = string.IsNullOrEmpty(paidPremium.Value) ? decimal.Zero : Convert.ToDecimal(paidPremium.Value),
                EndorsementType   = "Extended",
                CancelationDate   = DateTime.Now,
                NewInsuredCode    = string.Empty
            };
            var daysDiff = (txtEffectiveToDate.Text.CovertToCustomDateTime() - expireDate.Value.CovertToCustomDateTime()).TotalDays;

            motorEndorementQuote.ExtendedDays = Convert.ToInt32(daysDiff);
            motorEndorementQuote.DocumentNo   = ddlMotorPolicies.SelectedItem.Text.Trim();

            //Calculate the motor endorsement premium.
            var motorEndoQuoteResult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuoteResult>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote>
                                           (BKIC.SellingPoint.DTO.Constants.MotorEndorsementURI.GetMotorEndorsementQuote, motorEndorementQuote);

            if (motorEndoQuoteResult.StatusCode == 200 && motorEndoQuoteResult.Result.IsTransactionDone)
            {
                var endoresementPremium = motorEndoQuoteResult.Result.EndorsementPremium;
                calculatedPremium.Value = endoresementPremium.ToString();
                adjustedPremium.Value   = endoresementPremium.ToString();

                var  product           = master.GetProduct(MainClass, SubClass);
                bool includeCommission = false;
                if (product != null)
                {
                    var mEndorsement = product.MotorEndorsementMaster.Find(c => c.EndorsementType == "Extended");
                    if (mEndorsement != null)
                    {
                        includeCommission = mEndorsement.HasCommission;
                    }
                }

                var commisionRequest = new BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionRequest();
                commisionRequest.AgentCode     = userInfo.AgentCode;
                commisionRequest.Agency        = userInfo.Agency;
                commisionRequest.SubClass      = subClass.Value;
                commisionRequest.PremiumAmount = includeCommission ? endoresementPremium : decimal.Zero;
                commisionRequest.IsDeductable  = true;

                //Get commision for the endorsement premium.
                var commissionresult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionResponse>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionRequest>
                                           (BKIC.SellingPoint.DTO.Constants.CommissionURI.CalculateCommission, commisionRequest);

                if (commissionresult.StatusCode == 200 && commissionresult.Result.IsTransactionDone &&
                    commissionresult.Result.CommissionAmount >= 0)
                {
                    calculatedCommission.Value = Convert.ToString(commissionresult.Result.CommissionAmount);
                    adjustedCommission.Value   = Convert.ToString(commissionresult.Result.CommissionAmount);

                    if (showPremium)
                    {
                        ShowPremium(userInfo, endoresementPremium, commissionresult.Result.CommissionAmount);
                    }
                }
                else
                {
                    master.ShowLoading = false;
                    master.ShowErrorPopup(commissionresult.Result.TransactionErrorMessage, "Request Failed !");
                    return;
                }
                //Calculate VAT.
                var vatResponse = master.GetVat(endoresementPremium, commissionresult.Result.CommissionAmount);
                if (vatResponse != null && vatResponse.IsTransactionDone)
                {
                    decimal TotalPremium    = endoresementPremium + vatResponse.VatAmount;
                    decimal TotalCommission = commissionresult.Result.CommissionAmount + vatResponse.VatCommissionAmount;
                    ShowVAT(userInfo, vatResponse.VatAmount, vatResponse.VatCommissionAmount, TotalPremium, TotalCommission);
                }
                btnSubmit.Visible = true;
            }
            else
            {
                master.ShowLoading = false;
                master.ShowErrorPopup(motorEndoQuoteResult.Result.TransactionErrorMessage, "Request Failed !");
                return;
            }
        }
Esempio n. 5
0
        public void CalculateEndorsementQuote(bool showPremium)
        {
            master.IsSessionAvailable();
            var userInfo = CommonMethods.GetUserDetails();
            var service  = CommonMethods.GetLogedInService();

            if (string.IsNullOrEmpty(txtNewExcess.Text))
            {
                master.ShowErrorPopup("Please enter new excess amount !!", "Change Excess");
                return;
            }
            var motorEndorementQuote = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote();

            motorEndorementQuote.Agency            = userInfo.Agency;
            motorEndorementQuote.AgentCode         = userInfo.AgentCode;
            motorEndorementQuote.MainClass         = MainClass;
            motorEndorementQuote.SubClass          = SubClass;
            motorEndorementQuote.EffectiveFromDate = txtEffectiveFromDate.Text.CovertToCustomDateTime();
            motorEndorementQuote.EffectiveToDate   = txtEffectiveToDate.Text.CovertToCustomDateTime();
            motorEndorementQuote.PaidPremium       = string.IsNullOrEmpty(paidPremium.Value) ? decimal.Zero : Convert.ToDecimal(paidPremium.Value);
            motorEndorementQuote.EndorsementType   = "ChangeExcess";
            motorEndorementQuote.CancelationDate   = txtEffectiveToDate.Text.CovertToCustomDateTime();
            motorEndorementQuote.NewInsuredCode    = string.Empty;

            //Calculate the motor endorsement premium.
            var motorEndoQuoteResult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuoteResult>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorEndorsementQuote>
                                           (BKIC.SellingPoint.DTO.Constants.MotorEndorsementURI.GetMotorEndorsementQuote, motorEndorementQuote);

            if (motorEndoQuoteResult.StatusCode == 200 && motorEndoQuoteResult.Result.IsTransactionDone)
            {
                var endoPremium = motorEndoQuoteResult.Result.RefundPremium;
                calculatedPremium.Value = endoPremium.ToString();


                var  product           = master.GetProduct(MainClass, SubClass);
                bool includeCommission = false;
                if (product != null)
                {
                    var mEndorsement = product.MotorEndorsementMaster.Find(c => c.EndorsementType == "ChangeExcess");
                    if (mEndorsement != null)
                    {
                        includeCommission = mEndorsement.HasCommission;
                    }
                }
                var commisionRequest = new BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionRequest();
                commisionRequest.AgentCode     = userInfo.AgentCode;
                commisionRequest.Agency        = userInfo.Agency;
                commisionRequest.SubClass      = subClass.Value;
                commisionRequest.PremiumAmount = includeCommission ? endoPremium : decimal.Zero;
                // commisionRequest.PremiumAmount = decimal.Zero;

                //Get commision for the endorsement premium.
                var commissionresult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionResponse>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.CommissionRequest>
                                           (BKIC.SellingPoint.DTO.Constants.CommissionURI.CalculateCommission, commisionRequest);

                if (commissionresult.StatusCode == 200 && commissionresult.Result.IsTransactionDone &&
                    commissionresult.Result.CommissionAmount >= 0)
                {
                    //commission.Text = Convert.ToString(commissionresult.Result.CommissionAmount);
                    calculatedCommision.Value = Convert.ToString(commissionresult.Result.CommissionAmount);
                    if (showPremium)
                    {
                        ShowPremium(userInfo, endoPremium, commissionresult.Result.CommissionAmount);
                    }
                }
            }
        }