Пример #1
0
        internal void CheckQuantity(Entities edc, List <string> _warnings, StockLib lib)
        {
            if (this.ProductType.Value != Linq.ProductType.Cigarette)
            {
                return;
            }
            decimal _onStock = 0;

            foreach (Linq.StockEntry _stock in this.StockEntry(edc))
            {
                if (_stock.StockLibraryIndex != lib)
                {
                    continue;
                }
                _onStock += Convert.ToDecimal(_stock.Quantity);
            }
            if (Convert.ToDecimal(this.FGQuantityAvailable) != _onStock)
            {
                string _msg = string.Format(m_noMachingQuantityWarningMessage, Convert.ToDecimal(this.FGQuantityAvailable), _onStock, this.ProductType, this.Batch0, this.SKU);
                _warnings.Add(_msg);
            }
        }
Пример #2
0
        internal bool Validate(Entities edc, Dictionary <string, IGrouping <string, IPR> > _accountGroups, StockLib library)
        {
            ActivityLogCT.WriteEntry(m_ActivityLogEntryName, "Starting stock inventory validation.");
            int _problems = 0;
            Dictionary <string, Batch> _batches = new Dictionary <string, Batch>();

            foreach (StockEntry _sex in this.AllIPRFinishedGoods(edc))
            {
                Batch _batchLookup = Batch.FindStockToBatchLookup(edc, _sex.Batch);
                if (_batchLookup != null)
                {
                    if (!_batches.ContainsKey(_batchLookup.Batch0))
                    {
                        _batches.Add(_batchLookup.Batch0, _batchLookup);
                    }
                    _sex.BatchIndex = _batchLookup;
                    continue;
                }
                ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _sex.NoMachingBatchWarningMessage);
                _problems++;
            }
            foreach (StockEntry _sex in this.AllIPRTobacco(edc))
            {
                if (_accountGroups.ContainsKey(_sex.Batch))
                {
                    continue;
                }
                ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _sex.NoMachingTobaccoWarningMessage);
                _problems++;
            }
            List <string> _warnings = new List <string>();

            foreach (Batch _senbx in _batches.Values)
            {
                _senbx.CheckQuantity(edc, _warnings, library);
            }
            foreach (string _msg in _warnings)
            {
                ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _msg);
                _problems++;
            }
            foreach (Batch _btx in DanglingBatches(edc, _batches, library))
            {
                ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _btx.DanglingBatchWarningMessage);
                _problems++;
            }
            string _mtmplt = "Stock inventory validation passed successfully.";

            if (_problems > 0)
            {
                _mtmplt = "Stock inventory validation failed. There are problems reported that must be resolved to start calculation procedure.";
            }
            ActivityLogCT.WriteEntry(m_ActivityLogEntryName, _mtmplt);
            return(_problems == 0);
        }
Пример #3
0
        private IEnumerable <Batch> DanglingBatches(Entities edc, Dictionary <string, Batch> _batches, StockLib library)
        {
            Dictionary <string, Batch> _ret             = new Dictionary <string, Batch>();
            Dictionary <int, Batch>    _batchDictionary = (from _btx in edc.Batch
                                                           where _btx.FGQuantityAvailable.Value > 0
                                                           orderby _btx.Id.Value descending
                                                           select _btx).ToDictionary <Batch, int>(x => x.Id.Value);

            foreach (StockEntry _sex in library.StockEntry(edc))
            {
                if (_sex.BatchIndex != null && _batchDictionary.ContainsKey(_sex.BatchIndex.Id.Value))
                {
                    _batchDictionary.Remove(_sex.BatchIndex.Id.Value);
                }
            }
            foreach (Batch _bidx in _batchDictionary.Values)
            {
                if (_bidx.BatchStatus.Value == BatchStatus.Progress)
                {
                    continue;
                }
                if (_batches.ContainsKey(_bidx.Batch0))
                {
                    continue;
                }
                if (!_ret.ContainsKey(_bidx.Batch0))
                {
                    _ret.Add(_bidx.Batch0, _bidx);
                }
            }
            return(_ret.Values);
        }