Exemplo n.º 1
0
        public ActionResult Confirm(int id)
        {
            var  dt      = DateTime.Now;
            bool changed = false;
            var  entity  = CustomerRefund.Find(id);

            using (var scope = new TransactionScope()) {
                foreach (var item in entity.Details)
                {
                    var qty = GetRefundableQuantity(item.SalesOrderDetail.Id);

                    if (qty < item.Quantity)
                    {
                        changed = true;

                        if (qty > 0.0m)
                        {
                            item.Quantity = qty;
                            item.Update();
                        }
                        else
                        {
                            item.Delete();
                        }
                    }
                }

                if (changed)
                {
                    entity.Updater          = CurrentUser.Employee;
                    entity.ModificationTime = dt;
                    entity.UpdateAndFlush();

                    return(RedirectToAction("Edit", new { id = entity.Id, notify = true }));
                }
            }

            using (var scope = new TransactionScope()) {
                foreach (var detail in entity.Details.Where(x => !(x.Quantity > 0.0m)).ToList())
                {
                    detail.DeleteAndFlush();
                }

                foreach (var x in entity.Details)
                {
                    InventoryHelpers.ChangeNotification(TransactionType.CustomerRefund, entity.Id, dt,
                                                        x.SalesOrderDetail.Warehouse, null, x.Product, x.Quantity);
                }

                entity.Updater          = CurrentUser.Employee;
                entity.ModificationTime = dt;
                entity.Date             = dt;
                entity.IsCompleted      = true;
                entity.UpdateAndFlush();
            }

            return(RedirectToAction("View", new { id = entity.Id }));
        }
Exemplo n.º 2
0
        public ActionResult Cancel(int id)
        {
            var entity = CustomerRefund.Find(id);

            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;
            entity.Date             = DateTime.Now;
            entity.IsCancelled      = true;

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

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var entity = CustomerRefund.Find(id);

            return(View(entity));
        }
Exemplo n.º 4
0
        public ActionResult Totals(int id)
        {
            var item = CustomerRefund.Find(id);

            return(PartialView("_Totals", item));
        }
Exemplo n.º 5
0
        public ViewResult Print(int id)
        {
            var entity = CustomerRefund.Find(id);

            return(View(entity));
        }