//GET public ActionResult PostTransaction() { EodLogic logic = new EodLogic(); if (logic.isBusinessClosed()) { return(PartialView("_Closed")); } ViewBag.ErrorMessage = ""; ViewBag.CrGlAccount_Id = new SelectList(glActRepo.GetAll(), "ID", "AccountName");; ViewBag.DrGlAccount_Id = new SelectList(glActRepo.GetAll(), "ID", "AccountName"); return(View()); }
public ActionResult OpenOrCloseBusiness() { try { EodLogic logic = new EodLogic(); if (logic.isBusinessClosed()) { logic.OpenBusiness(); } else { string result = logic.RunEOD(); return(RedirectToAction("Index", new { message = result })); } } catch (Exception) { //ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n"); return(PartialView("Error")); } return(RedirectToAction("Index")); }
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")); }//
public BranchController() { db = new AppContext(); branchLogic = new BranchLogic(new BranchRepository()); eodLogic = new EodLogic(); }
public ActionResult PostTransaction(CreateGlPostViewModel model) { EodLogic logic = new EodLogic(); if (logic.isBusinessClosed()) { return(PartialView("_Closed")); } if (ModelState.IsValid) { try { if (model.DrGlAccount_Id == model.CrGlAccount_Id) { return(PartialView("_IncorrectData")); } if (model.CreditAmount == model.DebitAmount && model.CreditAmount > 0) //double checking { var drAct = glActRepo.GetById(model.DrGlAccount_Id); var crAct = glActRepo.GetById(model.CrGlAccount_Id); //check for sufficient balance on Vault and Tills if (crAct.AccountName.ToLower().Contains("till") || crAct.AccountName.ToLower().Contains("vault")) { if (crAct.AccountBalance < model.CreditAmount) { return(PartialView("_InsufficientBalance")); } } var user = getLoggedInUser(); if (user == null || user.Role.ID != 1) //admin with a role ID of 1 { return(RedirectToAction("Login", "UserManager", new { returnUrl = "/glposting/posttransaction" })); } decimal amt = model.CreditAmount; GlPosting glPosting = new GlPosting { CreditAmount = amt, DebitAmount = amt, Date = DateTime.Now, CrGlAccount = crAct, DrGlAccount = drAct, Naration = model.Naration, PostInitiator = user }; busLogic.CreditGl(crAct, amt); busLogic.DebitGl(drAct, amt); glPostRepo.Insert(glPosting); glActRepo.Update(crAct); glActRepo.Update(drAct); frLogic.CreateTransaction(drAct, amt, TransactionType.Debit); frLogic.CreateTransaction(crAct, amt, TransactionType.Credit); return(PartialView("_SuccessPost")); } } catch (Exception ex) { ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n"); return(PartialView("Error")); } }//end if ViewBag.DrGlAccount_Id = new SelectList(glActRepo.GetAll(), "ID", "AccountName", model.DrGlAccount_Id); ViewBag.CrGlAccount_Id = new SelectList(glActRepo.GetAll(), "ID", "AccountName", model.CrGlAccount_Id); return(PartialView("_IncorrectData")); }