public bool Deposit(decimal amt, int custId, int userId, TellerPosting tlPosting, DateTime date)
        {
            //Get teller till account
            var tillAccountId   = userId;
            var tillAccount     = _tillAccount.GetUserId(tillAccountId);
            var tillGlAccountId = tillAccount.AccountManagementId;
            var tellerGlAccount = _glContext.Get(tillGlAccountId);

            //Get Customer Account
            var customerAccount = _customer.Get(custId);
            var amount          = amt;
            var customerId      = custId;
            var datePosted      = date;


            if (tlPosting.Type == PostingType.Deposit)
            {
                //Performing transactions
                CreditCustomerAccount(amount, customerId, customerAccount);
                DebitGlAccount(amount, tellerGlAccount);


                //Saving teller posting
                SavePost(tlPosting);
                return(true);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TellerPosting tellerPosting = db.TellerPostings.Find(id);

            db.TellerPostings.Remove(tellerPosting);
            db.SaveChanges();
            return(RedirectToAction("UserPosts"));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            TellerPosting tellerPosting = context.TellerPostings.Find(id);

            context.TellerPostings.Remove(tellerPosting);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        public ActionResult Create()
        {
            var tellerRepository = new Repository <TellerManagement>();

            ViewBag.tillAccounts = tellerRepository.GetAll();
            var           glAccountRepository       = new Repository <GLAccount>();
            var           customerAccountRepository = new Repository <CustomerAccount>();
            TellerPosting tellerPosting             = new TellerPosting();

            tellerPosting.CustomerAccount = (CustomerAccount)TempData["CustomerAccount"];
            ViewBag.postType = Enum.GetValues(typeof(PostType));
            return(View(tellerPosting));
        }
Ejemplo n.º 5
0
        // GET: TellerPosting/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TellerPosting tellerPosting = db.TellerPostings.Find(id);

            if (tellerPosting == null)
            {
                return(HttpNotFound());
            }
            return(View(tellerPosting));
        }
Ejemplo n.º 6
0
        public ActionResult DeclineTellerPost(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TellerPosting tellerPosting = db.TellerPostings.Find(id);

            if (tellerPosting == null)
            {
                return(HttpNotFound());
            }
            tellerPosting.Status          = PostStatus.Declined;
            db.Entry(tellerPosting).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("TellerPosts"));
        }
Ejemplo n.º 7
0
        // GET: TellerPosting/Create
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerAccount customerAccount = db.CustomerAccounts.Find(id);

            if (customerAccount == null)
            {
                return(HttpNotFound());
            }

            TellerPosting model = new TellerPosting();

            model.CustomerAccountID = customerAccount.Id;

            ViewBag.PostingType = string.Empty;

            return(View(model));
        }
        public ActionResult PostingDetails(int?accountId)
        {
            if (accountId == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }
            var account = custActRepo.GetById((int)accountId);

            if (account == null)
            {
                return(HttpNotFound());
            }
            TellerPosting posting = new TellerPosting();

            posting.CustomerAccount = account;

            CustomerAccount sessionAccount = GetAccountToPostTo();

            sessionAccount         = account;
            Session["custAccount"] = sessionAccount;
            return(PartialView("_PostDetails", posting));
        }
