예제 #1
0
        public ActionResult Edit(LedgerVoucherModel model)
        {
            LedgerVoucherModel result = new LedgerVoucherModel();

            try
            {
                var obj = (TravelSession)Session["TravelPortalSessionInfo"];
                model.AppUserId = obj.AppUserId;

                string clientIP;
                clientIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (clientIP == string.Empty)
                {
                    clientIP = Request.ServerVariables["REMOTE_ADDR"];
                }
                model.CheckerTerminal = clientIP;

                _ser.EditGL_Transactions(model);
                result = _ser.GetLedgerVoucherByVoucherNo(model.VoucherNo);
                TempData["SuccessMessage"] = "Successfully Edited General Voucher";
                return(View(result));
            }
            catch (Exception ex)
            {
                TempData["ActionResponse"] = "There is an error: " + ex.Message;
                return(View(result));
            }
        }
예제 #2
0
        public bool EditGL_Transactions(LedgerVoucherModel model)
        {
            foreach (var t in model.TranList)
            {
                GL_Transactions transaction = ent.GL_Transactions.Where(x => x.TranId == t.TranID).FirstOrDefault();

                transaction.Dr_Cr      = t.Debit == "Dr" ? "D" : "C";
                transaction.LedgerId   = t.LedgerId;
                transaction.Narration1 = t.Narration1;
                if (t.Debit == "Dr")
                {
                    transaction.Amount = t.DebitAmount;
                }
                else if (t.Debit == "Cr")
                {
                    transaction.Amount = t.CreditAmount;
                }
                transaction.TranStatusId = 1;

                transaction.CheckerId         = model.AppUserId;
                transaction.CheckerDate       = DateTime.UtcNow;
                transaction.CheckerTerminalId = model.CheckerTerminal;
                transaction.CheckerRemark     = GetFormattedRemark(transaction.CheckerRemark, model.CheckerRemark, model.AppUserId);


                ent.ApplyCurrentValues(transaction.EntityKey.EntitySetName, transaction);
            }
            ent.SaveChanges();
            return(true);
        }
예제 #3
0
        public ActionResult Delete(Int64 Id, LedgerVoucherModel model)
        {
            var obj = (TravelSession)Session["TravelPortalSessionInfo"];

            model.DeletedBy = obj.AppUserId;
            try
            {
                string clientIP;
                clientIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (clientIP == string.Empty)
                {
                    clientIP = Request.ServerVariables["REMOTE_ADDR"];
                }
                model.CheckerTerminal = clientIP;
                _ser.DeleteVoucher(Id, model);
                model.TransactionList      = _ser.GetTransactionList(Id);
                TempData["SuccessMessage"] = "Voucher has been successfully deleted.";
                return(PartialView("VUC_TransactionList", model));
            }
            catch
            {
                TempData["ActionResponse"] = "Unable to delete voucher.";
                return(PartialView("VUC_TransactionList", model));
            }
        }
예제 #4
0
        public IEnumerable <LedgerVoucherModel> GetTransactionList(Int64 VoucherNumber)
        {
            List <LedgerVoucherModel> model = new List <LedgerVoucherModel>();

            var result = ent.GL_Transactions.Where(x => x.VoucherNo == VoucherNumber);


            foreach (var item in result)
            {
                var obj = new LedgerVoucherModel();
                obj.TranDate    = item.TranDate;
                obj.ProductName = item.Core_Products.ProductName;
                obj.ProductId   = item.ProductId;
                obj.Narration1  = item.Narration1;
                obj.VoucherNo   = item.VoucherNo;
                obj.Debit       = item.Dr_Cr;
                obj.Amount      = item.Amount;
                obj.MakerID     = item.MakerId;

                string userName = string.Empty;
                if (item.MakerId > 0)
                {
                    var userDetails = ent.UsersDetails.Where(x => x.AppUserId == item.MakerId).FirstOrDefault();
                    if (userDetails != null)
                    {
                        userName = userDetails.FullName;
                    }
                }

                obj.MakerName  = userName;
                obj.LegderName = item.GL_Ledgers.LedgerName;


                if (obj.Debit == "D")
                {
                    totalDrAmount = totalDrAmount + Convert.ToDecimal(item.Amount);
                }

                else if (obj.Debit == "C")
                {
                    totalCrAmount = totalCrAmount + Convert.ToDecimal(item.Amount);
                }
                obj.txtSumDrAmount = totalDrAmount;
                obj.txtSumCrAmount = totalCrAmount;
                // obj.TranStatusId = item.GL_TransactionStatus.TranStatusId;
                obj.TranStatusId   = (int)item.TranStatusId;
                obj.TranStatusName = item.GL_TransactionStatus.TranStatusName;

                obj.DeletedName = GetUserName(item.DeletedBy);
                obj.DeleteDate  = item.DeletedDate;



                model.Add(obj);
            }


            return(model.AsEnumerable());
        }
예제 #5
0
        public void DeleteVoucher(Int64 voucherno, LedgerVoucherModel model)
        {
            List <GL_Transactions> result = ent.GL_Transactions.Where(x => x.VoucherNo == voucherno).ToList();

            foreach (var item in result)
            {
                item.TranStatusId      = 4;
                item.DeletedBy         = model.DeletedBy;
                item.DeletedDate       = DateTime.Now;
                item.DeletedRemark     = GetFormattedRemark(item.DeletedRemark, model.DeleteRemark, model.DeletedBy ?? 0);
                item.DeletedTerminalId = model.CheckerTerminal;

                ent.ApplyCurrentValues(item.EntityKey.EntitySetName, item);
                ent.SaveChanges();
            }
        }
