public void GivenPurchaseOrder_WhenObjectStateIsOnHold_ThenCheckTransitions() { this.SetIdentity("orderProcessor"); var supplier = new OrganisationBuilder(this.Session).WithName("customer2").Build(); var internalOrganisation = this.InternalOrganisation; new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier).Build(); var order = new PurchaseOrderBuilder(this.Session) .WithTakenViaSupplier(supplier) .Build(); order.Confirm(); this.Session.Derive(); order.Hold(); this.Session.Derive(); Assert.Equal(new PurchaseOrderStates(this.Session).OnHold, order.PurchaseOrderState); var acl = new AccessControlList(order, this.Session.GetUser()); Assert.True(acl.CanExecute(M.PurchaseOrder.Cancel)); Assert.True(acl.CanExecute(M.PurchaseOrder.Continue)); Assert.False(acl.CanExecute(M.PurchaseOrder.Confirm)); Assert.False(acl.CanExecute(M.PurchaseOrder.Reject)); Assert.False(acl.CanExecute(M.PurchaseOrder.Approve)); Assert.False(acl.CanExecute(M.PurchaseOrder.Hold)); }
public void GivenShipmentReceiptForPartWithoutSelectedInventoryItemWhenDerivingThenInventoryItemIsFromDefaultFacility() { var supplier = new OrganisationBuilder(this.Session).WithName("supplier").Build(); new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier).Build(); var part = new NonUnifiedPartBuilder(this.Session) .WithProductIdentification(new PartNumberBuilder(this.Session) .WithIdentification("P1") .WithProductIdentificationType(new ProductIdentificationTypes(this.Session).Part).Build()) .Build(); var order = new PurchaseOrderBuilder(this.Session) .WithTakenViaSupplier(supplier) .WithVatRegime(new VatRegimes(this.Session).Export) .Build(); var item1 = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(1).Build(); order.AddPurchaseOrderItem(item1); this.Session.Derive(); order.Confirm(); this.Session.Derive(); this.Session.Commit(); var shipment = new PurchaseShipmentBuilder(this.Session).WithShipmentMethod(new ShipmentMethods(this.Session).Ground).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.Session).WithPart(part).Build(); shipment.AddShipmentItem(shipmentItem); var receipt = new ShipmentReceiptBuilder(this.Session) .WithQuantityAccepted(1M) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); shipment.AppsComplete(); this.Session.Derive(); this.Session.Commit(); Assert.Equal(new Facilities(this.Session).FindBy(M.Facility.FacilityType, new FacilityTypes(this.Session).Warehouse), receipt.InventoryItem.Facility); Assert.Equal(part.InventoryItemsWherePart[0], receipt.InventoryItem); this.Session.Rollback(); }
public void GivenPurchaseOrder_WhenConfirming_ThenAllValidItemsAreInConfirmedState() { var supplier = new OrganisationBuilder(this.Session).WithName("customer2").Build(); new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier).Build(); var part = new NonUnifiedPartBuilder(this.Session) .WithProductIdentification(new PartNumberBuilder(this.Session) .WithIdentification("1") .WithProductIdentificationType(new ProductIdentificationTypes(this.Session).Part).Build()) .Build(); var order = new PurchaseOrderBuilder(this.Session) .WithTakenViaSupplier(supplier) .WithVatRegime(new VatRegimes(this.Session).Exempt) .Build(); var item1 = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(1).Build(); var item2 = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(2).Build(); var item3 = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(3).Build(); var item4 = new PurchaseOrderItemBuilder(this.Session).WithPart(part).WithQuantityOrdered(4).Build(); order.AddPurchaseOrderItem(item1); order.AddPurchaseOrderItem(item2); order.AddPurchaseOrderItem(item3); order.AddPurchaseOrderItem(item4); this.Session.Derive(); order.Confirm(); this.Session.Derive(); item4.Cancel(); this.Session.Derive(); Assert.Equal(3, order.ValidOrderItems.Count); Assert.Contains(item1, order.ValidOrderItems); Assert.Contains(item2, order.ValidOrderItems); Assert.Contains(item3, order.ValidOrderItems); Assert.Equal(new PurchaseOrderItemStates(this.Session).InProcess, item1.PurchaseOrderItemState); Assert.Equal(new PurchaseOrderItemStates(this.Session).InProcess, item2.PurchaseOrderItemState); Assert.Equal(new PurchaseOrderItemStates(this.Session).InProcess, item3.PurchaseOrderItemState); Assert.Equal(new PurchaseOrderItemStates(this.Session).Cancelled, item4.PurchaseOrderItemState); }
public void GivenShipmentReceiptForGoodWithoutSelectedInventoryItemWhenDerivingThenInventoryItemIsFromDefaultFacility() { var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build(); var good = new GoodBuilder(this.DatabaseSession) .WithName("Good") .WithSku("10101") .WithVatRate(new VatRateBuilder(this.DatabaseSession).WithRate(21).Build()) .WithInventoryItemKind(new InventoryItemKinds(this.DatabaseSession).NonSerialized) .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece) .Build(); var order = new PurchaseOrderBuilder(this.DatabaseSession).WithTakenViaSupplier(supplier).Build(); var item1 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithProduct(good).WithQuantityOrdered(1).Build(); order.AddPurchaseOrderItem(item1); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); order.Confirm(); var shipment = new PurchaseShipmentBuilder(this.DatabaseSession).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.DatabaseSession).WithGood(good).Build(); shipment.AddShipmentItem(shipmentItem); var receipt = new ShipmentReceiptBuilder(this.DatabaseSession) .WithQuantityAccepted(1M) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); shipment.AppsComplete(); Assert.AreEqual(new Warehouses(this.DatabaseSession).FindBy(Warehouses.Meta.Name, "facility"), receipt.InventoryItem.Facility); Assert.AreEqual(good.InventoryItemsWhereGood[0], receipt.InventoryItem); this.DatabaseSession.Rollback(); }
public void GivenShipmentReceiptWhenDerivingThenOrderItemQuantityReceivedIsUpdated() { var supplier = new OrganisationBuilder(this.Session).WithName("supplier").Build(); new SupplierRelationshipBuilder(this.Session).WithSupplier(supplier).Build(); var good1 = new NonUnifiedGoods(this.Session).FindBy(M.Good.Name, "good1"); 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.Confirm(); var shipment = new PurchaseShipmentBuilder(this.Session).WithShipmentMethod(new ShipmentMethods(this.Session).Ground).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.Session).WithGood(good1).Build(); shipment.AddShipmentItem(shipmentItem); new ShipmentReceiptBuilder(this.Session) .WithQuantityAccepted(10) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); shipment.AppsComplete(); this.Session.Derive(); this.Session.Commit(); Assert.Equal(10, item1.QuantityReceived); this.Session.Rollback(); }
public void GivenShipmentReceiptForPartWithoutSelectedInventoryItemWhenDerivingThenInventoryItemIsFromDefaultFacility() { var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build(); var part = new RawMaterialBuilder(this.DatabaseSession) .WithName("RawMaterial") .Build(); var order = new PurchaseOrderBuilder(this.DatabaseSession) .WithTakenViaSupplier(supplier) .WithVatRegime(new VatRegimes(this.DatabaseSession).Export) .Build(); var item1 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithPart(part).WithQuantityOrdered(1).Build(); order.AddPurchaseOrderItem(item1); this.DatabaseSession.Derive(true); order.Confirm(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); var shipment = new PurchaseShipmentBuilder(this.DatabaseSession).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.DatabaseSession).WithPart(part).Build(); shipment.AddShipmentItem(shipmentItem); var receipt = new ShipmentReceiptBuilder(this.DatabaseSession) .WithQuantityAccepted(1M) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); shipment.AppsComplete(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); Assert.AreEqual(new Warehouses(this.DatabaseSession).FindBy(Warehouses.Meta.Name, "facility"), receipt.InventoryItem.Facility); Assert.AreEqual(part.InventoryItemsWherePart[0], receipt.InventoryItem); this.DatabaseSession.Rollback(); }
public void GivenShipmentReceiptWhenDerivingThenOrderItemQuantityReceivedIsUpdated() { var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build(); var good = new GoodBuilder(this.DatabaseSession) .WithName("Good") .WithSku("10101") .WithVatRate(new VatRateBuilder(this.DatabaseSession).WithRate(21).Build()) .WithInventoryItemKind(new InventoryItemKinds(this.DatabaseSession).NonSerialized) .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece) .Build(); var order = new PurchaseOrderBuilder(this.DatabaseSession).WithTakenViaSupplier(supplier).Build(); var item1 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithProduct(good).WithQuantityOrdered(10).Build(); order.AddPurchaseOrderItem(item1); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); order.Confirm(); var shipment = new PurchaseShipmentBuilder(this.DatabaseSession).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.DatabaseSession).WithGood(good).Build(); shipment.AddShipmentItem(shipmentItem); new ShipmentReceiptBuilder(this.DatabaseSession) .WithQuantityAccepted(10) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); shipment.AppsComplete(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); Assert.AreEqual(10, item1.QuantityReceived); this.DatabaseSession.Rollback(); }
public void GivenShipmentReceiptWhenDerivingThenInventoryItemQuantityOnHandIsUpdated() { var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build(); var mechelenAddress = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build(); var shipToMechelen = new PartyContactMechanismBuilder(this.DatabaseSession) .WithContactMechanism(mechelenAddress) .WithContactPurpose(new ContactMechanismPurposes(this.DatabaseSession).ShippingAddress) .WithUseAsDefault(true) .Build(); var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").WithPartyContactMechanism(shipToMechelen).Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(customer).WithInternalOrganisation(internalOrganisation).Build(); var good = new GoodBuilder(this.DatabaseSession) .WithName("Good") .WithSku("10101") .WithVatRate(new VatRateBuilder(this.DatabaseSession).WithRate(21).Build()) .WithInventoryItemKind(new InventoryItemKinds(this.DatabaseSession).NonSerialized) .WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece) .Build(); var inventoryItem = new NonSerializedInventoryItemBuilder(this.DatabaseSession).WithGood(good).Build(); inventoryItem.AddInventoryItemVariance(new InventoryItemVarianceBuilder(this.DatabaseSession).WithQuantity(20).WithReason(new VarianceReasons(this.DatabaseSession).Unknown).Build()); this.DatabaseSession.Derive(true); var order1 = new SalesOrderBuilder(this.DatabaseSession) .WithBillToCustomer(customer) .WithShipToCustomer(customer) .WithDeliveryDate(DateTime.UtcNow) .Build(); var salesItem = new SalesOrderItemBuilder(this.DatabaseSession).WithDescription("item1").WithProduct(good).WithQuantityOrdered(30).WithActualUnitPrice(15).Build(); order1.AddSalesOrderItem(salesItem); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); order1.Confirm(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); var sessionInventoryItem = (NonSerializedInventoryItem)this.DatabaseSession.Instantiate(inventoryItem); var sessionSalesItem = (SalesOrderItem)this.DatabaseSession.Instantiate(salesItem); var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build(); Assert.AreEqual(20, sessionSalesItem.QuantityPendingShipment); Assert.AreEqual(30, sessionSalesItem.QuantityReserved); Assert.AreEqual(10, sessionSalesItem.QuantityShortFalled); var order = new PurchaseOrderBuilder(this.DatabaseSession).WithTakenViaSupplier(supplier).Build(); var item1 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithProduct(good).WithQuantityOrdered(10).Build(); order.AddPurchaseOrderItem(item1); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); order.Confirm(); var shipment = new PurchaseShipmentBuilder(this.DatabaseSession).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.DatabaseSession).WithGood(good).Build(); shipment.AddShipmentItem(shipmentItem); new ShipmentReceiptBuilder(this.DatabaseSession) .WithQuantityAccepted(10) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); shipment.AppsComplete(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); Assert.AreEqual(30, sessionInventoryItem.QuantityOnHand); Assert.AreEqual(30, sessionSalesItem.QuantityPendingShipment); Assert.AreEqual(30, sessionSalesItem.QuantityReserved); Assert.AreEqual(0, sessionSalesItem.QuantityShortFalled); }
public void GivenPurchaseOrder_WhenShipmentIsReceived_ThenCurrenShipmentStatusIsUpdated() { var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build(); var part = new RawMaterialBuilder(this.DatabaseSession).WithName("RawMaterial").Build(); var order = new PurchaseOrderBuilder(this.DatabaseSession) .WithTakenViaSupplier(supplier) .WithBillToPurchaser(internalOrganisation) .WithVatRegime(new VatRegimes(this.DatabaseSession).Exempt) .Build(); var item1 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithPart(part).WithQuantityOrdered(1).Build(); var item2 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithPart(part).WithQuantityOrdered(2).Build(); var item3 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithPart(part).WithQuantityOrdered(3).Build(); order.AddPurchaseOrderItem(item1); order.AddPurchaseOrderItem(item2); order.AddPurchaseOrderItem(item3); this.DatabaseSession.Derive(true); order.Confirm(); this.DatabaseSession.Derive(true); var shipment1 = new PurchaseShipmentBuilder(this.DatabaseSession).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.DatabaseSession).WithPart(part).Build(); shipment1.AddShipmentItem(shipmentItem); new ShipmentReceiptBuilder(this.DatabaseSession) .WithQuantityAccepted(1) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); shipment1.AppsComplete(); this.DatabaseSession.Derive(true); Assert.AreEqual(new PurchaseOrderItemObjectStates(this.DatabaseSession).Received, item1.CurrentShipmentStatus.PurchaseOrderItemObjectState); Assert.AreEqual(new PurchaseOrderObjectStates(this.DatabaseSession).PartiallyReceived, order.CurrentShipmentStatus.PurchaseOrderObjectState); Assert.AreEqual(new PurchaseOrderObjectStates(this.DatabaseSession).InProcess, order.CurrentOrderStatus.PurchaseOrderObjectState); var shipment2 = new PurchaseShipmentBuilder(this.DatabaseSession).WithShipFromParty(supplier).Build(); shipmentItem = new ShipmentItemBuilder(this.DatabaseSession).WithPart(part).Build(); shipment2.AddShipmentItem(shipmentItem); new ShipmentReceiptBuilder(this.DatabaseSession) .WithQuantityAccepted(2) .WithShipmentItem(shipmentItem) .WithOrderItem(item2) .Build(); shipment2.AppsComplete(); this.DatabaseSession.Derive(true); Assert.AreEqual(new PurchaseOrderItemObjectStates(this.DatabaseSession).Received, item2.CurrentShipmentStatus.PurchaseOrderItemObjectState); Assert.AreEqual(new PurchaseOrderObjectStates(this.DatabaseSession).PartiallyReceived, order.CurrentShipmentStatus.PurchaseOrderObjectState); Assert.AreEqual(new PurchaseOrderObjectStates(this.DatabaseSession).InProcess, order.CurrentOrderStatus.PurchaseOrderObjectState); var shipment3 = new PurchaseShipmentBuilder(this.DatabaseSession).WithShipFromParty(supplier).Build(); shipmentItem = new ShipmentItemBuilder(this.DatabaseSession).WithPart(part).Build(); shipment3.AddShipmentItem(shipmentItem); new ShipmentReceiptBuilder(this.DatabaseSession) .WithQuantityAccepted(3) .WithShipmentItem(shipmentItem) .WithOrderItem(item3) .Build(); shipment3.AppsComplete(); this.DatabaseSession.Derive(true); Assert.AreEqual(new PurchaseOrderItemObjectStates(this.DatabaseSession).Received, item3.CurrentShipmentStatus.PurchaseOrderItemObjectState); Assert.AreEqual(new PurchaseOrderObjectStates(this.DatabaseSession).Received, order.CurrentShipmentStatus.PurchaseOrderObjectState); Assert.AreEqual(new PurchaseOrderObjectStates(this.DatabaseSession).Completed, order.CurrentOrderStatus.PurchaseOrderObjectState); }
public void GivenPurchaseOrder_WhenOrdering_ThenAllValidItemsAreInInProcessState() { var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build(); var part = new RawMaterialBuilder(this.DatabaseSession).WithName("RawMaterial").Build(); var order = new PurchaseOrderBuilder(this.DatabaseSession) .WithTakenViaSupplier(supplier) .WithVatRegime(new VatRegimes(this.DatabaseSession).Exempt) .Build(); var item1 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithPart(part).WithQuantityOrdered(1).Build(); var item2 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithPart(part).WithQuantityOrdered(2).Build(); var item3 = new PurchaseOrderItemBuilder(this.DatabaseSession).WithPart(part).WithQuantityOrdered(3).Build(); order.AddPurchaseOrderItem(item1); order.AddPurchaseOrderItem(item2); order.AddPurchaseOrderItem(item3); this.DatabaseSession.Derive(true); order.Confirm(); this.DatabaseSession.Derive(true); Assert.AreEqual(3, order.ValidOrderItems.Count); Assert.Contains(item1, order.ValidOrderItems); Assert.Contains(item2, order.ValidOrderItems); Assert.Contains(item3, order.ValidOrderItems); Assert.AreEqual(new PurchaseOrderItemObjectStates(this.DatabaseSession).InProcess, item1.CurrentObjectState); Assert.AreEqual(new PurchaseOrderItemObjectStates(this.DatabaseSession).InProcess, item2.CurrentObjectState); Assert.AreEqual(new PurchaseOrderItemObjectStates(this.DatabaseSession).InProcess, item3.CurrentObjectState); }
public void GivenPurchaseOrder_WhenObjectStateIsOnHold_ThenCheckTransitions() { Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("orderProcessor", "Forms"), new string[0]); var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); new SupplierRelationshipBuilder(this.DatabaseSession).WithSupplier(supplier).WithInternalOrganisation(internalOrganisation).Build(); var order = new PurchaseOrderBuilder(this.DatabaseSession) .WithTakenViaSupplier(supplier) .WithBillToPurchaser(internalOrganisation) .Build(); order.Confirm(); this.DatabaseSession.Derive(true); order.Hold(); this.DatabaseSession.Derive(true); Assert.AreEqual(new PurchaseOrderObjectStates(this.DatabaseSession).OnHold, order.CurrentObjectState); var acl = new AccessControlList(order, new Users(this.DatabaseSession).GetCurrentUser()); Assert.IsTrue(acl.CanExecute(PurchaseOrders.Meta.Cancel)); Assert.IsTrue(acl.CanExecute(PurchaseOrders.Meta.Continue)); Assert.IsFalse(acl.CanExecute(PurchaseOrders.Meta.Confirm)); Assert.IsFalse(acl.CanExecute(PurchaseOrders.Meta.Reject)); Assert.IsFalse(acl.CanExecute(PurchaseOrders.Meta.Approve)); Assert.IsFalse(acl.CanExecute(PurchaseOrders.Meta.Hold)); }
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).WithGeographicBoundary(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(DateTime.UtcNow).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(DateTime.UtcNow) .Build(); var salesItem = new SalesOrderItemBuilder(this.Session).WithDescription("item1").WithProduct(good1).WithQuantityOrdered(30).WithActualUnitPrice(15).Build(); order1.AddSalesOrderItem(salesItem); this.Session.Derive(); this.Session.Commit(); order1.Confirm(); this.Session.Derive(); this.Session.Commit(); 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.Confirm(); var shipment = new PurchaseShipmentBuilder(this.Session).WithShipmentMethod(new ShipmentMethods(this.Session).Ground).WithShipFromParty(supplier).Build(); var shipmentItem = new ShipmentItemBuilder(this.Session).WithGood(good1).Build(); shipment.AddShipmentItem(shipmentItem); new ShipmentReceiptBuilder(this.Session) .WithQuantityAccepted(10) .WithShipmentItem(shipmentItem) .WithOrderItem(item1) .Build(); this.Session.Derive(); this.Session.Commit(); shipment.AppsComplete(); 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); }