CreateInvoicesGetBackInvoiceIDs - accountsIQ/API-Wiki GitHub Wiki
The CreateInvoicesGetBackInvoiceIDs
function creates an array of given invoices in the system.
Note
:
This method is to be used for performance reasons when creating a set of new invoice records in bulk. Creating invoices in a bulk limits the amount of time spent in network traffic and SOAP XML serialization/deserialization. The attainable throughput is about 100 times the throughput of SaveInvoiceGetBackInvoiceID function.
public WSResult2OfArrayOfWSResultStatus CreateInvoicesGetBackInvoiceIDs(string token, Invoice[] invoices, out int[] invoiceIDs)
Public Function CreateInvoicesGetBackInvoiceIDs(ByVal token As String, ByVal invoices As Invoice(), ByRef invoiceIDs As Integer()) As WSResult2OfArrayOfWSResultStatus
Parameter | Type | Description |
---|---|---|
token | String | The session token retrieved during authentication. |
invoices | Invoice[] | Invoice to save/update back to the system. |
invoiceIDs | Int32[] | This is an out parameter. It will contain the IDs of the invoices after creation. |
Integration ws = new Integration();
String auth = ws.Login(entityID, partnerKey, userKey);
if (auth != null)
{
int i;
string[] customerCodes = new string[1000];
for (i = 0; i < customerCodes.Length; i++)
{
customerCodes[i] = "TESTINTEGR";
}
DateTime sdt = DateTime.Now;
WSResult2OfArrayOfInvoice results = this.ws.GetNewSalesInvoices(this.auth, customerCodes);
for (i = 0; i < 1000; i++)
{
InvoiceLine line = new InvoiceLine();
line.StockItemID = "STOCKITEM";
line.StockItemPrice = 100M;
line.TaxCode = "NT";
line.TaxRate = 0.21M;
line.StockItemDescription = "From default";
line.StockItemCost = 50M;
line.InvoicedQuantity = 10M;
line.NetAmount = 1000M;
line.TaxAmount = line.NetAmount * line.TaxRate;
line.GrossAmount = decimal.op_Increment(line.TaxRate) * line.NetAmount;
line.GLAccountCode = "1000";
line.ActualPrice = 100M;
line.LocationID = "1";
line.SublocationID = "GEN";
line.GLAccountCode = "1000";
line.OpeningStockGLAccountCode = "2000";
results.Result[i].AccountName = "Test integration";
results.Result[i].ExternalReference = "External reference 2";
results.Result[i].Lines = new InvoiceLine[] { line };
results.Result[i].ExchangeRate = 1M;
}
int[] invoiceIDs = new int[1000];
WSResult2OfArrayOfWSResultStatus results2 = this.ws.CreateInvoicesGetBackInvoiceIDs(this.auth, results.Result, out invoiceIDs);
DateTime edt = DateTime.Now;
for (i = 0; i < 1000; i++)
{
Assert.IsTrue(results2.Result[i].Status == OperationStatus.Created);
Assert.AreNotEqual<int>(-1, invoiceIDs[i]);
}
}
Dim ws As New Integration
Dim auth As String = ws.Login(entityID, partnerKey, userKey)
If (Not Me.auth Is Nothing) Then
Dim i As Integer
Dim customerCodes As String() = New String(1000 - 1) {}
i
For i = 0 To customerCodes.Length - 1
customerCodes(i) = "TESTINTEGR"
Next i
Dim sdt As DateTime = DateTime.Now
Dim results As WSResult2OfArrayOfInvoice = Me.ws.GetNewSalesInvoices(Me.auth, customerCodes)
i
For i = 0 To 1000 - 1
Dim line As New InvoiceLine
line.StockItemID = "STOCKITEM"
line.StockItemPrice = 100
line.TaxCode = "NT"
line.TaxRate = 0.21
line.StockItemDescription = "From default"
line.StockItemCost = 50
line.InvoicedQuantity = 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 = "GEN"
line.GLAccountCode = "1000"
line.OpeningStockGLAccountCode = "2000"
results.Result(i).AccountName = "Test integration"
results.Result(i).ExternalReference = "External reference 2"
results.Result(i).Lines = New InvoiceLine() { line }
results.Result(i).ExchangeRate = 1
Next i
Dim invoiceIDs As Integer() = New Integer(1000 - 1) {}
Dim results2 As WSResult2OfArrayOfWSResultStatus = Me.ws.CreateInvoicesGetBackInvoiceIDs(Me.auth, results.Result, invoiceIDs)
Dim edt As DateTime = DateTime.Now
i
For i = 0 To 1000 - 1
Assert.IsTrue((results2.Result(i).Status = OperationStatus.Created))
Assert.AreNotEqual(Of Integer)(-1, invoiceIDs(i))
Next i
End If