Esempio n. 1
0
        /**
         * SE:I --> satisfy by orders PuOP
         */
        public EntityCollector Satisfy(Demand demand, Quantity demandedQuantity)
        {
            EntityCollector entityCollector = new EntityCollector();
            M_Article       article         = demand.GetArticle();
            DueTime         dueTime         = demand.GetStartTimeBackward();

            if (article.ToBuild)
            {
                throw new MrpRunException(
                          "You try to create a purchaseOrderPart for a articleToBuild.");
            }

            // currently only one businessPartner per article TODO: This could be changing
            M_ArticleToBusinessPartner articleToBusinessPartner =
                _dbMasterDataCache.M_ArticleToBusinessPartnerGetAllByArticleId(article.GetId())[0];
            M_BusinessPartner businessPartner =
                _dbMasterDataCache.M_BusinessPartnerGetById(new Id(articleToBusinessPartner
                                                                   .BusinessPartnerId));
            T_PurchaseOrder purchaseOrder = new T_PurchaseOrder();

            // [Name],[DueTime],[BusinessPartnerId]
            purchaseOrder.DueTime         = dueTime.GetValue();
            purchaseOrder.BusinessPartner = businessPartner;
            purchaseOrder.Name            = $"PurchaseOrder{article.Name} for " +
                                            $"businessPartner {purchaseOrder.BusinessPartner.Id}";

            // init a new purchaseOderPart
            T_PurchaseOrderPart tPurchaseOrderPart = new T_PurchaseOrderPart();

            // [PurchaseOrderId],[ArticleId],[Quantity],[State],[ProviderId]
            tPurchaseOrderPart.PurchaseOrder   = purchaseOrder;
            tPurchaseOrderPart.PurchaseOrderId = purchaseOrder.Id;
            tPurchaseOrderPart.Article         = article;
            tPurchaseOrderPart.ArticleId       = article.Id;
            tPurchaseOrderPart.Quantity        =
                CalculateQuantity(articleToBusinessPartner, demandedQuantity) *
                articleToBusinessPartner
                .PackSize;
            if (tPurchaseOrderPart.Quantity < demandedQuantity.GetValue())
            {
                throw new MrpRunException("You cannot purchase less than you need!");
            }

            tPurchaseOrderPart.State = State.Created;

            PurchaseOrderPart purchaseOrderPart =
                new PurchaseOrderPart(tPurchaseOrderPart, null);

            T_DemandToProvider demandToProvider = new T_DemandToProvider()
            {
                DemandId   = demand.GetId().GetValue(),
                ProviderId = purchaseOrderPart.GetId().GetValue(),
                Quantity   = demandedQuantity.GetValue()
            };

            entityCollector.Add(purchaseOrderPart);
            entityCollector.Add(demandToProvider);
            return(entityCollector);
        }
Esempio n. 2
0
        /**
         * COP or PrOB --> satisfy by SE:W
         */
        public EntityCollector Satisfy(Demand demand, Quantity demandedQuantity)
        {
            EntityCollector entityCollector = new EntityCollector();

            Provider stockProvider = CreateStockExchangeProvider(demand.GetArticle(),
                                                                 demand.GetStartTimeBackward(), demandedQuantity);

            entityCollector.Add(stockProvider);

            T_DemandToProvider demandToProvider =
                new T_DemandToProvider(demand.GetId(), stockProvider.GetId(), demandedQuantity);

            entityCollector.Add(demandToProvider);


            return(entityCollector);
        }
        public void TestParentsDueTimeIsGreaterThanOrEqualToChildsDueTime(
            string testConfigurationFileName)
        {
            // init
            InitThisTest(testConfigurationFileName);

            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.ReloadTransactionData();

            foreach (var demandToProvider in dbTransactionData.DemandToProviderGetAll())
            {
                Demand parentDemand =
                    dbTransactionData.DemandsGetById(demandToProvider.GetDemandId());
                if (parentDemand.GetType() == typeof(CustomerOrderPart))
                {
                    continue;
                }

                Provider childProvider =
                    dbTransactionData.ProvidersGetById(demandToProvider.GetProviderId());


                DueTime parentDueTime = parentDemand.GetStartTimeBackward();
                DueTime childDueTime  = childProvider.GetEndTimeBackward();

                Assert.True(parentDueTime.IsGreaterThanOrEqualTo(childDueTime),
                            "ParentDemand's dueTime cannot be smaller than childProvider's dueTime.");
            }

            foreach (var providerToDemand in dbTransactionData.ProviderToDemandGetAll())
            {
                Provider parentProvider =
                    dbTransactionData.ProvidersGetById(providerToDemand.GetProviderId());
                Demand childDemand =
                    dbTransactionData.DemandsGetById(providerToDemand.GetDemandId());

                DueTime parentDueTime = parentProvider.GetStartTimeBackward();
                DueTime childDueTime  = childDemand.GetEndTimeBackward();

                Assert.True(parentDueTime.IsGreaterThanOrEqualTo(childDueTime),
                            "ParentProvider's dueTime cannot be smaller than childDemand's dueTime.");
            }
        }
