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); }
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); }