コード例 #1
0
ファイル: EodController.cs プロジェクト: Jayora50/JUCBA
        public ActionResult RunEOD()
        {
            if (logic.isBusinessClosed())
            {
                string result = logic.RunEOD();
                return(RedirectToAction("Index", new { message = result }));
            }

            return(RedirectToAction("Index", new { message = "Cannot Run EOD" }));
        }
コード例 #2
0
 public ActionResult SelectFirstAccount()
 {
     if (eodLogic.isBusinessClosed())
     {
         // return a view(partial view ? ) saying that business is closed
         // for now just return a non-populated select cr act view
         return(View(new List <GlAccount>()));
     }
     //db.GlAccounts.Include(g => g.GlCategory).Include(g => g.Branch).ToList()
     return(View(db.GlAccounts.ToList()));
 }
コード例 #3
0
        public ActionResult SelectAccount()
        {
            if (eodLogic.isBusinessClosed())
            {
                //return a non-populated select acct view
                //return View(new List<CustomerAccount>());
                // return a view(partial view ? ) saying that business is closed
                return(View("EODnotRUN"));
            }
            // check whether user has till here and bounce? or later in create's post ?

            return(View(db.CustomerAccounts.Include(a => a.Branch).Where(a => a.AccountType != AccountType.Loan && a.AccountStatus == AccountStatus.Active && a.Customer.Status == CustomerStatus.Active && a.Branch.Status == BranchStatus.Open).ToList()));
        }
        //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());
        }
コード例 #5
0
 public ActionResult OpenOrCloseBusiness()
 {
     try
     {
         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"));
        }//
コード例 #7
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("Index")); // 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("Index"));
                    }
                }
                catch (Exception ex)
                {
                    AddError(ex.ToString());
                    return(View(tellerPosting));
                }
            }
            AddError("Please, enter valid data");
            return(View(tellerPosting));
        }
コード例 #8
0
 // GET: Branch
 public ActionResult Index()
 {
     ViewBag.BusinessIsOpen = !eodLogic.isBusinessClosed();
     return(View(db.Branches.ToList()));
 }
        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"));
        }