예제 #6
0
        public LedgerVoucherModel GetLedgerVoucherByVoucherNo(Int64?voucherno)
        {
            var result = ent.GL_Transactions.Where(x => x.VoucherNo == voucherno);

            LedgerVoucherModel model = new LedgerVoucherModel();

            if (result.Count() != 0)
            {
                model.ProductList  = new SelectList(ent.Core_Products.Where(x => x.isActive == true).ToList(), "ProductId", "ProductName", result.First().ProductId);
                model.CurrencyList = new SelectList(ent.Currencies.ToList(), "CurrencyId", "CurrencyCode", result.First().CurrencyId);
                model.CurrencyID   = result.First().CurrencyId;
                model.ProductId    = result.First().ProductId;

                model.TranDate  = result.First().TranDate;
                model.VoucherNo = voucherno != null ? (long)voucherno : 0;
                List <LedgerVoucherModel> TransactionList = new List <LedgerVoucherModel>();

                foreach (var t in result)
                {
                    LedgerVoucherModel obj = new LedgerVoucherModel()
                    {
                        TranID       = t.TranId,
                        ProductId    = t.ProductId,
                        VoucherNo    = t.VoucherNo,
                        TranDate     = t.TranDate,
                        Narration1   = t.Narration1,
                        Narration2   = t.Narration2,
                        DebitAmount  = t.Dr_Cr == "D" ? t.Amount : 0,
                        CreditAmount = t.Dr_Cr == "C" ? t.Amount : 0,
                        Debit        = t.Dr_Cr == "D" ? "Dr" : "Cr",
                        LegderName   = t.GL_Ledgers.LedgerName,
                        LedgerId     = t.LedgerId
                    };
                    TransactionList.Add(obj);
                }
                model.TranList       = TransactionList;
                model.txtSumDrAmount = (decimal)TransactionList.Sum(x => x.DebitAmount);
                model.txtSumCrAmount = (decimal)TransactionList.Sum(x => x.CreditAmount);
                return(model);
            }
            return(null);
        }
예제 #7
0
        public ActionResult Create(LedgerVoucherModel model, FormCollection coll)
        {
            try
            {
                var   ts            = (TravelSession)Session["TravelPortalSessionInfo"];
                Int64 VoucherNumber = _ser.GetVoucherNumber(model.ProductId);

                ///////////Begin of Saving transaction info  ///////////////////////
                int totalentry = Convert.ToInt32(coll["noOfentry"]);
                List <GL_Transactions> entryDataList = new List <GL_Transactions>();
                for (int i = 0; i < totalentry; i++)
                {
                    string          Dr_Cr = coll["DrCr"] ?? coll["DrCr" + i];
                    GL_Transactions list  = new GL_Transactions();
                    if (string.IsNullOrEmpty(coll["Narration"] ?? coll["Narration" + i]) && (string.IsNullOrEmpty(coll["DrCr"] ?? coll["DrCr" + i])))
                    {
                        /////// TODO: Handle error due to java script error.Do not put this code here /////
                    }
                    else
                    {
                        list.LedgerId     = Convert.ToInt32(coll["LedgerId"] ?? coll["LedgerId" + i]);
                        list.Narration1   = coll["Narration"] ?? coll["Narration" + i];
                        list.TranDate     = model.TranDate;
                        list.ProductId    = model.ProductId;
                        list.CurrencyId   = model.CurrencyID;
                        list.TranStatusId = 1;
                        list.MakerId      = ts.AppUserId;
                        list.TranTypeId   = 2;
                        list.MakerDate    = DateTime.Now;
                        if (Dr_Cr == "Dr" || Dr_Cr == "D" || Dr_Cr == "d")
                        {
                            list.Dr_Cr  = "D";
                            list.Amount = Convert.ToDouble(coll["Debit"] ?? coll["Debit" + i]);
                        }
                        else if (Dr_Cr == "Cr" || Dr_Cr == "C" || Dr_Cr == "c")
                        {
                            list.Dr_Cr  = "C";
                            list.Amount = Convert.ToDouble(coll["Credit"] ?? coll["Credit" + i]);
                        }
                        list.VoucherNo      = VoucherNumber;
                        list.BaseCurrencyId = 1;

                        Core_FXRate ExchangeRate = ent.Core_FXRate.Where(x => (x.CurrencyID == model.CurrencyID && x.isApproved == true)).OrderByDescending(xx => xx.CreatedDate).FirstOrDefault();

                        double FXRate = 1;
                        if (ExchangeRate != null)
                        {
                            FXRate = ExchangeRate.ExchangeRate;
                        }

                        list.FXRate    = FXRate;
                        list.FCYAmount = list.Amount * FXRate;

                        list.CheckerRemark = model.CheckerRemark;
                        string clientIP;
                        clientIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                        if (clientIP == string.Empty)
                        {
                            clientIP = Request.ServerVariables["REMOTE_ADDR"];
                        }
                        list.CheckerTerminalId = clientIP;

                        entryDataList.Add(list);
                    }
                }
                _ser.SaveVoucher(entryDataList);
                TempData["SuccessMessage"] = "Successfully Created General Voucher";
                return(RedirectToAction("Create"));
            }
            catch (Exception ex)
            {
                TempData["ActionResponse"] = "There is an error: " + ex.Message;
                return(RedirectToAction("Create"));
            }
        }
예제 #8
0
        public ActionResult Search(LedgerVoucherModel model)
        {
            model.TransactionList = _ser.GetTransactionList(model.VoucherNo);

            return(PartialView("VUC_TransactionList", model));
        }