Entry::GetBalance (Interface: Entry)
 
Gets the balance for a group of account numbers.
 
DOUBLE GetBalance (
    BSTR bsAccount,
    DATE dStartDate,
    DATE dEndDate,
    VARIANT_BOOL bInterCompanyOnly
)
 
Parameters
bsAccount
[in] The account number of which you want to know the balance.
dStartDate
[in] The start date of the period for which you want to know the balance.
dEndDate
[in] The end date of the period for which you want to know the balance.
bInterCompanyOnly
[in] True if you want to limit the balance to intercompany entries only, false otherwise.
 
Return value
A DOUBLE containing the current balance of the given (group of) account number(s).
 
Remarks
This method is different from the GetBalance method in the Balan interface in that way that not one record must be read to determine the balance but all entry records are taken into account. Therefore it can be a lot slower!
The account number, which is normally composed of digits only, can contain the wild card '?' (which stands for any digit) and can end with '*' (all account numbers beginning with the digits before the '*').
The date parameters for this method must be part of the financial year of the Entry interface, otherwise the method returns 0.0.
 
See Also
CreateEntry
 
Samples
 
C++
 
// Retrieve the balance of all customers (assuming that '400' is the customer prefix account) for the month of March, limited to intercompany entries
COleDateTime odtStartDate, odtEndDate;
odtStartDate.SetDate (2024, 3, 1);
odtEndDate.SetDate (2024, 3, 31);
double lfBalance = pEntry->GetBalance ("400*", odtStartDate, odtEndDate, VARIANT_TRUE);

// Retrieve the balance of the accounts 1204, 1214, 1224,..., 1294 for the first quarter of the financial year, not limited to intercompany entries
odtStartDate.SetDate (2024, 1, 1);
odtEndDate.SetDate (2024, 3, 31);
lfBalance = pEntry->GetBalance ("1204", odtStartDate, odtEndDate, VARIANT_FALSE) + pEntry->GetBalance ("1214", odtStartDate, odtEndDate, VARIANT_FALSE) + ... + pEntry->GetBalance ("1294", odtStartDate, odtEndDate, VARIANT_FALSE);
// ...or using the '?'-wildcard
lfBalance = pEntry->GetBalance ("12?4", odtStartDate, odtEndDate, VARIANT_FALSE);

// Retrieve the balance of the account 1204 and all its sub-accounts (12041, 12042, 120420, 120421) for the month of May, not limited to intercompany entries
odtStartDate.SetDate (2024, 5, 1);
odtEndDate.SetDate (2024, 5, 31);
lfBalance = pEntry->GetBalance ("1204", odtStartDate, odtEndDate, VARIANT_FALSE) + pEntry->GetBalance ("12041", odtStartDate, odtEndDate, VARIANT_FALSE) + pEntry->GetBalance ("12042", odtStartDate, odtEndDate, VARIANT_FALSE) + pEntry->GetBalance ("120420", odtStartDate, odtEndDate, VARIANT_FALSE) + pEntry->GetBalance ("120421", odtStartDate, odtEndDate, VARIANT_FALSE);
// ...or using the '*'-wildcard
lfBalance = pEntry->GetBalance ("1204*", odtStartDate, odtEndDate, VARIANT_FALSE);

C#
 
// Retrieve the balance of all customers (assuming that '400' is the customer prefix account) for the month of March, limited to intercompany entries
DateTime dtStartDate = new DateTime (2024, 3, 1), dtEndDate = new DateTime (2024, 3, 31);
double lfBalance = oEntry.GetBalance ("400*", dtStartDate, dtEndDate, true);

// Retrieve the balance of the accounts 1204, 1214, 1224,..., 1294 for the first quarter of the financial year, not limited to intercompany entries
lfBalance = oEntry.GetBalance ("1204", dtStartDate, dtEndDate, false) + oEntry.GetBalance ("1214", dtStartDate, dtEndDate, false) + ... + oEntry.GetBalance ("1294", dtStartDate, dtEndDate, false);
// ...or using the '?'-wildcard
lfBalance = oEntry.GetBalance ("12?4", dtStartDate, dtEndDate, false);

