public string GetGraphizString(PurchaseOrderPart purchaseOrderPart) { // Demand(CustomerOrder);20;Truck string graphizString = $"P: PurchaseOrderPart;{ToGraphizString(purchaseOrderPart)}"; return(graphizString); }
/** * 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); }
private static void ArchivedPurchaseOrdersWithoutPurchaseOrderParts() { IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); Ids purchaseOrderIds = new Ids(); foreach (var demand in dbTransactionData.PurchaseOrderPartGetAll()) { PurchaseOrderPart purchaseOrderPart = (PurchaseOrderPart)demand; purchaseOrderIds.Add(purchaseOrderPart.GetPurchaseOrderId()); } foreach (var purchaseOrder in dbTransactionData.PurchaseOrderGetAll()) { bool purchaseOrderHasNoPurchaseOrderParts = purchaseOrderIds.Contains(purchaseOrder.GetId()) == false; if (purchaseOrderHasNoPurchaseOrderParts) { ArchivePurchaseOrder(purchaseOrder); } } }
public void TestApplyConfirmations(string testConfigurationFileName) { InitThisTest(testConfigurationFileName); IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator(); // Ein CustomerOrderParts darf kein Kind haben und darf nicht beendet sein Ids customerOrderIds = new Ids(); foreach (var demand in dbTransactionData.CustomerOrderPartGetAll()) { CustomerOrderPart customerOrderPart = (CustomerOrderPart)demand; customerOrderIds.Add(customerOrderPart.GetCustomerOrderId()); Providers childs = aggregator.GetAllChildProvidersOf(customerOrderPart); Assert.False(childs.Any()); Assert.False(customerOrderPart.IsFinished()); } // Ein PurchaseOrderPart darf kein Elter haben und darf nicht beendet sein. Ids purchaseOrderIds = new Ids(); foreach (var demand in dbTransactionData.PurchaseOrderPartGetAll()) { PurchaseOrderPart purchaseOrderPart = (PurchaseOrderPart)demand; purchaseOrderIds.Add(purchaseOrderPart.GetPurchaseOrderId()); Assert.False(purchaseOrderPart.IsFinished()); Demands demands = aggregator.GetAllParentDemandsOf(demand); Assert.True(demands == null || demands.Any() == false); } // Für jede CustomerOrder muss es mind. noch ein CustomerOrderPart geben. foreach (var customerOrder in dbTransactionData.CustomerOrderGetAll()) { Assert.True(customerOrderIds.Contains(customerOrder.GetId())); } // Für jede PurchaseOrder muss es mind. noch ein PurchaseOrderPart geben. foreach (var purchaseOrder in dbTransactionData.PurchaseOrderGetAll()) { Assert.True(purchaseOrderIds.Contains(purchaseOrder.GetId())); } // Ein StockExchangeProvider muss mind. ein Kind haben. foreach (var stockExchangeProvider in dbTransactionData.StockExchangeProvidersGetAll()) { Demands childs = aggregator.GetAllChildDemandsOf(stockExchangeProvider); Assert.True(childs.Any()); } // Ein StockExchangeDemand darf nicht beendet und geschlossen sein. foreach (var stockExchangeDemand in dbTransactionData.StockExchangeDemandsGetAll()) { bool isOpen = OpenDemandManager.IsOpen((StockExchangeDemand)stockExchangeDemand); Assert.False(stockExchangeDemand.IsFinished() && isOpen == false); } // Eine ProductionOrder darf nicht beendet sein und für eine ProductionOrder // muss es mind. eine Operation geben. Ids productionOrderIds = new Ids(); Ids operationIds = new Ids(); foreach (var operation in dbTransactionData.ProductionOrderOperationGetAll()) { Id productionOrderId = operation.GetProductionOrderId(); if (productionOrderIds.Contains(productionOrderId) == false) { productionOrderIds.Add(productionOrderId); } operationIds.Add(operation.GetId()); } foreach (var provider in dbTransactionData.ProductionOrderGetAll()) { ProductionOrder productionOrder = (ProductionOrder)provider; Assert.False(productionOrder.DetermineProductionOrderState() .Equals(State.Finished)); Assert.True(productionOrderIds.Contains(productionOrder.GetId())); } // Für jede ProductionOrderBom muss die dazugehörige Operation da sein. foreach (var demand in dbTransactionData.ProductionOrderBomGetAll()) { ProductionOrderBom productionOrderBom = (ProductionOrderBom)demand; operationIds.Contains(productionOrderBom.GetProductionOrderOperationId()); } // Für jeden DemandToProvider und ProviderToDemand müssen die dazugehörigen // Demands und Provider existieren. foreach (var demandToProvider in dbTransactionData.DemandToProviderGetAll()) { Demand demand = dbTransactionData.DemandsGetById(demandToProvider.GetDemandId()); Provider provider = dbTransactionData.ProvidersGetById(demandToProvider.GetProviderId()); Assert.NotNull(demand); Assert.NotNull(provider); } foreach (var providerToDemand in dbTransactionData.ProviderToDemandGetAll()) { Demand demand = dbTransactionData.DemandsGetById(providerToDemand.GetDemandId()); Provider provider = dbTransactionData.ProvidersGetById(providerToDemand.GetProviderId()); Assert.NotNull(demand); Assert.NotNull(provider); } }