Ejemplo n.º 1
0
        public static string SaveTransfer(CashBankTransferVm currVm)
        {
            string result = "true";
            //create cash In object


            CashInVm cashIn = new CashInVm();

            cashIn.CashType      = "cashin";
            cashIn.CreateBy      = CurrentUserId;
            cashIn.CreateDate    = DateTime.Now;
            cashIn.CurrencyId    = currVm.CurrentCurrencyId;
            cashIn.Notes         = currVm.Notes;
            cashIn.PaymentTermId = currVm.IsCashToBank ? (byte)PaymentTermEnum.CashToBank : (byte)PaymentTermEnum.BankToCash;
            cashIn.ReceiptAmount = currVm.CurrentAmount;
            cashIn.ReceiptDate   = DateTime.Now;

            var bankAcc = BankHelper.GetBankAccountInfo(currVm.BankAccId);

            cashIn.BankId    = bankAcc.BankId;
            cashIn.BankAccId = bankAcc.BankAccId;

            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    int cashInReceiptId, cashOutReceiptId;
                    CashHelper.AddEditCashReceipt(cashIn, out cashInReceiptId, false);
                    cashIn.CashType      = "cashout";
                    cashIn.CurrencyId    = currVm.CurrentCurrencyId;
                    cashIn.ReceiptAmount = currVm.CurrentAmount;
                    cashIn.ReceiptId     = 0;
                    cashIn.ReceiptCode   = "";
                    cashIn.BankId        = null;
                    cashIn.BankAccId     = null;
                    CashOutHelper.AddEditCashReceipt(cashIn, out cashOutReceiptId, false);

                    AddReceiptToTransTableTransfer(currVm, cashInReceiptId, cashOutReceiptId);

                    transaction.Complete();
                }
                catch (DbEntityValidationException e)
                {
                    result = "false " + e.Message;
                }
                catch (Exception e)
                {
                    result = "false " + e.Message;
                }
            }


            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult CashInReceipt(int invId, int agNoteId = 0)
        {
            ViewBag.CashRecTitle = "Cash In Receipt";
            ViewBag.PaymentTerm  = ListCommonHelper.GetPaymentTerm("en", true)
                                   .Where(x => x.Key != 2 && x.Key < 6)
                                   .ToDictionary(x => x.Key, x => x.Value);
            ViewBag.CurrencyList = ListCommonHelper.GetCurrencyList();
            ViewBag.BankList     = ListCommonHelper.GetBankList();
            var cashReceiptObj = CashHelper.GetCashReceiptInfo(invId, agNoteId);

            return(View(cashReceiptObj));
        }
Ejemplo n.º 3
0
        public ActionResult CCCashSettlement(int operationId, decimal receiptAmount = 0)
        {
            ViewBag.PaymentTerm = ListCommonHelper.GetPaymentTerm("en")
                                  .Where(x => x.Key == 1)
                                  .ToDictionary(x => x.Key, x => x.Value);
            ViewBag.CurrencyList = ListCommonHelper.GetCurrencyList();
            ViewBag.BankList     = ListCommonHelper.GetBankList();

            CashInVm cashReceiptObj = CashHelper.GetCashReceiptInfoForSettlement(operationId, receiptAmount);

            ViewBag.CashRecTitle = "Custom Clearance Cash Settlement (In) For Operation " + cashReceiptObj.OperationCode;

            return(View("~/Views/CashManagement/CashInReceipt.cshtml", cashReceiptObj));
        }
Ejemplo n.º 4
0
        public ActionResult PrintCashInV(int id, bool isOut)
        {
            CashInVm invObj;

            if (isOut)
            {
                invObj = CashOutHelper.GetCashReceiptInfo(0, 0, id);
            }
            else
            {
                invObj = CashHelper.GetCashReceiptInfo(0, 0, id);
            }
            return(View(invObj));
        }
Ejemplo n.º 5
0
        public ActionResult ArCashDeposit()
        {
            ViewBag.PaymentTerm = ListCommonHelper.GetPaymentTerm("en")
                                  .Where(x => x.Key == 1 || x.Key == 3) //Cash Or bank only
                                  .ToDictionary(x => x.Key, x => x.Value);
            ViewBag.CurrencyList  = ListCommonHelper.GetCurrencyList();
            ViewBag.BankList      = ListCommonHelper.GetBankList();
            ViewBag.ShipperList   = ListCommonHelper.GetShipperList();
            ViewBag.ConsigneeList = ListCommonHelper.GetConsigneeList();

            var cashReceiptObj = CashHelper.GetCashReceiptInfo(0, 0);

            cashReceiptObj.Notes = "Cash Deposit From Client";
            return(View(cashReceiptObj));
        }