Ejemplo n.º 9
0
        public ActionResult Create(TellerPostingViewModel model)
        {
            if (config.IsBusinessOpen == false)
            {
                return(View("BusinessClosed"));
            }

            if (ModelState.IsValid)
            {
                TellerPosting tellerPost = new TellerPosting();
                tellerPost.CreditAmount    = model.CreditAmount;
                tellerPost.DebitAmount     = model.DebitAmount;
                tellerPost.CustomerAccount = context.CustomerAccounts.Find(model.CustomerAccountID);
                tellerPost.Narration       = model.Narration;
                tellerPost.TransactionDate = DateTime.Now;
                tellerPost.PostingType     = (PostingType)model.PostingType;

                string          currentUserId = User.Identity.GetUserId();
                ApplicationUser currentUser   = context.Users.FirstOrDefault(x => x.Id == currentUserId);
                tellerPost.TillAccount = currentUser.GLAccount;

                string result = TellerPostingLogic.PostTeller(tellerPost.CustomerAccount, tellerPost.TillAccount, tellerPost.CreditAmount, tellerPost.PostingType, config);

                if (result == "success")
                {
                    context.TellerPostings.Add(tellerPost);
                    context.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.Message = result;
                return(View(model));
            }

            return(View(model));
        }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Exclude = "Till")] TellerPosting tellerPost)
        {
            var userdetails = (User)Session["User"];
            //int userID = userdetails.Id;
            bool IsUserAssigned = userdetails.IsAssigned;

            var tellerRepository = new Repository <TellerManagement>();

            var glAccountRepository       = new Repository <GLAccount>();
            var customerAccountRepository = new Repository <CustomerAccount>();

            ViewBag.postType = Enum.GetValues(typeof(PostType));

            if (IsUserAssigned)

            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        using (ISession session = NHibernateHelper.Session)
                        {
                            using (ITransaction transaction = session.BeginTransaction())
                            {
                                //get user's till account
                                var till = session.Query <TellerManagement>().FirstOrDefault(x => x.User == userdetails);
                                //For Till Account
                                var till_gl_account = session.Query <GLAccount>().FirstOrDefault(b => b.Id == till.TillAccount.Id);
                                //tellerPost.Till.TillAccount = tillAccount;
                                tellerPost.Till = till;
                                //For Customer Account
                                var customerAccount = session.Query <CustomerAccount>().FirstOrDefault(b => b.Id == tellerPost.CustomerAccount.Id);
                                tellerPost.CustomerAccount = customerAccount;
                                tellerPost.TransactionDate = DateTime.Now;
                                // SavingAccountConfig savingAccountConfig = new SavingAccountConfig();
                                //CurrentAccountConfig currentAccountConfig = new CurrentAccountConfig();

                                var current = session.Query <CurrentAccountConfig>().FirstOrDefault();
                                var savings = session.Query <SavingAccountConfig>().FirstOrDefault();



                                if (!customerAccount.IsClosed)
                                {
                                    if (IsPostDeposit(tellerPost.PostType))
                                    {
                                        till_gl_account.AccountBalance += tellerPost.PostAmount;
                                        customerAccount.AccountBalance += tellerPost.PostAmount;
                                        if (customerAccount.AccountType == AccountType.Savings)
                                        {
                                            savings.CustomerSavingAccount.AccountBalance += tellerPost.PostAmount;
                                        }
                                        if (customerAccount.AccountType == AccountType.Current && current != null)
                                        {
                                            current.CustomerCurrentAccount.AccountBalance += tellerPost.PostAmount;
                                        }
                                    }
                                    else
                                    {
                                        if (tellerPost.PostAmount <= till_gl_account.AccountBalance)
                                        {
                                            if (tellerPost.PostAmount <= customerAccount.AccountBalance)
                                            {
                                                //
                                                if (customerAccount.AccountBalance >= savings.MinimumBalance ||
                                                    customerAccount.AccountBalance >= current.MinimumBalance)
                                                {
                                                    till_gl_account.AccountBalance -= tellerPost.PostAmount;
                                                    customerAccount.AccountBalance -= tellerPost.PostAmount;

                                                    if (customerAccount.AccountType == AccountType.Savings)
                                                    {
                                                        savings.CustomerSavingAccount.AccountBalance -= tellerPost.PostAmount;
                                                    }
                                                    if (customerAccount.AccountType == AccountType.Current)
                                                    {
                                                        current.CustomerCurrentAccount.AccountBalance -= tellerPost.PostAmount;
                                                        current.CustomerCurrentAccount.AccountBalance -= current.COT;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ModelState.AddModelError("", "Insufficient Balance!");
                                                return(View());
                                            }
                                        }
                                        else
                                        {
                                            ModelState.AddModelError("", "Not Enough Money in Till Account");
                                            return(View());
                                        }
                                    }
                                }
                                else
                                {
                                    ModelState.AddModelError("", "Cannot Perform Transactions on Closed accounts");
                                    return(View());
                                }
                                glAccountRepository.Update(till_gl_account, till_gl_account.Id);
                                glAccountRepository.Update(savings.CustomerSavingAccount, savings.CustomerSavingAccount.Id);
                                glAccountRepository.Update(current.CustomerCurrentAccount, current.CustomerCurrentAccount.Id);
                                customerAccountRepository.Update(customerAccount, customerAccount.Id);
                                tellerPost.TransactionDate = DateTime.Now;
                                tellerPost.DateAdded       = DateTime.Now;
                                tellerPost.DateUpdated     = DateTime.Now;
                                _tellerPostingRepository.Save(tellerPost);
                            }
                        }
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception exception)
                    {
                        ViewBag.Exception = exception.Message;
                    }
                }
            }

            else
            {
                ModelState.AddModelError("", "User is not assinged to any Till Account");
            }
            return(View(new TellerPosting()));
        }
