예제 #1
0
        public ActionResult Create(int id)
        {
            Journal journal = ServiceFactory.GetJournalServices().Get(id);

            Ledger led = new Ledger();

            led.LedgerPeriod = journal.JournalPeriod;
            led.CompanyId    = Convert.ToInt32(Session["CompanyId"]);

            List <Account>   accList    = new List <Account>();
            List <int>       idList     = (List <int>)ServiceFactory.GetTransactionDetailServices().GetDistinctAccount(journal.Id);
            IAccountServices accService = ServiceFactory.GetAccountServices();

            foreach (int i in idList)
            {
                Account acc = accService.Get(i);
                accList.Add(acc);
            }

            Session["Ledger"]      = led;
            Session["Journal"]     = journal;
            Session["AccountList"] = accList;

            if (journal.LedgerId != 0)
            {
                return(RedirectToAction("GetStoredLedger", new { id = journal.LedgerId }));
            }
            return(RedirectToAction("GenerateLedger"));
        }
예제 #2
0
        public ActionResult Details(int id)
        {
            Ledger           led        = ServiceFactory.GetLedgerServices().Get(id);
            Journal          journal    = ServiceFactory.GetJournalServices().GetByLedger(led.Id);
            List <int>       accId      = (List <int>)ServiceFactory.GetTransactionDetailServices().GetDistinctAccount(journal.Id);
            List <Account>   accList    = new List <Account>();
            IAccountServices accService = ServiceFactory.GetAccountServices();

            foreach (int i in accId)
            {
                Account ac = accService.Get(i);
                accList.Add(ac);
            }
            Session["Ledger"]      = led;
            Session["Journal"]     = journal;
            Session["AccountList"] = accList;
            return(View());
        }
예제 #3
0
        public ActionResult DeleteWithRollBack(int id)
        {
            Transaction transaction = ServiceFactory.GetTransactionServices().Get(id);

            if (transaction.JournalId != 0)
            {
                ServiceFactory.GetJournalServices().Delete(transaction.JournalId);
            }

            IAccountServices           accService    = ServiceFactory.GetAccountServices();
            ITransactionTypeServices   tTypeService  = ServiceFactory.GetTransactionTypeServices();
            ITransactionDetailServices detailService = ServiceFactory.GetTransactionDetailServices();

            List <TransactionDetail> detail  = (List <TransactionDetail>)detailService.GetAll(transaction.Id);
            List <Account>           accList = new List <Account>();

            foreach (TransactionDetail d in detail)
            {
                Account         acc    = accService.Get(d.AccountId);
                TransactionType type   = tTypeService.Get(d.TransactionType);
                string          action = accService.GetRollBackAction(acc.Id, type.Type);

                if (action == "Increase")
                {
                    acc.Amount += d.Amount;
                }
                else
                {
                    acc.Amount -= d.Amount;
                }
                accService.Update(acc);
                accList.Add(acc);
                detailService.Delete(d.Id);
            }
            ServiceFactory.GetTransactionServices().Delete(transaction.Id);
            ViewBag.AccountList = accList;
            return(View());
        }
예제 #4
0
 public ActionResult <IEnumerable <Account> > Get()
 {
     return(Ok(_accountServices.Get()));
 }