Ejemplo n.º 6
0
        public ActionResult GetCashReceiptsForNote(int agNoteId, bool isOut = false)
        {
            List <CashInInvoiceVm> cashReceiptList;

            if (isOut)
            {
                cashReceiptList = CashOutHelper.GetCashAgNoteList(agNoteId);
            }
            else
            {
                cashReceiptList = CashHelper.GetCashAgNoteList(agNoteId);
            }

            return(PartialView("~/Views/CashManagement/_CashReceiptsForInv.cshtml", cashReceiptList));
        }
Ejemplo n.º 7
0
        public ActionResult DeleteCashIn(int receiptId, int invId, string deleteReason)
        {
            #region Check Rights
            bool hasRights = false;
            hasRights = AdminHelper.CheckUserAction(ScreenEnum.CashManagment, ActionEnum.Delete);
            if (!hasRights)
            {
                return(Json("You are UnAuthorized to do this action", JsonRequestBehavior.AllowGet));
            }

            #endregion

            string isDeleted = CashHelper.DeleteCashInReceipt(receiptId, invId, deleteReason);
            return(Json(isDeleted, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        public static string AddArCashDeposit(CashInVm cashInVm)
        {
            string             isSaved       = "true";
            AccountingEntities db            = new AccountingEntities();
            ArCashDeposit      arCashDeposit = new ArCashDeposit();

            Mapper.CreateMap <CashInVm, ArCashDeposit>()
            .IgnoreAllNonExisting();
            Mapper.Map(cashInVm, arCashDeposit);

            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    arCashDeposit.ReceiptCode = AdminHelper.GeneratePrefixCode(PrefixForEnum.CashIn, true);
                    db.ArCashDeposits.Add(arCashDeposit);

                    db.SaveChanges();



                    cashInVm.ReceiptId   = arCashDeposit.ReceiptId;
                    cashInVm.ReceiptCode = arCashDeposit.ReceiptCode;

                    string creditAccountId = ((int)AccountingChartEnum.DepositRevenues).ToString();

                    //Add invoice to accounting transactions table
                    CashHelper.AddReceiptToTransTable(creditAccountId, cashInVm, "ArCashDeposit");

                    //Add or update deposit balance for this client
                    CashDepositBalanceHelper.AddEditArDepBalance(cashInVm.ShipperId, cashInVm.ConsigneeId,
                                                                 cashInVm.CurrencyId, cashInVm.ReceiptAmount.Value, db);

                    transaction.Complete();
                }
                catch (DbEntityValidationException e)
                {
                    isSaved = "false " + e.Message;
                }
                catch (Exception e)
                {
                    isSaved = "false " + e.Message;
                }
            }


            return(isSaved);
        }
        public ActionResult AddEditCashReceipt(ViewModel.CashInVm cashObj)
        {
            string isSaved = "false";
            int    receiptId;

            if (cashObj.CashType == "cashin")
            {
                isSaved = CashHelper.AddEditCashReceipt(cashObj, out receiptId);
            }
            else
            {
                isSaved = CashOutHelper.AddEditCashReceipt(cashObj, out receiptId);
            }

            return(Json(isSaved + "_" + receiptId));
        }
Ejemplo n.º 10
0
        public ActionResult AddEditCashReceipt(CashInVm cashVmObj)
        {
            string isSaved = "false";
            int    receiptId;

            if (cashVmObj.CashType == "cashin")
            {
                isSaved = CashHelper.AddEditCashReceipt(cashVmObj, out receiptId);
            }
            else //Cash Out Receipt or CC cash deposit
            {
                isSaved = CashOutHelper.AddEditCashReceipt(cashVmObj, out receiptId);
            }


            return(Json(isSaved + "_" + receiptId));
        }
Ejemplo n.º 11
0
        public ActionResult ViewCashInPartial(int id, bool isOut = false)
        {
            System.Globalization.CultureInfo clut = new System.Globalization.CultureInfo("ar-EG");

            Session["receiptId"] = id;
            Session["CashType"]  = isOut;
            CashInVm invObj;

            if (isOut)
            {
                invObj = CashOutHelper.GetCashReceiptInfo(0, 0, id);
            }
            else
            {
                invObj = CashHelper.GetCashReceiptInfo(0, 0, id);
            }
            return(PartialView("~/Views/CashManagement/_ViewCashInReceipt.cshtml", invObj));
        }
Ejemplo n.º 12
0
        public static string SaveCurrencyExchange(CurrencyExchangeVm currVm)
        {
            string result = "true";
            //create cash In object
            CashInVm cashIn = new CashInVm();

            cashIn.CashType      = "cashin";
            cashIn.CreateBy      = CurrentUserId;
            cashIn.CreateDate    = DateTime.Now;
            cashIn.CurrencyId    = currVm.NewCurrencyId;
            cashIn.Notes         = currVm.Notes;
            cashIn.PaymentTermId = (byte)PaymentTermEnum.CurrencyExchange; //CurrencyExchange
            cashIn.ReceiptAmount = currVm.NewAmount;
            cashIn.ReceiptDate   = DateTime.Now;

            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    int cashInReceiptId, cashOutReceiptId;
                    CashHelper.AddEditCashReceipt(cashIn, out cashInReceiptId, false);
                    cashIn.CashType      = "cashout";
                    cashIn.CurrencyId    = currVm.CurrentCurrencyId;
                    cashIn.ReceiptAmount = currVm.CurrentAmount;
                    cashIn.ReceiptId     = 0;
                    cashIn.ReceiptCode   = "";
                    CashOutHelper.AddEditCashReceipt(cashIn, out cashOutReceiptId, false);

                    AddReceiptToTransTable(currVm, cashInReceiptId, cashOutReceiptId);

                    transaction.Complete();
                }
                catch (DbEntityValidationException e)
                {
                    result = "false " + e.Message;
                }
                catch (Exception e)
                {
                    result = "false " + e.Message;
                }
            }
            return(result);
        }
