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); }
public List <Models.MInventoryBalance> GetInventoryBalance(DateTime fromDate, DateTime toDate) { List <Models.MInventoryBalance> Data = new List <Models.MInventoryBalance>(); var query = from o in obj.InventoryBalances where o.Date >= fromDate && o.Date <= toDate select o; Classes.CProducts cp = new CProducts(); Classes.CWareHouse cw = new CWareHouse(); foreach (var item in query) { Models.MInventoryBalance mib = new Models.MInventoryBalance(); string ProductName = string.Empty; string WarehouseName = string.Empty; ProductName = cp.GetProductNameWithTagsById(Convert.ToInt32(item.ProductsId)); mib.WareHouseId = Convert.ToInt32(item.WarehouseId.ToString()); WarehouseName = cw.GetWareHouseNameById(Convert.ToInt32(item.WarehouseId)); mib.BalanceTotal = item.BalanceTotal; mib.BalanceUnits = item.BalanceUnits; mib.BalanceUnitsCost = item.BalanceUnitsCost; mib.date = Convert.ToDateTime(item.Date); mib.ProductName = ProductName; mib.PurchaseTotal = item.PurchaseTotal; mib.PurchaseUnits = item.PurchaseUnits; mib.PurchaseUnitsCost = item.PurchaseUnitsCost; mib.SaleTotal = item.SaleTotal; mib.SaleUnits = item.SaleUnits; mib.SaleUnitsCost = item.SaleUnitsCost; mib.WareHouseName = WarehouseName; Data.Add(mib); } return(Data); }
public List <Models.MInventory> GetInventoryData() { List <Models.MInventory> Data = new List <Models.MInventory>(); var query = from o in obj.Inventories orderby o.WareHouseId ascending select o; if (query != null) { foreach (var item in query) { Models.MInventory mi = new Models.MInventory(); string Get = string.Empty; string WareHouseName = string.Empty; Classes.CProducts cp = new CProducts(); Classes.CWareHouse cw = new CWareHouse(); Get = cp.GetProductNameWithTagsById(Convert.ToInt32(item.ProductId)); WareHouseName = cw.GetWareHouseNameById(Convert.ToInt32(item.WareHouseId)); string[] ProductDetails = Get.Split('-'); mi.ProductCode = ProductDetails[0]; mi.ProductName = ProductDetails[1]; mi.ProducyTag1 = ProductDetails[2]; mi.ProductTag2 = ProductDetails[3]; mi.ProductId = item.ProductId.ToString(); mi.WareHouseld = item.WareHouseId.ToString(); mi.WareHouseName = WareHouseName; mi.Cost = item.Cost; mi.Quantity = item.Quantity; mi.TotalCost = Convert.ToSingle(Convert.ToSingle(item.Cost) * Convert.ToSingle(item.Quantity)); Data.Add(mi); } } return(Data); }
public List <Models.MViewModels.MViewOrderDetails> GetAllDetails(int OrderId) { List <Models.MViewModels.MViewOrderDetails> OrderDetails = new List <Models.MViewModels.MViewOrderDetails>(); List <Models.MOrdersLine> OrderLine = new List <Models.MOrdersLine>(); Models.MViewModels.MViewOrderDetails mvo = new Models.MViewModels.MViewOrderDetails(); Classes.COrderOnline coo = new COrderOnline(); Classes.COrders co = new COrders(); Classes.CProducts cp = new CProducts(); OrderLine = coo.GetAll(); OrderLine = OrderLine.Where(o => o.OrderId == OrderId.ToString()).ToList(); for (int i = 0; i < OrderLine.Count; i++) { mvo = new Models.MViewModels.MViewOrderDetails(); string CurrentProductPrice = string.Empty, ProductName = string.Empty; ProductName = cp.GetProductNameWithTagsById(Convert.ToInt32(OrderLine[i].ProductId)); string OrderType = co.ReturnOrderTypeById(OrderId); switch (OrderType) { case "Client": { CurrentProductPrice = cp.ReturnSalePrice(Convert.ToInt32(OrderLine[i].ProductId)); break; } case "Vendor": { CurrentProductPrice = cp.ReturnCostPrice(Convert.ToInt32(OrderLine[i].ProductId)); break; } default: break; } mvo.CurrentProductPrice = CurrentProductPrice; mvo.OrderProductPrice = OrderLine[i].SalePrice; mvo.ProductCost = OrderLine[i].totalProductCost; mvo.ProductName = ProductName; mvo.Units = OrderLine[i].unit; OrderDetails.Add(mvo); } return(OrderDetails); }
public List <Models.MRevertInventory.RevertConfirm> GetAllConfirm(int OrderId) { List <Models.MRevertInventory.RevertConfirm> RevertConfirm = new List <Models.MRevertInventory.RevertConfirm>(); List <Models.MOrdersLine> OrdersLine = new List <Models.MOrdersLine>(); Classes.COrderOnline coo = new COrderOnline(); Classes.CProducts cp = new CProducts(); OrdersLine = coo.GetAll(); OrdersLine = OrdersLine.Where(o => o.OrderId == OrderId.ToString()).ToList(); for (int i = 0; i < OrdersLine.Count; i++) { Models.MRevertInventory.RevertConfirm mrc = new Models.MRevertInventory.RevertConfirm(); mrc.Price = OrdersLine[i].SalePrice; mrc.ProductId = OrdersLine[i].ProductId; mrc.ProductName = cp.GetProductNameWithTagsById(Convert.ToInt32(mrc.ProductId)); mrc.Units = OrdersLine[i].unit; RevertConfirm.Add(mrc); } return(RevertConfirm); }
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); }