public ActionResult SummaryUpdate(Status Stats, string Remarks, int SONumber)
        {
            Cement cement = db.Cements.Where(t => t.SOnumber == SONumber).FirstOrDefault();



            switch (Stats)
            {
            case Status.Pending: cement.Stats = Status.Pending;
                break;

            case Status.Cleared: cement.Stats = Status.Cleared;
                break;

            case Status.Closed: cement.Stats = Status.Closed;
                break;
            }



            db.Cements.Attach(cement);
            cement.Stats   = Stats;
            cement.Remarks = Remarks;
            var entry = db.Entry(cement);

            entry.Property(e => e.Remarks).IsModified = true;
            entry.Property(e => e.Stats).IsModified   = true;



            db.SaveChanges();

            return(RedirectToAction("Index", "SummaryTransaction", new { @SOnumberPass = SONumber }));
        }
Esempio n. 2
0
        public ActionResult RenewSO(int CementID, int CurrentStock)
        {
            Cement newCement = new Cement();

            newCement = db.Cements.Find(CementID);
            newCement.TotalQuantity = CurrentStock;
            Transaction transaction = db.Transactions.Find(newCement.TransactionID);

            if (transaction == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }



            if (newCement == null)
            {
                return(HttpNotFound());
            }



            ViewBag.TransactionID = newCement.TransactionID;

            return(View(newCement));
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int?SOnumber)
        {
            Cement cement = db.Cements.Where(t => t.SOnumber == SOnumber).OrderByDescending(c => c.DateCreation).FirstOrDefault();

            db.Cements.Remove(cement);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
 public Floor(float x, float z)
 {
     key     = "floor";
     obj     = false;
     texture = new Texture("Recursos/blanco2.jpg");
     cement  = new Cement();
     cement.setVertex(x, z);
     addPart(cement);
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "CementID,SOnumber,CompanyName,BuyingTo,CurrentDate,CementType,TotalQuantity,PaymentMethod,ChequeNumber,Remarks,ImageLocation")] Cement cement)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cement).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cement));
 }
Esempio n. 6
0
        public ActionResult DetailedExpenses(int SOnumberPass)
        {
            int TotalExpenses = 0;
            ExpenseDetailedViewModel        ExpenseVM     = new ExpenseDetailedViewModel();
            List <ExpenseDetailedViewModel> ExpenseVMList = new List <ExpenseDetailedViewModel>();

            Cement   cement   = db.Cements.Where(c => c.SOnumber == SOnumberPass).FirstOrDefault();
            Delivery delivery = db.Deliveries.Where(t => t.TransactionID == cement.TransactionID).FirstOrDefault();
            Payment  payment  = db.Payments.Include(t => t.Expenses).Where(c => c.TransactionID == cement.TransactionID).FirstOrDefault();

            if (cement.RenewalPayment != 0)
            {
                ExpenseVM                       = new ExpenseDetailedViewModel();
                ExpenseVM.Description           = "Renewal Expense";
                ExpenseVM.Amount                = 1;
                ExpenseVM.QuantityTobeDelivered = 0;
                ExpenseVM.Destination           = "";
                ExpenseVM.DateOfExpenseCreated  = cement.CurrentDate;
                ExpenseVM.Total                 = cement.RenewalPayment;
                ExpenseVMList.Add(ExpenseVM);
                TotalExpenses += cement.RenewalPayment;
            }
            foreach (Payment pays in db.Payments.Where(t => t.TransactionID == cement.TransactionID))
            {
                foreach (Expense exp in db.Expenses.Where(t => t.PaymentID == pays.PaymentID))
                {
                    ExpenseVM                       = new ExpenseDetailedViewModel();
                    ExpenseVM.Description           = exp.Description;
                    ExpenseVM.Amount                = exp.Amount;
                    ExpenseVM.QuantityTobeDelivered = delivery.QuantityToDeliver;
                    ExpenseVM.Destination           = payment.Name;
                    ExpenseVM.DateOfExpenseCreated  = cement.CurrentDate;
                    ExpenseVM.Total                 = exp.Total;
                    ExpenseVMList.Add(ExpenseVM);
                    TotalExpenses += exp.Total;
                }
            }

            //foreach (Expense exp in db.Expenses.Where(t => t.PaymentID == payment.PaymentID))
            //{
            //    ExpenseVM.Description = exp.Description;
            //    ExpenseVM.Amount = exp.Amount;
            //    ExpenseVM.QuantityTobeDelivered = delivery.QuantityToDeliver;
            //    ExpenseVM.Destination = payment.Name;
            //    ExpenseVM.DateOfExpenseCreated = cement.CurrentDate;
            //    ExpenseVM.Total = exp.Total;
            //    ExpenseVMList.Add(ExpenseVM);
            //    TotalExpenses += exp.Total;
            //}

            ViewBag.TotalExpenses = TotalExpenses;

            return(View(ExpenseVMList));
        }
