コード例 #1
0
        public ActionResult LoanPaymentDetails()
        {
            int    userId;
            string loanCode;

            try
            {
                userId = userData.UserId;

                loanCode = Session["loanCode"].ToString();
            }
            catch (Exception)
            {
                return(RedirectToAction("UserLogin", "Login"));
            }
            //int userId = 57;

            LoanSetupStep1 loanSetupStep1 = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode);


            LoanPaymentDetails advance = (new UnitAccess()).GetLoanPaymentDetailsByLoanId(loanSetupStep1.loanId);

            ViewBag.AvailableBalance = advance.Amount - advance.UsedAmount;

            return(PartialView(advance));
        }
コード例 #2
0
        public JsonResult GetPaymentInfo(string date, decimal money, int loanId)
        {
            DateTime paymentDate = FormattingUtils.ParseDateWithoutTime(date);
            Loan     loan        = this.loanRepository.Get(loanId);

            var hasRollover = this.rolloverRepository.GetByLoanId(loanId).Any(x => x.Status == RolloverStatus.New);

            var payEarlyCalc = new LoanRepaymentScheduleCalculator(loan, paymentDate, CurrentValues.Instance.AmountToChargeFrom);
            var state        = payEarlyCalc.GetState();

            try {
                long nlLoanId = this.serviceClient.Instance.GetLoanByOldID(loan.Id, loan.Customer.Id, this.context.UserId).Value;
                if (nlLoanId > 0)
                {
                    var nlModel = this.serviceClient.Instance.GetLoanState(loan.Customer.Id, nlLoanId, paymentDate, this.context.UserId, true).Value;
                    Log.InfoFormat("<<< NL_Compare: {0}\n================= loan: {1}  >>>", nlModel, loan);
                }
                // ReSharper disable once CatchAllClause
            } catch (Exception ex) {
                Log.InfoFormat("<<< NL_Compare Fail at: {0}, err: {1}", Environment.StackTrace, ex.Message);
            }

            var model = new LoanPaymentDetails {
                Balance  = payEarlyCalc.TotalEarlyPayment(),
                MinValue = !hasRollover ? 0.01m : state.Fees + state.Interest
            };

            model.Amount = money;

            decimal amount = Math.Min(money, state.Fees);

            model.Fee = amount;
            money     = money - amount;

            amount         = Math.Min(money, state.Interest);
            model.Interest = amount;
            money          = money - amount;

            model.Principal = money;

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        /*
         *
         * Frontend page   : Add Unit
         * Title           : Add or Advance Units
         * Designed        : Kasun Samarawickrama
         * User story      :
         * Developed       : Kasun Samarawickrama
         * Date created    : 02/24/2016
         *
         */
        public ActionResult AddUnit()
        {
            // Handle Record successfully update or Error message

            int Flag = 0;

            if (TempData["Msg"] != null)
            {
                Flag = int.Parse(TempData["Msg"].ToString());
                if (Flag == 1)
                {
                    ViewBag.Msg = "Success";
                }
                else if (Flag == 3)
                {
                    ViewBag.Msg = "Requested";
                }
                else if (Flag == 2)
                {
                    ViewBag.Msg = "Error";
                }
            }


            int userId = userData.UserId;

            ViewBag.Role = userData.RoleId;;

            //Check loan is null or not
            if (Session["loanCode"] == null || Session["loanCode"].ToString() == "")
            {
                return(RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" }));
            }

            // for role id3 - user section
            if (userData.RoleId == 3)
            {
                // check user has rights to access this loan - if not redirect to dashboard
                if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "")
                {
                    return(RedirectToAction("UserDetails", "UserManagement"));
                }
                else
                {
                    var checkPermission = false;
                    var checkAdvance    = false;

                    // check user permission to the site
                    string rgts = "";
                    rgts = (string)Session["CurrentLoanRights"];
                    string[] rgtList = null;
                    //spit the permission string
                    if (rgts != "")
                    {
                        rgtList = rgts.Split(',');
                    }
                    if (rgtList != null)
                    {
                        foreach (var x in rgtList)
                        {
                            //check user have rights to add unit page
                            if (x == "U04")
                            {
                                checkPermission = true;
                            }
                            // check user have right to advance units in this page
                            if (x == "U01")
                            {
                                checkAdvance = true;
                            }
                        }
                        if (checkAdvance == true)
                        {
                            ViewBag.advanceAllow = true;
                        }
                        else
                        {
                            ViewBag.advanceAllow = false;
                        }
                        if (checkPermission == false)
                        {
                            return(RedirectToAction("UserDetails", "UserManagement"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("UserDetails", "UserManagement"));
                    }
                }
            }
            string loanCode = Session["loanCode"].ToString();
            // retrive loan details
            LoanSetupStep1 loan = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode);

            int loanId = loan.loanId;

            Session["addUnitloan"] = loan;


            ViewBag.loanDetails = loan;
            //set default unit type for add unit page
            if (loan.selectedUnitTypes.Count == 1)
            {
                ViewBag.UnitTypeId = loan.selectedUnitTypes[0].unitTypeName;
            }

            Models.Unit unit = new Models.Unit();

            unit.AdvancePt   = loan.advancePercentage;
            unit.LoanId      = loanId;
            unit.LoanAmount  = loan.loanAmount;
            unit.AdvanceDate = DateTime.Now;
            unit.StartDate   = loan.startDate;
            unit.EndDate     = loan.maturityDate;

            //get company type
            //1 - Lender
            //2 - Dealer
            BranchAccess ba          = new BranchAccess();
            int          companyType = ba.getCompanyTypeByUserId(userId);

            ViewBag.CompabyType = companyType;
            ViewBag.RoleId      = userData.RoleId;

            //Check title
            TitleAccess ta    = new TitleAccess();
            Title       title = ta.getTitleDetails(loan.loanId);

            // check title track allow or not
            if (title != null)
            {
                bool isTitleTrack = title.IsTitleTrack;
                if (isTitleTrack)
                {
                    ViewBag.IsTitleTrack = "Yes";
                }

                string upload = title.TitleAcceptMethod;
                if (!string.IsNullOrEmpty(upload) && upload == "Scanned Title Adequate")
                {
                    ViewBag.Upload = "Yes";
                }
            }
            // loan Details for (loan Detail box) in the page
            UnitAccess         ua = new UnitAccess();
            LoanPaymentDetails loanPaymentDetails = ua.GetLoanPaymentDetailsByLoanId(loanId);

            unit.Balance = loanPaymentDetails.BalanceAmount;
            // check balane field is editable or not for this loan
            ViewBag.Editable = loan.isEditAllowable ? "Yes" : "No";


            //set user role to restrict add & advance unit if this user is dealer user(role id = 4)
            ViewBag.RoleId = userData.RoleId;

            return(PartialView(unit));
        }