public IActionResult GetTurnOverByMonth([FromBody] int month)
        {
            var s = _saleService.All().Where(i => i.Date.Month == month && i.Payment == true)
                    .Select(x => new InfoMoneyVM
            {
                Date = x.Date.ToString("dd.MM.yyyy"),
                Sum  = x.Sum
            });


            return(Ok(_saleService.All().Where(i => i.Date.Month == month && i.Payment == true)
                      .Select(x => new InfoMoneyVM
            {
                Date = x.Date.ToString("dd.MM.yyyy"),
                Sum = x.Sum
            })));
        }
        // GET: SalesController
        public ActionResult Index(string msg = null)
        {
            if (msg != null)
            {
                ViewBag.Msg = msg;
            }

            return(View(_saleService.All()));
        }
Exemple #3
0
 public IActionResult Index()
 {
     return(View(_shopService.All().ToList().Select(x => new ShopVM()
     {
         Id = x.Id,
         Title = x.Title,
         CashOnHand = _shopService.CashOnHand(_db, x.Id),
         Margin = _shopService.Margin(x.Id),
         Sales = _saleService.All()
                 .Where(s => s.Date.Month == DateTime.Now.AddHours(3).Month&& s.Payment == true)
                 .Count(s => s.ShopId == x.Id),
         Turnover = _shopService.Turnover(x.Id)
     })));
 }
        public IActionResult CheckPrint(int?saleId, int?bookingId, decimal operationSum)
        {
            if (saleId != null)
            {
                var sale = _saleService.All().FirstOrDefault(x => x.Id == saleId);

                ViewBag.SaleProducts = _saleProductService.All()
                                       .Where(x => x.SaleId == sale.Id)
                                       .Include(x => x.Product);

                ViewBag.Sale         = true;
                ViewBag.OperationSum = operationSum;

                if (sale.SaleType != SaleType.SaleFromStock)
                {
                    ViewBag.TotalOperationSum = _infoMoneyService.All()
                                                .Where(x => x.SaleId == sale.Id)
                                                .Sum(x => x.Sum);
                }
                else
                {
                    ViewBag.TotalOperationSum = operationSum;
                }

                return(View(sale));
            }
            else
            {
                var booking = _bookingService.All().FirstOrDefault(x => x.Id == bookingId);

                ViewBag.SaleProducts = _bookingProductService.All()
                                       .Where(x => x.BookingId == bookingId)
                                       .Include(x => x.Product);

                ViewBag.OperationSum      = operationSum;
                ViewBag.TotalOperationSum = _infoMoneyService.All()
                                            .Where(x => x.BookingId == booking.Id)
                                            .Sum(x => x.Sum);

                ViewBag.Sale = false;

                return(View(booking));
            }
        }
Exemple #5
0
        public IActionResult Detail(int id)
        {
            var userName = HttpContext.User.Identity.Name;
            var user     = _userService.All().First(u => u.Login == userName).Role.ToString();

            ViewBag.Role = user;

            var infoMoneys = _db.InfoMonies.ToList();

            Sale sale = _saleService.All()
                        .Select(x => new Sale()
            {
                Id    = x.Id,
                Title = x.Title,
                Date  = x.Date,
                //Sum = infoMoneys.Where(z => z.SaleId == x.Id).Sum(z => z.Sum),
                Discount   = x.Discount,
                Margin     = x.Margin,
                Partner    = x.Partner,
                PrimeCost  = x.PrimeCost,
                Shop       = x.Shop,
                SaleType   = x.SaleType,
                ForRussian = x.ForRussian
            }).First(p => p.Id == id);

            sale.Sum = infoMoneys.Where(z => z.SaleId == sale.Id)
                       .Sum(z => z.Sum);

            ViewBag.SalesProducts = _saleProductService.All().Select(sp => new SaleProduct
            {
                SaleId     = sp.SaleId,
                Product    = sp.Product,
                Amount     = sp.Amount,
                Additional = sp.Additional,
                Cost       = sp.Cost
            }).Where(sp => sp.SaleId == sale.Id).ToList();

            ViewBag.PaymentType = _saleInfoService.PaymentType(sale.Id, infoMoneys);

            var scores = _infoMoneyService.All().Where(x => x.SaleId == id);

            ViewBag.SaleFinanceDetail = new SaleDetailFinanceVM
            {
                CashScores = scores.Where(x => x.PaymentType == PaymentType.Cash)
                             .Select(x => new SaleDetailFinanceItemVM
                {
                    MoneyWorkerTitle = x.MoneyWorker.Title,
                    Sum = x.Sum.ToString()
                }),
                CashlessScores = scores.Where(x => x.PaymentType == PaymentType.Cashless)
                                 .Select(x => new SaleDetailFinanceItemVM
                {
                    MoneyWorkerTitle = x.MoneyWorker.Title,
                    Sum = x.Sum.ToString()
                })
            };

            var managerId = _postgresContext.SaleManagersOld
                            .FirstOrDefault(x => x.SaleId == id)?.ManagerId;

            if (managerId != null)
            {
                ViewBag.Manager = _postgresContext.Managers
                                  .FirstOrDefault(x => x.Id == managerId)?.Name ??
                                  "Менеджер не указан или не найден";
            }
            else
            {
                ViewBag.Manager = "Менеджер не указан или не найден";
            }

            return(View(sale));
        }
Exemple #6
0
 public IActionResult All() => View(sales.All());
 public IActionResult All()
 {
     return(View(saleService.All()));
 }
Exemple #8
0
 // GET: SalesController
 public ActionResult Index()
 {
     return(View(_saleService.All()));
 }
Exemple #9
0
 public IActionResult All()
 {
     return(View(sales.All()));
 }