CreateCreditNotesGetBackCreditNoteIDs - accountsIQ/API-Wiki GitHub Wiki

The CreateCreditNotesGetBackCreditNoteIDs function creates an array of given CreditNotes in the system.

Note: This method is to be used for performance reasons when creating a set of new CreditNote records in bulk. Creating CreditNotes 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 SaveCreditNote function.

Declaration

C#

public WSResult2OfArrayOfWSResultStatus CreateCreditNotesGetBackCreditNoteIDs(string token, CreditNote[] CreditNotes, out int[] CreditNoteIDs)

Visual Basic

Public Function CreateCreditNotesGetBackCreditNoteIDs(ByVal token As String, ByVal CreditNotes As CreditNote(), ByRef CreditNoteIDs As Integer()) As WSResult2OfArrayOfWSResultStatus

Parameter List

Parameter Type Description
token String The session token retrieved during authentication.
CreditNotes CreditNote[] CreditNote to save/update back to the system.
CreditNoteIDs Int32[] This is an out parameter. It will contain the IDs of the CreditNotes after creation.

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;
  WSResult2OfArrayOfCreditNote results = this.ws.GetNewSalesCreditNotes(this.auth, customerCodes);
  for (i = 0; i < 1000; i++)
  {
      CreditNoteLine line = new InvoiceLine();
      line.StockItemID = "STOCKITEM";
      line.StockItemPrice = 100M;
      line.TaxCode = "NT";
      line.TaxRate = 0.21M;
      line.StockItemDescription = "From default";
      line.StockItemCost = 50M;
      line.CreditNotedQuantity = 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[] CreditNoteIDs = new int[1000];
  WSResult2OfArrayOfWSResultStatus results2 = this.ws.CreateCreditNotesGetBackCreditNoteIDs(this.auth, results.Result, out CreditNoteIDs);
  DateTime edt = DateTime.Now;
  for (i = 0; i < 1000; i++)
  {
      Assert.IsTrue(results2.Result[i].Status == OperationStatus.Created);
      Assert.AreNotEqual<int>(-1, CreditNoteIDs[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 WSResult2OfArrayOfCreditNote = Me.ws.GetNewSalesCreditNotes(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.CreditNotedQuantity = 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 CreditNoteIDs As Integer() = New Integer(1000  - 1) {}
  Dim results2 As WSResult2OfArrayOfWSResultStatus = Me.ws.CreateCreditNotesGetBackCreditNoteIDs(Me.auth, results.Result, CreditNoteIDs)
  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, CreditNoteIDs(i))
  Next i

End If

See Also

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