Esempio n. 7
0
        // GET: TransactionMain
        public ActionResult Index(int SOnumberPass)
        {
            TransactionMainVM transactionVM = new TransactionMainVM();

            List <TransactionMainVM> transactionVMList = new List <TransactionMainVM>();
            Cement   cement       = new Cement();
            Delivery delivery     = new Delivery();
            Payment  payment      = new Payment();
            int      TotalExpense = 0;
            int      TotalIncome  = 0;

            cement = db.Cements.Where(t => t.SOnumber == SOnumberPass).FirstOrDefault();
            List <Cement> listCement = new List <Cement>();

            foreach (Cement asdf in db.Cements.Where(t => t.TransactionID == cement.TransactionID))
            {
                listCement.Add(asdf);
            }


            foreach (Cement fullSO in listCement)
            {
                TotalExpense = 0;
                TotalIncome  = 0;
                foreach (Delivery del in db.Deliveries.Include("Cement").Where(t => t.Cement.CementID == fullSO.CementID))
                {
                    transactionVM.SONumber          = del.Cement.SOnumber;
                    transactionVM.QuantityDelivered = del.QuantityToDeliver;
                    transactionVM.DeliveryTo        = del.DeliveryTo;
                    payment = new Payment();
                    payment = db.Payments.Include("Expenses").Where(t => t.DeliveryID == del.DeliveryID).FirstOrDefault();
                    transactionVM.PricePerSack = payment.PricePHP;
                    transactionVM.DRNumber     = delivery.DRNumber;
                    foreach (Expense exp in payment.Expenses)
                    {
                        TotalExpense += exp.Total;
                    }

                    TotalIncome                += payment.PricePHP * del.QuantityToDeliver;
                    transactionVM.BankName      = payment.BankName;
                    transactionVM.TotalExpenses = TotalExpense;
                    transactionVM.Income        = TotalIncome;
                    transactionVM.ChequeNumber  = payment.ChequeNumber;
                    transactionVMList.Add(transactionVM);
                }
            }



            return(View(transactionVMList.ToList()));
        }
Esempio n. 8
0
        // GET: Cements/Delete/5
        public ActionResult Delete(int?SOnumber)
        {
            if (SOnumber == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cement cement = db.Cements.Where(t => t.SOnumber == SOnumber).OrderByDescending(c => c.DateCreation).FirstOrDefault();

            if (cement == null)
            {
                return(HttpNotFound());
            }
            return(View(cement));
        }
Esempio n. 9
0
        // GET: Cements/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cement cement = db.Cements.Find(id);

            if (cement == null)
            {
                return(HttpNotFound());
            }
            return(View(cement));
        }
Esempio n. 10
0
        // GET: AccountsRecievable
        public ActionResult Index(DateTime?DateFrom, DateTime?DateTo)
        {
            List <AccountsRecievable> ARList = new List <AccountsRecievable>();
            AccountsRecievable        AR     = new AccountsRecievable();
            Cement   cement      = new Cement();
            Payment  payment     = new Payment();
            Delivery delivery    = new Delivery();
            int      TotalAmount = 0;

            if (DateFrom != null && DateTo != null)
            {
                foreach (var pay in db.Payments.Where(t => t.DateofCheque > DateFrom && t.DateofCheque < DateTo))
                {
                    AR = new AccountsRecievable();
                    AR.DateProcessed = DateTime.Now;
                    AR.CustomerName  = pay.Name;
                    AR.Amount        = pay.PricePHP; // Not sure About this
                    AR.BankName      = pay.BankName;
                    AR.Branch        = pay.Branch;
                    AR.ChequeNumber  = pay.ChequeNumber;
                    AR.DateOfCheque  = pay.DateofCheque;

                    ARList.Add(AR);
                    TotalAmount += AR.Amount;
                }
            }
            else
            {
                foreach (var pay in db.Payments.Include("Delivery"))
                {
                    AR = new AccountsRecievable();
                    AR.DateProcessed = pay.Delivery.DateOfArrival;
                    AR.CustomerName  = pay.Name;
                    AR.Amount        = pay.PricePHP * pay.Delivery.QuantityToDeliver;
                    AR.BankName      = pay.BankName;
                    AR.Branch        = pay.Branch;
                    AR.ChequeNumber  = pay.ChequeNumber;
                    AR.DateOfCheque  = pay.DateofCheque;

                    ARList.Add(AR);
                    TotalAmount += AR.Amount;
                }
            }


            ViewBag.TotalAmount = String.Format("{0:0,0}", TotalAmount);
            return(View(ARList.ToList()));
        }
