Beispiel #1
0
        public void GivenPackingingContent_WhenDeriving_ThenAssertQuantityPackedIsNotGreaterThanQuantityShipped()
        {
            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var shipToMechelen  = new PartyContactMechanismBuilder(this.Session)
                                  .WithContactMechanism(mechelenAddress)
                                  .WithContactPurpose(new ContactMechanismPurposes(this.Session).ShippingAddress)
                                  .WithUseAsDefault(true)
                                  .Build();

            var customer = new PersonBuilder(this.Session).WithLastName("customer").WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).Build();

            var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1");
            var good2 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good2");

            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100).WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good1.Part).Build();
            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100).WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good2.Part).Build();

            this.Session.Derive();

            var order = new SalesOrderBuilder(this.Session)
                        .WithBillToCustomer(customer)
                        .WithShipToCustomer(customer)
                        .Build();

            var item1 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(1).WithAssignedUnitPrice(15).Build();
            var item2 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(2).WithAssignedUnitPrice(15).Build();
            var item3 = new SalesOrderItemBuilder(this.Session).WithProduct(good2).WithQuantityOrdered(5).WithAssignedUnitPrice(15).Build();

            order.AddSalesOrderItem(item1);
            order.AddSalesOrderItem(item2);
            order.AddSalesOrderItem(item3);

            this.Session.Derive();

            order.SetReadyForPosting();
            this.Session.Derive();

            order.Post();
            this.Session.Derive();

            order.Accept();
            this.Session.Derive();

            var shipment = (CustomerShipment)mechelenAddress.ShipmentsWhereShipToAddress[0];

            var package = new ShipmentPackageBuilder(this.Session).Build();

            package.AddPackagingContent(new PackagingContentBuilder(this.Session)
                                        .WithShipmentItem(shipment.ShipmentItems[0])
                                        .WithQuantity(shipment.ShipmentItems[0].Quantity + 1)
                                        .Build());

            Assert.True(this.Session.Derive(false).HasErrors);
        }
Beispiel #2
0
        public SalesOrderItemInventoryAssignmentTests()
        {
            this.reasons = new InventoryTransactionReasons(this.Session);

            var customer             = new PersonBuilder(this.Session).WithFirstName("Koen").Build();
            var internalOrganisation = this.InternalOrganisation;

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).Build();

            var mechelen = new CityBuilder(this.Session).WithName("Mechelen").Build();

            this.part = new NonUnifiedPartBuilder(this.Session)
                        .WithProductIdentification(new PartNumberBuilder(this.Session)
                                                   .WithIdentification("1")
                                                   .WithProductIdentificationType(new ProductIdentificationTypes(this.Session).Part).Build())
                        .WithInventoryItemKind(new InventoryItemKinds(this.Session).NonSerialised)
                        .Build();

            var good = new NonUnifiedGoodBuilder(this.Session)
                       .WithProductIdentification(new ProductNumberBuilder(this.Session)
                                                  .WithIdentification("10101")
                                                  .WithProductIdentificationType(new ProductIdentificationTypes(this.Session).Good).Build())
                       .WithName("good")
                       .WithPart(this.part)
                       .WithUnitOfMeasure(new UnitsOfMeasure(this.Session).Piece)
                       .WithVatRegime(new VatRegimes(this.Session).BelgiumStandard)
                       .Build();

            this.Session.Derive();

            new InventoryItemTransactionBuilder(this.Session)
            .WithPart(this.part)
            .WithReason(new InventoryTransactionReasons(this.Session).IncomingShipment)
            .WithQuantity(11)
            .Build();

            this.Session.Derive();

            var salesOrder = new SalesOrderBuilder(this.Session)
                             .WithTakenBy(this.InternalOrganisation)
                             .WithShipToCustomer(customer)
                             .WithAssignedShipToAddress(new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build())
                             .WithAssignedBillToContactMechanism(new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build())
                             .Build();

            this.salesOrderItem = new SalesOrderItemBuilder(this.Session)
                                  .WithProduct(good)
                                  .WithQuantityOrdered(3)
                                  .WithAssignedUnitPrice(5)
                                  .Build();

            salesOrder.AddSalesOrderItem(this.salesOrderItem);

            this.Session.Derive();

            salesOrder.SetReadyForPosting();
            this.Session.Derive();

            salesOrder.Post();
            this.Session.Derive();

            salesOrder.Accept();
            this.Session.Derive();

            this.Session.Commit();
        }
        public void GivenShipmentReceiptWhenDerivingThenInventoryItemQuantityOnHandIsUpdated()
        {
            var store = this.Session.Extent <Store>().First;

            store.IsImmediatelyPicked = false;

            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var shipToMechelen  = new PartyContactMechanismBuilder(this.Session)
                                  .WithContactMechanism(mechelenAddress)
                                  .WithContactPurpose(new ContactMechanismPurposes(this.Session).ShippingAddress)
                                  .WithUseAsDefault(true)
                                  .Build();

            var customer = new PersonBuilder(this.Session).WithLastName("customer").WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).Build();

            var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1");

            new InventoryItemTransactionBuilder(this.Session).WithQuantity(20).WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good1.Part).Build();

            this.Session.Derive();

            var inventoryItem = good1.Part.InventoryItemsWherePart.First;

            var order1 = new SalesOrderBuilder(this.Session)
                         .WithBillToCustomer(customer)
                         .WithShipToCustomer(customer)
                         .WithDeliveryDate(this.Session.Now())
                         .Build();

            var salesItem = new SalesOrderItemBuilder(this.Session).WithDescription("item1").WithProduct(good1).WithQuantityOrdered(30).WithAssignedUnitPrice(15).Build();

            order1.AddSalesOrderItem(salesItem);

            this.Session.Derive();
            this.Session.Commit();

            order1.SetReadyForPosting();

            this.Session.Derive();

            order1.Post();
            this.Session.Derive();

            order1.Accept();
            this.Session.Derive();

            var sessionInventoryItem = (NonSerialisedInventoryItem)this.Session.Instantiate(inventoryItem);
            var sessionSalesItem     = (SalesOrderItem)this.Session.Instantiate(salesItem);

            var supplier = new OrganisationBuilder(this.Session).WithName("supplier").Build();

            new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier).Build();

            Assert.Equal(20, sessionSalesItem.QuantityPendingShipment);
            Assert.Equal(30, sessionSalesItem.QuantityReserved);
            Assert.Equal(10, sessionSalesItem.QuantityShortFalled);

            var order = new PurchaseOrderBuilder(this.Session).WithTakenViaSupplier(supplier).Build();

            var item1 = new PurchaseOrderItemBuilder(this.Session).WithPart(good1.Part).WithQuantityOrdered(10).Build();

            order.AddPurchaseOrderItem(item1);

            this.Session.Derive();
            this.Session.Commit();

            order.SetReadyForProcessing();

            order.OrderedBy.IsAutomaticallyReceived = true;
            order.QuickReceive();

            this.Session.Derive();
            this.Session.Commit();

            Assert.Equal(30, sessionInventoryItem.QuantityOnHand);

            Assert.Equal(30, sessionSalesItem.QuantityPendingShipment);
            Assert.Equal(30, sessionSalesItem.QuantityReserved);
            Assert.Equal(0, sessionSalesItem.QuantityShortFalled);
        }
