private NebimV3.Shipments.RetailSale CreateRetailSaleShipment(NebimV3.Orders.RetailSale order, string description, DateTime?shipmentDate) { if (order == null) { throw new Exception("order can not be null for shipment"); } if (!order.ExistsInDB()) { throw new Exception("order does not exists for the shipment. order description:" + order.Description); } order.Load(); NebimV3.Shipments.RetailSale shipment = new NebimV3.Shipments.RetailSale(); // Required fields shipment.IsOrderBase = true; shipment.ShippingDate = shipmentDate.HasValue ? shipmentDate.Value : NebimV3.ApplicationCommon.V3Application.Context.Today; // Or --> shipment.ShippingDate = new DateTime(2011, 12, 05) shipment.ShippingTime = shipmentDate.HasValue ? shipmentDate.Value.TimeOfDay : NebimV3.ApplicationCommon.V3Application.Context.Time; // (Optional) shipment.OfficeCode = _nebimIntegrationSettings.API_OfficeCode; shipment.WarehouseCode = _nebimIntegrationSettings.API_WarehouseCode; shipment.CustomerCode = order.CustomerCode; //shipment.Customer.CurrAccDefault.Load(); shipment.ShippingPostalAddressID = order.ShippingPostalAddressID; shipment.BillingPostalAddressID = order.BillingPostalAddressID; // Optional shipment.Description = description; return(shipment); }
public void CreateShipment(string orderDescription) { try { using (JoinedSqlTransactionScope sqlTrans = new JoinedSqlTransactionScope()) { var OrderHeaderID = FindOrderHeaderIDByDescription(orderDescription); if (!OrderHeaderID.HasValue) { throw new Exception("CreateShipment=> B2C order id:" + orderDescription + "can not find order from B2C id"); } NebimV3.Orders.RetailSale order = new NebimV3.Orders.RetailSale(OrderHeaderID.Value); //order.get NebimV3.Shipments.RetailSale newShipment = CreateRetailSaleShipment(order, "", null); CreateRetailSaleShipmentLinesFromOrderLines(order, newShipment); newShipment.SaveAsCompleted(); sqlTrans.Commit(); } } catch (Exception ex) { NebimV3.Library.V3Exception v3Ex = ex as NebimV3.Library.V3Exception; if (v3Ex != null) { throw new Exception(NebimV3.ApplicationCommon.ExceptionHandlerBase.Default.GetExceptionMessage(v3Ex), ex); } throw; } }
//creates the shipment event => stock inventory update private void CreateShipment(NebimV3.Orders.RetailSale order) { try { using (JoinedSqlTransactionScope sqlTrans = new JoinedSqlTransactionScope()) { NebimV3.Shipments.RetailSale newShipment = CreateRetailSaleShipment(order, "", null); CreateRetailSaleShipmentLinesFromOrderLines(order, newShipment); newShipment.SaveAsCompleted(); sqlTrans.Commit(); } } catch (Exception ex) { NebimV3.Library.V3Exception v3Ex = ex as NebimV3.Library.V3Exception; if (v3Ex != null) { throw new Exception(NebimV3.ApplicationCommon.ExceptionHandlerBase.Default.GetExceptionMessage(v3Ex), ex); } throw; } }
private void CreateRetailSaleShipmentLinesFromOrderLines(NebimV3.Orders.RetailSale order, NebimV3.Shipments.RetailSale ST) { foreach (NebimV3.Orders.RetailSaleLine orderLine in order.Lines) { NebimV3.Shipments.RetailSaleLine line = (NebimV3.Shipments.RetailSaleLine)(ST.TransactionFactory.CreateLine(ST)); // Required line.OrderLineID = orderLine.LineID; line.Qty1 = orderLine.Qty1; // Or may be less. line.ItemCode = orderLine.ItemCode; // Optional line.LineDescription = orderLine.LineDescription; line.Save(); } }