GetNewPurchasesOrder - accountsIQ/API-Wiki GitHub Wiki
The GetNewPurchasesOrder
function creates a new order for a given Supplier account. It fills the order defaulting the information with the Supplier information.
public WSResult2OfOrder GetNewPurchasesOrder(string token, string SupplierCode)
Public Function GetNewPurchasesOrder(ByVal token As String, ByVal SupplierCode As String) As WSResult2OfOrder
Parameter | Type | Description |
---|---|---|
token | String | The session token retrieved during authentication. |
SupplierCode | String | Code of the Supplier to create a new Purchase order for. |
Integration ws = new Integration();
String auth = ws.Login(entityID, partnerKey, userKey);
if (auth != null)
{
WSResult2OfOrder result = ws.GetNewPurchasesOrder(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.GetNewPurchasesOrder(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