Beispiel #4
0
        public void GivenPackingingContent_WhenDerived_ThenShipmentItemsQuantityPackedIsSet()
        {
            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var shipToMechelen  = new PartyContactMechanismBuilder(this.Session)
                                  .WithContactMechanism(mechelenAddress)
                                  .WithContactPurpose(new ContactMechanismPurposes(this.Session).ShippingAddress)
                                  .WithUseAsDefault(true)
                                  .Build();

            var customer = new PersonBuilder(this.Session).WithLastName("customer").WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).Build();

            var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1");
            var good2 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good2");

            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100).WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good1.Part).Build();
            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100).WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good1.Part).Build();

            this.Session.Derive();

            var order = new SalesOrderBuilder(this.Session)
                        .WithBillToCustomer(customer)
                        .WithShipToCustomer(customer)
                        .Build();

            var item1 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(1).WithAssignedUnitPrice(15).Build();
            var item2 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(2).WithAssignedUnitPrice(15).Build();
            var item3 = new SalesOrderItemBuilder(this.Session).WithProduct(good2).WithQuantityOrdered(5).WithAssignedUnitPrice(15).Build();

            order.AddSalesOrderItem(item1);
            order.AddSalesOrderItem(item2);
            order.AddSalesOrderItem(item3);

            this.Session.Derive();

            order.SetReadyForPosting();
            this.Session.Derive();

            order.Post();
            this.Session.Derive();

            order.Accept();
            this.Session.Derive();

            var shipment = (CustomerShipment)mechelenAddress.ShipmentsWhereShipToAddress[0];

            shipment.Pick();
            this.Session.Derive();

            var pickList = shipment.ShipmentItems[0].ItemIssuancesWhereShipmentItem[0].PickListItem.PickListWherePickListItem;

            pickList.Picker = this.OrderProcessor;
            pickList.SetPicked();

            var package = new ShipmentPackageBuilder(this.Session).Build();

            foreach (ShipmentItem shipmentItem in shipment.ShipmentItems)
            {
                package.AddPackagingContent(new PackagingContentBuilder(this.Session).WithShipmentItem(shipmentItem).WithQuantity(shipmentItem.Quantity).Build());
            }

            this.Session.Derive();

            shipment.Ship();
            this.Session.Derive();

            foreach (ShipmentItem shipmentItem in shipment.ShipmentItems)
            {
                Assert.Equal(shipmentItem.QuantityShipped, shipmentItem.Quantity);
            }
        }
