示例#1
0
 public IActionResult FrontEndExpenseTypes()
 {
     return(Json(new { data = CashDeskStaticValues.StaticValues().
                              Where(k => k.Meta == "FrontExpense").
                              Select(k => new { k.Key, k.Text }).
                              ToList() }));
 }
示例#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 }));
            }
        }
示例#3
0
        //array gelmesini denemem lazim. Specific item adi ile cagirmagla

        public IActionResult SubmitRefund(string postRefundHeaderString, string[] postRefundDetail)
        {
            if (postRefundHeaderString == null)
            {
                return(Json(new { success = false, message = "Refund is empty" }));
            }
            try
            {
                var claimIntetity = (ClaimsIdentity)User.Identity;
                var claim         = claimIntetity.FindFirst(ClaimTypes.NameIdentifier);

                string[] refundHeaderArr = postRefundHeaderString.Split(new char[] { ',' });

                double       totalAmount  = Convert.ToDouble(refundHeaderArr[1]);
                RefundHeader refundHeader = new RefundHeader()
                {
                    OrderHeaderId = Convert.ToInt32(refundHeaderArr[0]),
                    TotalAmount   = totalAmount,
                    Comment       = refundHeaderArr[2],
                    RefundDate    = DateTime.Now
                };

                _unitOfWork.RefundHeader.Add(refundHeader);


                CurrentMovement currentMovement = new CurrentMovement()
                {
                    //AccountingBookId
                    CurrentDate  = DateTime.Now,
                    Description  = Utility.StaticValues.Accounting.Refund,
                    IsInflow     = false,
                    MovementType = (string)CashDeskStaticValues.StaticValues().FirstOrDefault(u => u.Key == "Refund").Key,  //bUnu yeni elave etdim test etmedim
                    Sum          = totalAmount,
                    UserId       = claim.Value,
                    Cleared      = false,
                };

                _unitOfWork.CurrentMovement.Add(currentMovement);

                _unitOfWork.Save();



                foreach (var item in postRefundDetail)
                {
                    string[]     detailArr    = item.Split(new char[] { ',' });
                    int          productId    = Convert.ToInt32(detailArr[0]);
                    int          quantity     = Convert.ToInt32(detailArr[2]);
                    RefundDetail refundDetail = new RefundDetail()
                    {
                        RefundHeaderId = refundHeader.Id,
                        ProductId      = productId,
                        Price          = Convert.ToDouble(detailArr[1]),
                        Count          = quantity
                    };

                    _unitOfWork.RefundDetail.Add(refundDetail);
                    _unitOfWork.Product.AddStockQuantity(productId, quantity);
                }

                _unitOfWork.Save();
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }));
            }

            return(Json(new { success = true, message = "Refunded successfully" }));
        }
示例#4
0
        public IActionResult Index()
        {
            var a = CashDeskStaticValues.StaticValues().Where(k => k.Meta == "Front").ToList();

            return(Json(new { data = a }));
        }