Пример #1
0
        public IActionResult ClearingCashDesk()
        {
            CurrentMovementViewModel currentMovement = new CurrentMovementViewModel();

            var inflowAmount  = _unitOfWork.CurrentMovement.GetAll(filter: u => u.Cleared == false && u.IsInflow == true).Sum(u => u.Sum);
            var outflowAmount = _unitOfWork.CurrentMovement.GetAll(filter: u => u.Cleared == false && u.IsInflow == false).Sum(u => u.Sum);

            currentMovement.totalInflow  = (double)inflowAmount;
            currentMovement.totalOutflow = (double)outflowAmount;

            return(View(currentMovement));
        }
Пример #2
0
        public IActionResult ClearCashDesk(CurrentMovementViewModel currentMovementVM)
        {
            if (currentMovementVM == null)
            {
                return(Json(new { success = false, data = "Empty data" }));
            }
            try
            {
                var claimIntetity = (ClaimsIdentity)User.Identity;
                var claim         = claimIntetity.FindFirst(ClaimTypes.NameIdentifier);

                AccountingBook accountingBook = new AccountingBook
                {
                    AccountingDate = DateTime.Now,
                    CashLeft       = currentMovementVM.cashLeft,
                    InFlowSum      = currentMovementVM.totalInflow,
                    OutFlowSum     = currentMovementVM.totalOutflow,
                    UserId         = claim.Value
                };

                _unitOfWork.AccountingBook.Add(accountingBook);
                _unitOfWork.Save();

                _unitOfWork.CurrentMovement.setAccountingBookId(accountingBook.Id);



                CurrentMovement currentMovement = new CurrentMovement()
                {
                    //AccountingBookId
                    CurrentDate  = DateTime.Now,
                    Description  = "After Cleared",
                    IsInflow     = true,
                    MovementType = CashDeskStaticValues.StaticValues().FirstOrDefault(u => u.Key == "CashDeskClearInFlow").Key,
                    Sum          = currentMovementVM.cashLeft,
                    UserId       = claim.Value,
                    Cleared      = false,
                };

                _unitOfWork.CurrentMovement.Add(currentMovement);


                _unitOfWork.Save();

                return(RedirectToAction("ClearingCashDesk"));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, data = ex.Message }));
            }
        }