Beispiel #5
0
        public void GivenNonSerialisedNonUnifiedPart_WhenPurchased_ThenAverageCostIsCalculated()
        {
            this.InternalOrganisation.IsAutomaticallyReceived = true;

            var secondFacility = new FacilityBuilder(this.Session)
                                 .WithFacilityType(new FacilityTypes(this.Session).Warehouse)
                                 .WithName("second facility")
                                 .WithOwner(this.InternalOrganisation)
                                 .Build();

            var supplier = this.InternalOrganisation.ActiveSuppliers.First;
            var customer = this.InternalOrganisation.ActiveCustomers.First;

            var part = new NonUnifiedPartBuilder(this.Session).WithNonSerialisedDefaults(this.InternalOrganisation).Build();
            var good = new NonUnifiedGoodBuilder(this.Session)
                       .WithName(part.Name)
                       .WithPart(part)
                       .WithVatRate(new VatRates(this.Session).Zero)
                       .Build();

            this.Session.Derive();

            var purchaseOrder1 = new PurchaseOrderBuilder(this.Session)
                                 .WithTakenViaSupplier(supplier)
                                 .WithDeliveryDate(this.Session.Now())
                                 .Build();

            this.Session.Derive();

            // Beginning inventory: 150 items at 8 euro received in 2 facilities
            var purchaseItem = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(100).WithAssignedUnitPrice(8M).Build();

            purchaseOrder1.AddPurchaseOrderItem(purchaseItem);

            this.Session.Derive();

            purchaseOrder1.SetReadyForProcessing();
            this.Session.Derive();

            purchaseOrder1.Send();
            this.Session.Derive();

            purchaseItem.QuickReceive();
            this.Session.Derive();

            var purchaseOrder2 = new PurchaseOrderBuilder(this.Session)
                                 .WithTakenViaSupplier(supplier)
                                 .WithFacility(secondFacility)
                                 .WithDeliveryDate(this.Session.Now())
                                 .Build();

            this.Session.Derive();

            // Beginning inventory: 150 items at 8 euro
            purchaseItem = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(50).WithAssignedUnitPrice(8M).Build();
            purchaseOrder2.AddPurchaseOrderItem(purchaseItem);

            this.Session.Derive();

            purchaseOrder2.SetReadyForProcessing();
            this.Session.Derive();

            purchaseOrder2.Send();
            this.Session.Derive();

            purchaseItem.QuickReceive();
            this.Session.Derive();

            Assert.Equal(150, part.QuantityOnHand);
            Assert.Equal(8, part.PartWeightedAverage.AverageCost);

            purchaseOrder1.Revise();
            this.Session.Derive();

            // Purchase: 75 items at 8.1 euro
            purchaseItem = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(75).WithAssignedUnitPrice(8.1M).Build();
            purchaseOrder1.AddPurchaseOrderItem(purchaseItem);

            this.Session.Derive();

            purchaseOrder1.SetReadyForProcessing();
            this.Session.Derive();

            purchaseOrder1.Send();
            this.Session.Derive();

            purchaseItem.QuickReceive();
            this.Session.Derive();

            Assert.Equal(225, part.QuantityOnHand);
            Assert.Equal(8.03M, part.PartWeightedAverage.AverageCost);

            var salesOrder = new SalesOrderBuilder(this.Session)
                             .WithTakenBy(this.InternalOrganisation)
                             .WithShipToCustomer(customer)
                             .Build();

            this.Session.Derive();

            // Sell 50 items for 20 euro
            var salesItem1 = new SalesOrderItemBuilder(this.Session).WithProduct(good).WithQuantityOrdered(50).WithAssignedUnitPrice(20M).Build();

            salesOrder.AddSalesOrderItem(salesItem1);

            this.Session.Derive();

            salesOrder.SetReadyForPosting();
            this.Session.Derive();

            salesOrder.Post();
            this.Session.Derive();

            salesOrder.Accept();
            this.Session.Derive();

            salesOrder.Ship();
            this.Session.Derive();

            var customerShipment = salesItem1.OrderShipmentsWhereOrderItem.First.ShipmentItem.ShipmentWhereShipmentItem as CustomerShipment;

            customerShipment.Pick();
            this.Session.Derive();

            customer.PickListsWhereShipToParty.First(v => v.PickListState.Equals(new PickListStates(this.Session).Created)).SetPicked();

            var package = new ShipmentPackageBuilder(this.Session).Build();

            customerShipment.AddShipmentPackage(package);

            foreach (ShipmentItem shipmentItem in customerShipment.ShipmentItems)
            {
                package.AddPackagingContent(new PackagingContentBuilder(this.Session).WithShipmentItem(shipmentItem).WithQuantity(shipmentItem.Quantity).Build());
            }

            this.Session.Derive();

            customerShipment.Ship();
            this.Session.Derive();

            Assert.Equal(175, part.QuantityOnHand);
            Assert.Equal(8.03M, part.PartWeightedAverage.AverageCost);
            Assert.Equal(401.5M, salesItem1.CostOfGoodsSold);

            // Again Sell 50 items for 20 euro
            salesOrder.Revise();
            this.Session.Derive();

            var salesItem2 = new SalesOrderItemBuilder(this.Session).WithProduct(good).WithQuantityOrdered(50).WithAssignedUnitPrice(20M).Build();

            salesOrder.AddSalesOrderItem(salesItem2);

            this.Session.Derive();

            salesOrder.SetReadyForPosting();
            this.Session.Derive();

            salesOrder.Post();
            this.Session.Derive();

            salesOrder.Accept();
            this.Session.Derive();

            salesOrder.Ship();
            this.Session.Derive();

            var customerShipment2 = salesItem2.OrderShipmentsWhereOrderItem.First.ShipmentItem.ShipmentWhereShipmentItem as CustomerShipment;

            customerShipment2.Pick();
            this.Session.Derive();

            customer.PickListsWhereShipToParty.First(v => v.PickListState.Equals(new PickListStates(this.Session).Created)).SetPicked();

            var package2 = new ShipmentPackageBuilder(this.Session).Build();

            customerShipment2.AddShipmentPackage(package2);

            foreach (ShipmentItem shipmentItem in customerShipment2.ShipmentItems)
            {
                package.AddPackagingContent(new PackagingContentBuilder(this.Session).WithShipmentItem(shipmentItem).WithQuantity(shipmentItem.Quantity).Build());
            }

            this.Session.Derive();

            customerShipment2.Ship();
            this.Session.Derive();

            Assert.Equal(125, part.QuantityOnHand);
            Assert.Equal(8.03M, part.PartWeightedAverage.AverageCost);
            Assert.Equal(401.5M, salesItem1.CostOfGoodsSold);

            // Purchase: 50 items at 8.25 euro
            purchaseOrder1.Revise();
            this.Session.Derive();

            purchaseItem = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(50).WithAssignedUnitPrice(8.25M).Build();
            purchaseOrder1.AddPurchaseOrderItem(purchaseItem);

            this.Session.Derive();

            purchaseOrder1.SetReadyForProcessing();
            this.Session.Derive();

            purchaseOrder1.Send();
            this.Session.Derive();

            purchaseItem.QuickReceive();
            this.Session.Derive();

            Assert.Equal(175, part.QuantityOnHand);
            Assert.Equal(8.09M, part.PartWeightedAverage.AverageCost);

            // Use 65 items in a workorder
            var workEffort = new WorkTaskBuilder(this.Session).WithName("Activity").WithCustomer(customer).WithTakenBy(this.InternalOrganisation).Build();

            this.Session.Derive(true);

            var inventoryAssignment = new WorkEffortInventoryAssignmentBuilder(this.Session)
                                      .WithAssignment(workEffort)
                                      .WithInventoryItem(part.InventoryItemsWherePart.First)
                                      .WithQuantity(65)
                                      .Build();

            this.Session.Derive(true);

            Assert.Equal(110, part.QuantityOnHand);
            Assert.Equal(8.09M, part.PartWeightedAverage.AverageCost);
            Assert.Equal(525.85M, inventoryAssignment.CostOfGoodsSold);

            // Cancel workeffort inventory assignment
            inventoryAssignment.Delete();

            this.Session.Derive(true);

            Assert.Equal(175, part.QuantityOnHand);
            Assert.Equal(8.09M, part.PartWeightedAverage.AverageCost);

            // Use 35 items in a workorder
            inventoryAssignment = new WorkEffortInventoryAssignmentBuilder(this.Session)
                                  .WithAssignment(workEffort)
                                  .WithInventoryItem(part.InventoryItemsWherePart.First)
                                  .WithQuantity(35)
                                  .Build();

            this.Session.Derive(true);

            this.Session.Derive(true);

            Assert.Equal(140, part.QuantityOnHand);
            Assert.Equal(8.09M, part.PartWeightedAverage.AverageCost);
            Assert.Equal(283.15M, inventoryAssignment.CostOfGoodsSold);

            // Use 30 items in a workorder form second facility
            inventoryAssignment = new WorkEffortInventoryAssignmentBuilder(this.Session)
                                  .WithAssignment(workEffort)
                                  .WithInventoryItem(part.InventoryItemsWherePart.First(v => v.Facility.Equals(secondFacility)))
                                  .WithQuantity(30)
                                  .Build();

            this.Session.Derive(true);

            Assert.Equal(110, part.QuantityOnHand);
            Assert.Equal(8.09M, part.PartWeightedAverage.AverageCost);
            Assert.Equal(242.7M, inventoryAssignment.CostOfGoodsSold);

            // Purchase: 90 items at 8.35 euro
            var purchaseOrder3 = new PurchaseOrderBuilder(this.Session)
                                 .WithTakenViaSupplier(supplier)
                                 .WithDeliveryDate(this.Session.Now())
                                 .Build();

            this.Session.Derive();

            purchaseItem = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(90).WithAssignedUnitPrice(8.35M).Build();
            purchaseOrder3.AddPurchaseOrderItem(purchaseItem);

            this.Session.Derive();

            purchaseOrder3.SetReadyForProcessing();
            this.Session.Derive();

            purchaseOrder3.Send();
            this.Session.Derive();

            purchaseOrder3.QuickReceive();
            this.Session.Derive();

            // Purchase: 50 items at 8.45 euro
            var purchaseOrder4 = new PurchaseOrderBuilder(this.Session)
                                 .WithTakenViaSupplier(supplier)
                                 .WithDeliveryDate(this.Session.Now())
                                 .Build();

            this.Session.Derive();

            purchaseItem = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(50).WithAssignedUnitPrice(8.45M).Build();
            purchaseOrder4.AddPurchaseOrderItem(purchaseItem);

            this.Session.Derive();

            purchaseOrder4.SetReadyForProcessing();
            this.Session.Derive();

            purchaseOrder4.Send();
            this.Session.Derive();

            purchaseOrder4.QuickReceive();
            this.Session.Derive();

            Assert.Equal(250, part.QuantityOnHand);
            Assert.Equal(8.26M, part.PartWeightedAverage.AverageCost);

            // Ship 10 items to customer (without sales order)
            var outgoingShipment = new CustomerShipmentBuilder(this.Session)
                                   .WithShipToParty(customer)
                                   .WithShipToAddress(customer.ShippingAddress)
                                   .WithShipmentMethod(new ShipmentMethods(this.Session).Ground)
                                   .Build();

            this.Session.Derive(true);

            var outgoingItem = new ShipmentItemBuilder(this.Session).WithGood(good).WithQuantity(10).Build();

            outgoingShipment.AddShipmentItem(outgoingItem);

            this.Session.Derive(true);

            outgoingShipment.Pick();
            this.Session.Derive();

            customer.PickListsWhereShipToParty.First(v => v.PickListState.Equals(new PickListStates(this.Session).Created)).SetPicked();

            package = new ShipmentPackageBuilder(this.Session).Build();
            customerShipment2.AddShipmentPackage(package);

            foreach (ShipmentItem shipmentItem in outgoingShipment.ShipmentItems)
            {
                package.AddPackagingContent(new PackagingContentBuilder(this.Session).WithShipmentItem(shipmentItem).WithQuantity(shipmentItem.Quantity).Build());
            }

            this.Session.Derive();

            outgoingShipment.Ship();
            this.Session.Derive();

            Assert.Equal(240, part.QuantityOnHand);
            Assert.Equal(8.26M, part.PartWeightedAverage.AverageCost);

            // Receive 10 items at 8.55 from supplier (without purchase order)
            var incomingShipment = new PurchaseShipmentBuilder(this.Session)
                                   .WithShipmentMethod(new ShipmentMethods(this.Session).Ground)
                                   .WithShipFromParty(supplier)
                                   .Build();

            this.Session.Derive();

            var incomingItem = new ShipmentItemBuilder(this.Session).WithPart(part).WithQuantity(10).WithUnitPurchasePrice(8.55M).Build();

            incomingShipment.AddShipmentItem(incomingItem);

            this.Session.Derive();

            incomingShipment.Receive();
            this.Session.Derive();

            Assert.Equal(250, part.QuantityOnHand);
            Assert.Equal(8.27M, part.PartWeightedAverage.AverageCost);

            // Receive 100 items at 7.9 from supplier (without purchase order)
            incomingShipment = new PurchaseShipmentBuilder(this.Session)
                               .WithShipmentMethod(new ShipmentMethods(this.Session).Ground)
                               .WithShipFromParty(supplier)
                               .Build();

            this.Session.Derive();

            incomingItem = new ShipmentItemBuilder(this.Session).WithPart(part).WithQuantity(100).WithUnitPurchasePrice(7.9M).Build();
            incomingShipment.AddShipmentItem(incomingItem);

            this.Session.Derive();

            incomingShipment.Receive();
            this.Session.Derive();

            Assert.Equal(350, part.QuantityOnHand);
            Assert.Equal(8.17M, part.PartWeightedAverage.AverageCost);

            // Ship all items to customer (without sales order)
            outgoingShipment = new CustomerShipmentBuilder(this.Session)
                               .WithShipToParty(customer)
                               .WithShipFromFacility(part.DefaultFacility)
                               .WithShipToAddress(customer.ShippingAddress)
                               .WithShipmentMethod(new ShipmentMethods(this.Session).Ground)
                               .Build();

            this.Session.Derive(true);

            outgoingItem = new ShipmentItemBuilder(this.Session).WithGood(good).WithQuantity(330).Build();
            outgoingShipment.AddShipmentItem(outgoingItem);

            this.Session.Derive(true);

            outgoingShipment.Pick();
            this.Session.Derive();

            customer.PickListsWhereShipToParty.First(v => v.PickListState.Equals(new PickListStates(this.Session).Created)).SetPicked();

            package = new ShipmentPackageBuilder(this.Session).Build();
            customerShipment2.AddShipmentPackage(package);

            foreach (ShipmentItem shipmentItem in outgoingShipment.ShipmentItems)
            {
                package.AddPackagingContent(new PackagingContentBuilder(this.Session).WithShipmentItem(shipmentItem).WithQuantity(shipmentItem.Quantity).Build());
            }

            this.Session.Derive();

            outgoingShipment.Ship();
            this.Session.Derive();

            // Ship all items to customer (without sales order)
            outgoingShipment = new CustomerShipmentBuilder(this.Session)
                               .WithShipToParty(customer)
                               .WithShipFromFacility(secondFacility)
                               .WithShipToAddress(customer.ShippingAddress)
                               .WithShipmentMethod(new ShipmentMethods(this.Session).Ground)
                               .Build();

            this.Session.Derive(true);

            outgoingItem = new ShipmentItemBuilder(this.Session).WithGood(good).WithQuantity(20).Build();
            outgoingShipment.AddShipmentItem(outgoingItem);

            this.Session.Derive(true);

            outgoingShipment.Pick();
            this.Session.Derive();

            customer.PickListsWhereShipToParty.First(v => v.PickListState.Equals(new PickListStates(this.Session).Created)).SetPicked();

            package = new ShipmentPackageBuilder(this.Session).Build();
            customerShipment2.AddShipmentPackage(package);

            foreach (ShipmentItem shipmentItem in outgoingShipment.ShipmentItems)
            {
                package.AddPackagingContent(new PackagingContentBuilder(this.Session).WithShipmentItem(shipmentItem).WithQuantity(shipmentItem.Quantity).Build());
            }

            this.Session.Derive();

            outgoingShipment.Ship();
            this.Session.Derive();

            Assert.Equal(0, part.QuantityOnHand);
            Assert.Equal(8.17M, part.PartWeightedAverage.AverageCost);

            purchaseOrder1.Revise();
            this.Session.Derive();

            // Purchase 150 items at 8 euro
            purchaseItem = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(150).WithAssignedUnitPrice(8M).Build();
            purchaseOrder1.AddPurchaseOrderItem(purchaseItem);

            this.Session.Derive();

            purchaseOrder1.SetReadyForProcessing();
            this.Session.Derive();

            purchaseOrder1.Send();
            this.Session.Derive();

            purchaseItem.QuickReceive();
            this.Session.Derive();

            Assert.Equal(150, part.QuantityOnHand);
            Assert.Equal(8, part.PartWeightedAverage.AverageCost);
        }
