示例#1
0
        public ActionResult Create([Bind(Include = "ID,AccountName,GlCategoryID,BranchID")] GlAccount glAccount)
        {
            ViewBag.BranchID     = new SelectList(db.Branches, "ID", "Name", glAccount.BranchID);
            ViewBag.GlCategoryID = new SelectList(db.GlCategories, "ID", "Name", glAccount.GlCategoryID);

            if (ModelState.IsValid)
            {
                try
                {
                    if (!glActLogic.IsUniqueName(glAccount.AccountName))
                    {
                        AddError("Account name must be unique");
                        return(View(glAccount));
                    }

                    GlCategory glCategory = db.GlCategories.Find(glAccount.GlCategoryID);

                    glAccount.CodeNumber     = glActLogic.GenerateGLAccountNumber(glCategory.MainCategory);
                    glAccount.AccountBalance = 0;
                    db.GlAccounts.Add(glAccount);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    AddError(ex.ToString());
                    return(View(glAccount));
                }
            }
            AddError("Please enter valid data");
            return(View(glAccount));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,MainCategory")] GlCategory glCategory)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (!glCatLogic.IsUniqueName(glCategory.Name))
                    {
                        AddError("Please select another name");
                        return(View(glCategory));
                    }

                    db.GlCategories.Add(glCategory);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    AddError(ex.ToString());
                    return(View(glCategory));
                }
            }
            AddError("Please enter valid data");
            return(View(glCategory));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "ID,Name,Address")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (branchLogic.IsBranchNameExists(branch.Name))
                    {
                        // use model state for now, change to pop up later
                        ModelState.AddModelError("", "Branch name must be unique");
                        return(View(branch));
                    }
                    branch.SortCode = branchLogic.GetSortCode();
                    branch.Status   = BranchStatus.Closed;

                    db.Branches.Add(branch);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    // partial view error ?
                    // for now all error to model state and return view model
                    ModelState.AddModelError("", ex.ToString());
                    return(View(branch));
                }
            }
            ModelState.AddModelError("", "Please enter valid data");
            return(View(branch));
        }
示例#4
0
 public ActionResult Create([Bind(Include = "FullName,Address,Email,PhoneNumber,Gender,Status")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         try
         {
             customer.CustId = custLogic.GenerateCustomerId();
             //this makes the account to be activated by default.
             customer.Status = CustomerStatus.Active;
             db.Customers.Add(customer);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             // what will later happen is that exceptions will be logged
             // a short message will be sent out instead like (An error occured, please try again).
             // but the sake of development purposes exceptions messages are sent as error message.
             AddError(ex.ToString());
             return(View(customer));
         }
     }
     AddError("Please enter valid data");
     return(View(customer));
 }
示例#5
0
 public ActionResult Create([Bind(Include = "ID,UserId,GlAccountID")] TillToUser tillToUser)
 {
     if (ModelState.IsValid)
     {
         db.TillToUsers.Add(tillToUser);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Users       = new SelectList(tellerMgtLogic.ExtractTellersWithoutTill(), "Id", "UserName", tillToUser.UserId);
     ViewBag.GlAccountID = new SelectList(tellerMgtLogic.ExtractTillsWithoutTeller(), "ID", "AccountName", tillToUser.GlAccountID);
     return(View(tillToUser));
 }
示例#6
0
        public ActionResult Create([Bind(Include = "ID,CreditAmount,DebitAmount,Narration,DrGlAccountID,CrGlAccountID")] GlPosting glPosting)
        {
            if (eodLogic.isBusinessClosed())
            {
                // return business closed view , for now use model error.
                AddError("Sorry, business closed");
                return(View(glPosting));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var drAct = db.GlAccounts.Find(glPosting.DrGlAccountID);
                    var crAct = db.GlAccounts.Find(glPosting.CrGlAccountID);

                    if (crAct.AccountName.ToLower().Contains("till") || crAct.AccountName.ToLower().Contains("vault"))
                    {
                        if (crAct.AccountBalance < glPosting.CreditAmount)
                        {// is it really better to return an insuficient balance partial view ?
                            AddError("Insufficient funds in asset account to be credited");
                            return(View(glPosting));
                        }
                    }

                    glPosting.PostInitiatorId = GetLoggedInUserId();
                    glPosting.Date            = DateTime.Now;

                    glPosting.Status = PostStatus.Pending;

                    db.GlPostings.Add(glPosting);
                    db.SaveChanges();

                    return(RedirectToAction("UserPosts")); // success post partial view or pop-up on post page ?
                }
                catch (Exception ex)
                {
                    AddError(ex.ToString());
                    return(View(glPosting));
                }
            }
            AddError("Please, enter valid data");
            return(View(glPosting));
        }
