Exemple #1
0
        public void GenerateAutomaticInventoryByUnit()
        {
            var ethDate = new EthiopianDate.EthiopianDate();
            var stores  = new Stores();

            stores.GetActiveStores();
            var rec     = new ReceiveDoc();
            var itm     = new Items();
            var yearEnd = new YearEnd();
            var balance = new Balance();

            if (!InventoryRequiredForHandlingUnit(false))
            {
                return;
            }
            while (!stores.EOF) //This needs to be done for each store and for each item
            {
                //bereket
                //itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID);
                itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnitOptimized(stores.ID, ethDate.Year);
                while (!itm.EOF) //For each item
                {
                    var receivedoc = rec.GetDistinctUnitIDFromReceivedDoc(itm.ID);
                    foreach (var dr in receivedoc.Rows.Cast <DataRow>().Where(dr => !DoesBalanceExistByUnit(ethDate.Year, itm.ID, stores.ID, true, Convert.ToInt32(dr["UnitID"]))))
                    {
                        //need optimization
                        //we can exclude the already calculated items when we exclude never recieved items
                        yearEnd.LoadByItemIDStoreAndYearAndUnit(itm.ID, stores.ID, ethDate.Year, true, Convert.ToInt32(dr["UnitID"]));

                        if (yearEnd.RowCount > 0)
                        {
                            continue;
                        }

                        yearEnd.AddNew();
                        yearEnd.ItemID  = itm.ID;
                        yearEnd.StoreID = stores.ID;
                        yearEnd.Year    = ethDate.Year;

                        //need optimization
                        //atleast we can get the value directly by filtering using storeid and itemid rather than
                        //selecting all items in all stores and filter it by code
                        //yearEnd.EBalance = balance.GetSOHByUnit(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"]));
                        yearEnd.EBalance             = balance.GetSOHByUnitOptimized(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"]));
                        yearEnd.PhysicalInventory    = yearEnd.EBalance;
                        yearEnd.AutomaticallyEntered = true;
                        yearEnd.UnitID = Convert.ToInt32(dr["UnitID"]);
                        yearEnd.Save();
                    }
                    itm.MoveNext();
                }
                stores.MoveNext();
            }
        }
Exemple #2
0
        public void GenerateAutomaticInventory()
        {
            var ethDate = new EthiopianDate.EthiopianDate();

            if (InventoryRequired(false))
            {
                Stores stores = new Stores();
                stores.GetActiveStores();
                while (!stores.EOF) //This needs to be done for each store
                {
                    if (!DoesBalanceExist(ethDate.Year, stores.ID, true))
                    //If Inventory information hasn't already been filled for this store
                    {
                        var itm = new Items();

                        //bereket
                        //itm.ExcludeNeverReceivedItemsNoCategory(stores.ID);
                        itm.ExcludeNeverReceivedItemsNoCategoryOptimized(stores.ID, ethDate.Year);
                        while (!itm.EOF) //For each time
                        {
                            var yearEnd = new YearEnd();
                            var balance = new Balance();

                            yearEnd.LoadByItemIDStoreAndYear(itm.ID, stores.ID, ethDate.Year, true);

                            if (yearEnd.RowCount > 0)
                            {
                                return;
                            }

                            //YearEnd.PurgeAutomaticallyEnteredInventory(itm.ID, stores.ID, ethDate.Year);
                            yearEnd.AddNew();
                            yearEnd.ItemID  = itm.ID;
                            yearEnd.StoreID = stores.ID;
                            yearEnd.Year    = ethDate.Year;

                            //bereket
                            //yearEnd.EBalance = balance.GetSOH(itm.ID, stores.ID, 10, ethDate.Year);
                            yearEnd.EBalance             = balance.GetSOHOptimized(itm.ID, stores.ID, 10, ethDate.Year);
                            yearEnd.PhysicalInventory    = yearEnd.EBalance;
                            yearEnd.AutomaticallyEntered = true;
                            yearEnd.UnitID = 0;
                            yearEnd.Save();
                            itm.MoveNext();
                        }
                    }
                    stores.MoveNext();
                }
            }
        }
Exemple #3
0
        public bool InventoryRequiredForHandlingUnit(bool ignoreAutomatic)
        {
            var ethDate = new EthiopianDate.EthiopianDate();

            if ((ethDate.Month == 10 && ethDate.Day == 30) || ethDate.Month == 11)
            {
                var stores = new Stores();
                stores.GetActiveStores();
                while (!stores.EOF)
                {
                    var itm = new Items();
                    itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID);
                    if (!this.DoesBalanceExist(ethDate.Year, stores.ID, !ignoreAutomatic) && itm.RowCount > 0)
                    {
                        return(true);
                    }
                    stores.MoveNext();
                }
            }
            return(false);
        }
 public bool InventoryRequiredForHandlingUnit(bool ignoreAutomatic)
 {
     var ethDate = new EthiopianDate.EthiopianDate();
     if ((ethDate.Month == 10 && ethDate.Day == 30) || ethDate.Month == 11)
     {
         var stores = new Stores();
         stores.GetActiveStores();
         while (!stores.EOF)
         {
             var itm = new Items();
             itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID);
             if (!this.DoesBalanceExist(ethDate.Year,stores.ID, !ignoreAutomatic) && itm.RowCount > 0)
             {
                 return true;
             }
             stores.MoveNext();
         }
     }
     return false;
 }
        public void GenerateAutomaticInventoryByUnit()
        {
            var ethDate = new EthiopianDate.EthiopianDate();
            var stores = new Stores();
            stores.GetActiveStores();
            var rec = new ReceiveDoc();
            var itm = new Items();
            var yearEnd = new YearEnd();
            var balance = new Balance();

            if (!InventoryRequiredForHandlingUnit(false)) return;
            while (!stores.EOF) //This needs to be done for each store and for each item
            {
                //bereket
                //itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID);
                itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnitOptimized(stores.ID, ethDate.Year);
                while (!itm.EOF) //For each item
                {
                    var receivedoc = rec.GetDistinctUnitIDFromReceivedDoc(itm.ID);
                    foreach (var dr in receivedoc.Rows.Cast<DataRow>().Where(dr =>!DoesBalanceExistByUnit(ethDate.Year, itm.ID, stores.ID, true,Convert.ToInt32(dr["UnitID"]))))
                    {
                        //need optimization
                        //we can exclude the already calculated items when we exclude never recieved items
                        yearEnd.LoadByItemIDStoreAndYearAndUnit(itm.ID, stores.ID, ethDate.Year, true, Convert.ToInt32(dr["UnitID"]));

                        if (yearEnd.RowCount > 0) continue;

                        yearEnd.AddNew();
                        yearEnd.ItemID = itm.ID;
                        yearEnd.StoreID = stores.ID;
                        yearEnd.Year = ethDate.Year;

                        //need optimization
                        //atleast we can get the value directly by filtering using storeid and itemid rather than
                        //selecting all items in all stores and filter it by code
                        //yearEnd.EBalance = balance.GetSOHByUnit(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"]));
                        yearEnd.EBalance = balance.GetSOHByUnitOptimized(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"]));
                        yearEnd.PhysicalInventory = yearEnd.EBalance;
                        yearEnd.AutomaticallyEntered = true;
                        yearEnd.UnitID = Convert.ToInt32(dr["UnitID"]);
                        yearEnd.Save();

                    }
                    itm.MoveNext();
                }
                stores.MoveNext();
            }
        }
        public void GenerateAutomaticInventory()
        {
            var ethDate = new EthiopianDate.EthiopianDate();
            if (InventoryRequired(false))
            {
                Stores stores = new Stores();
                stores.GetActiveStores();
                while (!stores.EOF) //This needs to be done for each store
                {
                  if (!DoesBalanceExist(ethDate.Year, stores.ID, true))
                        //If Inventory information hasn't already been filled for this store
                    {
                        var itm = new Items();

                      //bereket
                      //itm.ExcludeNeverReceivedItemsNoCategory(stores.ID);
                        itm.ExcludeNeverReceivedItemsNoCategoryOptimized(stores.ID, ethDate.Year);
                        while (!itm.EOF) //For each time
                        {
                            var yearEnd = new YearEnd();
                            var balance = new Balance();

                            yearEnd.LoadByItemIDStoreAndYear(itm.ID, stores.ID, ethDate.Year, true);

                            if (yearEnd.RowCount > 0)
                            {
                                return;
                            }

                            //YearEnd.PurgeAutomaticallyEnteredInventory(itm.ID, stores.ID, ethDate.Year);
                            yearEnd.AddNew();
                            yearEnd.ItemID = itm.ID;
                            yearEnd.StoreID = stores.ID;
                            yearEnd.Year = ethDate.Year;

                            //bereket
                            //yearEnd.EBalance = balance.GetSOH(itm.ID, stores.ID, 10, ethDate.Year);
                            yearEnd.EBalance = balance.GetSOHOptimized(itm.ID, stores.ID, 10, ethDate.Year);
                            yearEnd.PhysicalInventory = yearEnd.EBalance;
                            yearEnd.AutomaticallyEntered = true;
                            yearEnd.UnitID = 0;
                            yearEnd.Save();
                            itm.MoveNext();
                        }
                    }
                    stores.MoveNext();
                }

            }
        }