// Retrieve the balance of the account 1204 and all its sub-accounts (12041, 12042, 120420, 120421) for the month of May, not limited to intercompany entries
lfBalance = oEntry.GetBalance ("1204", dtStartDate, dtEndDate, false) + oEntry.GetBalance ("12041", dtStartDate, dtEndDate, false) + oEntry.GetBalance ("12042", dtStartDate, dtEndDate, false) + oEntry.GetBalance ("120420", dtStartDate, dtEndDate, false) + oEntry.GetBalance ("120421", dtStartDate, dtEndDate, false);
// ...or using the '*'-wildcard
lfBalance = oEntry.GetBalance ("1204*", dtStartDate, dtEndDate, false);

VBS
 
Dim lfBalance
Dim dtStartDate, dtEndDate
dtStartDate = #3/1/2024#
dtEndDate = #3/31/2024#

' Retrieve the balance of all customers (assuming that '400' is the customer prefix account) for the month of March, limited to intercompany entries
lfBalance = oEntry.GetBalance("400*", dtStartDate, dtEndDate, true)

' Retrieve the balance of the accounts 1204, 1214, 1224,..., 1294 for the first quarter of the financial year, not limited to intercompany entries
lfBalance = oEntry.GetBalance("1204", dtStartDate, dtEndDate, false) + oEntry.GetBalance("1214", dtStartDate, dtEndDate, false) + ... + oEntry.GetBalance("1294", dtStartDate, dtEndDate, false)
' ...or using the '?'-wildcard
lfBalance = oEntry.GetBalance("12?4", dtStartDate, dtEndDate, false)

' Retrieve the balance of the account 1204 and all its sub-accounts (12041, 12042, 120420, 120421) for the month of May, not limited to intercompany entries
lfBalance = oEntry.GetBalance("1204", dtStartDate, dtEndDate, false) + oEntry.GetBalance("12041", dtStartDate, dtEndDate, false) + oEntry.GetBalance("12042", dtStartDate, dtEndDate, false) + oEntry.GetBalance("120420", dtStartDate, dtEndDate, false) + oEntry.GetBalance("120421", dtStartDate, dtEndDate, false)
' ...or using the '*'-wildcard
lfBalance = oEntry.GetBalance("1204*", dtStartDate, dtEndDate, false)

VB.NET
 
Dim lfBalance As Double
Dim dtStartDate, dtEndDate As Date
dtStartDate = #3/1/2024#
dtEndDate = #3/31/2024#

' Retrieve the balance of all customers (assuming that '400' is the customer prefix account) for the month of March, limited to intercompany entries
lfBalance = oEntry.GetBalance("400*", dtStartDate, dtEndDate, true)

' Retrieve the balance of the accounts 1204, 1214, 1224,..., 1294 for the first quarter of the financial year, not limited to intercompany entries
lfBalance = oEntry.GetBalance("1204", dtStartDate, dtEndDate, false) + oEntry.GetBalance("1214", dtStartDate, dtEndDate, false) + ... + oEntry.GetBalance("1294", dtStartDate, dtEndDate, false)
' ...or using the '?'-wildcard
lfBalance = oEntry.GetBalance("12?4", dtStartDate, dtEndDate, false)

' Retrieve the balance of the account 1204 and all its sub-accounts (12041, 12042, 120420, 120421) for the month of May, not limited to intercompany entries
lfBalance = oEntry.GetBalance("1204", dtStartDate, dtEndDate, false) + oEntry.GetBalance("12041", dtStartDate, dtEndDate, false) + oEntry.GetBalance("12042", dtStartDate, dtEndDate, false) + oEntry.GetBalance("120420", dtStartDate, dtEndDate, false) + oEntry.GetBalance("120421", dtStartDate, dtEndDate, false)
' ...or using the '*'-wildcard
lfBalance = oEntry.GetBalance("1204*", dtStartDate, dtEndDate, false)