-
Notifications
You must be signed in to change notification settings - Fork 2
AllocateTransactionsWithDiscount
The AllocateTransactionsWithDiscount
function allocates two outstanding transactions together. Several functionalities of the accountsIQ requires sales and purchases transactions to be allocated.
This is especially important for VAT on cash receipt/basis reporting.
public WSResultStatus AllocateTransactionsWithDiscount(string token, int transactionID_1, int transactionID_2, string allocationReference, decimal allocationAmount, DateTime allocationDate)
Public Function AllocateTransactionsWithDiscount(ByVal token As String, ByVal transactionID_1 As Integer, ByVal transactionID_2 As Integer, ByVal allocationReference As String, ByVal allocationAmount As Decimal, ByVal allocationDate As DateTime) As WSResultStatus
Here is the parameter list required to use the function:
Parameter | Type | Description |
---|---|---|
token | String | The session token retrieved during authentication. |
transactionID_1 | Int32 | Unique identifier of first transaction to allocate. |
transactionID_2 | Int32 | Unique identifier of second transaction to allocate. |
allocationAmount | Decimal | Amount to allocate from one transaction to the other. Must be positive and in the account currency. |
allocationDate | DateTime | Date at which the allocation takes place. This will impact the retrospective ageing: before this date the two transactions will appear outstanding. |
discountAmount | Decimal | Amount of the discount to create. The discount will be allocated to the invoice. |
Note
:
The two transactions must belong to the same customer or supplier. The two transactions must be distinct. The outstanding amount on each transaction must be greater or equal to the allocated amount.
Important Note
:
The two transactions to allocate must be of opposite kind. There are two kinds of allocatable transactions:
SI, SP, SD, PI, PR, PC
SN, SR, SC, PN, PP, PD
The following example allocates 50 customer currency units of a sales receipt (transaction ID 2092) against an invoice (transaction ID 2091).
Note
:
Always make sure that the amount to allocate is less than each transaction's outstanding amount and that the two transactions are of opposite allocatable transaction kind.
// Integration is the reference to the accountsIQ web service
Integration ws = new Integration();
// Try to login using the entity ID, the integrator partner key and the user provided key
string auth = ws.Login(entityID, partnerKey, userKey);
if (auth != null)
{
// Get the transaction IDs from some listing method
int invoiceTid = 2091;
int receiptTid = 2092;
// Proceed to allocate the two transactions against each other for 50 customer currency units.
WSResultStatus result = ws.AllocateTransactionsWithDiscount(auth, invoiceTid, receiptTid, "Allocation 1", 50, DateTime.Now, 5); // 5 of discount
if (result.Status == OperationStatus.Success)
{
// The operation succeeded
}
else if (result.HasExpired)
{
// The login has expired. Log the user in again.
}
else if (result.Status == OperationStatus.Failure)
{
// The operation failed.
// The ErrorCode field will provide more information as to what is the cause of the failure.
}
}
else
{
// The login failed. For security reasons, we cannot give more information on what went wrong.
// The most likely cause is an incorrect user key or an expired partner key.
// Put here your error handling for invalid login. Either one of the three piece of information can be incorrect.
}
' Integration is the reference to the accountsIQ web service
Dim ws As New Integration_1_1
' Try to login using the entity ID, the integrator partner key and the user provided key
Dim auth As String = ws.Login(entityID, partnerKey, userKey)
If (Not auth Is Nothing) Then
' Get the transaction IDs from some listing method
Dim invoiceTid As Integer = 2091
Dim receiptTid As Integer = 2092
' Proceed to allocate the two transactions against each other for 50 customer currency units.
Dim result As WSResultStatus = ws.AllocateTransactionsWithDiscount(auth, invoiceTid, receiptTid, "Allocation 1", 50, DateTime.Now, 5) ' 5 of discount
If (result.Status = OperationStatus.Success) Then
' The operation succeeded
Else
If result.HasExpired Then
' The login has expired. Log the user in again.
ElseIf (result.Status = OperationStatus.Failure) Then
' The operation failed.
' The ErrorCode field will provide more information as to what is the cause of the failure.
End If
End If
Else
' Put here your error handling for invalid login. Either one of the three piece of information can be incorrect.
End If