SaveInvoiceGetBackInvoiceID - accountsIQ/API-Wiki GitHub Wiki

The SaveInvoiceGetBackInvoiceID function saves a modified invoice back to the system.

Declaration

C#

public WSResultStatus SaveInvoiceGetBackInvoiceID(string token, Invoice invoice, bool create, out int invoiceID)

Visual Basic

Public Function SaveInvoiceGetBackInvoiceID(ByVal token As String, ByVal invoice As Invoice, ByVal create As Boolean, ByRef invoiceID As Integer) As WSResultStatus

Parameter List

Parameter Type Description
token String The session token retrieved during authentication.
invoice Invoice Invoice to save/update back to the system.
create Boolean Flag indicating whether to create the invoice if it does not already exist. If the invoice already exist the flag is ignored. If the invoice does not already exist and the flag is on, the invoice is created. If the invoice does not already exist and the flag is off, the invoice is not created.
invoiceID Int32 This is an out parameter. It will contain the ID of the invoice after creation.

Example

C#

Integration ws = new Integration();

String auth = ws.Login(entityID, partnerKey, userKey);
if (auth != null)
{
  WSResult2OfInvoice result = ws.GetNewSalesInvoice(auth, "TESTINTEGR");
  Assert.IsNotNull(result.Result);

  InvoiceLine line = new InvoiceLine();
  line.StockItemID = "STOCKITEM1";
  line.StockItemPrice = 100M;
  line.TaxCode = "NT";
  line.TaxRate = 0.21M;
  line.StockItemDescription = "From default";
  line.StockItemCost = 50M;
  line.InvoicedQuantity = 10;
  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 InvoiceLine[1];
  result.Result.Lines[0] = line;
  result.Result.ExchangeRate = 1;

  int invoiceID = 0;
  WSResultStatus r = ws.SaveInvoiceGetBackInvoiceID(auth, result.Result, true, out invoiceID);
  Assert.IsTrue(r.Status == OperationStatus.Created);
  Assert.IsTrue( invoiceID != 0 && invoiceID != -1 );
}

Visual Basic

Dim ws As New Integration

Dim auth As String = ws.Login(entityID, partnerKey, userKey)
If (Not Me.auth Is Nothing) Then
  Dim result As WSResult2OfInvoice = Me.ws.GetNewSalesInvoice(Me.auth, "TESTINTEGR")
  Assert.IsNotNull(result.Result)
  Dim line As New InvoiceLine
  line.StockItemID = "STOCKITEM1"
  line.StockItemPrice = 100
  line.TaxCode = "NT"
  line.TaxRate = 0.21
  line.StockItemDescription = "From default"
  line.StockItemCost = 50
  line.InvoicedQuantity = 10
  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 InvoiceLine() { line }
  result.Result.ExchangeRate = 1
  Dim invoiceID as Integer
  Assert.IsTrue((Me.ws.SaveInvoice(Me.auth, result.Result, True, invoiceID).Status = OperationStatus.Created))
  Assert.IsTrue( invoiceID <> 0 and invoiceID <> -1 )
End If

See Also

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