Esempio n. 11
0
        public ActionResult RenewSO(Cement cement, HttpPostedFileBase Upload)
        {
            cement.DateCreation = DateTime.Now;

            if (Upload.ContentLength > 0)
            {
                var FileName = Upload.FileName;
                var path     = Path.Combine(Server.MapPath("~/Content/Images"), FileName);
                Upload.SaveAs(path);
                cement.ImageLocation = ("/Content/Images/" + FileName);
            }

            if (ModelState.IsValid)
            {
                db.Cements.Add(cement);
                db.SaveChanges();
            }


            return(RedirectToAction("Index", "SummaryTransaction", new { SOnumberPass = cement.SOnumber }));
        }
Esempio n. 12
0
        public ActionResult ExpensesIndex(DateTime?DateFrom, DateTime?DateTo)
        {
            int TotalExpense = 0;
            int AllExpense   = 0;
            ExpenseIndexViewModel        expIndex = new ExpenseIndexViewModel();
            List <ExpenseIndexViewModel> expList  = new List <ExpenseIndexViewModel>();
            Payment payment = new Payment();
            Cement  cement  = new Cement();

            if (DateFrom != null && DateTo != null)
            {
                foreach (Expense exp in db.Expenses.Include(t => t.Payment).Where(t => t.Payment.DateofCheque > DateFrom && t.Payment.DateofCheque < DateTo))
                {
                    expIndex               = new ExpenseIndexViewModel();
                    cement                 = db.Cements.Where(t => t.TransactionID == exp.Payment.TransactionID).FirstOrDefault();
                    expIndex.SONumber      = cement.SOnumber;
                    expIndex.DateProcessed = cement.CurrentDate;
                    expIndex.Stats         = cement.Stats;
                    if (cement.RenewalPayment != 0)
                    {
                        expIndex.TotalExpense += cement.RenewalPayment;
                    }
                    foreach (Expense addExpense in db.Expenses.Where(t => t.PaymentID == exp.PaymentID))
                    {
                        TotalExpense     += addExpense.Total;
                        expIndex.SONumber = db.Cements.Where(t => t.TransactionID == addExpense.Payment.TransactionID).LastOrDefault().SOnumber;
                    }
                    expIndex.TotalExpense = TotalExpense;

                    TotalExpense = 0;
                    expList.Add(expIndex);
                    AllExpense += exp.Total;
                }
            }
            else
            {
                foreach (Expense exp in db.Expenses.Include(t => t.Payment))
                {
                    expIndex               = new ExpenseIndexViewModel();
                    cement                 = db.Cements.Where(t => t.TransactionID == exp.Payment.TransactionID).OrderByDescending(t => t.DateCreation).First();
                    expIndex.SONumber      = cement.SOnumber;
                    expIndex.DateProcessed = cement.CurrentDate;
                    expIndex.Stats         = cement.Stats;
                    if (cement.RenewalPayment != 0)
                    {
                        expIndex.TotalExpense += cement.RenewalPayment;
                    }
                    foreach (Expense addExpense in db.Expenses.Where(t => t.PaymentID == exp.PaymentID))
                    {
                        TotalExpense += addExpense.Total;
                    }
                    expIndex.TotalExpense = TotalExpense;

                    TotalExpense = 0;

                    expList.Add(expIndex);
                    AllExpense += exp.Total;
                }
            }

            ViewBag.AllExpense = AllExpense;
            return(View(expList.ToList().GroupBy(l => l.SONumber).Select(group => group.Last())));
        }
