Exemplo n.º 1
0
            public List <Models.MViewModels.MViewTransactions> GetAll()
            {
                List <Models.MViewModels.MViewTransactions> Transactions    = new List <Models.MViewModels.MViewTransactions>();
                List <Models.MSaleTransactions>             AllTransactions = new List <Models.MSaleTransactions>();

                Models.MViewModels.MViewTransactions mvv = new Models.MViewModels.MViewTransactions();
                Classes.CProducts        cp  = new CProducts();
                Classes.CSaleTransations cst = new CSaleTransations();
                Classes.CWareHouse       cw  = new CWareHouse();
                AllTransactions = cst.GetAll();
                AllTransactions = (from o in AllTransactions select o).OrderBy(o => o.date).ToList();
                for (int i = 0; i < AllTransactions.Count; i++)
                {
                    mvv = new Models.MViewModels.MViewTransactions();
                    string ProductId     = AllTransactions[i].ProductID;
                    string ProductName   = cp.GetProductNameWithTagsById(Convert.ToInt32(ProductId));
                    string WareHouseId   = AllTransactions[i].WareHouseId;
                    string WareHouseName = cw.GetWareHouseNameById(Convert.ToInt32(WareHouseId));
                    mvv.TransactionId = AllTransactions[i].id.ToString();
                    mvv.Date          = AllTransactions[i].date.ToShortDateString();
                    mvv.Product       = ProductName;
                    mvv.Type          = AllTransactions[i].transactionType;
                    mvv.Units         = AllTransactions[i].units;
                    mvv.WareHouse     = WareHouseName;
                    mvv.OrderId       = AllTransactions[i].OrderId;
                    mvv.WareHouseId   = WareHouseId;
                    Transactions.Add(mvv);
                }
                return(Transactions);
            }
Exemplo n.º 2
0
        public int RevertOrderTransaction(int OrderId)
        {
            try
            {
                List <Models.MSaleTransactions> Transactions = new List <Models.MSaleTransactions>();
                Classes.CSaleTransations        cs           = new CSaleTransations();
                Transactions = cs.GetAll();
                Transactions = (from o in Transactions
                                where o.OrderId == OrderId.ToString()
                                select o).ToList();
                foreach (var item in Transactions)
                {
                    RevertSingleTransaction(item.id);
                }

                //deleting orders line
                var OrderLine = from o in obj.OrderLines
                                where o.OrderId == OrderId
                                select o;
                foreach (var item in OrderLine)
                {
                    obj.OrderLines.DeleteOnSubmit(item);
                }
                obj.SubmitChanges();

                //deleting order
                var Orders = from o in obj.Orders
                             where o.id == OrderId
                             select o;
                foreach (var item in Orders)
                {
                    obj.Orders.DeleteOnSubmit(item);
                }
                obj.SubmitChanges();
                return(1);
            }
            catch
            {
                //return 0;
                return(-1);
            }
        }
Exemplo n.º 3
0
        public int RevertOrderTransaction(int OrderId, int Units, int ProductId)
        {
            try
            {
                string PaymentId = string.Empty, PaymentLineId = string.Empty;
                string CashAccount = string.Empty, BankAccount = string.Empty;
                List <Models.MSaleTransactions> Transactions = new List <Models.MSaleTransactions>();
                Classes.CSaleTransations        cs           = new CSaleTransations();
                Transactions = cs.GetAll();
                Transactions = (from o in Transactions
                                where o.OrderId == OrderId.ToString() && o.ProductID == ProductId.ToString()
                                select o).ToList();
                foreach (var item in Transactions)
                {
                    RevertSingleTransaction(item.id, Units, ProductId);
                }

                //updating orders line
                var OrderLine = from o in obj.OrderLines
                                where o.OrderId == OrderId && o.ProductId == ProductId
                                select o;


                foreach (var item in OrderLine)
                {
                    item.units = Units.ToString();
                }


                //payments
                var Pyid = (from o in obj.Payments
                            where o.OrderId == Convert.ToInt32(OrderId)
                            select o.id).FirstOrDefault();
                var PylId = (from o in obj.PaymentLines
                             where o.PaymentId == Pyid
                             select o.id).FirstOrDefault();

                //cash account



                //cash transaction

                //bank account

                //bank transaction

                //inventory

                //inventory balance

                //transactions


                obj.SubmitChanges();


                return(1);
            }
            catch
            {
                //return 0;
                return(-1);
            }
        }
Exemplo n.º 4
0
            public List <Models.MViewModels.MItemProfatibilityReport> GetAll(DateTime fromDate, DateTime toDate)
            {
                #region Class Objects
                Classes.CSaleTransations ct = new CSaleTransations();
                Classes.CWareHouse       cw = new CWareHouse();
                Classes.CProducts        cp = new CProducts();

                #endregion

                #region Models
                Models.MSaleTransactions mt = new Models.MSaleTransactions();
                Models.MViewModels.MItemProfatibilityReport mii = new Models.MViewModels.MItemProfatibilityReport();
                #endregion

                #region Lists
                List <Models.MViewModels.MItemProfatibilityReport> ItemProfatiblity = new List <Models.MViewModels.MItemProfatibilityReport>();
                List <Models.MSaleTransactions> Transactions = new List <Models.MSaleTransactions>();
                List <string> Products = new List <string>();
                #endregion

                #region Logic
                float totalUnits = 0;
                Transactions = ct.GetAll();

                //filtering for only deductions
                Transactions = (from o in Transactions
                                where o.transactionType == Common.Constants.SaleTransactions.Deduction.ToString() &&
                                Convert.ToDateTime(o.date) >= fromDate && Convert.ToDateTime(o.date) <= toDate
                                select o).ToList();
                totalUnits = (from o in Transactions select Convert.ToSingle(o.units)).Sum();
                Products   = (from o in Transactions select o.ProductID).Distinct().ToList();
                for (int i = 0; i < Products.Count; i++)
                {
                    mii = new Models.MViewModels.MItemProfatibilityReport();
                    List <Models.MSaleTransactions> ProductWise = new List <Models.MSaleTransactions>();
                    ProductWise = (from o in Transactions where o.ProductID == Products[i] select o).ToList();
                    string ProductName = cp.GetProductNameWithTagsById(Convert.ToInt32(Products[i]));

                    float CostPrice = (from a in ProductWise
                                       where a.ProductID == Products[i]
                                       select Convert.ToSingle(a.CostPrice)).Sum();
                    float Revenue = (from a in ProductWise
                                     where a.ProductID == Products[i]
                                     select Convert.ToSingle(a.SalePrice)).Sum();
                    float units = (from a in ProductWise
                                   where a.ProductID == Products[i]
                                   select Convert.ToSingle(a.units)).Sum();
                    CostPrice = CostPrice * units;
                    Revenue   = Revenue * units;
                    float Difference = Revenue - CostPrice;
                    float totalCost  = Transactions.Select(o => Convert.ToSingle(o.units)).Sum();
                    float Percentage = (units / totalUnits) * 100;
                    mii.Inventory     = ProductName;
                    mii.WareHouse     = "Remaining";
                    mii.ActualCost    = CostPrice.ToString();
                    mii.ActualRevenue = Revenue.ToString();
                    mii.Diff          = Difference.ToString();
                    mii.UnitsSold     = units.ToString();
                    mii.Percent       = Percentage.ToString() + "%";
                    ItemProfatiblity.Add(mii);
                }
                #endregion
                return(ItemProfatiblity);
            }