本文整理汇总了C#中SalesOrderItemBuilder.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# SalesOrderItemBuilder.Cancel方法的具体用法?C# SalesOrderItemBuilder.Cancel怎么用?C# SalesOrderItemBuilder.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SalesOrderItemBuilder
的用法示例。
在下文中一共展示了SalesOrderItemBuilder.Cancel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InventoryItemVarianceBuilder
public void GivenOrderItemWithPendingShipmentAndAssignedPickList_WhenOrderItemIsCancelled_ThenNegativePickListIsCreatedAndShipmentItemIsDeleted()
{
this.InstantiateObjects(this.DatabaseSession);
var inventoryItem = (NonSerializedInventoryItem)this.part.InventoryItemsWherePart.First;
inventoryItem.AddInventoryItemVariance(new InventoryItemVarianceBuilder(this.DatabaseSession).WithQuantity(10).WithReason(new VarianceReasons(this.DatabaseSession).Unknown).Build());
this.DatabaseSession.Derive(true);
var item1 = new SalesOrderItemBuilder(this.DatabaseSession)
.WithProduct(this.good)
.WithQuantityOrdered(3)
.WithActualUnitPrice(5)
.Build();
var item2 = new SalesOrderItemBuilder(this.DatabaseSession)
.WithProduct(this.good)
.WithQuantityOrdered(2)
.WithActualUnitPrice(5)
.Build();
this.order.AddSalesOrderItem(item1);
this.order.AddSalesOrderItem(item2);
this.DatabaseSession.Derive(true);
this.order.Confirm();
this.DatabaseSession.Derive(true);
var shipment = (CustomerShipment)this.order.ShipToCustomer.ShipmentsWhereShipToParty.First;
Assert.AreEqual(5, shipment.ShipmentItems[0].Quantity);
var pickList = shipment.ShipmentItems[0].ItemIssuancesWhereShipmentItem[0].PickListItem.PickListWherePickListItem;
Assert.AreEqual(5, pickList.PickListItems[0].RequestedQuantity);
pickList.Picker = new Persons(this.DatabaseSession).FindBy(Persons.Meta.LastName, "orderProcessor");
this.DatabaseSession.Derive(true);
item1.Cancel();
this.DatabaseSession.Derive(true);
var negativePickList = this.order.ShipToCustomer.PickListsWhereShipToParty[1];
Assert.AreEqual(1, shipment.ShipmentItems.Count);
Assert.AreEqual(2, shipment.ShipmentItems[0].Quantity);
Assert.AreEqual(5, pickList.PickListItems[0].RequestedQuantity);
Assert.AreEqual(-3, negativePickList.PickListItems[0].RequestedQuantity);
}
示例2: SalesOrderItemBuilder
public void GivenConfirmedOrderItemForGood_WhenOrderItemIsCancelled_ThenNonSerializedInventoryQuantitiesAreReleased()
{
this.InstantiateObjects(this.DatabaseSession);
var item = new SalesOrderItemBuilder(this.DatabaseSession)
.WithProduct(this.good)
.WithQuantityOrdered(3)
.WithActualUnitPrice(5)
.Build();
this.order.AddSalesOrderItem(item);
this.DatabaseSession.Derive(true);
this.order.Confirm();
this.DatabaseSession.Derive(true);
Assert.AreEqual(item.QuantityOrdered, item.ReservedFromInventoryItem.QuantityCommittedOut);
Assert.AreEqual(0, item.ReservedFromInventoryItem.AvailableToPromise);
var previous = item.ReservedFromInventoryItem;
this.DatabaseSession.Derive(true);
item.Cancel();
this.DatabaseSession.Derive(true);
Assert.AreEqual(0, previous.QuantityCommittedOut);
Assert.AreEqual(0, previous.AvailableToPromise);
}
示例3: GivenOrderItem_WhenObjectStateIsCancelled_ThenItemMayNotBeCancelledOrRejectedOrDeleted
public void GivenOrderItem_WhenObjectStateIsCancelled_ThenItemMayNotBeCancelledOrRejectedOrDeleted()
{
var administrator = new PersonBuilder(this.DatabaseSession).WithFirstName("Koen").WithUserName("admin").Build();
var administrators = new UserGroups(this.DatabaseSession).Administrators;
administrators.AddMember(administrator);
this.DatabaseSession.Derive(true);
this.DatabaseSession.Commit();
this.InstantiateObjects(this.DatabaseSession);
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("admin", "Forms"), new string[0]);
var item = new SalesOrderItemBuilder(this.DatabaseSession)
.WithProduct(this.good)
.WithQuantityOrdered(3)
.WithActualUnitPrice(5)
.Build();
this.order.AddSalesOrderItem(item);
this.DatabaseSession.Derive(true);
item.Cancel();
this.DatabaseSession.Derive(true);
Assert.AreEqual(new SalesOrderItemObjectStates(this.DatabaseSession).Cancelled, item.CurrentObjectState);
var acl = new AccessControlList(item, new Users(this.DatabaseSession).GetCurrentUser());
Assert.IsFalse(acl.CanExecute(SalesOrderItems.Meta.Cancel));
Assert.IsFalse(acl.CanExecute(SalesOrderItems.Meta.Reject));
Assert.IsFalse(acl.CanExecute(SalesOrderItems.Meta.Delete));
}
示例4: GivenSalesOrder_WhenConfirming_ThenAllValidItemsAreInConfirmedState
public void GivenSalesOrder_WhenConfirming_ThenAllValidItemsAreInConfirmedState()
{
var billToCustomer = new PersonBuilder(this.DatabaseSession).WithLastName("person1").Build();
var shipToCustomer = new PersonBuilder(this.DatabaseSession).WithLastName("person2").Build();
var internalOrganisation = Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation;
new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(billToCustomer).WithInternalOrganisation(internalOrganisation).Build();
new CustomerRelationshipBuilder(this.DatabaseSession).WithFromDate(DateTime.UtcNow).WithCustomer(shipToCustomer).WithInternalOrganisation(internalOrganisation).Build();
var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
var shipToContactMechanism = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
var vatRate21 = new VatRateBuilder(this.DatabaseSession).WithRate(21).Build();
var part1 = new FinishedGoodBuilder(this.DatabaseSession).WithName("part1").Build();
var part2 = new FinishedGoodBuilder(this.DatabaseSession).WithName("part2").Build();
var good1 = new GoodBuilder(this.DatabaseSession)
.WithSku("10101")
.WithVatRate(vatRate21)
.WithName("good1")
.WithFinishedGood(part1)
.WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece)
.Build();
var good2 = new GoodBuilder(this.DatabaseSession)
.WithSku("10102")
.WithVatRate(vatRate21)
.WithName("good1")
.WithFinishedGood(part2)
.WithUnitOfMeasure(new UnitsOfMeasure(this.DatabaseSession).Piece)
.Build();
this.DatabaseSession.Derive(true);
var order = new SalesOrderBuilder(this.DatabaseSession)
.WithBillToCustomer(billToCustomer)
.WithShipToCustomer(shipToCustomer)
.WithShipToAddress(shipToContactMechanism)
.Build();
var item1 = new SalesOrderItemBuilder(this.DatabaseSession).WithProduct(good1).WithQuantityOrdered(1).WithActualUnitPrice(15).Build();
var item2 = new SalesOrderItemBuilder(this.DatabaseSession).WithProduct(good1).WithQuantityOrdered(2).WithActualUnitPrice(15).Build();
var item3 = new SalesOrderItemBuilder(this.DatabaseSession).WithProduct(good2).WithQuantityOrdered(3).WithActualUnitPrice(15).Build();
var item4 = new SalesOrderItemBuilder(this.DatabaseSession).WithProduct(good2).WithQuantityOrdered(4).WithActualUnitPrice(15).Build();
order.AddSalesOrderItem(item1);
order.AddSalesOrderItem(item2);
order.AddSalesOrderItem(item3);
order.AddSalesOrderItem(item4);
order.Confirm();
this.DatabaseSession.Derive(true);
item4.Cancel();
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 SalesOrderItemObjectStates(this.DatabaseSession).InProcess, item1.CurrentObjectState);
Assert.AreEqual(new SalesOrderItemObjectStates(this.DatabaseSession).InProcess, item2.CurrentObjectState);
Assert.AreEqual(new SalesOrderItemObjectStates(this.DatabaseSession).InProcess, item3.CurrentObjectState);
Assert.AreEqual(new SalesOrderItemObjectStates(this.DatabaseSession).Cancelled, item4.CurrentObjectState);
}