コード例 #1
0
        public ActionResult SetCashier(int id, int value)
        {
            var entity = ExpenseVoucher.Find(id);
            var item   = Employee.TryFind(value);

            if (GetSession() == null)
            {
                return(Content(Resources.InvalidCashDrawer));
            }

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            if (item != null)
            {
                entity.Creator          = item;
                entity.Updater          = CurrentUser.Employee;
                entity.ModificationTime = DateTime.Now;

                using (var scope = new TransactionScope())
                {
                    entity.UpdateAndFlush();
                }
            }

            return(Json(new
            {
                id = id,
                value = entity.Creator.ToString()
            }));
        }
コード例 #2
0
        public ActionResult New()
        {
            var cashsession = GetSession();

            if (cashsession == null)
            {
                return(RedirectToAction("OpenSession", "Payments"));
            }

            ExpenseVoucher item = new ExpenseVoucher();

            item.Date             = DateTime.Now;
            item.Creator          = cashsession.Cashier;
            item.Updater          = cashsession.Cashier;
            item.Store            = WebConfig.Store;
            item.CashSession      = cashsession;
            item.ModificationTime = DateTime.Now;
            item.CreationTime     = DateTime.Now;
            item.Date             = DateTime.Now;


            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(RedirectToAction("Edit", new { id = item.Id }));
        }
コード例 #3
0
        public ActionResult SetComment(int id, string value)
        {
            if (GetSession() == null)
            {
                return(Content(Resources.InvalidCashDrawer));
            }

            var    entity = ExpenseVoucher.Find(id);
            string val    = (value ?? string.Empty).Trim();

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            entity.Comment          = (value.Length == 0) ? null : val;
            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;

            using (var scope = new TransactionScope())
            {
                entity.UpdateAndFlush();
            }

            return(Json(new
            {
                id = id,
                value = entity.Comment
            }));
        }
コード例 #4
0
        public JsonResult GetSuggestions(int expensevoucher, string pattern)
        {
            var item = ExpenseVoucher.Find(expensevoucher);

            var query = Expense.Queryable.Where(x => x.Name.Contains(pattern) || x.Comment.Contains(pattern));
            var items = query.Take(15).ToList().Select(x => new { id = x.Id, name = x.Name, comment = x.Comment });

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public ActionResult Print(int id)
        {
            var model = ExpenseVoucher.Find(id);

            if (!model.IsCancelled && model.IsCompleted)
            {
                return(PdfTicketView("Print", model));
            }
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public ActionResult Edit(int id)
        {
            ExpenseVoucher item = ExpenseVoucher.Find(id);

            if (item.IsCompleted || item.IsCancelled)
            {
                return(RedirectToAction("View", new { id = item.Id }));
            }

            return(View(item));
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: Nottos/go-api
        private static void CreateExpenseAndReverse(Go api)
        {
            var apiExpenseVoucher = new ExpenseVoucher()
            {
                CurrencyCode            = "NOK",
                DepartmentCode          = "123",
                ProjectCode             = "122",
                VoucherDate             = DateTime.Today,
                DueDate                 = DateTime.Today.AddDays(10),
                Description             = "Testbilag",
                EmployeeCode            = 1,
                EmployeeBankAccountCode = "12061614271"
            };

            apiExpenseVoucher.Lines = new List <ExpenseVoucherLine>
            {
                new ExpenseVoucherLine
                {
                    AccountCode    = 4000,
                    Amount         = 50000,
                    DepartmentCode = null,
                    ProjectCode    = null,
                    ProductCode    = null,
                    Description    = "Noe greier",
                    VatCode        = "1"
                },
                new ExpenseVoucherLine
                {
                    AccountCode    = 4000,
                    Amount         = 50000,
                    DepartmentCode = null,
                    ProjectCode    = null,
                    ProductCode    = null,
                    Description    = "Mere greier"
                }
            };

            //Saves and posts a Expense to PowerOffice Go
            var expense = api.Voucher.Expense.Save(apiExpenseVoucher);

            Console.WriteLine($"Expense: {expense.Id} - Is Expense Reversed ? {expense.IsReversed}");

            //Reverses the newly created Expense. This will reverse all accounting entries created by the previous voucher.
            Console.WriteLine($"Reversing voucher with id: {expense.Id}");
            var isReversed = api.Voucher.Expense.Reverse(expense.Id.Value).Success;

            Console.WriteLine($"Was reversal request a success ? {isReversed}");

            expense = api.Voucher.Expense.Get(expense.Id.Value);
            Console.WriteLine($"Is expense reversed after reverse ? {expense.IsReversed}");
        }
コード例 #8
0
        public ActionResult Confirm(int id)
        {
            var entity = ExpenseVoucher.Find(id);

            if (entity.IsCancelled || entity.IsCompleted || GetSession() == null)
            {
                return(RedirectToAction("Index"));
            }

            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;
            entity.IsCompleted      = true;

            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public ActionResult AddItem(int expensevoucher, int expense)
        {
            ExpenseVoucher entity = ExpenseVoucher.Find(expensevoucher);
            Expense        item   = Expense.Find(expense);

            if (entity.IsCancelled || entity.IsCompleted)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            ExpenseVoucherDetail detail = new ExpenseVoucherDetail {
                ExpenseVoucher = entity, Expense = item, Comment = item.Comment
            };

            using (var scope = new TransactionScope()) {
                detail.CreateAndFlush();
            }

            return(Json(new { id = detail.Id }, JsonRequestBehavior.AllowGet));
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: mirkomaty/NDO
        static void CreateObjects()
        {
            PersistenceManager pm = new PersistenceManager();

            pm.BuildDatabase();

            Employee e = new Employee();

            e.FirstName = "John";
            e.LastName  = "Becker";
            pm.MakePersistent(e);

            Travel t = e.NewTravel();

            t.Purpose = "NDO Workshop";

            ExpenseVoucher ev = new ExpenseVoucher();

            ev.VoucherText = "Taxi";
            ev.Sum         = 30;
            ev.Date        = DateTime.Now.Date;
            t.AddExpense(ev);

            MileageAllowance ma = new MileageAllowance();

            ma.MilesDriven = 200;
            ma.Date        = DateTime.Now.Date;
            t.AddExpense(ma);

            PerDiemAllowance pda = new PerDiemAllowance();

            pda.Hours = (decimal)12.5;
            pda.Date  = DateTime.Now.Date;
            t.AddExpense(pda);

            pm.Save();
        }
コード例 #11
0
 public ActionResult Pdf(int id)
 {
     return(PdfView("Print", ExpenseVoucher.Find(id)));
 }
コード例 #12
0
 public ViewResult View(int id)
 {
     return(View(ExpenseVoucher.Find(id)));
 }
コード例 #13
0
        public ActionResult Totals(int id)
        {
            var entity = ExpenseVoucher.Find(id);

            return(PartialView("_Totals", entity));
        }