GetNewSalesInvoices - accountsIQ/API-Wiki GitHub Wiki

The GetNewSalesInvoices gets multiple new invoices for specified customer accounts. It fills the invoices defaulting the information with the related customers' information.

Note: This method is to be used when you need to bulk insert a larger number of invoice records into a company database. Creating invoices in 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 the equivalent GetNewSalesInvoice function.

Declaration

C#

public WSResult2OfArrayOfInvoice GetNewSalesInvoices(string token, string[] customerCodes)

Visual Basic

Public Function GetNewSalesInvoices(ByVal token As String, ByVal customerCodes As String()) As WSResult2OfArrayOfInvoice

Parameter List

Parameter Type Description
token String The session token retrieved during authentication.
customerCodes String[] Code of the customer to create a new sales invoice for.

Example

C#

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]);
  }
}

Visual Basic

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

See Also

⚠️ **GitHub.com Fallback** ⚠️