Beispiel #6
0
        public void GivenCustomerBuyingFromDifferentStores_WhenShipping_ThenPickListIsCreatedForEachStore()
        {
            var store1 = new Stores(this.Session).FindBy(M.Store.Name, "store");

            var store2 = new StoreBuilder(this.Session).WithName("second store")
                         .WithDefaultFacility(new Facilities(this.Session).Extent().First)
                         .WithDefaultShipmentMethod(new ShipmentMethods(this.Session).Ground)
                         .WithDefaultCarrier(new Carriers(this.Session).Fedex)
                         .WithSalesOrderNumberPrefix("")
                         .WithOutgoingShipmentNumberPrefix("")
                         .WithIsImmediatelyPacked(true)
                         .Build();

            var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1");

            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100).WithReason(new InventoryTransactionReasons(this.Session).PhysicalCount).WithPart(good1.Part).Build();

            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var shipToMechelen  = new PartyContactMechanismBuilder(this.Session)
                                  .WithContactMechanism(mechelenAddress)
                                  .WithContactPurpose(new ContactMechanismPurposes(this.Session).ShippingAddress)
                                  .WithUseAsDefault(true)
                                  .Build();

            var customer = new PersonBuilder(this.Session).WithLastName("customer").WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer).Build();

            this.Session.Derive(true);

            var order1 = new SalesOrderBuilder(this.Session)
                         .WithStore(store1)
                         .WithBillToCustomer(customer)
                         .WithAssignedBillToContactMechanism(mechelenAddress)
                         .WithShipToCustomer(customer)
                         .Build();

            var order1Item = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(1).WithAssignedUnitPrice(15).Build();

            order1.AddSalesOrderItem(order1Item);

            this.Session.Derive(true);

            order1.SetReadyForPosting();
            this.Session.Derive(true);

            order1.Post();
            this.Session.Derive();

            order1.Accept();
            this.Session.Derive();

            Assert.Single(customer.ShipmentsWhereShipToParty);

            var order2 = new SalesOrderBuilder(this.Session)
                         .WithStore(store1)
                         .WithBillToCustomer(customer)
                         .WithShipToCustomer(customer)
                         .Build();

            var order2Item = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(2).WithAssignedUnitPrice(15).Build();

            order2.AddSalesOrderItem(order2Item);

            this.Session.Derive(true);

            order2.SetReadyForPosting();
            this.Session.Derive(true);

            order2.Post();
            this.Session.Derive();

            order2.Accept();
            this.Session.Derive();

            Assert.Single(customer.ShipmentsWhereShipToParty);

            var store1Shipment = (CustomerShipment)mechelenAddress.ShipmentsWhereShipToAddress.First(v => v.Store.Equals(store1));

            store1Shipment.Pick();
            this.Session.Derive();

            var order3 = new SalesOrderBuilder(this.Session)
                         .WithStore(store2)
                         .WithBillToCustomer(customer)
                         .WithShipToCustomer(customer)
                         .Build();

            var order3Item = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(5).WithAssignedUnitPrice(15).Build();

            order3.AddSalesOrderItem(order3Item);

            this.Session.Derive(true);

            order3.SetReadyForPosting();
            this.Session.Derive(true);

            order3.Post();
            this.Session.Derive();

            order3.Accept();
            this.Session.Derive();

            var store2Shipment = (CustomerShipment)mechelenAddress.ShipmentsWhereShipToAddress.First(v => v.Store.Equals(store2));

            store2Shipment.Pick();
            this.Session.Derive();

            var store1PickList = customer.PickListsWhereShipToParty.FirstOrDefault(v => v.Store.Equals(store1));
            var store2PickList = customer.PickListsWhereShipToParty.FirstOrDefault(v => v.Store.Equals(store2));

            Assert.Equal(2, customer.PickListsWhereShipToParty.Count);
            Assert.NotNull(store1PickList);
            Assert.Equal(3, store1PickList.PickListItems[0].Quantity);
            Assert.NotNull(store2PickList);
            Assert.Equal(5, store2PickList.PickListItems[0].Quantity);
        }