Esempio n. 13
0
        public ActionResult AddDelivery(DeliveryPaymentViewModel delivery, int CementID, int TransactionID)
        {
            // Create Individiual Instance.
            Transaction    transaction = new Transaction();
            Delivery       Deliveries  = new Delivery();
            Payment        Payments    = new Payment();
            Expense        Expenses    = new Expense();
            Cement         Cements     = new Cement();
            List <Expense> expenseList = new List <Expense>();

            // Delivery Instantiate
            Deliveries.CementID          = CementID;
            Deliveries.DateOfArrival     = delivery.DeliveryModel.DateOfArrival;
            Deliveries.DateofCreation    = DateTime.Now;
            Deliveries.DeliveryTo        = delivery.DeliveryModel.DeliveryTo;
            Deliveries.Destination       = delivery.DeliveryModel.Destination;
            Deliveries.DriverName        = delivery.DeliveryModel.DriverName;
            Deliveries.DRNumber          = delivery.DeliveryModel.DRNumber;
            Deliveries.HaulerCompany     = delivery.DeliveryModel.HaulerCompany;
            Deliveries.DestinationTo     = delivery.DeliveryModel.DestinationTo;
            Deliveries.Hauling           = delivery.DeliveryModel.Hauling;
            Deliveries.PlateNumber       = delivery.DeliveryModel.PlateNumber;
            Deliveries.QuantityToDeliver = delivery.DeliveryModel.QuantityToDeliver;
            Deliveries.TransactionID     = TransactionID;


            db.Deliveries.Add(Deliveries);
            db.SaveChanges();
            transaction.DeliveryID = delivery.DeliveryModel.DeliveryID;



            //if (!db.Transactions.Any(t => t.CementID == CementID))
            //{
            //    transaction.CementID = CementID;
            //    transaction.DeliveryID = delivery.DeliveryModel.DeliveryID;

            //    db.Transactions.Add(transaction);
            //    db.SaveChanges();

            //    Deliveries.TransactionID = transaction.TransactionID;
            //    db.Deliveries.Attach(Deliveries);
            //    var entry = db.Entry(Deliveries);
            //    entry.Property(e => e.TransactionID).IsModified = true;
            //    // Transaction Creation + Delivery ID added completed

            //    Cements = db.Cements.Find(Deliveries.CementID);
            //    Cements.TransactionID = transaction.TransactionID;
            //    db.Cements.Attach(Cements);
            //    var entry2 = db.Entry(Cements);
            //    entry2.Property(e => e.TransactionID).IsModified = true;

            //}
            //else
            //{
            //    transaction = db.Transactions.Where(t => t.CementID == CementID).First();
            //    Deliveries.TransactionID = transaction.TransactionID;
            //    db.Deliveries.Attach(Deliveries);
            //    var entry = db.Entry(Deliveries);
            //    entry.Property(e => e.TransactionID).IsModified = true;
            //    // Updated Transaction added delivery entity with The transaction ID


            //    // other changed properties

            //}


            //Checking if Payment DR Number is not null Save Payment
            if (!String.IsNullOrEmpty(delivery.PaymentModel.Name) || !String.IsNullOrEmpty(delivery.PaymentModel.BankName))
            {
                Payments.BankName       = delivery.PaymentModel.BankName;
                Payments.Name           = delivery.PaymentModel.Name;
                Payments.Branch         = delivery.PaymentModel.Branch;
                Payments.DateofCheque   = delivery.PaymentModel.DateofCheque;
                Payments.DRNumber       = delivery.DeliveryModel.DRNumber;
                Payments.PricePHP       = delivery.PaymentModel.PricePHP;
                Payments.ChequeNumber   = delivery.PaymentModel.ChequeNumber;
                Payments.TermsOfPayment = delivery.PaymentModel.TermsOfPayment;
                Payments.TransactionID  = TransactionID;
                Payments.DeliveryID     = Deliveries.DeliveryID;
                db.Payments.Add(Payments);
                db.SaveChanges();
                //Save Transactions PaymentID;

                //transaction.PaymentID = Payments.PaymentID;
                //db.Transactions.Attach(transaction);
                //var entry = db.Entry(transaction);
                //entry.Property(e => e.PaymentID).IsModified = true;

                // Expese Checking.
                if (delivery.PaymentModel.Expenses != null)
                {
                    foreach (Expense exp in delivery.PaymentModel.Expenses)
                    {
                        exp.PaymentID = Payments.PaymentID;

                        db.Expenses.Add(exp);
                    }
                }
            }

            db.SaveChanges();
            Cements = db.Cements.Find(CementID);
            return(RedirectToAction("Index", "SummaryTransaction", new { SOnumberPass = Cements.SOnumber }));
        }
        public ActionResult PreviousSummary(int?SOnumberPass)
        {
            SummaryTransactionViewModel summaryTransactionVM = new SummaryTransactionViewModel();

            Cement   cement        = new Cement();
            Delivery deliver       = new Delivery();
            Payment  payment       = new Payment();
            int      TotalExpense  = 0;
            int      TotalAsWhole  = 0;
            int      IncomeAsWhole = 0;

            List <Expense> expenseList    = new List <Expense>();
            List <Expense> expenseASWhole = new List <Expense>();
            List <Payment> paymentList    = new List <Payment>();

            cement = db.Cements.Where(t => t.SOnumber == SOnumberPass).FirstOrDefault();
            if (db.Deliveries.Any(t => t.Cement.SOnumber == cement.SOnumber))
            {
                deliver = db.Deliveries.Where(t => t.Cement.SOnumber == cement.SOnumber).OrderByDescending(t => t.DateofCreation).FirstOrDefault();
            }


            if (deliver != null)
            {
                payment = db.Payments.Where(t => t.DeliveryID == deliver.DeliveryID).OrderByDescending(t => t.Delivery.DateofCreation).FirstOrDefault();
            }
            else
            {
                deliver = new Delivery();
                payment = new Payment();
            }


            foreach (Expense exp in db.Expenses)
            {
                if (payment != null)
                {
                    if (exp.PaymentID == payment.PaymentID)
                    {
                        expenseList.Add(new Expense {
                            PaymentID = exp.PaymentID, Amount = exp.Amount, Description = exp.Description, ExpenseID = exp.ExpenseID, Total = exp.Total
                        });
                        TotalExpense += exp.Total;
                    }
                    //TOTAL Expense as a Whole
                    if (exp.Payment.TransactionID == cement.TransactionID)
                    {
                        expenseASWhole.Add(new Expense {
                            PaymentID = exp.PaymentID, Amount = exp.Amount, Description = exp.Description, ExpenseID = exp.ExpenseID, Total = exp.Total
                        });
                        TotalAsWhole += exp.Total;
                    }
                }
            }


            //Checking if SO have Renewal Payment.
            if (cement.RenewalPayment != 0)
            {
                expenseList.Add(new Expense {
                    PaymentID = 0, Amount = 1, Description = "Renewal SO", ExpenseID = 0, Total = cement.RenewalPayment
                });
                TotalExpense += cement.RenewalPayment;
            }



            //if (expenseList.Count <= 0)
            //{
            //    expenseList.Add(new Expense { PaymentID = 0, Amount = 0, Description = "", ExpenseID = 0, Total = 0 });
            //}

            if (payment == null)
            {
                //payment = new Payment {BankName="",Branch="",DateofCheque=DateTime.Now,DeliveryID=0,DRNumber="",Name="",PaymentID=0,TermsOfPayment=Terms.Cash };
                payment = new Payment();
            }
            else
            {
                summaryTransactionVM.DateOfCheque  = payment.DateofCheque;
                summaryTransactionVM.DateProcessed = payment.Delivery.DateofCreation;
            }


            //Creation of Total as whole income
            foreach (Payment payWhole in db.Payments.Include("Delivery").Where(t => t.TransactionID == cement.TransactionID))
            {
                paymentList.Add(payWhole);
                IncomeAsWhole += (payWhole.PricePHP * payWhole.Delivery.QuantityToDeliver);
            }

            //Creation of Summary
            summaryTransactionVM.BankName     = payment.BankName;
            summaryTransactionVM.Branch       = payment.Branch;
            summaryTransactionVM.ChequeNumber = cement.ChequeNumber;
            summaryTransactionVM.CurrentStock = cement.TotalQuantity - deliver.QuantityToDeliver;
            summaryTransactionVM.CustomerName = payment.Name;

            summaryTransactionVM.Income            = payment.PricePHP * deliver.QuantityToDeliver;
            summaryTransactionVM.TotalIncome       = (payment.PricePHP * deliver.QuantityToDeliver) - TotalExpense;
            summaryTransactionVM.QuantityToDeliver = deliver.QuantityToDeliver;
            summaryTransactionVM.Remarks           = cement.Remarks;
            summaryTransactionVM.SONumber          = cement.SOnumber;
            summaryTransactionVM.Stats             = cement.Stats; // for Now everything is Pending;
            summaryTransactionVM.Expenses          = expenseList;
            summaryTransactionVM.ExpensesAsWhole   = expenseASWhole;


            //Checking How Many SO relations

            int           relations   = 0;
            List <Cement> countCement = new List <Cement>();

            countCement = db.Cements.Where(t => t.TransactionID == cement.TransactionID).ToList();
            relations   = countCement.Count;

            summaryTransactionVM.RelatedCementList = countCement;

            ViewBag.relations     = relations;
            ViewBag.CementID      = cement.CementID;
            ViewBag.TotalExpense  = TotalExpense;
            ViewBag.TotalAsWhole  = TotalAsWhole;
            ViewBag.IncomeAsWhole = IncomeAsWhole;
            ViewBag.TransactionID = cement.TransactionID;
            return(View("Index", summaryTransactionVM));
        }