Ejemplo n.º 11
0
        //        [Authorize]
        public HttpResponseMessage AddTellerPosting(TellerPostingDto tellerPostingDto)
        {
            var businessStatus        = _context.BusinessStatus.SingleOrDefault();
            var customerAccountStatus = _context.CustomerAccounts
                                        .SingleOrDefault(c => c.Id == tellerPostingDto.CustomerAccountId).IsClosed;
            var userId = _context.Users.SingleOrDefault(c => c.Email.Equals(RoleName.EMAIL)).Id;
            var teller = _context.Tellers.SingleOrDefault(c => c.UserTellerId.Equals(userId));

            if (teller != null)
            {
                var tellerId = teller.Id;
                tellerPostingDto.TellerId = tellerId;


                if (businessStatus.Status == false)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, CBA.BUSINESS_CLOSED_REFRESH_MSG));
                }

                if (customerAccountStatus == true)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Customer Account is <b>CLOSED</b>"));
                }

                tellerPostingDto.TransactionDate = DateTime.Now;

                var tellerPosting = new TellerPosting();
                tellerPosting = Mapper.Map <TellerPostingDto, TellerPosting>(tellerPostingDto);

                _context.TellerPostings.Add(tellerPosting);
                _context.SaveChanges();

                EnforceDoubleEntry(tellerPostingDto.Amount, tellerPosting.CustomerAccountId,
                                   tellerPostingDto.PostingType);

                var financialReportDto = new FinancialReportDto();
                financialReportDto.PostingType = "Teller Posting";
                if (tellerPostingDto.PostingType == "Deposit")
                {
                    financialReportDto.CreditAccount = GetCustomerAccountName(tellerPostingDto.CustomerAccountId);
                    financialReportDto.CreditAmount  = tellerPostingDto.Amount;
                    financialReportDto.DebitAccount  = GetTillAccountName();
                    financialReportDto.DebitAmount   = tellerPostingDto.Amount;
                }
                else
                {
                    financialReportDto.DebitAccount  = GetCustomerAccountName(tellerPostingDto.CustomerAccountId);
                    financialReportDto.DebitAmount   = tellerPostingDto.Amount;
                    financialReportDto.CreditAccount = GetTillAccountName();
                    financialReportDto.CreditAmount  = tellerPostingDto.Amount;
                }

                financialReportDto.ReportDate = DateTime.Now;
                if (!errorMessage.Equals(""))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage));
                }

                CBA.AddReport(financialReportDto);

                return(Request.CreateResponse(HttpStatusCode.OK, "Teller Posted Successfully"));
            }

            errorMessage = "You have not been assigned a Till Account";
            return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage));
        }