示例#7
0
        public ActionResult Edit([Bind(Include = "ID,IsBusinessOpen,FinancialDate,SavingsCreditInterestRate,SavingsMinimumBalance,SavingsInterestExpenseGlID,SavingsInterestPayableGlID,CurrentCreditInterestRate,CurrentMinimumBalance,CurrentCot,CurrentInterestExpenseGlID,CurrentCotIncomeGlID,CurrentInterestPayableGlID,LoanDebitInterestRate,LoanInterestIncomeGlID,LoanInterestExpenseGLID,LoanInterestReceivableGlID")] AccountConfiguration accountConfiguration)
        {
            if (ModelState.IsValid)
            {
                if (accountConfiguration.SavingsInterestExpenseGlID == 0)
                {
                    accountConfiguration.SavingsInterestExpenseGlID = null;
                }
                if (accountConfiguration.SavingsInterestPayableGlID == 0)
                {
                    accountConfiguration.SavingsInterestPayableGlID = null;
                }
                if (accountConfiguration.CurrentCotIncomeGlID == 0)
                {
                    accountConfiguration.CurrentCotIncomeGlID = null;
                }
                if (accountConfiguration.CurrentInterestExpenseGlID == 0)
                {
                    accountConfiguration.CurrentInterestExpenseGlID = null;
                }
                if (accountConfiguration.CurrentInterestPayableGlID == 0)
                {
                    accountConfiguration.CurrentInterestPayableGlID = null;
                }
                if (accountConfiguration.LoanInterestExpenseGLID == 0)
                {
                    accountConfiguration.LoanInterestExpenseGLID = null;
                }
                if (accountConfiguration.LoanInterestIncomeGlID == 0)
                {
                    accountConfiguration.LoanInterestIncomeGlID = null;
                }
                if (accountConfiguration.LoanInterestReceivableGlID == 0)
                {
                    accountConfiguration.LoanInterestReceivableGlID = null;
                }

                db.Entry(accountConfiguration).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Details"));
            }
            SetPostGlActViewBags(accountConfiguration);
            return(View(accountConfiguration));
        }
示例#8
0
        public ActionResult CloseAllBranches()
        {
            // code to close all branches
            using (var db = new AppContext())
            {
                List <Branch> branches = db.Branches.Where(b => b.Status == BranchStatus.Open).ToList();
                branches.ForEach(b => { b.Status = BranchStatus.Closed; });
                db.SaveChanges();
            }

            return(RedirectToAction("Index", new { message = "All branches closed, you can now proceed to run EOD" }));
        }
示例#9
0
        public ActionResult CreateSavings([Bind(Include = "AccountName,BranchID,CustomerID")] CreateAccountViewModel model)
        {
            ViewBag.BranchID = new SelectList(db.Branches, "ID", "Name", model.BranchID);

            if (ModelState.IsValid)
            {
                try
                {
                    CustomerAccount customerAccount = new CustomerAccount();
                    customerAccount.AccountName    = model.AccountName;
                    customerAccount.AccountType    = AccountType.Savings;
                    customerAccount.CustomerID     = model.CustomerID;
                    customerAccount.AccountNumber  = custActLogic.GenerateCustomerAccountNumber(AccountType.Savings, model.CustomerID);
                    customerAccount.DateCreated    = DateTime.Now;
                    customerAccount.BranchID       = model.BranchID;
                    customerAccount.AccountStatus  = AccountStatus.Closed;
                    customerAccount.AccountBalance = 0;

                    db.CustomerAccounts.Add(customerAccount);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    AddError(ex.ToString());
                    return(View(model));
                }
            }
            AddError("Please enter valid data");
            return(View(model));
        }
示例#10
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            if (db.AccountConfigurations.Count() < 1)
            {
                db.AccountConfigurations.Add(new AccountConfiguration {
                    FinancialDate = DateTime.Now, IsBusinessOpen = false
                });
                db.SaveChanges();
                db.Dispose();
            }
        }
示例#11
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.TillToUsers.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.TillToUsers.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.Pending;
                            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.Pending;
                        db.TellerPostings.Add(tellerPosting);
                        db.SaveChanges();

                        //string result = telPostLogic.PostTeller(custAct, tillAct, amt, TellerPostingType.Deposit);
                        //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));
        }
示例#12
0
        public ActionResult Create(CreateRoleViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (roleLogic.isRoleNameExists(model.Name))
                    {
                        ModelState.AddModelError("", "Role name must be unique");
                        return(View(model));
                    }
                    Role role = new Role {
                        Name = model.Name
                    };
                    db.Roles.Add(role);
                    db.SaveChanges();

                    int roleid = db.Roles.OrderByDescending(r => r.ID).FirstOrDefault().ID;

                    #region addingRoleClaimsToDatabase
                    if (model.BranchMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "BranchMgt", RoleID = roleid
                        });
                    }

                    if (model.RoleMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "RoleMgt", RoleID = roleid
                        });
                    }

                    if (model.CustomerMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "CustomerMgt", RoleID = roleid
                        });
                    }

                    if (model.CustomerAccountMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "CustomerAccountMgt", RoleID = roleid
                        });
                    }

                    if (model.FinancialReport)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "FinancialReport", RoleID = roleid
                        });
                    }

                    if (model.GLMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "GLMgt", RoleID = roleid
                        });
                    }

                    if (model.GLPosting)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "GLPosting", RoleID = roleid
                        });
                    }

                    if (model.PostingAuth)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "PostingAuth", RoleID = roleid
                        });
                    }

                    if (model.AccountConfigMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "AccountConfigMgt", RoleID = roleid
                        });
                    }

                    if (model.RunEOD)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "RunEOD", RoleID = roleid
                        });
                    }

                    if (model.TellerMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "TellerMgt", RoleID = roleid
                        });
                    }

                    if (model.TellerPosting)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "TellerPosting", RoleID = roleid
                        });
                    }

                    if (model.UserMgt)
                    {
                        db.RoleClaims.Add(new RoleClaim {
                            Name = "UserMgt", RoleID = roleid
                        });
                    }
                    #endregion

                    db.SaveChanges();
                    return(RedirectToAction("RoleClaims"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.ToString());
                    return(View(model));
                }
            }
            ModelState.AddModelError("", "Please enter valid data");
            return(View(model));
        }
示例#13
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!" }));
            }
        }