Esempio n. 1
0
        public ChartOfAccount ChartOfAccountData(string accountCode)
        {
            var coaItem = new POSAccount.Contract.ChartOfAccount();

            if (accountCode != null && accountCode.Length > 0)
            {
                coaItem = new POSAccount.BusinessFactory.ChartOfAccountBO().GetChartOfAccount(new Contract.ChartOfAccount {
                    AccountCode = accountCode, BranchID = Utility.SsnBranch
                });
            }

            coaItem.CurrencyCodeList = Utility.GetCurrencyItemList();
            coaItem.AccountGroupList = Utility.GetAccountGroupItemList(Convert.ToInt16((Session["BranchId"]))).Where(x => x.Value != accountCode).ToList();
            coaItem.DebitCreditList  = Utility.GetLookupItemList("DebitCredit");

            return(coaItem);
        }
Esempio n. 2
0
        public ActionResult UpdateChartOfAccount(POSAccount.Contract.ChartOfAccount item)
        {
            if (ModelState.IsValid)
            {
                if (item.BranchID == 0)
                {
                    item.BranchID = Utility.SsnBranch;
                }
                if (item == null)
                {
                    return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
                }

                item.CreatedBy  = Utility.DEFAULTUSER;
                item.ModifiedBy = Utility.DEFAULTUSER;

                var result = new POSAccount.BusinessFactory.ChartOfAccountBO().SaveChartOfAccount(item);
            }
            return(RedirectToAction("ChartOfAccountMaster", "MasterData"));
        }
Esempio n. 3
0
        public ActionResult ChartOfAccountMaster(string branchID, string _accountCode = "")
        {
            var accountCode = Request.Form["hdnAccountCode"];

            if (string.IsNullOrWhiteSpace(accountCode))
            {
                if (!string.IsNullOrWhiteSpace(_accountCode))
                {
                    accountCode = _accountCode;
                }
            }
            ViewData["hdnAccountCode"] = accountCode;

            short branchId = -1;

            if (branchID != null)
            {
                branchId = Convert.ToInt16(branchID);
            }
            else
            {
                branchId = Convert.ToInt16(Session["BranchId"]);
            }
            //var ChartOfAccounts = new POSAccount.BusinessFactory.ChartOfAccountBO().GetList();
            var accountGroupList    = new POSAccount.BusinessFactory.AccountGroupBO().GetList();
            var chartOfAccountsList = new POSAccount.BusinessFactory.ChartOfAccountBO().GetList(branchId);

            List <AccountGroupVm> accountGroupVm = new List <AccountGroupVm>();

            for (var i = 0; i < accountGroupList.Count; i++)
            {
                var            code         = accountGroupList[i].Code;
                AccountGroupVm accountGroup = new AccountGroupVm();
                accountGroup.Code         = accountGroupList[i].Code;
                accountGroup.AccountType  = accountGroupList[i].AccountType;
                accountGroup.Description  = accountGroupList[i].Description;
                accountGroup.Description1 = accountGroupList[i].Description1;
                accountGroup.Description2 = accountGroupList[i].Description2;
                accountGroup.SequenceNo   = accountGroupList[i].SequenceNo;

                accountGroup.COAList = chartOfAccountsList.Where(x => x.AccountGroup == accountGroupList[i].Code)
                                       .Select(x => new ChartOfAccountsVm()
                {
                    AccountCode             = x.AccountCode,
                    Description             = x.Description,
                    Description2            = x.Description2,
                    AccountGroup            = x.AccountGroup,
                    DebitCredit             = x.DebitCredit,
                    CurrencyCode            = x.CurrencyCode,
                    Status                  = x.Status,
                    Sequence                = x.Sequence,
                    BranchID                = x.BranchID,
                    CreatedBy               = x.CreatedBy,
                    CreatedOn               = x.CreatedOn,
                    ModifiedBy              = x.ModifiedBy,
                    ModifiedOn              = x.ModifiedOn,
                    AccountGroupDescription = x.AccountGroupDescription,
                    COAList                 = PopulateChilds(x.AccountCode, chartOfAccountsList)
                }).ToList <ChartOfAccountsVm>();

                accountGroupVm.Add(accountGroup);
            }

            /*
             * var list = ChartOfAccounts.GroupBy(x => x.AccountGroup)
             *                          .Select(x => new MyItem() {
             *                              Description = x.FirstOrDefault().Description,
             *                              Description2 = x.FirstOrDefault().Description2,
             *                              AccountGroupDescription = x.FirstOrDefault().AccountGroupDescription,
             *                              Sequence = x.FirstOrDefault().Sequence,
             *                              AccountCode = x.FirstOrDefault().AccountCode,
             *                              ChildItems = (ChartOfAccounts.Where(y => y.AccountGroup == x.FirstOrDefault().AccountGroup)
             *                                              .Select(y => new MyItem() {
             *                                                  Description = y.Description,
             *                                                  Description2 = y.Description2,
             *                                                  AccountGroupDescription = y.AccountGroupDescription,
             *                                                  Sequence = y.Sequence,
             *                                                  AccountCode = y.AccountCode
             *                                              })).ToList()
             *                          }).ToList<MyItem>();*/

            if (Request.IsAjaxRequest())
            {
                return(Json(accountGroupVm, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(View("ChartOfAccounts", accountGroupVm));
            }
        }