Esempio n. 1
0
 public InformationWareHouse()
 {
     this._ingredientDAO    = (IngredientDAO) new IngredientDAOImpl();
     this._supplierDAO      = (SupplierDAO) new SupplierDAOImpl();
     this._receiptDAO       = (ReceiptDAO) new ReceiptDAOImpl();
     this._receiptDetailDAO = (ReceiptDetailDAO) new ReceiptDetailDAOImpl();
 }
Esempio n. 2
0
        public ActionResult Create(SupplierMaster supplier)
        {
            int branchid  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int companyid = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            //if (ModelState.IsValid)
            //{
            //ViewBag.country = DropDownList<CountryMaster>.LoadItems(

            //ObjectSourceModel.GetCountry(), "CountryID", "CountryName");

            var supplierMasterTypes = (from d in db.SupplierTypes select d).ToList();

            ViewBag.SupplierType = supplierMasterTypes;

            var query = (from t in db.SupplierMasters where t.SupplierName == supplier.SupplierName select t).ToList();

            if (query.Count > 0)
            {
                ViewBag.SuccessMsg = "Supplier name is already exist";
                return(View());
            }
            supplier.BranchID    = branchid;
            supplier.AcCompanyID = companyid;
            //supplier.SupplierID = ObjectSourceModel.GetMaxNumberSupplier();
            db.SupplierMasters.Add(supplier);
            db.SaveChanges();
            ReceiptDAO.ReSaveSupplierCode();
            ViewBag.SuccessMsg = "You have successfully added Supplier.";
            return(RedirectToAction("Index"));
            //}
        }
