SaveOrderGetBackOrderID - accountsIQ/API-Wiki GitHub Wiki
The SaveOrderGetBackOrderID
function saves a modified Order back to the system.
public WSResultStatus SaveOrderGetBackOrderID(string token, Order Order, bool create, out int OrderID)
Public Function SaveOrderGetBackOrderID(ByVal token As String, ByVal Order As Order, ByVal create As Boolean, ByRef OrderID As Integer) As WSResultStatus
Parameter | Type | Description |
---|---|---|
token | String | The session token retrieved during authentication. |
Order | Order | Order to save/update back to the system. |
create | Boolean | Flag indicating whether to create the Order if it does not already exist. If the Order already exist the flag is ignored. If the Order does not already exist and the flag is on, the Order is created. If the Order does not already exist and the flag is off, the Order is not created. |
OrderID | Int32 | This is an out parameter. It will contain the ID of the Order after creation. |
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.OrderdQuantity = 10;
line.NetAmount = 1000M;
line.TaxAmount = line.NetAmount * line.TaxRate;
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.AccountName = "Test integration";
result.Result.ExternalReference = "External reference 2";
result.Result.Lines = new OrderLine[1];
result.Result.Lines[0] = line;
result.Result.ExchangeRate = 1;
int OrderID = 0;
WSResultStatus r = ws.SaveOrderGetBackOrderID(auth, result.Result, true, out OrderID);
Assert.IsTrue(r.Status == OperationStatus.Created);
Assert.IsTrue( OrderID != 0 && OrderID != -1 );
}
Dim ws As New Integration
Dim auth As String = ws.Login(entityID, partnerKey, userKey)
If (Not Me.auth Is Nothing) Then
Dim result As WSResult2OfOrder = Me.ws.GetNewSalesOrder(Me.auth, "TESTINTEGR")
Assert.IsNotNull(result.Result)
Dim line As New OrderLine
line.StockItemID = "STOCKITEM1"
line.StockItemPrice = 100
line.TaxCode = "NT"
line.TaxRate = 0.21
line.StockItemDescription = "From default"
line.StockItemCost = 50
line.OrderdQuantity = 10
line.NetAmount = 1000
line.TaxAmount = (line.NetAmount * line.TaxRate)
line.GrossAmount = (Decimal.op_Increment(line.TaxRate) * line.NetAmount)
line.GLAccountCode = "1000"
line.ActualPrice = 100
line.LocationID = "1"
line.SublocationID = "BIN1"
line.GLAccountCode = "1000"
line.OpeningStockGLAccountCode = "2000"
result.Result.AccountName = "Test integration"
result.Result.ExternalReference = "External reference 2"
result.Result.Lines = New OrderLine() { line }
result.Result.ExchangeRate = 1
Dim OrderID as Integer
Assert.IsTrue((Me.ws.SaveOrder(Me.auth, result.Result, True, OrderID).Status = OperationStatus.Created))
Assert.IsTrue( OrderID <> 0 and OrderID <> -1 )
End If