-
Notifications
You must be signed in to change notification settings - Fork 2
GetNewSalesOrder
PatrickLane edited this page Oct 30, 2014
·
1 revision
The GetNewSalesOrder
function creates a new order for a given customer account. It fills the order defaulting the information with the customer information.
public WSResult2OfOrder GetNewSalesOrder(string token, string customerCode)
Public Function GetNewSalesOrder(ByVal token As String, ByVal customerCode As String) As WSResult2OfOrder
Parameter | Type | Description |
---|---|---|
token | String | The session token retrieved during authentication. |
customerCode | String | Code of the customer to create a new sales order for. |
Integration ws = new Integration();
String auth = ws.Login(entityID, partnerKey, userKey);
if (auth != null)
{
WSResult2OfOrder result = ws.GetNewSalesOrder(auth, "TESTINTEGR");
Assert.IsNotNull(result.Result);
OrderLine line = new OrderLine();
line.StockItemID = "STOCKITEM1";
line.StockItemPrice = 100M;
line.TaxCode = "NT";
line.TaxRate = 0.21M;
line.StockItemDescription = "From default";
line.StockItemCost = 50M;
line.OrderedQuantity = 10;
line.NetAmount = 1000M;
line.GrossAmount = (1 + line.TaxRate) * line.NetAmount;
line.GLAccountCode = "1000";
line.ActualPrice = 100M;
line.LocationID = "1";
line.SublocationID = "BIN1";
line.GLAccountCode = "1000";
line.OpeningStockGLAccountCode = "2000";
result.Result.ExternalReference = "Example order 1";
result.Result.Lines = new OrderLine[1];
result.Result.Lines[0] = line;
WSResultStatus r = ws.SaveOrder(auth, result.Result, true);
Assert.IsTrue(r.Status == OperationStatus.Created);
WSResult2OfArrayOfOrder rr = ws.GetOrdersByExternalReference(auth, "Example order 1");
result.Result = rr.Result[rr.Result.Length - 1];
line = result.Result.Lines[0];
WSResult2OfDeliveryLine dl = ws.GetNewDeliveryLine(auth, line);
Assert.IsNotNull(dl); Assert.IsTrue(dl.Status == OperationStatus.Success);
dl.Result.DeliveredQuantity = 5;
dl.Result.DeliveryReference = "150";
WSResultStatus dle = ws.DeliverOrderLines(auth, result.Result, new DeliveryLine[] { dl.Result });
Assert.IsTrue(dle.Status == OperationStatus.Created);
}
Dim ws As New Integration
Dim auth As String = ws.Login(entityID, partnerKey, userKey)
If (Not auth Is Nothing) Then
WSResult2OfOrder result = this.ws.GetNewSalesOrder(this.auth, "TESTINTEGR");
Assert.IsNotNull(result.Result);
OrderLine line = new OrderLine();
line.StockItemID = "STOCKITEM1";
line.StockItemPrice = 100M;
line.TaxCode = "NT";
line.TaxRate = 0.21M;
line.StockItemDescription = "From default";
line.StockItemCost = 50M;
line.OrderedQuantity = 10M;
line.NetAmount = 1000M;
line.GrossAmount = decimal.op_Increment(line.TaxRate) * line.NetAmount;
line.GLAccountCode = "1000";
line.ActualPrice = 100M;
line.LocationID = "1";
line.SublocationID = "BIN1";
line.GLAccountCode = "1000";
line.OpeningStockGLAccountCode = "2000";
result.Result.ExternalReference = "Example order 1";
result.Result.Lines = new OrderLine[] { line };
Assert.IsTrue(this.ws.SaveOrder(this.auth, result.Result, true).Status == OperationStatus.Created);
WSResult2OfArrayOfOrder rr = this.ws.GetOrdersByExternalReference(this.auth, "Example order 1");
result.Result = rr.Result[rr.Result.Length - 1];
line = result.Result.Lines[0];
WSResult2OfDeliveryLine dl = this.ws.GetNewDeliveryLine(this.auth, line);
Assert.IsNotNull(dl);
Assert.IsTrue(dl.Status == OperationStatus.Success);
dl.Result.DeliveredQuantity = 5M;
dl.Result.DeliveryReference = "150";
Assert.IsTrue(this.ws.DeliverOrderLines(this.auth, result.Result, new DeliveryLine[] { dl.Result }).Status == OperationStatus.Created);
End If