Ejemplo n.º 12
0
        public ActionResult Create([Bind(Include = "ID,Amount,Narration,PostingType,CustomerAccountID")] TellerPosting tellerPosting)
        {
            /*if (eodLogic.isBusinessClosed())
             * {
             *  AddError("Sorry, business is closed");
             *  return View(tellerPosting); // closed partial view ?
             * }*/

            if (ModelState.IsValid)
            {
                try
                {
                    string tellerId = GetLoggedInUserId();
                    // if user doesn't have till, error.. implement user till checking earlier ?
                    bool tellerHasTill = db.TillUsers.Any(tu => tu.UserId.Equals(tellerId));
                    if (!tellerHasTill)
                    {
                        AddError("No till associated with logged in teller");
                        return(View(tellerPosting));
                    }
                    // get user's till and do all the necessary jargons
                    int tillId = db.TillUsers.Where(tu => tu.UserId.Equals(tellerId)).First().GlAccountID;
                    tellerPosting.TillAccountID = tillId;
                    var tillAct = db.GlAccounts.Find(tillId);

                    var custAct = db.CustomerAccounts.Find(tellerPosting.CustomerAccountID);

                    tellerPosting.PostInitiatorId = tellerId;
                    tellerPosting.Date            = DateTime.Now;

                    var amt = tellerPosting.Amount;

                    if (tellerPosting.PostingType == TellerPostingType.Withdrawal)
                    {
                        if (custActLogic.CustomerAccountHasSufficientBalance(custAct, amt))
                        {
                            if (!(tillAct.AccountBalance >= amt))
                            {
                                AddError("Insuficient funds in till account");
                                return(View(tellerPosting));
                            }

                            tellerPosting.Status = PostStatus.Approved;
                            //db.TellerPostings.Add(tellerPosting);
                            //db.SaveChanges();

                            //all this is happening after transaction is approved by checker.
                            string result = telPostLogic.PostTeller(custAct, tillAct, amt, TellerPostingType.Withdrawal);
                            if (!result.Equals("success"))
                            {
                                AddError(result);
                                return(View(tellerPosting));
                            }

                            db.Entry(custAct).State = EntityState.Modified;
                            db.Entry(tillAct).State = EntityState.Modified;
                            db.TellerPostings.Add(tellerPosting);
                            db.SaveChanges();

                            reportLogic.CreateTransaction(tillAct, amt, TransactionType.Credit);
                            reportLogic.CreateTransaction(custAct, amt, TransactionType.Debit);

                            return(RedirectToAction("UserPosts")); // suceess partial view or pop-up ?
                        }
                        else
                        {
                            AddError("Insufficient funds in customer account");
                            return(View(tellerPosting));
                        }
                    }
                    else
                    {
                        tellerPosting.Status = PostStatus.Approved;
                        //db.TellerPostings.Add(tellerPosting);
                        //db.SaveChanges();

                        string result = telPostLogic.PostTeller(custAct, tillAct, amt, TellerPostingType.Deposit);
                        custAct.AccountStatus = AccountStatus.Active;
                        if (!result.Equals("success"))
                        {
                            AddError(result);
                            return(View(tellerPosting));
                        }

                        db.Entry(custAct).State = EntityState.Modified;
                        db.Entry(tillAct).State = EntityState.Modified;
                        db.TellerPostings.Add(tellerPosting);
                        db.SaveChanges();

                        reportLogic.CreateTransaction(tillAct, amt, TransactionType.Debit);
                        reportLogic.CreateTransaction(custAct, amt, TransactionType.Credit);

                        return(RedirectToAction("UserPosts"));
                    }
                }
                catch (Exception ex)
                {
                    AddError(ex.ToString());
                    return(View(tellerPosting));
                }
            }
            AddError("Please, enter valid data");
            return(View(tellerPosting));
        }
 public void UpdatePost(TellerPosting savePost)
 {
     //Updating database values
     _teller.Save(savePost);
 }
 public void SavePost(TellerPosting savePost)
 {
     //saving into the database
     _teller.Add(savePost);
     _teller.Save(savePost);
 }
        public bool Withdrawal(decimal amount, int custId, int userId, TellerPosting tlPosting, DateTime date)
        {
            //Get teller till account
            var tillAccountId   = userId;
            var tillAccount     = _tillAccount.GetUserId(tillAccountId);
            var tillGlAccountId = tillAccount.AccountManagementId;
            var tellerGlAccount = _glContext.Get(tillGlAccountId);

            //Get Customer Account
            var CustomerAccount = _customer.Get(custId);
            var Amount          = amount;
            var CustomerId      = custId;
            var DatePosted      = date;



            if (CustomerAccount.AccountType == AccountType.Savings)
            {
                DebitCustomerAccount(Amount, custId, CustomerAccount);
                CreditGlAccount(Amount, tellerGlAccount);

                //Saving teller posting
                SavePost(tlPosting);

                return(true);
            }

            if (CustomerAccount.AccountType == AccountType.Current)
            {
                //Getting the Income COT Account
                var CurrentIncomeGl = _glContext.Get(_current.GetFirst().IncomeGlAccountId);


                //Getting Cot Values from the current account configuration
                var currentConfig = _current.GetFirst();
                var cot           = currentConfig.CommissionOnTurnover;

                var cotValue = calcCOT(cot, Amount);

                var isPossible = CheckWithdrawalPossible(cot, CustomerAccount.Balance, Amount);

                if (isPossible)
                {
                    DebitCustomerAccount(Amount + cotValue, CustomerId, CustomerAccount);
                    CreditGlAccount(Amount, tellerGlAccount);
                    CreditGlAccount(cotValue, CurrentIncomeGl);

                    //saving into database
                    SavePost(tlPosting);

                    //Loging values into database
                    var CotLog = new COTPost()
                    {
                        CustomerAccountId = CustomerId,
                        GlAccountId       = tillAccountId,
                        Amount            = Amount,
                        WhenPosted        = DatePosted
                    };


                    CustomerAccount.CotAccured += cotValue;

                    //Adding into customerAccount Entity
                    _context.Entry(CustomerAccount).State = EntityState.Modified;
                    _context.SaveChanges();


                    //Adding into COTPost Entity
                    _cotLogic.SavePost(CotLog);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
        public ActionResult PostTransaction(TellerPosting model)
        {
            EodLogic logic = new EodLogic();

            if (logic.isBusinessClosed())
            {
                return(PartialView("_Closed"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Amount <= 0)
                    {
                        return(PartialView("_IncorrectData"));
                    }

                    var loggedInTeller = getLoggedInUser();
                    if (loggedInTeller == null)
                    {
                        return(PartialView("_UnauthorizedTeller"));
                    }
                    var tillAct = new TellerMgtRepository().GetUserTill(loggedInTeller);
                    if (tillAct == null)
                    {
                        return(PartialView("_UnauthorizedTeller"));
                    }

                    var act     = (CustomerAccount)Session["custAccount"];
                    var account = custActRepo.GetByAccountNumber(act.AccountNumber);

                    if (account == null)
                    {
                        ViewBag.ErrorMessage = "Invalid account selected";
                        return(PartialView("_InvalidAccount"));
                    }

                    model.Date = DateTime.Now;
                    TellerPosting telPosting = new TellerPosting {
                        Amount = model.Amount, Narration = model.Narration, Date = DateTime.Now, PostingType = model.PostingType, CustomerAccount = account, PostInitiator = loggedInTeller
                    };
                    //check for balance sufficiency upon withdrawal
                    if (model.PostingType == TellerPostingType.Withdrawal)
                    {
                        if (new CustomerAccountLogic().CustomerAccountHasSufficientBalance(account, model.Amount))
                        {
                            if (!(tillAct.AccountBalance >= model.Amount))
                            {
                                return(PartialView("_TellerInsufficientBalance"));
                            }
                            string result = new TellerPostingLogic().PostTeller(account, tillAct, model.Amount, model.PostingType);
                            if (!result.Equals("success"))
                            {
                                return(PartialView("_UnknownError"));
                            }
                            tpRepo.Insert(telPosting);
                            new CustomerAccountRepository().Update(account);
                            new GlAccountRepository().Update(tillAct);
                            RemoveAccountFromSession();
                            return(PartialView("_SuccessPost"));
                        }
                        else    //no sufficient balance
                        {
                            ViewBag.ErrorMessage = "Insufficient balance";
                            return(PartialView("_InsufficientBalance"));
                        }
                    }
                    else  //deposit
                    {
                        string result = new TellerPostingLogic().PostTeller(account, tillAct, model.Amount, model.PostingType);
                        if (!result.Equals("success"))
                        {
                            return(PartialView("_UnknownError"));
                        }
                        tpRepo.Insert(telPosting);
                        new CustomerAccountRepository().Update(account);
                        new GlAccountRepository().Update(tillAct);
                        RemoveAccountFromSession();
                        return(PartialView("_SuccessPost"));
                    }
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n");
                    return(PartialView("Error"));
                }
            }
            ViewBag.CustomerAccountId = new SelectList(custActRepo.GetAll().Where(a => a.AccountType != AccountType.Loan), "ID", "AccountNumber");
            return(PartialView("_IncorrectData"));
        }//
Ejemplo n.º 17
0
        public ActionResult ApproveTellerPost(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TellerPosting tellerPosting = db.TellerPostings.Find(id);

            if (tellerPosting == null)
            {
                return(HttpNotFound());
            }

            var amt = tellerPosting.Amount;

            var tillAct = tellerPosting.TillAccount;
            var custAct = tellerPosting.CustomerAccount;

            if (tellerPosting.PostingType == TellerPostingType.Withdrawal)
            {
                if (custActLogic.CustomerAccountHasSufficientBalance(custAct, amt))
                {
                    if (!(tillAct.AccountBalance >= amt))
                    {
                        // i have no choice but to send the error messages with partial views.
                        return(RedirectToAction("TellerPosts", new { message = "Insuficient funds in till account" }));
                    }

                    //all this is happening after transaction is approved by checker.
                    string result = telPostLogic.PostTeller(custAct, tillAct, amt, TellerPostingType.Withdrawal);
                    if (!result.Equals("success"))
                    {
                        return(RedirectToAction("TellerPosts", new { message = result }));
                    }

                    tellerPosting.Status          = PostStatus.Approved;
                    db.Entry(tellerPosting).State = EntityState.Modified;
                    db.Entry(custAct).State       = EntityState.Modified;
                    db.Entry(tillAct).State       = EntityState.Modified;

                    db.SaveChanges();

                    reportLogic.CreateTransaction(tillAct, amt, TransactionType.Credit);
                    reportLogic.CreateTransaction(custAct, amt, TransactionType.Debit);

                    return(RedirectToAction("TellerPosts", new { message = "Transaction Approved!" }));
                }
                else
                {
                    return(RedirectToAction("TellerPosts", new { message = "Insufficient funds in customer account" }));
                }
            }
            else
            {
                string result = telPostLogic.PostTeller(custAct, tillAct, amt, TellerPostingType.Deposit);
                if (!result.Equals("success"))
                {
                    return(RedirectToAction("TellerPosts", new { message = result }));
                }

                tellerPosting.Status          = PostStatus.Approved;
                db.Entry(tellerPosting).State = EntityState.Modified;
                db.Entry(custAct).State       = EntityState.Modified;
                db.Entry(tillAct).State       = EntityState.Modified;

                db.SaveChanges();

                reportLogic.CreateTransaction(tillAct, amt, TransactionType.Debit);
                reportLogic.CreateTransaction(custAct, amt, TransactionType.Credit);

                return(RedirectToAction("TellerPosts", new { message = "Transaction Approved!" }));
            }
        }
        public ActionResult Save(TellerPosting tellerPosting)
        {
            bool   status  = false;
            string message = "";

            var checkConfig = _config.checkConfig();

            if (checkConfig)
            {
                //Getting values from form
                tellerPosting.Amount        = Convert.ToDecimal(Request.Form["Amount"], CultureInfo.InvariantCulture);
                tellerPosting.Narration     = Request.Form["Narration"];
                tellerPosting.DateOfPosting = DateTime.Now;
                tellerPosting.Type          = (PostingType)Convert.ToInt32(Request.Form["Type"]);
                tellerPosting.CustomerId    = Convert.ToInt32(Request.Form["Id"]);
                tellerPosting.UserId        = Convert.ToInt32(Request.Form["tellerId"]);

                var customerAccount = _contextAccount.Get(tellerPosting.CustomerId);
                var amount          = tellerPosting.Amount;
                var customerId      = tellerPosting.CustomerId;
                var userId          = tellerPosting.UserId;
                var datePosted      = tellerPosting.DateOfPosting;

                var tillAccountId   = Convert.ToInt32(Session["ID"]);
                var tillAccount     = _tillAccount.GetUserId(tillAccountId);
                var tillGlAccountId = tillAccount.AccountManagementId;
                var tellerGlAccount = _glContext.Get(tillGlAccountId);

                if (tellerPosting.Type == PostingType.Withdrawal)
                {
                    if (tellerGlAccount.AccountBalance < tellerPosting.Amount)
                    {
                        ModelState.AddModelError("Account", "Insufficient funds in till account");
                        return(View());
                    }

                    if (customerAccount.Balance < tellerPosting.Amount)
                    {
                        ModelState.AddModelError("Account", "Insufficient funds in customer account");
                        return(View());
                    }

                    if (customerAccount.Balance < amount + customerAccount.CurrentLien)
                    {
                        ModelState.AddModelError("Account", "Cannot Withdraw This Amount");
                        return(View());
                    }

                    var withdraw = _logic.Withdrawal(amount, customerId, userId, tellerPosting, datePosted);

                    if (withdraw != true)
                    {
                        ViewBag.Message = "Withdraw Failed";
                        ViewBag.Status  = false;
                        return(View());
                    }


                    message = "Withdrawal Successful";
                    status  = true;

                    ViewBag.Message = message;
                    ViewBag.Status  = status;
                    return(RedirectToAction("Index", "TellerPosting"));
                }


                var deposit = _logic.Deposit(amount, customerId, userId, tellerPosting, datePosted);

                if (deposit != true)
                {
                    ViewBag.Message = "Deposit Failed";
                    ViewBag.Status  = false;
                    return(View());
                }


                message = "Deposit Successful";
                status  = true;

                ViewBag.Message = message;
                ViewBag.Status  = status;
            }
            else
            {
                TempData["Error"] = "A Configuration is not set";
                return(View());
            }

            return(RedirectToAction("Index", "TellerPosting"));
        }