Beispiel #7
0
        public void GivenMultipleOrders_WhenCombinedPickListIsPicked_ThenSingleShipmentIsPickedState()
        {
            var store = this.Session.Extent <Store>().First;

            store.IsImmediatelyPicked = false;

            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen)
                                  .WithAddress1("Haverwerf").Build();
            var shipToMechelen = new PartyContactMechanismBuilder(this.Session)
                                 .WithContactMechanism(mechelenAddress)
                                 .WithContactPurpose(new ContactMechanismPurposes(this.Session).ShippingAddress)
                                 .WithUseAsDefault(true)
                                 .Build();

            var supplier = new OrganisationBuilder(this.Session).WithName("supplier").Build();
            var customer = new PersonBuilder(this.Session).WithLastName("person1")
                           .WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer)
            .Build();

            new SupplierRelationshipBuilder(this.Session)
            .WithSupplier(supplier)
            .WithFromDate(this.Session.Now())
            .Build();

            var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1");
            var good2 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good2");

            new SupplierOfferingBuilder(this.Session)
            .WithPart(good1.Part)
            .WithFromDate(this.Session.Now())
            .WithUnitOfMeasure(new UnitsOfMeasure(this.Session).Piece)
            .WithCurrency(new Currencies(this.Session).FindBy(M.Currency.IsoCode, "EUR"))
            .WithPrice(7)
            .WithSupplier(supplier)
            .Build();

            new SupplierOfferingBuilder(this.Session)
            .WithPart(good2.Part)
            .WithFromDate(this.Session.Now())
            .WithUnitOfMeasure(new UnitsOfMeasure(this.Session).Piece)
            .WithCurrency(new Currencies(this.Session).FindBy(M.Currency.IsoCode, "EUR"))
            .WithPrice(7)
            .WithSupplier(supplier)
            .Build();

            this.Session.Derive();

            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100)
            .WithReason(new InventoryTransactionReasons(this.Session).PhysicalCount).WithPart(good1.Part).Build();
            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100)
            .WithReason(new InventoryTransactionReasons(this.Session).PhysicalCount).WithPart(good2.Part).Build();

            this.Session.Derive();

            var order1 = new SalesOrderBuilder(this.Session)
                         .WithBillToCustomer(customer)
                         .WithShipToCustomer(customer)
                         .Build();

            var item1 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(1)
                        .WithAssignedUnitPrice(15).Build();
            var item2 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(2)
                        .WithAssignedUnitPrice(15).Build();
            var item3 = new SalesOrderItemBuilder(this.Session).WithProduct(good2).WithQuantityOrdered(5)
                        .WithAssignedUnitPrice(15).Build();

            order1.AddSalesOrderItem(item1);
            order1.AddSalesOrderItem(item2);
            order1.AddSalesOrderItem(item3);

            this.Session.Derive();

            order1.SetReadyForPosting();
            this.Session.Derive();

            order1.Post();
            this.Session.Derive();

            order1.Accept();
            this.Session.Derive();

            var order2 = new SalesOrderBuilder(this.Session)
                         .WithBillToCustomer(customer)
                         .WithShipToCustomer(customer)
                         .Build();

            var itema = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(1)
                        .WithAssignedUnitPrice(15).Build();
            var itemb = new SalesOrderItemBuilder(this.Session).WithProduct(good2).WithQuantityOrdered(1)
                        .WithAssignedUnitPrice(15).Build();

            order2.AddSalesOrderItem(itema);
            order2.AddSalesOrderItem(itemb);

            this.Session.Derive();

            order2.SetReadyForPosting();
            this.Session.Derive();

            order2.Post();
            this.Session.Derive();

            order2.Accept();
            this.Session.Derive();

            var shipment = (CustomerShipment)mechelenAddress.ShipmentsWhereShipToAddress[0];

            shipment.Pick();
            this.Session.Derive();

            var pickList = good1.Part.InventoryItemsWherePart[0].PickListItemsWhereInventoryItem[0]
                           .PickListWherePickListItem;

            pickList.Picker = this.OrderProcessor;

            pickList.SetPicked();

            this.Session.Derive();

            Assert.Single(customer.ShipmentsWhereShipToParty);

            var customerShipment = (CustomerShipment)customer.ShipmentsWhereShipToParty.First;

            Assert.Equal(new ShipmentStates(this.Session).Picked, customerShipment.ShipmentState);
        }
