private void CreateNegativePickList(IDerivation derivation, CustomerShipment shipment, SalesOrderItem orderItem, decimal quantity) { if (this.ExistShipToParty) { var pickList = new PickListBuilder(this.Strategy.Session) .WithCustomerShipmentCorrection(shipment) .WithShipToParty(this.ShipToParty) .WithStore(this.Store) .Build(); pickList.AddPickListItem(new PickListItemBuilder(this.Strategy.Session) .WithInventoryItem(orderItem.ReservedFromNonSerialisedInventoryItem) .WithRequestedQuantity(0 - quantity) .Build()); } }
private void CreatePickList() { if (this.ExistShipmentItems && this.ExistShipToParty) { var pickList = new PickListBuilder(this.Strategy.Session).WithShipToParty(this.ShipToParty).WithStore(this.Store).Build(); foreach (var shipmentItem in this.ShipmentItems .Where(v => v.ShipmentItemState.Equals(new ShipmentItemStates(this.Session()).Created) || v.ShipmentItemState.Equals(new ShipmentItemStates(this.Session()).Picking))) { var quantityIssued = 0M; foreach (ItemIssuance itemIssuance in shipmentItem.ItemIssuancesWhereShipmentItem) { quantityIssued += itemIssuance.Quantity; } var quantityToIssue = shipmentItem.Quantity - quantityIssued; if (quantityToIssue == 0) { return; } var unifiedGood = shipmentItem.Good as UnifiedGood; var nonUnifiedGood = shipmentItem.Good as NonUnifiedGood; var serialized = unifiedGood?.InventoryItemKind.Equals(new InventoryItemKinds(this.Session()).Serialised); var part = unifiedGood ?? nonUnifiedGood?.Part; var facilities = ((InternalOrganisation)this.ShipFromParty).FacilitiesWhereOwner; var inventoryItems = part.InventoryItemsWherePart.Where(v => facilities.Contains(v.Facility)); SerialisedInventoryItem issuedFromSerializedInventoryItem = null; foreach (InventoryItem inventoryItem in shipmentItem.ReservedFromInventoryItems) { // shipment item originates from sales order. Sales order item has only 1 ReservedFromInventoryItem. // Foreach loop wil execute once. var pickListItem = new PickListItemBuilder(this.Strategy.Session) .WithInventoryItem(inventoryItem) .WithQuantity(quantityToIssue) .Build(); new ItemIssuanceBuilder(this.Strategy.Session) .WithInventoryItem(pickListItem.InventoryItem) .WithShipmentItem(shipmentItem) .WithQuantity(pickListItem.Quantity) .WithPickListItem(pickListItem) .Build(); pickList.AddPickListItem(pickListItem); if (serialized.HasValue && serialized.Value) { issuedFromSerializedInventoryItem = (SerialisedInventoryItem)inventoryItem; } } // shipment item is not linked to sales order item if (!shipmentItem.ExistReservedFromInventoryItems) { var quantityLeftToIssue = quantityToIssue; foreach (var inventoryItem in inventoryItems) { if (serialized.HasValue && serialized.Value && quantityLeftToIssue > 0) { var serializedInventoryItem = (SerialisedInventoryItem)inventoryItem; if (serializedInventoryItem.AvailableToPromise == 1) { var pickListItem = new PickListItemBuilder(this.Strategy.Session) .WithInventoryItem(inventoryItem) .WithQuantity(quantityLeftToIssue) .Build(); new ItemIssuanceBuilder(this.Strategy.Session) .WithInventoryItem(inventoryItem) .WithShipmentItem(shipmentItem) .WithQuantity(pickListItem.Quantity) .WithPickListItem(pickListItem) .Build(); pickList.AddPickListItem(pickListItem); quantityLeftToIssue = 0; issuedFromSerializedInventoryItem = serializedInventoryItem; } } else if (quantityLeftToIssue > 0) { var nonSerializedInventoryItem = (NonSerialisedInventoryItem)inventoryItem; var quantity = quantityLeftToIssue > nonSerializedInventoryItem.AvailableToPromise ? nonSerializedInventoryItem.AvailableToPromise : quantityLeftToIssue; if (quantity > 0) { var pickListItem = new PickListItemBuilder(this.Strategy.Session) .WithInventoryItem(inventoryItem) .WithQuantity(quantity) .Build(); new ItemIssuanceBuilder(this.Strategy.Session) .WithInventoryItem(inventoryItem) .WithShipmentItem(shipmentItem) .WithQuantity(pickListItem.Quantity) .WithPickListItem(pickListItem) .Build(); shipmentItem.AddReservedFromInventoryItem(inventoryItem); pickList.AddPickListItem(pickListItem); quantityLeftToIssue -= pickListItem.Quantity; } } } } } } }
private void CreateNegativePickList(IDerivation derivation, CustomerShipment shipment, Allors.Domain.SalesOrderItem orderItem, decimal quantity) { if (this.ExistShipToParty) { var pickList = new PickListBuilder(this.Strategy.Session) .WithCustomerShipmentCorrection(shipment) .WithShipToParty(this.ShipToParty) .WithStore(this.Store) .Build(); pickList.AddPickListItem(new PickListItemBuilder(this.Strategy.Session) .WithInventoryItem(orderItem.ReservedFromInventoryItem) .WithRequestedQuantity(0 - quantity) .Build()); } }