GetNewSalesInvoice - accountsIQ/API-Wiki GitHub Wiki
The GetNewSalesInvoice
creates a new invoice for a given customer account. It fills the invoice defaulting the information with the related customer's information.
public WSResult2OfInvoice GetNewSalesInvoice(string token, string customerCode)
Public Function GetNewSalesInvoice(ByVal token As String, ByVal customerCode As String) As WSResult2OfInvoice
Parameter | Type | Description |
---|---|---|
token | String | The session token retrieved during authentication. |
customerCode | String | Code of the customer to create a new sales invoice for. |
Integration ws = new Integration();
String auth = "";// See Authentication page for more
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.NetAmount = 1000M;
line.TaxAmoutn = line.NetAmount * line.TaxRate;
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 integrator partner";
result.Result.ExternalReference = "NEWSALESINVOICE0001";
result.Result.Lines = new InvoiceLine[1];
result.Result.Lines[0] = line;
result.Result.ExchangeRate = 1;
WSResultStatus r = ws.SaveInvoice(auth, result.Result, true);
Assert.IsTrue(r.Status == OperationStatus.Created);
}
Dim ws As New Integration
Dim auth As String = "" // See Authentication page for more
If (Not 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.NetAmount = 1000
line.TaxAmoutn = line.NetAmount * line.TaxRate
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 integrator partner"
result.Result.ExternalReference = "NEWSALESINVOICE0001"
result.Result.Lines = New InvoiceLine() { line }
result.Result.ExchangeRate = 1
Assert.IsTrue((Me.ws.SaveInvoice(Me.auth, result.Result, True).Status = OperationStatus.Created))
End If