GetTrialBalanceForPeriod - accountsIQ/API-Wiki GitHub Wiki

The GetTrialBalanceForPeriod function returns the pre-calculated reporting dataset for the trial balance report based on period values. This has accuracy to the period, it is not possible to return data for a mid-period date point. For this, please see GetTrialBalanceFromStartOfPeriod function.

This function is available on all types of companies.

Declaration

C#

public WSResult2OfWSTrialBalance GetTrialBalanceForPeriod(string token, DateTime date)

Visual Basic

Public Function GetTrialBalanceForPeriod(ByVal token As String, ByVal date As DateTime) As WSResult2OfWSTrialBalance 

Parameter List

Here is the parameter list required to use the function:

Parameter Type Description
token String The session token retrieved during authentication.
date DateTime A date in time. If the date is in the middle of a period, then the data is going to be returned for the end of the period containing the date point.

Please see WSTrialBalance for the detail of the return type.

Examples

C#

// 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)
{
  WSResultStatusOfWSTrialBalance result = ws.GetTrialBalanceForPeriod(auth, DateTime.Now);
  if (result.Status == OperationStatus.Success)
  {
      // The operation succeeded
      Console.WriteLine(String.Format("Trial balance for {0} - {1} {2}", 
         result.Result.FinancialYear, result.Result.PeriodNumber, result.Result.PeriodName));
      foreach(var glbal in result.Result.Balances)
      {
          var depts = String.Join(", ", glbal.DepartmentBalances.Select(d => d.DepartmentID));
          Console.WriteLine(String.Format("Balance on GL {0} is {1} spread across the following departments: {2}",
           glbal.GLAccountCode, glbal.OverallBalance, depts));
      }
  }
  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.
}

See Also

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