Beispiel #8
0
        public void GivenPickList_WhenPicked_ThenInventoryIsAdjustedAndOrderItemsQuantityPickedIsSet()
        {
            var store = this.Session.Extent <Store>().First;

            store.IsImmediatelyPicked = false;

            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen)
                                  .WithAddress1("Haverwerf 15").Build();
            var shipToMechelen = new PartyContactMechanismBuilder(this.Session)
                                 .WithContactMechanism(mechelenAddress)
                                 .WithContactPurpose(new ContactMechanismPurposes(this.Session).ShippingAddress)
                                 .WithUseAsDefault(true)
                                 .Build();

            var supplier = new OrganisationBuilder(this.Session).WithName("supplier").Build();
            var customer = new PersonBuilder(this.Session).WithLastName("person1")
                           .WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer)
            .Build();

            new SupplierRelationshipBuilder(this.Session)
            .WithSupplier(supplier)
            .WithFromDate(this.Session.Now())
            .Build();

            var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1");
            var good2 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good2");

            new SupplierOfferingBuilder(this.Session)
            .WithPart(good1.Part)
            .WithSupplier(supplier)
            .WithFromDate(this.Session.Now())
            .WithUnitOfMeasure(new UnitsOfMeasure(this.Session).Piece)
            .WithCurrency(new Currencies(this.Session).FindBy(M.Currency.IsoCode, "EUR"))
            .WithPrice(7)
            .Build();

            this.Session.Derive();

            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100)
            .WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good1.Part).Build();
            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100)
            .WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good2.Part).Build();

            this.Session.Derive();

            var good1Inventory = (NonSerialisedInventoryItem)good1.Part.InventoryItemsWherePart.First;
            var good2Inventory = (NonSerialisedInventoryItem)good2.Part.InventoryItemsWherePart.First;

            var colorWhite = new ColourBuilder(this.Session)
                             .WithName("white")
                             .Build();
            var extraLarge = new SizeBuilder(this.Session)
                             .WithName("Extra large")
                             .Build();

            var order = new SalesOrderBuilder(this.Session)
                        .WithBillToCustomer(customer)
                        .WithShipToCustomer(customer)
                        .WithAssignedVatRegime(new VatRegimes(this.Session).ZeroRated)
                        .Build();

            var item1 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(1).WithAssignedUnitPrice(15).Build();

            var item2 = new SalesOrderItemBuilder(this.Session)
                        .WithInvoiceItemType(new InvoiceItemTypes(this.Session).ProductFeatureItem)
                        .WithProductFeature(colorWhite).WithQuantityOrdered(1).WithAssignedUnitPrice(15).Build();

            var item3 = new SalesOrderItemBuilder(this.Session)
                        .WithInvoiceItemType(new InvoiceItemTypes(this.Session).ProductFeatureItem)
                        .WithProductFeature(extraLarge).WithQuantityOrdered(1).WithAssignedUnitPrice(15).Build();

            item1.AddOrderedWithFeature(item2);
            item1.AddOrderedWithFeature(item3);

            var item4 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(2).WithAssignedUnitPrice(15).Build();

            var item5 = new SalesOrderItemBuilder(this.Session).WithProduct(good2).WithQuantityOrdered(5).WithAssignedUnitPrice(15).Build();

            order.AddSalesOrderItem(item1);
            order.AddSalesOrderItem(item2);
            order.AddSalesOrderItem(item3);
            order.AddSalesOrderItem(item4);
            order.AddSalesOrderItem(item5);

            this.Session.Derive();

            order.SetReadyForPosting();
            this.Session.Derive();

            order.Post();
            this.Session.Derive();

            order.Accept();
            this.Session.Derive();

            var shipment = (CustomerShipment)mechelenAddress.ShipmentsWhereShipToAddress[0];

            shipment.Pick();
            this.Session.Derive();

            var pickList = good1.Part.InventoryItemsWherePart[0].PickListItemsWhereInventoryItem[0].PickListWherePickListItem;

            pickList.Picker = this.OrderProcessor;

            //// item5: only 4 out of 5 are actually picked
            foreach (PickListItem pickListItem in pickList.PickListItems)
            {
                if (pickListItem.Quantity == 5)
                {
                    pickListItem.QuantityPicked = 4;
                }
            }

            pickList.SetPicked();

            this.Session.Derive();

            //// all orderitems have same physical finished good, so there is only one picklist item.
            Assert.Equal(1, item1.QuantityReserved);
            Assert.Equal(0, item1.QuantityRequestsShipping);
            Assert.Equal(2, item4.QuantityReserved);
            Assert.Equal(0, item4.QuantityRequestsShipping);
            Assert.Equal(5, item5.QuantityReserved);
            Assert.Equal(0, item5.QuantityRequestsShipping);
            Assert.Equal(97, good1Inventory.QuantityOnHand);
            Assert.Equal(0, good1Inventory.QuantityCommittedOut);
            Assert.Equal(96, good2Inventory.QuantityOnHand);
            Assert.Equal(0, good2Inventory.QuantityCommittedOut);
        }