Ejemplo n.º 13
0
        public ActionResult CashOpenBalance(string accid, int cid)
        {
            ViewBag.PaymentTerm = ListCommonHelper.GetPaymentTerm("en", true)
                                  .Where(x => x.Key != 2 && x.Key < 6)
                                  .ToDictionary(x => x.Key, x => x.Value);

            ViewBag.CurrencyList = ListCommonHelper.GetCurrencyList();
            ViewBag.BankList     = ListCommonHelper.GetBankList();

            var cashReceiptObj = CashHelper.GetCashReceiptOpenBalance(accid, cid);

            var openBalanceObject = AccountingHelper.Get_OpenBalanceObject(accid, cid);

            ViewBag.OpenBalanceObject = openBalanceObject;

            ViewBag.CashRecTitle = openBalanceObject.Amount < 0 ? "Cash Out Receipt" : "Cash In Receipt";

            return(View(cashReceiptObj));
        }
Ejemplo n.º 14
0
        public PartialViewResult GetCCCashDepositList(int operId)
        {
            var ccCashDepList = CashOutHelper.GetCCCashDepositList(operId);

            if (ccCashDepList.Count > 0)
            {
                Dictionary <string, decimal> DepositTotals = new Dictionary <string, decimal>();

                var DepositTotalsObj = ccCashDepList.GroupBy(x => x.CurrencySign)
                                       .Select(x => new { curr = x.Key, total = x.Sum(y => y.ReceiptAmount.Value) }).ToList();

                //Get any collcted back deposits
                var     depositSattl = CashHelper.GetCashSettlementForOper(operId);
                decimal depositAmout = 0;
                if (depositSattl != null)
                {
                    foreach (var item in DepositTotalsObj)
                    {
                        if (depositSattl.Keys.Contains(item.curr))
                        {
                            depositAmout = item.total - depositSattl[item.curr];
                        }
                        else
                        {
                            depositAmout = item.total;
                        }

                        DepositTotals.Add(item.curr, depositAmout);
                    }
                }

                ViewBag.DepositTotal = DepositTotals;
                //ViewBag.Currency = ccCashDepList.FirstOrDefault().CurrencySign;
            }
            else
            {
                ViewBag.DepositTotal = 0;
                ViewBag.Currency     = "EGP";
            }
            //Get AP invoices
            var apInvList = APInvoiceHelper.GetInvoiceListForOper(operId);

            if (apInvList.Count > 0)
            {
                var currList    = ListCommonHelper.GetCurrencyList();
                var apInvTotals = apInvList.Where(x => x.InvoiceType == 3).GroupBy(x => x.InvCurrencyId)
                                  .Select(x => new { curr = x.Key, total = x.Sum(y => y.InvoiceDetails.Sum(c => c.InvoiceAmount)) });

                Dictionary <string, decimal> apInvTotalsDic = new Dictionary <string, decimal>();
                string currSign = "";

                foreach (var item in apInvTotals)
                {
                    currSign = currList.Where(x => x.Key == item.curr).FirstOrDefault().Value;
                    apInvTotalsDic.Add(currSign, item.total);
                }

                ViewBag.CCInvTotal = apInvTotalsDic;
            }
            else
            {
                ViewBag.CCInvTotal = 0;
            }

            ViewBag.OperId = operId;

            var cashSettlement = CashHelper.GetCashSettlementForOper(operId);

            // if(cashSettlement.Count > 0)
            ViewBag.CashSettlement = cashSettlement;


            return(PartialView("~/Views/CashDeposit/_CCCashDepositList.cshtml", ccCashDepList));
        }
Ejemplo n.º 15
0
        public JObject GetTableJson(FormCollection form, string cashType = "cashin")
        {
            JObject quotationOrders = CashHelper.GetCashReceiptsJson(form, cashType);

            return(quotationOrders);
        }