Esempio n. 4
0
        /*public static T_ProductionOrderBom CreateT_ProductionOrderBom()
         * {
         *  T_ProductionOrderBom tProductionOrderBom = new T_ProductionOrderBom();
         *  tProductionOrderBom.Quantity = new Random().Next(1, 100);
         *  M_Article article = dbMasterDataCache.M_ArticleGetById(
         *      IdGenerator.GetRandomId(0.M_ArticleGetAll().Count - 1));
         *  tProductionOrderBom.ArticleChild = article;
         *  tProductionOrderBom.ProductionOrderParent = CreateT_ProductionOrder()
         * }*/

        public static ProductionOrder CreateT_ProductionOrder(

            Demand demand, Quantity quantity)
        {
            if (quantity == null || quantity.GetValue() == null)
            {
                throw new MrpRunException("Quantity is not set.");
            }
            T_ProductionOrder tProductionOrder = new T_ProductionOrder();

            // [ArticleId],[Quantity],[Name],[DueTime],[ProviderId]
            tProductionOrder.DueTime   = demand.GetStartTimeBackward().GetValue();
            tProductionOrder.Article   = demand.GetArticle();
            tProductionOrder.ArticleId = demand.GetArticle().Id;
            tProductionOrder.Name      = $"ProductionOrder for Demand {demand.GetArticle()}";
            // connects this provider with table T_Provider
            tProductionOrder.Quantity = quantity.GetValue().GetValueOrDefault();

            return(new ProductionOrder(tProductionOrder));
        }
Esempio n. 5
0
        public EntityCollector CreateProductionOrder(Demand demand, Quantity quantity)
        {
            if (quantity == null || quantity.GetValue() == null)
            {
                throw new MrpRunException("Quantity is not set.");
            }
            T_ProductionOrder tProductionOrder = new T_ProductionOrder();

            // [ArticleId],[Quantity],[Name],[DueTime],[ProviderId]
            tProductionOrder.DueTime   = demand.GetStartTimeBackward().GetValue();
            tProductionOrder.Article   = demand.GetArticle();
            tProductionOrder.ArticleId = demand.GetArticle().Id;
            tProductionOrder.Name      = $"ProductionOrder for Demand {demand.GetArticle()}";
            tProductionOrder.Quantity  = quantity.GetValue().GetValueOrDefault();

            ProductionOrder productionOrder =
                new ProductionOrder(tProductionOrder);

            EntityCollector entityCollector = new EntityCollector();

            entityCollector.Add(productionOrder);

            return(entityCollector);
        }
Esempio n. 6
0
 private string ToGraphizString(Demand demand)
 {
     return($"\\n{demand.GetId()}: {demand.GetArticle().Name};Anzahl: {demand.GetQuantity()};"
            + $"\\nStart/End: {demand.GetStartTimeBackward()}/{demand.GetEndTimeBackward()};"
            );
 }