Beispiel #9
0
        public void GivenPickList_WhenActualQuantityPickedIsLess_ThenShipmentItemQuantityIsAdjusted()
        {
            var store = this.Session.Extent <Store>().First;

            store.IsImmediatelyPicked = false;

            var mechelen        = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var mechelenAddress = new PostalAddressBuilder(this.Session).WithPostalAddressBoundary(mechelen)
                                  .WithAddress1("Haverwerf 15").Build();
            var shipToMechelen = new PartyContactMechanismBuilder(this.Session)
                                 .WithContactMechanism(mechelenAddress)
                                 .WithContactPurpose(new ContactMechanismPurposes(this.Session).ShippingAddress)
                                 .WithUseAsDefault(true)
                                 .Build();

            var supplier = new OrganisationBuilder(this.Session).WithName("supplier").Build();
            var customer = new PersonBuilder(this.Session).WithLastName("person1")
                           .WithPartyContactMechanism(shipToMechelen).Build();

            new CustomerRelationshipBuilder(this.Session).WithFromDate(this.Session.Now()).WithCustomer(customer)
            .Build();

            new SupplierRelationshipBuilder(this.Session)
            .WithSupplier(supplier)
            .WithFromDate(this.Session.Now())
            .Build();

            var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1");
            var good2 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good2");

            new SupplierOfferingBuilder(this.Session)
            .WithPart(good1.Part)
            .WithSupplier(supplier)
            .WithFromDate(this.Session.Now())
            .WithUnitOfMeasure(new UnitsOfMeasure(this.Session).Piece)
            .WithPrice(7)
            .WithCurrency(new Currencies(this.Session).FindBy(M.Currency.IsoCode, "EUR"))
            .Build();

            new SupplierOfferingBuilder(this.Session)
            .WithPart(good2.Part)
            .WithSupplier(supplier)
            .WithFromDate(this.Session.Now())
            .WithUnitOfMeasure(new UnitsOfMeasure(this.Session).Piece)
            .WithPrice(7)
            .WithCurrency(new Currencies(this.Session).FindBy(M.Currency.IsoCode, "EUR"))
            .Build();

            this.Session.Derive();

            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100)
            .WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good1.Part).Build();
            new InventoryItemTransactionBuilder(this.Session).WithQuantity(100)
            .WithReason(new InventoryTransactionReasons(this.Session).Unknown).WithPart(good2.Part).Build();

            this.Session.Derive();

            var order = new SalesOrderBuilder(this.Session)
                        .WithBillToCustomer(customer)
                        .WithShipToCustomer(customer)
                        .Build();

            var item1 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(1).WithAssignedUnitPrice(15).Build();
            var item2 = new SalesOrderItemBuilder(this.Session).WithProduct(good1).WithQuantityOrdered(2).WithAssignedUnitPrice(15).Build();
            var item3 = new SalesOrderItemBuilder(this.Session).WithProduct(good2).WithQuantityOrdered(5).WithAssignedUnitPrice(15).Build();

            order.AddSalesOrderItem(item1);
            order.AddSalesOrderItem(item2);
            order.AddSalesOrderItem(item3);

            this.Session.Derive();

            order.SetReadyForPosting();
            this.Session.Derive();

            order.Post();
            this.Session.Derive();

            order.Accept();
            this.Session.Derive();

            var shipment = (CustomerShipment)mechelenAddress.ShipmentsWhereShipToAddress[0];

            shipment.Pick();
            this.Session.Derive();

            var pickList = good1.Part.InventoryItemsWherePart[0].PickListItemsWhereInventoryItem[0].PickListWherePickListItem;

            pickList.Picker = this.OrderProcessor;

            //// item3: only 4 out of 5 are actually picked
            PickListItem adjustedPicklistItem = null;

            foreach (PickListItem pickListItem in pickList.PickListItems)
            {
                if (pickListItem.Quantity == 5)
                {
                    adjustedPicklistItem = pickListItem;
                }
            }

            var itemIssuance = adjustedPicklistItem.ItemIssuancesWherePickListItem[0];
            var shipmentItem = adjustedPicklistItem.ItemIssuancesWherePickListItem[0].ShipmentItem;

            Assert.Equal(2, shipment.ShipmentItems.Count);
            Assert.Equal(5, itemIssuance.Quantity);
            Assert.Equal(5, shipmentItem.Quantity);
            Assert.Equal(5, item3.QuantityPendingShipment);

            adjustedPicklistItem.QuantityPicked = 4;

            pickList.SetPicked();
            this.Session.Derive();

            // When SalesOrder is derived 1 quantity is requested for shipping (because inventory is available and quantity ordered (5) is greater then quantity pending shipment (4)
            // A new shipment item is created with quantity 1 and QuantityPendingShipment remains 5
            Assert.Equal(4, itemIssuance.Quantity);
            Assert.Equal(4, shipmentItem.Quantity);
            Assert.Equal(3, shipment.ShipmentItems.Count);
            Assert.Equal(1, shipment.ShipmentItems.Last().Quantity);
            Assert.Equal(5, item3.QuantityPendingShipment);
        }