Esempio n. 3
0
        public string GetMaxPaymentDocumentNo()
        {
            string Docno = "";

            Docno = ReceiptDAO.SP_GetMaxPVID();

            return(Docno);
        }
        public JsonResult GetCustomerCode(string custname)
        {
            string status       = "ok";
            string customercode = "";

            //List<CourierStatu> _cstatus = new List<CourierStatu>();
            try
            {
                customercode = ReceiptDAO.GetMaxCustomerCode(custname);
                //string custform = "000000";
                //string maxcustomercode = (from d in db.CustomerMasters orderby d.CustomerID descending select d.CustomerCode).FirstOrDefault();
                //string last6digit = "";
                //if (maxcustomercode==null || maxcustomercode=="")
                //{
                //    //maxcustomercode="AA000000";
                //    last6digit = "0";

                //}
                //else
                //{
                //    last6digit = maxcustomercode.Substring(maxcustomercode.Length - 6); //, maxcustomercode.Length - 6);
                //}
                //if (last6digit !="")
                //{

                //    string customerfirst = custname.Substring(0, 1);
                //    string customersecond = "";
                //    try
                //    {
                //        customersecond = custname.Split(' ')[1];
                //        customersecond = customersecond.Substring(0, 1);
                //    }
                //    catch(Exception ex)
                //    {

                //    }

                //    if (customerfirst !="" && customersecond!="")
                //    {
                //        customercode = customerfirst + customersecond + String.Format("{0:000000}", Convert.ToInt32(last6digit) + 1);
                //    }
                //    else
                //    {
                //        customercode = customerfirst + "C" + String.Format("{0:000000}", Convert.ToInt32(last6digit) + 1);
                //    }

                //}

                return(Json(new { data = customercode, result = status }, JsonRequestBehavior.AllowGet));
            }

            catch (Exception ex)
            {
                status = ex.Message;
            }

            return(Json(new { data = "", result = "failed" }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
 public InformationAccountant()
 {
     this._orderDAO           = (OrderDAO) new OrderDAOImpl();
     this._orderItemDAO       = (OrderItemDAO) new OrderItemDAOImpl();
     this._receiptDAO         = (ReceiptDAO) new ReceiptDAOImpl();
     this._receiptDetailDAO   = (ReceiptDetailDAO) new ReceiptDetailDAOImpl();
     this._timeSheetDAO       = (TimeSheetDAO) new TimeSheetDAOImpl();
     this._timeSheetDetailDAO = (TimeSheetDetailDAO) new TimeSheetDetailDAOImpl();
     this._payrollDAO         = (PayrollDAO) new PayrollDAOImpl();
     this._accDAO             = (AccountDAO) new AccountDAOImpl();
     this._employeeDAO        = (EmployeeDAO) new EmployeeDAOImpl();
 }
        public ActionResult Table()
        {
            int        branchid   = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int        depotId    = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int        FyearId    = Convert.ToInt32(Session["fyearid"]);
            DatePicker datePicker = SessionDataModel.GetTableVariable();

            ViewBag.Token = datePicker;
            List <ReceiptVM> Receipts = new List <ReceiptVM>();

            Receipts = ReceiptDAO.GetCODReceipts(FyearId, datePicker.FromDate, datePicker.ToDate);

            return(View("Table", Receipts));
        }
        public JsonResult GetCODItems(decimal?amountreceived, int RecPayId = 0)
        {
            var codcust      = db.CustomerMasters.Where(cc => cc.CustomerName == "Cod Customer").FirstOrDefault();
            var salesinvoice = new List <CustomerTradeReceiptVM>();

            if (codcust != null)
            {
                int fyearid = Convert.ToInt32(Session["fyearid"].ToString());
                salesinvoice          = ReceiptDAO.GetCODPending(fyearid, RecPayId);
                Session["CODAWBList"] = salesinvoice;
                return(Json(salesinvoice, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(salesinvoice, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            //int k = 0;
            if (id != 0)
            {
                DataTable dt = ReceiptDAO.DeleteInvoice(id);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        //if (dt.Rows[0][0] == "OK")
                        TempData["SuccessMsg"] = dt.Rows[0][1].ToString();
                    }
                }
                else
                {
                    TempData["ErrorMsg"] = "Error at delete";
                }
            }

            return(RedirectToAction("Index"));

            //CustomerInvoice a = db.CustomerInvoices.Find(id);
            //if (a == null)
            //{
            //    return HttpNotFound();
            //}
            //else
            //{
            //    var _inscans = db.InScanMasters.Where(cc => cc.InvoiceID == id).ToList();
            //    foreach(InScanMaster _inscan in _inscans)
            //    {
            //        _inscan.InvoiceID = null;
            //        db.Entry(_inscan).State = EntityState.Modified;
            //        db.SaveChanges();
            //    }
            //    a.IsDeleted = true;
            //    db.Entry(a).State = EntityState.Modified;
            //    db.SaveChanges();
            //    TempData["SuccessMsg"] = "You have successfully deleted Pickup Request.";


            //    return RedirectToAction("Index");
            //}
        }
        //
        // GET: /CustomerMaster/Delete/5



        public ActionResult DeleteConfirmed(int id)
        {
            //int k = 0;
            if (id != 0)
            {
                DataTable dt = ReceiptDAO.DeleteCustomer(id);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        //if (dt.Rows[0][0] == "OK")
                        TempData["SuccessMsg"] = dt.Rows[0][1].ToString();
                    }
                }
                else
                {
                    TempData["ErrorMsg"] = "Error at delete";
                }
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
        public JsonResult SetTradeInvoiceOfSupplier(int?ID, decimal?amountreceived, int DebitNoteID, string TransType)
        {
            int fyearid = Convert.ToInt32(Session["fyearid"].ToString());

            //DateTime fromdate = Convert.ToDateTime(Session["FyearFrom"].ToString());
            //DateTime todate = Convert.ToDateTime(Session["FyearTo"].ToString());
            //var receipts = (from d in db.RecPays where d.FYearID == fyearid && d.SupplierID == ID select d.FMoney).Sum();
            //var receiptdetails = (from d in db.RecPays join c in db.RecPayDetails on d.RecPayID equals c.RecPayID where d.FYearID == fyearid && d.SupplierID == ID && c.InvoiceID > 0 && c.Amount < 0 select (-1 * c.Amount)).Sum();

            //            decimal Advance = 0;
            //            Advance = ReceiptDAO.SP_GetSupplierAdvance(Convert.ToInt32(cust.SupplierID), Convert.ToInt32(id), fyearid);

            ////            var advance = receipts - receiptdetails;

            var salesinvoice = new List <CustomerTradeReceiptVM>();

            if (TransType == "DN")
            {
                salesinvoice = ReceiptDAO.SP_GetSupplierInvoicePending(Convert.ToInt32(ID), 0, 0, Convert.ToInt32(DebitNoteID), "OP");
            }
            else
            {
                salesinvoice = ReceiptDAO.SP_GetSupplierReceiptPending(Convert.ToInt32(ID), 0, 0, Convert.ToInt32(DebitNoteID), "OP");
            }


            //var AllOPInvoices = (from d in db.AcOPInvoiceDetails join m in db.AcOPInvoiceMasters on d.AcOPInvoiceMasterID equals m.AcOPInvoiceMasterID where m.AcFinancialYearID == fyearid && m.StatusSDSC != "C" && m.PartyID == ID select d).ToList();

            //foreach (var item in AllOPInvoices)
            //{
            //    decimal? totamt = 0;
            //    decimal? totamtpaid = 0;
            //    decimal? totadjust = 0;
            //    totamtpaid = ReceiptDAO.SP_GetSupplierInvoicePaid(Convert.ToInt32(cust.SupplierID), Convert.ToInt32(item.AcOPInvoiceDetailID), 0, DebitNoteID, "OP");
            //    var Invoice = new CustomerTradeReceiptVM();
            //    Invoice.AcOPInvoiceDetailID = item.AcOPInvoiceDetailID;
            //    Invoice.SalesInvoiceID = item.AcOPInvoiceDetailID;
            //    Invoice.InvoiceType = "OP";
            //    Invoice.JobCode = "OP" + item.AcOPInvoiceDetailID.ToString();
            //    Invoice.InvoiceNo = item.InvoiceNo; ;
            //    Invoice.InvoiceAmount = item.Amount * -1;
            //    Invoice.date = item.InvoiceDate;
            //    Invoice.DateTime = Convert.ToDateTime(item.InvoiceDate).ToString("dd/MM/yyyy");
            //    Invoice.AmountReceived = totamtpaid;
            //    Invoice.Balance = Invoice.InvoiceAmount - totamtpaid;
            //    Invoice.AdjustmentAmount = totadjust;
            //    Invoice.Amount = 0;
            //    if (Invoice.Balance > 0)
            //    {
            //        if (amountreceived != null)
            //        {
            //            if (amountreceived >= Invoice.Balance)
            //            {
            //                Invoice.Amount = Invoice.Balance;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else if (amountreceived > 0)
            //            {
            //                Invoice.Amount = amountreceived;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else
            //            {
            //                Invoice.Amount = 0;
            //            }
            //        }
            //        salesinvoice.Add(Invoice);
            //    }

            //}

            ////transaction
            //var AllInvoices = (from d in db.SupplierInvoices where d.SupplierID == ID && (d.IsDeleted == false || d.IsDeleted == null) select d).ToList();
            //foreach (var item in AllInvoices)
            //{
            //    decimal? totamtpaid = 0;
            //    decimal? totadjust = 0;

            //    totamtpaid = ReceiptDAO.SP_GetSupplierInvoicePaid(Convert.ToInt32(cust.SupplierID), Convert.ToInt32(item.SupplierInvoiceID), 0, DebitNoteID, "TR");

            //    var Invoice = new CustomerTradeReceiptVM();

            //    Invoice.JobCode = "TR" + item.SupplierInvoiceID.ToString();
            //    Invoice.SalesInvoiceID = item.SupplierInvoiceID; // SalesInvoiceID;
            //    Invoice.InvoiceNo = item.InvoiceNo;
            //    Invoice.InvoiceType = "TR";
            //    Invoice.InvoiceAmount = item.InvoiceTotal; // CourierCharge;
            //    Invoice.date = item.InvoiceDate;
            //    Invoice.DateTime = item.InvoiceDate.ToString("dd/MM/yyyy");
            //    Invoice.AmountReceived = totamtpaid;
            //    Invoice.Balance = Invoice.InvoiceAmount - totamtpaid;
            //    Invoice.AdjustmentAmount = totadjust;
            //    Invoice.Amount = 0;
            //    if (Invoice.Balance > 0)
            //    {
            //        if (amountreceived != null)
            //        {
            //            if (amountreceived >= Invoice.Balance)
            //            {
            //                Invoice.Amount = Invoice.Balance;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else if (amountreceived > 0)
            //            {
            //                Invoice.Amount = amountreceived;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else
            //            {
            //                Invoice.Amount = 0;
            //            }
            //        }
            //        salesinvoice.Add(Invoice);
            //    }
            //}
            Session["SupplierInvoice"] = salesinvoice;
            return(Json(salesinvoice, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
        public ActionResult Create(EmployeeVM v)
        {
            int BranchID          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int companyid         = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            PickupRequestDAO _dao = new PickupRequestDAO();
            //if (ModelState.IsValid)
            //{
            EmployeeMaster a   = new EmployeeMaster();
            int            max = (from c in db.EmployeeMasters orderby c.EmployeeID descending select c.EmployeeID).FirstOrDefault();

            a.EmployeeID   = max + 1;
            a.EmployeeName = v.EmployeeName;
            a.EmployeeCode = "";// v.EmployeeCode;
            a.Address1     = v.Address1;
            a.Address2     = v.Address2;
            a.Address3     = v.Address3;
            a.Phone        = v.Phone;

            a.Fax         = v.Fax;
            a.Email       = v.Email;
            a.Mobile      = v.MobileNo;
            a.AcCompanyID = companyid;

            a.CountryName = v.CountryName;
            a.CityName    = v.CityName;

            a.DesignationID    = v.DesignationID;
            a.JoinDate         = Convert.ToDateTime(v.JoinDate);
            a.BranchID         = BranchID;
            a.DepotID          = v.Depot;
            a.Password         = v.Password;
            a.MobileDeviceID   = v.MobileDeviceID;
            a.MobileDevicePwd  = v.MobileDevicePWD;
            a.StatusCommission = v.StatusCommision;
            a.statusDefault    = v.StatusDefault;
            a.StatusActive     = v.StatusActive;
            a.Type             = "E";

            UserRegistration u = new UserRegistration();

            UserRegistration x = (from b in db.UserRegistrations where b.UserName == v.Email select b).FirstOrDefault();

            if (x == null)
            {
                int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();
                u.UserID   = max + 1;
                u.UserName = v.Email;
                u.EmailId  = v.Email;
                u.Password = v.Password;
                u.Phone    = v.Phone;
                u.IsActive = true;
                u.RoleID   = v.RoleID;
                db.UserRegistrations.Add(u);
                db.SaveChanges();
            }

            a.UserID = u.UserID;

            db.EmployeeMasters.Add(a);
            db.SaveChanges();
            ReceiptDAO.ReSaveEmployeeCode();


            TempData["SuccessMsg"] = "You have successfully added Employee.";
            return(RedirectToAction("Index"));
            //}
        }
        public ActionResult Create(CustmorVM c)
        {
            string locationname = c.LocationName;
            string country      = c.CountryName;
            string city         = c.CityName;


            CustomerMaster   obj  = new CustomerMaster();
            PickupRequestDAO _dao = new PickupRequestDAO();

            if (c.CustomerID == 0)
            {
                int max         = (from d in db.CustomerMasters orderby d.CustomerID descending select d.CustomerID).FirstOrDefault();
                int accompanyid = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
                int branchid    = Convert.ToInt32(Session["CurrentBranchID"].ToString());
                obj.CustomerID  = max + 1;
                obj.AcCompanyID = accompanyid;

                obj.CustomerCode = c.CustomerCode; //  _dao.GetMaxCustomerCode(branchid); // c.CustomerCode;
            }
            else
            {
                obj = db.CustomerMasters.Find(c.CustomerID);
            }
            obj.CustomerName = c.CustomerName;
            obj.CustomerType = c.CustomerType;

            obj.ReferenceCode = c.ReferenceCode;
            obj.ContactPerson = c.ContactPerson;
            obj.Address1      = c.Address1;
            obj.Address2      = c.Address2;
            obj.Address3      = c.Address3;
            obj.Phone         = c.Phone;
            obj.Mobile        = c.Mobile;
            obj.Fax           = c.Fax;
            obj.Email         = c.Email;
            obj.WebSite       = c.Website;
            obj.CountryID     = c.CountryID;
            if (c.CityID == 0)
            {
                obj.CityID = null;
            }
            else
            {
                obj.CityID = c.CityID;
            }
            if (c.LocationID == 0)
            {
                obj.LocationID = null;
            }
            else
            {
                obj.LocationID = c.LocationID;
            }
            obj.CountryName  = c.CountryName;
            obj.CityName     = c.CityName;
            obj.LocationName = c.LocationName;
            if (c.CurrenceyID == 0)
            {
                c.CurrenceyID = Convert.ToInt32(Session["CurrencyId"].ToString());
            }
            else
            {
                obj.CurrencyID = c.CurrenceyID;
            }
            obj.StatusActive     = c.StatusActive;
            obj.CreditLimit      = c.CreditLimit;
            obj.StatusTaxable    = c.StatusTaxable;
            obj.EmployeeID       = c.EmployeeID;
            obj.statusCommission = c.StatusCommission;
            obj.VATTRN           = c.VATTRN;

            obj.CourierServiceID = c.CourierServiceID;
            obj.BranchID         = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            obj.CustomerUsername = c.CustomerUsername;
            //obj.Password = c.Password;
            obj.Password        = _dao.RandomPassword(6);
            obj.BusinessTypeId  = c.BusinessTypeId;
            obj.Referal         = c.Referal;
            obj.OfficeOpenTime  = c.OfficeTimeFrom;
            obj.OfficeCloseTime = c.OfficeTimeTo;
            if (c.DepotID == null)
            {
                obj.DepotID = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            }
            else
            {
                obj.DepotID = c.DepotID;
            }

            if (c.CustomerType == "CR" && c.ChkApprovedBy)
            {
                obj.ApprovedBy = Convert.ToInt32(Session["UserID"]);
                obj.ApprovedOn = c.ApprovedOn;
            }

            //UserRegistration u = new UserRegistration();
            //if (c.Email != null)
            //{
            //    if (c.Email != "")
            //    {

            //        UserRegistration x = (from a in db.UserRegistrations where a.UserName == c.Email select a).FirstOrDefault();
            //        if (x == null)
            //        {

            //            int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();
            //            u.UserID = max1 + 1;
            //            u.UserName = c.Email;
            //            u.EmailId = c.Email;
            //            u.Password = obj.Password;
            //            u.Phone = c.Phone;
            //            u.IsActive = true;
            //            u.RoleID = c.RoleID;


            //        }
            //        try
            //        {
            //            db.UserRegistrations.Add(u);
            //            db.SaveChanges();
            //        }
            //        catch (DbEntityValidationException e)
            //        {
            //            foreach (var eve in e.EntityValidationErrors)
            //            {
            //                Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
            //                    eve.Entry.Entity.GetType().Name, eve.Entry.State);
            //                foreach (var ve in eve.ValidationErrors)
            //                {
            //                    Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
            //                        ve.PropertyName, ve.ErrorMessage);
            //                }

            //            }
            //        }
            //    }
            //}

            try
            {
                //  obj.UserID = u.UserID;
                if (c.CustomerID > 0)
                {
                    db.Entry(obj).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    db.CustomerMasters.Add(obj);
                    db.SaveChanges();
                    ReceiptDAO.ReSaveCustomerCode();
                }


                if (c.EmailNotify == true)
                {
                    EmailDAO _emaildao = new EmailDAO();
                    _emaildao.SendCustomerEmail(c.Email, c.CustomerName, obj.Password);
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }


            TempData["SuccessMsg"] = "You have successfully added Customer.";
            return(RedirectToAction("Index"));



            return(View());
        }
Esempio n. 13
0
        public void SetTradeInvoiceOfCustomer(int?ID, decimal?amountreceived, int?CreditNoteId, string TransType)
        {
            int fyearid = Convert.ToInt32(Session["fyearid"].ToString());
            //DateTime fromdate = Convert.ToDateTime(Session["FyearFrom"].ToString());
            //DateTime todate = Convert.ToDateTime(Session["FyearTo"].ToString());
            //var AllInvoices = (from d in db.CustomerInvoices where d.CustomerID == ID select d).ToList();
            List <ReceiptAllocationDetailVM> AWBAllocation = new List <ReceiptAllocationDetailVM>();
            var salesinvoice = new List <CustomerTradeReceiptVM>();

            if (TransType == "CN")
            {
                salesinvoice = ReceiptDAO.SP_GetCustomerInvoicePending(Convert.ToInt32(ID), 0, 0, Convert.ToInt32(CreditNoteId), "OP");
            }
            else
            {
                salesinvoice = ReceiptDAO.SP_GetCustomerReceiptPending(Convert.ToInt32(ID), 0, 0, Convert.ToInt32(CreditNoteId), "OP");
            }


            //var AllOPInvoices = (from d in db.AcOPInvoiceDetails join m in db.AcOPInvoiceMasters on d.AcOPInvoiceMasterID equals m.AcOPInvoiceMasterID where m.AcFinancialYearID == fyearid && m.StatusSDSC == "C" && m.PartyID == ID && d.RecPayDetailId == null && (d.RecPayStatus == null || d.RecPayStatus < 2) select d).ToList();

            //foreach (var item in AllOPInvoices)
            //{

            //    decimal? totamtpaid = 0;
            //    decimal? totadjust = 0;

            //    totamtpaid = ReceiptDAO.SP_GetCustomerInvoiceReceived(Convert.ToInt32(ID), Convert.ToInt32(item.AcOPInvoiceDetailID), 0, Convert.ToInt32(CreditNoteId), "OP");

            //    var Invoice = new CustomerTradeReceiptVM();
            //    Invoice.AcOPInvoiceDetailID = item.AcOPInvoiceDetailID;
            //    Invoice.SalesInvoiceID = item.AcOPInvoiceDetailID;
            //    Invoice.InvoiceType = "OP";
            //    Invoice.InvoiceNo = item.InvoiceNo; ;
            //    Invoice.InvoiceAmount = item.Amount;
            //    Invoice.date = item.InvoiceDate;
            //    Invoice.DateTime = Convert.ToDateTime(item.InvoiceDate).ToString("dd/MM/yyyy");
            //    Invoice.AmountReceived = totamtpaid;
            //    Invoice.Balance = Invoice.InvoiceAmount - totamtpaid;
            //    Invoice.AdjustmentAmount = totadjust;

            //    if (Invoice.Balance > 0)
            //    {
            //        if (amountreceived != null)
            //        {
            //            if (amountreceived >= Invoice.Balance)
            //            {
            //                Invoice.Allocated = true;
            //                Invoice.Amount = Invoice.Balance;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else if (amountreceived > 0)
            //            {
            //                Invoice.Amount = amountreceived;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else
            //            {
            //                Invoice.Amount = 0;
            //            }
            //        }
            //        salesinvoice.Add(Invoice);
            //    }

            //}
            //foreach (var item in AllInvoices)
            //{
            //    //var invoicedeails = (from d in db.SalesInvoiceDetails where d.SalesInvoiceID == item.SalesInvoiceID where (d.RecPayStatus < 2 || d.RecPayStatus == null) select d).ToList();
            //    //var invoicedeails = (from d in db.CustomerInvoiceDetails where d.CustomerInvoiceID == item.CustomerInvoiceID where (d.RecPayStatus < 2 || d.RecPayStatus == null) select d).ToList();
            //    decimal? totamtpaid = 0;
            //    decimal? totadjust = 0;

            //    totamtpaid = ReceiptDAO.SP_GetCustomerInvoiceReceived(Convert.ToInt32(ID), Convert.ToInt32(item.CustomerInvoiceID), 0, Convert.ToInt32(CreditNoteId), "TR");

            //    var Invoice = new CustomerTradeReceiptVM();
            //    Invoice.InvoiceType = "TR";
            //    Invoice.JobCode = "";
            //    Invoice.SalesInvoiceID = item.CustomerInvoiceID; // SalesInvoiceID;
            //    Invoice.InvoiceNo = item.CustomerInvoiceNo;
            //    Invoice.InvoiceAmount = item.InvoiceTotal; // CourierCharge;
            //    Invoice.date = item.InvoiceDate;
            //    Invoice.DateTime = item.InvoiceDate.ToString("dd/MM/yyyy");
            //    Invoice.AmountReceived = totamtpaid;
            //    Invoice.Balance = Invoice.InvoiceAmount - totamtpaid;
            //    Invoice.AdjustmentAmount = totadjust;

            //    if (Invoice.Balance > 0)
            //    {
            //        if (amountreceived != null)
            //        {
            //            if (amountreceived >= Invoice.Balance)
            //            {
            //                Invoice.Allocated = true;
            //                Invoice.Amount = Invoice.Balance;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else if (amountreceived > 0)
            //            {
            //                Invoice.Amount = amountreceived;
            //                amountreceived = amountreceived - Invoice.Amount;
            //            }
            //            else
            //            {
            //                Invoice.Amount = 0;
            //            }
            //        }
            //        salesinvoice.Add(Invoice);
            //        //if (RecPayId == null)
            //        //{
            //        //    AWBAllocation = ReceiptDAO.GetAWBAllocation(AWBAllocation, Convert.ToInt32(Invoice.SalesInvoiceID), Convert.ToDecimal(Invoice.Amount), 0); //customer invoiceid,amount
            //        //}
            //        //else
            //        //{
            //        //    AWBAllocation = ReceiptDAO.GetAWBAllocation(AWBAllocation, Convert.ToInt32(Invoice.SalesInvoiceID), Convert.ToDecimal(Invoice.Amount), Convert.ToInt32(RecPayId)); //customer invoiceid,amount
            //        //}
            //    }
            //}

            Session["CustomerInvoice"] = salesinvoice;
        }
      public JsonResult getMaxInvoiceNo(int TypeId)
      {
          var InvoiceNo = ReceiptDAO.SP_GetMaxSINo(TypeId);

          return(Json(new { InvoiceNo = InvoiceNo }, JsonRequestBehavior.AllowGet));
      }
Esempio n. 15
0
        public ActionResult Create(int id = 0)
        {
            int FyearId           = Convert.ToInt32(Session["fyearid"]);
            CustomerRcieptVM cust = new CustomerRcieptVM();

            cust.CustomerRcieptChildVM = new List <CustomerRcieptChildVM>();
            List <CurrencyMaster> Currencys = new List <CurrencyMaster>();

            Currencys        = MM.GetCurrency();
            ViewBag.Currency = new SelectList(Currencys, "CurrencyID", "CurrencyName");
            if (Session["UserID"] != null)
            {
                var branchid = Convert.ToInt32(Session["CurrentBranchID"]);

                if (id > 0)
                {
                    ViewBag.Title = "COD Receipt - Modify";
                    cust          = RP.GetRecPayByRecpayID(id);

                    var acheadforcash = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Cash" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList();
                    var acheadforbank = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Bank" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList();
                    ViewBag.achead     = acheadforcash;
                    ViewBag.acheadbank = acheadforbank;
                    cust.recPayDetail  = db.RecPayDetails.Where(item => item.RecPayID == id).ToList();
                    int fyearid      = Convert.ToInt32(Session["fyearid"].ToString());
                    var salesinvoice = new List <CustomerTradeReceiptVM>();
                    salesinvoice               = ReceiptDAO.GetCODPending(fyearid, id);
                    Session["CODAWBList"]      = salesinvoice;
                    cust.CustomerRcieptChildVM = new List <CustomerRcieptChildVM>();
                    foreach (var item in cust.recPayDetail)
                    {
                        if (item.InScanID > 0)
                        {
                            if (salesinvoice.Count > 0)
                            {
                                CustomerTradeReceiptVM sales = salesinvoice.Where(cc => cc.InScanID == Convert.ToInt32(item.InScanID)).FirstOrDefault();
                                decimal invoicetotal         = Convert.ToDecimal(sales.InvoiceAmount);
                                decimal received             = Convert.ToDecimal(sales.AmountReceived);
                                var     allrecpay            = (from d in db.RecPayDetails where d.InScanID == item.InScanID select d).ToList();
                                var     totamtpaid           = allrecpay.Sum(d => d.Amount) * -1;
                                var     totadjust            = allrecpay.Sum(d => d.AdjustmentAmount);

                                var customerinvoice = new CustomerRcieptChildVM();

                                customerinvoice.InvoiceType = "D";
                                var inscan = db.InScanMasters.Find(item.InScanID);

                                if (inscan != null)
                                {
                                    customerinvoice.InScanID      = inscan.InScanID;
                                    customerinvoice.ConsignmentNo = inscan.ConsignmentNo;
                                    customerinvoice.strDate       = Convert.ToDateTime(inscan.TransactionDate).ToString("dd/MM/yyyy");
                                }

                                customerinvoice.AmountToBeRecieved = invoicetotal;
                                customerinvoice.AmountToBePaid     = received;
                                customerinvoice.Amount             = Convert.ToDecimal(item.Amount) * -1;
                                customerinvoice.Balance            = invoicetotal - received;
                                customerinvoice.RecPayDetailID     = item.RecPayDetailID;

                                customerinvoice.RecPayID         = Convert.ToInt32(item.RecPayID);
                                customerinvoice.AdjustmentAmount = 0;
                                cust.CustomerRcieptChildVM.Add(customerinvoice);
                            }
                        }
                    }
                    Session["AWBAllocation"] = cust.AWBAllocation;
                }
                else
                {
                    ViewBag.Title = "COD Receipt - Create";
                    var codcust = db.CustomerMasters.Where(cc => cc.CustomerName == "Cod Customer").FirstOrDefault();

                    var acheadforcash = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Cash" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList();
                    var acheadforbank = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Bank" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList();

                    ViewBag.achead     = acheadforcash;
                    ViewBag.acheadbank = acheadforbank;

                    DateTime pFromDate = AccountsDAO.CheckParamDate(DateTime.Now, FyearId).Date;
                    cust.RecPayDate = pFromDate;
                    cust.RecPayID   = 0;
                    cust.CustomerID = codcust.CustomerID;
                    cust.DocumentNo = ReceiptDAO.SP_GetMaxCODID();
                    cust.CurrencyId = Convert.ToInt32(Session["CurrencyId"].ToString());

                    var salesinvoice = new List <CustomerTradeReceiptVM>();
                    if (codcust != null)
                    {
                        int fyearid = Convert.ToInt32(Session["fyearid"].ToString());
                        salesinvoice          = ReceiptDAO.GetCODPending(fyearid, 0);
                        Session["CODAWBList"] = salesinvoice;
                    }
                }
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
            var StaffNotes = (from d in db.StaffNotes where d.PageTypeId == 2 orderby d.NotesId descending select d).ToList();
            var users      = (from d in db.UserRegistrations select d).ToList();

            var staffnotemodel = new List <StaffNoteModel>();

            foreach (var item in StaffNotes)
            {
                var model = new StaffNoteModel();
                model.id         = item.NotesId;
                model.employeeid = item.EmployeeId;
                //model.jobid = item.JobId;
                model.TaskDetails = item.Notes;
                model.Datetime    = item.EntryDate;
                model.EmpName     = users.Where(d => d.UserID == item.EmployeeId).FirstOrDefault().UserName;
                staffnotemodel.Add(model);
            }
            ViewBag.StaffNoteModel = staffnotemodel;
            var customerdetails = (from d in db.CustomerMasters where d.CustomerID == cust.CustomerID && d.CustomerType == "CS" select d).FirstOrDefault();

            if (customerdetails == null)
            {
                customerdetails = new CustomerMaster();
            }
            ViewBag.CustomerDetail = customerdetails;
            var CustomerNotification = (from d in db.CustomerNotifications where d.RecPayID == id && d.PageTypeId == 2 orderby d.NotificationId descending select d).ToList();

            var customernotification = new List <CustomerNotificationModel>();

            foreach (var item in CustomerNotification)
            {
                var model = new CustomerNotificationModel();
                model.id         = item.NotificationId;
                model.employeeid = item.UserId;
                model.jobid      = item.RecPayID;
                model.Message    = item.MessageText;
                model.Datetime   = item.EntryDate;
                model.IsEmail    = item.NotifyByEmail;
                model.IsSms      = item.NotifyBySMS;
                model.IsWhatsapp = item.NotifyByWhatsApp;
                model.EmpName    = users.Where(d => d.UserID == item.UserId).FirstOrDefault().UserName;
                customernotification.Add(model);
            }
            cust.AWBAllocation           = new List <ReceiptAllocationDetailVM>();
            ViewBag.CustomerNotification = customernotification;
            return(View(cust));
        }
Esempio n. 16
0
        public ActionResult Create(CustomerRcieptVM RecP, string Command, string Currency)
        {
            int RPID    = 0;
            int fyearid = Convert.ToInt32(Session["fyearid"].ToString());
            int i       = 0;

            RecP.FYearID = Convert.ToInt32(Session["fyearid"]);
            RecP.UserID  = Convert.ToInt32(Session["UserID"]);
            var StaffNotes = (from d in db.StaffNotes where d.RecPayID == RecP.RecPayID && d.PageTypeId == 2 orderby d.NotesId descending select d).ToList();
            var branchid   = Convert.ToInt32(Session["CurrentBranchID"]);
            var users      = (from d in db.UserRegistrations select d).ToList();
            List <ReceiptAllocationDetailVM> AWBAllocationall = (List <ReceiptAllocationDetailVM>)Session["AWBAllocation"];
            var staffnotemodel = new List <StaffNoteModel>();

            foreach (var item in StaffNotes)
            {
                var model = new StaffNoteModel();
                model.id         = item.NotesId;
                model.employeeid = item.EmployeeId;
                //model.jobid = item.JobId;
                model.TaskDetails = item.Notes;
                model.Datetime    = item.EntryDate;
                model.EmpName     = users.Where(d => d.UserID == item.EmployeeId).FirstOrDefault().UserName;
                staffnotemodel.Add(model);
            }
            ViewBag.StaffNoteModel = staffnotemodel;
            //if (RecP.RecPayID > 0)
            //{
            //    RP.EditCustomerRecPay(RecP, Session["UserID"].ToString());
            //    RP.EditCustomerRecieptDetails(RecP.recPayDetail, RecP.RecPayID);
            //}
            if (RecP.CashBank != null)
            {
                RecP.StatusEntry = "CS";
                int acheadid = Convert.ToInt32(RecP.CashBank);
                var achead   = (from t in db.AcHeads where t.AcHeadID == acheadid select t.AcHead1).FirstOrDefault();
                RecP.BankName = achead;
            }
            else
            {
                RecP.StatusEntry = "BK";
                int acheadid = Convert.ToInt32(RecP.ChequeBank);
                var achead   = (from t in db.AcHeads where t.AcHeadID == acheadid select t.AcHead1).FirstOrDefault();
                RecP.BankName = achead;
            }
            if (RecP.CustomerRcieptChildVM == null)
            {
                RecP.CustomerRcieptChildVM = new List <CustomerRcieptChildVM>();
            }
            //Adding Entry in Rec PAY

            ///Insert Entry For RecPay Details
            ///
            if (RecP.RecPayID <= 0)
            {
                decimal Fmoney = 0;
                //for (int j = 0; j < RecP.CustomerRcieptChildVM.Count; j++)
                //{
                //    Fmoney = Fmoney + Convert.ToDecimal(RecP.CustomerRcieptChildVM[j].Amount);
                //}
                //if (Fmoney > 0)
                //{
                //    RecP.FMoney = Fmoney;
                //}
                RecP.AcCompanyID = branchid;

                RPID = ReceiptDAO.AddCustomerRecieptPayment(RecP, Session["UserID"].ToString()); //.AddCustomerRecieptPayment(RecP, Session["UserID"].ToString());

                RecP.RecPayID = (from c in db.RecPays orderby c.RecPayID descending select c.RecPayID).FirstOrDefault();
                decimal TotalAmount = 0;

                foreach (var item in RecP.CustomerRcieptChildVM)
                {
                    if (item.Amount > 0)
                    {
                        RecPayDetail recpd             = new RecPayDetail();
                        int?         maxrecpaydetailid = (from c in db.RecPayDetails orderby c.RecPayDetailID descending select c.RecPayDetailID).FirstOrDefault();
                        if (maxrecpaydetailid == null)
                        {
                            maxrecpaydetailid = 1;
                        }
                        else
                        {
                            maxrecpaydetailid = maxrecpaydetailid + 1;
                        }

                        recpd.RecPayDetailID      = Convert.ToInt32(maxrecpaydetailid);
                        recpd.Amount              = -(item.Amount);
                        recpd.CurrencyID          = item.CurrencyId;
                        recpd.AdjustmentAmount    = 0;
                        recpd.InvDate             = item.InvoiceDate.Value;
                        recpd.RecPayID            = RecP.RecPayID;
                        recpd.Remarks             = item.Remarks;
                        recpd.InvoiceID           = 0;
                        recpd.InScanID            = item.InScanID;
                        recpd.AcOPInvoiceDetailID = 0;
                        recpd.StatusInvoice       = "D";
                        db.RecPayDetails.Add(recpd);
                        db.SaveChanges();
                    }
                }


                //To Balance Invoice AMount
                if (RecP.FMoney > 0)
                {
                    //int l = ReceiptDAO.InsertRecpayDetailsForCust(RecP.RecPayID, 0, 0, Convert.ToDecimal(RecP.FMoney), null, "D", false, null, null, null, Convert.ToInt32(RecP.CurrencyId), 4, 0);
                    int fyaerId = Convert.ToInt32(Session["fyearid"].ToString());
                    ReceiptDAO.InsertJournalOfCustomer(RecP.RecPayID, fyaerId);
                }
                // var Recpaydata = (from d in db.RecPays where d.RecPayID == RecP.RecPayID select d).FirstOrDefault();

                //Recpaydata.RecPayID = RecP.RecPayID;
                //Recpaydata.IsTradingReceipt = true;
                //db.Entry(Recpaydata).State = EntityState.Modified;
                //db.SaveChanges();
            }
            else //edit mode
            {
                var details = (from d in db.RecPayDetails where d.RecPayID == RecP.RecPayID select d).ToList();
                if (details != null)
                {
                    db.RecPayDetails.RemoveRange(details);
                    db.SaveChanges();
                }

                RecPay recpay = new RecPay();
                recpay                  = db.RecPays.Find(RecP.RecPayID);
                recpay.RecPayDate       = RecP.RecPayDate;
                recpay.RecPayID         = RecP.RecPayID;
                recpay.AcJournalID      = RecP.AcJournalID;
                recpay.BankName         = RecP.BankName;
                recpay.ChequeDate       = RecP.ChequeDate;
                recpay.ChequeNo         = RecP.ChequeNo;
                recpay.CustomerID       = RecP.CustomerID;
                recpay.DocumentNo       = RecP.DocumentNo;
                recpay.EXRate           = RecP.EXRate;
                recpay.FYearID          = RecP.FYearID;
                recpay.FMoney           = RecP.FMoney;
                recpay.StatusEntry      = RecP.StatusEntry;
                recpay.IsTradingReceipt = true;
                recpay.FMoney           = RecP.FMoney;
                recpay.Remarks          = RecP.Remarks;
                recpay.ModifiedBy       = RecP.UserID;
                recpay.ModifiedDate     = DateTime.Now;
                db.Entry(recpay).State  = EntityState.Modified;
                db.SaveChanges();

                foreach (var item in RecP.CustomerRcieptChildVM)
                {
                    if (item.Amount > 0)
                    {
                        RecPayDetail recpd = new RecPayDetail();

                        int?maxrecpaydetailid = (from c in db.RecPayDetails orderby c.RecPayDetailID descending select c.RecPayDetailID).FirstOrDefault();
                        if (maxrecpaydetailid == null)
                        {
                            maxrecpaydetailid = 1;
                        }
                        else
                        {
                            maxrecpaydetailid = maxrecpaydetailid + 1;
                        }

                        recpd.RecPayDetailID   = Convert.ToInt32(maxrecpaydetailid);
                        recpd.Amount           = -(item.Amount);
                        recpd.CurrencyID       = item.CurrencyId;
                        recpd.AdjustmentAmount = 0;
                        if (item.InvoiceDate != null)
                        {
                            recpd.InvDate = item.InvoiceDate.Value;
                        }
                        recpd.RecPayID            = RecP.RecPayID;
                        recpd.Remarks             = item.Remarks;
                        recpd.InvoiceID           = 0;
                        recpd.InScanID            = item.InScanID;
                        recpd.AcOPInvoiceDetailID = 0;
                        recpd.StatusInvoice       = "D";
                        db.RecPayDetails.Add(recpd);
                        db.SaveChanges();
                    }
                }
                //int editrecPay = 0;
                //var sumOfAmount = db.RecPayDetails.Where(m => m.RecPayID == RecP.RecPayID && m.InvoiceID != 0).Sum(c => c.Amount);
                //editrecPay = editfu.EditRecpayDetailsCustR(RecP.RecPayID, Convert.ToInt32(sumOfAmount));
                if (RecP.AcJournalID == null)
                {
                    ReceiptDAO.InsertJournalOfCustomer(RecP.RecPayID, fyearid);
                }
                else
                {
                    int editAcJdetails = editfu.EditAcJDetails(RecP.AcJournalID.Value, Convert.ToDecimal(RecP.FMoney));
                }
            }


            return(RedirectToAction("Index", "CODReceipt"));
        }