Example #1
0
 public GlAccount GetLastGlIn(MainGlCategory mainCategory)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         return(session.Query <GlAccount>().Where(g => g.GlCategory.MainCategory == mainCategory).OrderByDescending(a => a.ID).First());
     }
 }
Example #2
0
 public List <GlAccount> GetByMainCategory(MainGlCategory mainCategory)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         return(session.Query <GlAccount>().Where(a => a.GlCategory.MainCategory == mainCategory).ToList());
     }
 }
Example #3
0
 public bool AnyGlIn(MainGlCategory mainCategory)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         return(session.Query <GlAccount>().Any(gl => gl.GlCategory.MainCategory == mainCategory));
     }
 }
        public long GenerateGLAccountNumber(MainGlCategory glMainCategory)
        {
            long code = 0;

            //get the last account number in this category
            if (glRepo.AnyGlIn(glMainCategory))
            {
                var lastAct = glRepo.GetLastGlIn(glMainCategory);
                code = lastAct.CodeNumber + 1;
            }

            else                        //this is going to be the first act in this category
            {
                switch (glMainCategory) //these codes are assumed at author's descretion
                {
                case MainGlCategory.Asset:
                    code = 1000102016;
                    break;

                case MainGlCategory.Capital:
                    code = 3000102016;
                    break;

                case MainGlCategory.Expenses:
                    code = 5000102016;
                    break;

                case MainGlCategory.Income:
                    code = 4000102016;
                    break;

                case MainGlCategory.Liability:
                    code = 2000102016;
                    break;

                default:
                    break;
                }
            }//end if

            return(code);
        }
        public long GenerateGLAccountNumber(MainGlCategory glMainCategory)
        {
            long code = 0;

            //get the last account number in this category
            if (glRepo.AnyGlIn(glMainCategory))
            {
                var lastAct = glRepo.GetLastGlIn(glMainCategory);
                code = lastAct.CodeNumber + 1;
            }

            else
            {
                switch (glMainCategory)     //the codes below are just used at my discretion.
                {
                case MainGlCategory.Asset:
                    code = 1000102016;
                    break;

                case MainGlCategory.Capital:
                    code = 3000102016;
                    break;

                case MainGlCategory.Expenses:
                    code = 5000102016;
                    break;

                case MainGlCategory.Income:
                    code = 4000102016;
                    break;

                case MainGlCategory.Liability:
                    code = 2000102016;
                    break;

                default:
                    break;
                }
            }//end if

            return(code);
        }
Example #6
0
        public ActionResult Create(AddGlActViewModel model)
        {
            ViewBag.GlCategoryId = new SelectList(glCatRepo.GetAll(), "ID", "Name", model.GlCategoryId);
            ViewBag.BranchId     = new SelectList(branchRepo.GetAll(), "ID", "Name", model.BranchId);

            if (ModelState.IsValid)
            {
                try
                {
                    var            category     = glCatRepo.GetById(model.GlCategoryId);
                    var            branch       = branchRepo.GetById(model.BranchId);
                    MainGlCategory mainCategory = (MainGlCategory)((int)category.MainCategory);

                    //if is unique account name
                    if (!gllogic.IsUniqueName(model.AccountName))
                    {
                        ViewBag.Msg = "Account name must be unique";
                        return(View(model));
                    }

                    GlAccount glAccount = new GlAccount()
                    {
                        AccountName = model.AccountName, GlCategory = category, Branch = branch, CodeNumber = gllogic.GenerateGLAccountNumber(mainCategory)
                    };
                    glactRepo.Insert(glAccount);
                    //ViewBag.Msg = "successfully added account";

                    return(RedirectToAction("Create", new { message = "successfully added account" }));
                }
                catch (Exception ex)
                {
                    //ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n");
                    return(PartialView("Error"));
                }
            }

            ViewBag.Msg = "Please enter correct data";
            return(View(model));
        }
Example #7
0
 public List <GlAccount> GetByMainCategory(MainGlCategory mainCategory)
 {
     return(db.GlAccounts.Where(a => a.GlCategory.MainCategory == mainCategory).ToList());
 }
Example #8
0
 public GlAccount GetLastGlIn(MainGlCategory mainCategory)
 {
     return(db.GlAccounts.Where(g => g.GlCategory.MainCategory == mainCategory).OrderByDescending(a => a.ID).First());
 }
Example #9
0
 public bool AnyGlIn(MainGlCategory mainCategory)
 {
     return(db.GlAccounts.Any(gl => gl.GlCategory.MainCategory == mainCategory));
 }