public ActionResult CloseBusiness() { var bankConfig = _bankConfigContext.GetConfig(); var configReport = _configContext.IsAccountConfigurationSet(); if (bankConfig.IsBusinessOpen && configReport == "Success") { bankConfig.IsBusinessOpen = false; _bankConfigContext.Update(bankConfig); Session["isBusinessOpen"] = false; } //run rod when business is closed var runEod = _context.RunEod(); if (runEod != "Success") { TempData["Error"] = runEod; } else { TempData["Success"] = "EOD run Successful"; Session["FinancialDate"] = _bankConfigContext.GetConfig().FinancialDate; } return(RedirectToAction("Index", "BankConfig")); }
public ActionResult AuthenticateUser(User user) { var curUser = _context.GetByUsername(user.Username); if (_context.Authenticate(user)) { //authentication successful Session["id"] = curUser.Id; Session["Password"] = curUser.Password; Session["Username"] = curUser.Username; Session["Role"] = curUser.Role; if (_bankConfigContext.GetConfig() != null)//if bank has been set up create session for financial date { Session["FinancialDate"] = _bankConfigContext.GetConfig().FinancialDate; } if ((string)Session["Role"] == $"Admin") { var bankConfig = _bankConfigContext.GetConfig(); if (bankConfig == null)//if bank configuration is not set show the button to setup bank { Session["setup"] = "start"; } else { Session["isBusinessOpen"] = bankConfig.IsBusinessOpen; } return(RedirectToAction("AdminDashboard", "Users")); } if (curUser.PasswordStatus == false) { //user using default password return(RedirectToAction("ChangePassword", "Users")); } if ((string)Session["Role"] == $"Teller" && curUser.PasswordStatus) { //user has changed password return(RedirectToAction("TellerDashboard", "Users")); } } ViewBag.msg = "Incorrect Username or Password"; return(View("LoginForm")); }
public ActionResult PLReport() { var incomeAccounts = _context.GetAllIncomeAccounts(); var expenseAccounts = _context.GetAllExpenseAccounts(); var incomeTotal = incomeAccounts.Sum(c => c.Balance); var expenseTotal = expenseAccounts.Sum(c => c.Balance); var viewModel = new PlViewModel { IncomeGls = incomeAccounts, ExpenseGls = expenseAccounts, IncomeTotal = Math.Round(incomeTotal, 2), ExpenseTotal = Math.Round(expenseTotal, 2), Profit = Math.Round(incomeTotal - expenseTotal, 2), Date = _bankContext.GetConfig() != null ? _bankContext.GetConfig().FinancialDate : DateTime.Now, }; return(View(viewModel)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (_context == null) { _context = new BankConfigLogic(); } var bankConfig = _context.GetConfig(); _context = null; if (bankConfig == null || !bankConfig.IsBusinessOpen) { filterContext.Result = new RedirectResult(string.Format("/BankConfig/")); } }
//GET: BankConfig public ActionResult Index() { var bankConfig = _context.GetConfig(); return(View(bankConfig)); }
public ActionResult Save(Loan loan) { var customerAccount = _customerAccContext.Get(Convert.ToInt32(Request.Form["customerId"])); var isLoanComplete = _customerAccContext.CheckForLoanStatus(customerAccount); if (_accountTypeConfigContext.GetLoanConfig() != null && _bankConfigContext.GetConfig() != null)//check if bank and loan configurations are set { if (!isLoanComplete) { TempData["Error"] = "Customer Has Unpaid Loan (Click Here To Review)"; var currentLoan = new Loan { CustomerAccount = customerAccount }; return(View("LoanForm", currentLoan)); } else { var dInterestRate = _accountTypeConfigContext.GetLoanConfig().DInterestRate; //Fill Loan Account Details loan.Name = customerAccount.AccountName; loan.AccountNumber = _customerAccContext.GenerateAccountNumber(customerAccount.CustomerId, "Loan"); loan.CustomerAccountId = customerAccount.Id; loan.StartDate = DateTime.Today; loan.EndDate = DateTime.Now.AddDays(loan.DurationInMonths * 30); loan.Interest = loan.LoanAmount * (dInterestRate / 100) * (Convert.ToDecimal(loan.DurationInMonths) / 12); loan.InterestRemaining = loan.Interest; loan.InterestPayable = loan.Interest / (loan.DurationInMonths * 30); loan.LoanAmountRemaining = loan.LoanAmount; // debiting Loan Account loan.LoanPayable = loan.LoanAmount / (loan.DurationInMonths * 30); loan.DayCount = 0; _context.Save(loan); //create customer Loan Account var customerLoanAcc = new CustomerAccount { CustomerId = customerAccount.CustomerId, AccountName = customerAccount.AccountName, AccountNumber = loan.AccountNumber, BranchId = customerAccount.BranchId, Balance = 0, AccountType = AccountType.Loan, IsOpen = true, CreatedAt = DateTime.Now, }; _customerAccContext.CreditCustomer(customerAccount, loan.LoanAmount); _customerAccContext.DebitCustomer(customerLoanAcc, loan.LoanAmount); _customerAccContext.Save(customerLoanAcc); } TempData["Success"] = "Loan Taken Successfully"; return(RedirectToAction("Index")); } TempData["ConfigError"] = "Setup Loan Configurations"; var view = new Loan { CustomerAccount = customerAccount }; return(View("LoanForm", view)); }