private void UpdateShipment(ShipmentCommands.ReceiveItem c, ICreateOrMergePatchOrRemoveShipmentReceipt updateReceipt) { var updateShipment = new MergePatchShipment(); updateShipment.ShipmentReceiptCommands.Add(updateReceipt); updateShipment.ShipmentId = c.ShipmentId; updateShipment.Version = c.Version; updateShipment.CommandId = c.CommandId; updateShipment.RequesterId = c.RequesterId; When(updateShipment); }
public override void When(ShipmentCommands.ReceiveItem c) { var shipment = AssertShipmentStatus(c.ShipmentId, StatusItemIds.PurchShipShipped); var shipmentItem = shipment.ShipmentItems.Get(c.ShipmentItemSeqId); if (shipmentItem == null) { throw new ArgumentException(String.Format("CANNOT get shipment item. ShipmentItemSeqId: {0}", c.ShipmentItemSeqId)); } if (shipmentItem.Quantity != c.AcceptedQuantity + c.RejectedQuantity) { throw new ArgumentException(String.Format("shipmentItem.Quantity != c.AcceptedQuantity + c.RejectedQuantity. {0} != {1} + {2}" , shipmentItem.Quantity, c.AcceptedQuantity, c.RejectedQuantity)); } // //////////////////////////////////////////////////// ICreateOrMergePatchOrRemoveShipmentReceipt updateReceipt = CreateOrUpdateShipmentReceipt(c, shipment, shipmentItem); // //////////////////////////////////////////////////// UpdateShipment(c, updateReceipt); }
private ICreateOrMergePatchOrRemoveShipmentReceipt CreateOrUpdateShipmentReceipt(ShipmentCommands.ReceiveItem c, IShipmentState shipment, IShipmentItemState shipmentItem) { ICreateOrMergePatchOrRemoveShipmentReceipt updateReceipt = null; var receiptSeqId = c.ShipmentItemSeqId; var receipt = shipment.ShipmentReceipts.Get(receiptSeqId, false, true); if (receipt == null) { updateReceipt = new CreateShipmentReceipt(); } else { updateReceipt = new MergePatchShipmentReceipt(); } var prdState = GetProductState(shipmentItem.ProductId); string attrSetInstId = AttributeSetInstanceUtils.CreateAttributeSetInstance(AttributeSetService, AttributeSetInstanceApplicationService, prdState.AttributeSetId, c.AttributeSetInstance); if (_log.IsDebugEnabled) { _log.Debug("Create attribute set instance, id: " + attrSetInstId); } updateReceipt.AttributeSetInstanceId = attrSetInstId; updateReceipt.ReceiptSeqId = receiptSeqId; updateReceipt.ShipmentItemSeqId = shipmentItem.ShipmentItemSeqId; updateReceipt.ProductId = shipmentItem.ProductId; updateReceipt.AcceptedQuantity = c.AcceptedQuantity; updateReceipt.RejectedQuantity = c.RejectedQuantity; updateReceipt.DamagedQuantity = c.DamagedQuantity; updateReceipt.DamageStatusIds = c.DamageStatusIds; updateReceipt.DamageReasonId = c.DamageReasonId; updateReceipt.ReceivedBy = c.RequesterId; return(updateReceipt); }