コード例 #1
0
        public static LedgerAccountGroup CreateLedgerAccountGroup(string dataAreaId, string ledgerPostingGroup)
        {
            LedgerAccountGroup ledgerAccountGroup = new LedgerAccountGroup();

            ledgerAccountGroup.dataAreaId         = dataAreaId;
            ledgerAccountGroup.LedgerPostingGroup = ledgerPostingGroup;
            return(ledgerAccountGroup);
        }
コード例 #2
0
        // GET: /ProductMaster/Create

        public ActionResult Create()
        {
            PrepareViewBag(null);
            LedgerAccountGroup vm = new LedgerAccountGroup();

            vm.IsActive = true;
            return(View("Create", vm));
        }
コード例 #3
0
        public ActionResult Modify(int id)
        {
            LedgerAccountGroup pt = _LedgerAccountGroupService.Find(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            PrepareViewBag(pt);
            return(View("Create", pt));
        }
コード例 #4
0
        /// <summary>
        /// Generates a new account number
        /// </summary>
        /// <param name="group">Ledger Account Group</param>
        /// <returns>Account Number</returns>
        public int GenerateNewAccountNumber(LedgerAccountGroup group)
        {
            var defaultAccountNumber = group > 0 ? (int)group * 10000 + 1 : (int)group * 10000 - 1;

            var lastGroupLedgerAccount = group > 0
                ? _repository.Get <LedgerAccount>(la => la.Group.Equals(group))
                                         .OrderByDescending(la => la.AccountNumber)
                                         .FirstOrDefault()
                : _repository.Get <LedgerAccount>(la => la.Group.Equals(group))
                                         .OrderBy(la => la.AccountNumber)
                                         .FirstOrDefault();

            return(lastGroupLedgerAccount == null
                ? defaultAccountNumber
                : group > 0 ? lastGroupLedgerAccount.AccountNumber + 1 : lastGroupLedgerAccount.AccountNumber - 1);
        }
コード例 #5
0
        public void PrepareViewBag(LedgerAccountGroup vm)
        {
            List <SelectListItem> nature = new List <SelectListItem>();

            nature.Add(new SelectListItem {
                Text = LedgerAccountNatureConstants.Assets, Value = LedgerAccountNatureConstants.Assets
            });
            nature.Add(new SelectListItem {
                Text = LedgerAccountNatureConstants.Liabilities, Value = LedgerAccountNatureConstants.Liabilities
            });
            nature.Add(new SelectListItem {
                Text = LedgerAccountNatureConstants.Income, Value = LedgerAccountNatureConstants.Income
            });
            nature.Add(new SelectListItem {
                Text = LedgerAccountNatureConstants.Expenditure, Value = LedgerAccountNatureConstants.Expenditure
            });


            List <SelectListItem> type = new List <SelectListItem>();

            type.Add(new SelectListItem {
                Text = LedgerAccountTypeConstants.Real, Value = LedgerAccountTypeConstants.Real
            });
            type.Add(new SelectListItem {
                Text = LedgerAccountTypeConstants.Personal, Value = LedgerAccountTypeConstants.Personal
            });
            type.Add(new SelectListItem {
                Text = LedgerAccountTypeConstants.Nominal, Value = LedgerAccountTypeConstants.Nominal
            });
            type.Add(new SelectListItem {
                Text = LedgerAccountTypeConstants.Bank, Value = LedgerAccountTypeConstants.Bank
            });

            if (vm == null)
            {
                ViewBag.LedgerAccountNature = new SelectList(nature, "Value", "Text");
                ViewBag.LedgerAccountType   = new SelectList(type, "Value", "Text");
            }
            else
            {
                ViewBag.LedgerAccountNature = new SelectList(nature, "Value", "Text", vm.LedgerAccountNature);
                ViewBag.LedgerAccountType   = new SelectList(type, "Value", "Text", vm.LedgerAccountType);
            }
        }
コード例 #6
0
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LedgerAccountGroup LedgerAccountGroup = _LedgerAccountGroupService.Find(id);

            if (LedgerAccountGroup == null)
            {
                return(HttpNotFound());
            }

            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
コード例 #7
0
 public void Update(LedgerAccountGroup pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <LedgerAccountGroup>().Update(pt);
 }
コード例 #8
0
 public void Delete(LedgerAccountGroup pt)
 {
     _unitOfWork.Repository <LedgerAccountGroup>().Delete(pt);
 }
コード例 #9
0
 public LedgerAccountGroup Create(LedgerAccountGroup pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <LedgerAccountGroup>().Insert(pt);
     return(pt);
 }
コード例 #10
0
 public LedgerAccountGroup Add(LedgerAccountGroup pt)
 {
     _unitOfWork.Repository <LedgerAccountGroup>().Insert(pt);
     return(pt);
 }
コード例 #11
0
 public void Update(LedgerAccountGroup pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _LedgerAccountGroupRepository.Update(pt);
 }
コード例 #12
0
 public void Delete(LedgerAccountGroup pt)
 {
     _LedgerAccountGroupRepository.Delete(pt);
 }
コード例 #13
0
 public LedgerAccountGroup Create(LedgerAccountGroup pt)
 {
     pt.ObjectState = ObjectState.Added;
     _LedgerAccountGroupRepository.Insert(pt);
     return(pt);
 }
コード例 #14
0
        public ActionResult Post(LedgerAccountGroup vm)
        {
            LedgerAccountGroup pt = vm;

            if (vm.ParentLedgerAccountGroupId == null || vm.ParentLedgerAccountGroupId == 0)
            {
                string message = "Under Group is required.";
                ModelState.AddModelError("", message);
                PrepareViewBag(vm);
                return(View("Create", vm));
            }

            if (ModelState.IsValid)
            {
                if (vm.LedgerAccountGroupId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _LedgerAccountGroupService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        PrepareViewBag(vm);
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.LedgerAccountGroup).DocumentTypeId,
                        DocId        = pt.LedgerAccountGroupId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Create").Success("Data saved successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    LedgerAccountGroup temp = _LedgerAccountGroupService.Find(pt.LedgerAccountGroupId);

                    LedgerAccountGroup ExRec = Mapper.Map <LedgerAccountGroup>(temp);

                    temp.LedgerAccountGroupName     = pt.LedgerAccountGroupName;
                    temp.LedgerAccountNature        = pt.LedgerAccountNature;
                    temp.LedgerAccountType          = pt.LedgerAccountType;
                    temp.ParentLedgerAccountGroupId = pt.ParentLedgerAccountGroupId;
                    temp.IsActive     = pt.IsActive;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    temp.ObjectState  = Model.ObjectState.Modified;
                    _LedgerAccountGroupService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }
                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        PrepareViewBag(vm);
                        return(View("Create", pt));
                    }


                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.LedgerAccountGroup).DocumentTypeId,
                        DocId           = temp.LedgerAccountGroupId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            PrepareViewBag(vm);
            return(View("Create", vm));
        }