public static Demand CreateStockExchangeProductionOrderDemand(M_ArticleBom articleBom, DueTime dueTime)
        {
            IDbMasterDataCache dbMasterDataCache =
                ZppConfiguration.CacheManager.GetMasterDataCache();
            T_StockExchange stockExchange = new T_StockExchange();

            stockExchange.StockExchangeType = StockExchangeType.Demand;
            stockExchange.Quantity          = articleBom.Quantity;
            stockExchange.State             = State.Created;
            M_Stock stock = dbMasterDataCache.M_StockGetByArticleId(new Id(articleBom.ArticleChildId));

            stockExchange.Stock          = stock;
            stockExchange.StockId        = stock.Id;
            stockExchange.RequiredOnTime = dueTime.GetValue();
            stockExchange.ExchangeType   = ExchangeType.Withdrawal;

            StockExchangeDemand stockExchangeDemand =
                new StockExchangeDemand(stockExchange);

            return(stockExchangeDemand);
        }
Beispiel #2
0
        /**
         * returns a provider, which can be a stockExchangeProvider, if article can be fulfilled by stock, else
         * a productionOrder/purchaseOrderPart
         */
        private Provider CreateStockExchangeProvider(M_Article article, DueTime dueTime,
                                                     Quantity demandedQuantity)
        {
            if (demandedQuantity == null || demandedQuantity.GetValue() == 0)
            {
                throw new MrpRunException("Quantity is not set.");
            }
            M_Stock         stock         = _dbMasterDataCache.M_StockGetByArticleId(article.GetId());
            T_StockExchange stockExchange = new T_StockExchange();

            stockExchange.StockExchangeType = StockExchangeType.Provider;
            stockExchange.Quantity          = demandedQuantity.GetValue(); // TODO: PASCAL .GetValueOrDefault();
            stockExchange.State             = State.Created;

            stockExchange.Stock          = stock;
            stockExchange.StockId        = stock.Id;
            stockExchange.RequiredOnTime = dueTime.GetValue();
            stockExchange.ExchangeType   = ExchangeType.Withdrawal;
            StockExchangeProvider stockExchangeProvider = new StockExchangeProvider(stockExchange);

            return(stockExchangeProvider);
        }
        public static Demand CreateStockExchangeStockDemand(Id articleId, DueTime dueTime, Quantity quantity)
        {
            if (quantity == null || quantity.GetValue() == null)
            {
                throw new MrpRunException("Quantity is not set.");
            }
            IDbMasterDataCache dbMasterDataCache =
                ZppConfiguration.CacheManager.GetMasterDataCache();
            T_StockExchange stockExchange = new T_StockExchange();

            stockExchange.StockExchangeType = StockExchangeType.Demand;
            stockExchange.Quantity          = quantity.GetValue().GetValueOrDefault();
            stockExchange.State             = State.Created;
            M_Stock stock = dbMasterDataCache.M_StockGetByArticleId(articleId);

            stockExchange.Stock          = stock;
            stockExchange.StockId        = stock.Id;
            stockExchange.RequiredOnTime = dueTime.GetValue();
            stockExchange.ExchangeType   = ExchangeType.Insert;
            StockExchangeDemand stockExchangeDemand =
                new StockExchangeDemand(stockExchange);

            return(stockExchangeDemand);
        }