Class AccountUtil
java.lang.Object
com.infinitekind.moneydance.model.AccountUtil
public abstract class AccountUtil
extends java.lang.Object
Miscellaneous functions
-
Field Summary
Fields Modifier and Type Field Description static intACCOUNTsort by account (this is always 'other' acct - the first split's account).static intACCOUNT_NAMEstatic java.util.Comparator<Account>ACCOUNT_NAME_COMPARATORCompare two accounts by name, for sorting a list by account name.static java.util.Comparator<Account>ACCOUNT_TYPE_NAME_COMPARATORCompare two accounts by name, for sorting a list by account name.static intACTIONstatic intAMOUNTstatic java.util.Comparator<Txn>AMOUNT_COMPARATORstatic intCATEGORYSort by category account.static intCATEGORY_NAMEstatic intCHECKNUMstatic intCHECKNUM_INTstatic intCHECKNUM_PARENTSort by check#, but only check the parent's check# and ignore the split's.static intDATEstatic intDATE_ENTEREDstatic java.util.Comparator<Txn>DATE_ENTERED_COMPARATORComparator for sorting transactions by date-entered.static intDATE_THEN_AMOUNTstatic java.util.Comparator<Txn>DATE_THEN_AMOUNT_COMPARATORstatic intDATE_THEN_CHECKNUMstatic intDATE_THEN_STATUSstatic intDESCRIPTIONstatic intNOT_CATEGORYSort by non-category account.static intSTATUS_THEN_CKNUMstatic intSTATUS_THEN_DATEstatic intTAXDATE_THEN_CHECKNUMSort by tax date then by check#.static java.util.Comparator<Txn>TXN_CATEGORY_THEN_DATE_ENTEREDstatic java.util.Comparator<Txn>TXN_DATE_THEN_CHECKNUMstatic java.util.Comparator<Txn>TXN_DESCRIPTIONstatic java.util.Comparator<Txn>TXN_TAXDATE_THEN_CHECKNUM -
Constructor Summary
Constructors Constructor Description AccountUtil() -
Method Summary
Modifier and Type Method Description static java.util.List<Account>allMatchesForSearch(AccountBook book, AcctFilter search)Return a list of accounts matching the given filterstatic java.util.List<Account>allMatchesForSearch(Account rootAccount, AcctFilter search)Deprecated.Please use allMatchesForSearch(AccountBook, AcctFilter)static intcompAccountDateEntered(Txn t1, Txn t2)static longcompAmount(Txn t1, Txn t2)static intcompareAccountNames(Account a1, Account a2)static intcompCategoryDateEntered(Txn t1, Txn t2)static intcompCategoryOrAccount(Txn t1, Txn t2)Compare the category account for two transactions.static intcompCheckIntId(AbstractTxn t1, AbstractTxn t2)static intcompCheckNumAmt(Txn t1, Txn t2)Compare the two transactions based on their check number and then their amount if the check numbers are the same.static intcompCheckNumBoth(AbstractTxn t1, AbstractTxn t2)Compare the check number field for both numeric only and also text values.static intcompCheckNumBoth(Txn t1, Txn t2, boolean forceUseParent)Compare the check number field for both numeric only and also text values.static intcompCheckNumId(AbstractTxn t1, AbstractTxn t2)static intcompCheckNumParent(AbstractTxn t1, AbstractTxn t2)Compare the check number field, but only use the parent transaction's check number, do not use the check number for a split.static intcompDate(Txn t1, Txn t2)Compare the transaction date of two transactions.static intcompDateCheckNum(Txn t1, Txn t2, boolean useTaxDate)Compare two transactions by date.static intcompDateDateEntered(Txn t1, Txn t2)static intcompDateEntered(Txn t1, Txn t2)static longcompDateThenAmount(AbstractTxn t1, AbstractTxn t2)static longcompDateThenAmountTxn(Txn t1, Txn t2)static intcompDateThenStatus(AbstractTxn t1, AbstractTxn t2)static intcompDescription(Txn t1, Txn t2)Compare the description, or 'payee', of two transactions.static intcompDescriptionDate(AbstractTxn t1, AbstractTxn t2)static intcompDescriptionDateEntered(Txn t1, Txn t2)static intcompStatus(AbstractTxn t1, AbstractTxn t2)static intcompStatusChecknum(AbstractTxn t1, AbstractTxn t2)static intcompTaxDate(Txn t1, Txn t2)Compare the tax date of two transactions.static AccountfindAccountWithID(Account root, java.lang.String accountUUID)Find and return the account having the given UUIDstatic voidfindAllReferencesToAccount(java.util.List<MoneydanceSyncableItem> itemsWithReferences, Account acct)Adds to the list of all items that reference the given account.static AccountfirstMatchForSearch(Account rootAccount, AcctFilter search)Return the first account that matches the given filter under the specified accountstatic java.util.Iterator<Account>getAccountIterator(Account account)Return an iterator for all of the accounts that are under the given account.static java.util.Iterator<Account>getAccountIterator(AccountBook book)Return an iterator for all of the accounts that are within the given data set.static longgetBalanceAsOfDate(AccountBook book, Account account, int asofDate)Get a single account's balance as of a given date.static longgetBalanceAsOfDate(AccountBook book, Account account, int asofDate, boolean outOfDateAsZero)Get a single account's balance as of a given date.static long[]getBalancesAsOfDates(AccountBook book, Account account, int[] asofDates)Get a single account's balance as of a list of given dates.static long[]getBalancesAsOfDates(AccountBook book, Account account, int[] asofDates, boolean outOfDateAsZero)Get a single account's balance as of a list of given dates.static AccountgetCategoryFromTxn(AbstractTxn previousTxn)static AccountgetDefaultCategoryForAcct(Account acct)Get the default category for use transactions in the given account.static AccountgetDefaultTransferAcct(Account acct)Get the default transfer account for transaction in the given account.static AcctFiltergetFilterForType(Account.AccountType type)static AccountgetNonCategoryFromTxn(AbstractTxn txn)Return the non-category account from a transaction.static intinsertSortedTransaction(TxnSet transactions, AbstractTxn t, int sortedBy)Inserts the given transaction into the specified array in sorted order.static intinsertSortedTransaction(TxnSet transactions, AbstractTxn t, TxnSortOrder sortedBy)Inserts the given transaction into the specified array in sorted order.static booleanisCompatibleWith(OnlineAccountInfo olAcct, Account acct)Returns true iff the given online account can be associated with the given local account.static booleanisTransactionSorted(int index, AbstractTxn t, TxnSet transactions, int sortedBy)static booleanisTransactionSorted(int index, AbstractTxn t, TxnSet transactions, TxnSortOrder sortedBy)static voidsortTransactions(TxnSet transactions, int sortField)static java.util.HashMap<CurrencyType,java.lang.Long>sumBalancesByCurrency(AccountBook book, AcctFilter accountFilter)Gather the current value of all accounts matching the given filter for each currency
-
Field Details
-
DATE
public static final int DATE- See Also:
- Constant Field Values
-
DATE_ENTERED
public static final int DATE_ENTERED- See Also:
- Constant Field Values
-
DESCRIPTION
public static final int DESCRIPTION- See Also:
- Constant Field Values
-
AMOUNT
public static final int AMOUNT- See Also:
- Constant Field Values
-
STATUS_THEN_DATE
public static final int STATUS_THEN_DATE- See Also:
- Constant Field Values
-
ACCOUNT
public static final int ACCOUNTsort by account (this is always 'other' acct - the first split's account).- See Also:
- Constant Field Values
-
DATE_THEN_STATUS
public static final int DATE_THEN_STATUS- See Also:
- Constant Field Values
-
DATE_THEN_AMOUNT
public static final int DATE_THEN_AMOUNT- See Also:
- Constant Field Values
-
DATE_THEN_CHECKNUM
public static final int DATE_THEN_CHECKNUM- See Also:
- Constant Field Values
-
CHECKNUM
public static final int CHECKNUM- See Also:
- Constant Field Values
-
ACTION
public static final int ACTION- See Also:
- Constant Field Values
-
CHECKNUM_INT
public static final int CHECKNUM_INT- See Also:
- Constant Field Values
-
STATUS_THEN_CKNUM
public static final int STATUS_THEN_CKNUM- See Also:
- Constant Field Values
-
CATEGORY
public static final int CATEGORYSort by category account. Only use this when sorting splits.- See Also:
- Constant Field Values
-
NOT_CATEGORY
public static final int NOT_CATEGORYSort by non-category account. Only use this when sorting splits.- See Also:
- Constant Field Values
-
TAXDATE_THEN_CHECKNUM
public static final int TAXDATE_THEN_CHECKNUMSort by tax date then by check#.- See Also:
- Constant Field Values
-
CHECKNUM_PARENT
public static final int CHECKNUM_PARENTSort by check#, but only check the parent's check# and ignore the split's.- See Also:
- Constant Field Values
-
ACCOUNT_NAME
public static final int ACCOUNT_NAME- See Also:
- Constant Field Values
-
CATEGORY_NAME
public static final int CATEGORY_NAME- See Also:
- Constant Field Values
-
ACCOUNT_NAME_COMPARATOR
Compare two accounts by name, for sorting a list by account name. Uses the full name so that sub-accounts are kept with their parent accounts. -
ACCOUNT_TYPE_NAME_COMPARATOR
Compare two accounts by name, for sorting a list by account name. Uses the full name so that sub-accounts are kept with their parent accounts. -
DATE_ENTERED_COMPARATOR
Comparator for sorting transactions by date-entered.- Since:
- build 744
-
AMOUNT_COMPARATOR
-
DATE_THEN_AMOUNT_COMPARATOR
-
TXN_CATEGORY_THEN_DATE_ENTERED
-
TXN_DATE_THEN_CHECKNUM
-
TXN_TAXDATE_THEN_CHECKNUM
-
TXN_DESCRIPTION
-
-
Constructor Details
-
AccountUtil
public AccountUtil()
-
-
Method Details
-
compareAccountNames
-
firstMatchForSearch
Return the first account that matches the given filter under the specified account -
allMatchesForSearch
@Deprecated public static java.util.List<Account> allMatchesForSearch(Account rootAccount, AcctFilter search)Deprecated.Please use allMatchesForSearch(AccountBook, AcctFilter)Return a list of accounts matching the given filter -
allMatchesForSearch
Return a list of accounts matching the given filter- Since:
- build 1527 (Moneydance 2017)
-
findAccountWithID
Find and return the account having the given UUID -
getFilterForType
-
getDefaultCategoryForAcct
Get the default category for use transactions in the given account. This is guaranteed to return a non-null value.- Since:
- build 410
-
getDefaultTransferAcct
Get the default transfer account for transaction in the given account.- Since:
- build 565
-
getAccountIterator
Return an iterator for all of the accounts that are under the given account. If the root account is provided, all accounts will be included in the iterator. -
getAccountIterator
Return an iterator for all of the accounts that are within the given data set. If the root account is provided, all accounts will be included in the iterator. -
sumBalancesByCurrency
public static java.util.HashMap<CurrencyType,java.lang.Long> sumBalancesByCurrency(AccountBook book, AcctFilter accountFilter)Gather the current value of all accounts matching the given filter for each currency -
isCompatibleWith
Returns true iff the given online account can be associated with the given local account. -
insertSortedTransaction
Inserts the given transaction into the specified array in sorted order. -
insertSortedTransaction
public static int insertSortedTransaction(TxnSet transactions, AbstractTxn t, TxnSortOrder sortedBy)Inserts the given transaction into the specified array in sorted order.- Since:
- Moneydance 2019.4 build 1893
-
compAmount
-
compDateThenAmount
-
compDateThenAmountTxn
-
compDateThenStatus
-
compStatus
-
compStatusChecknum
-
compDescriptionDateEntered
-
compDescriptionDate
-
compDescription
Compare the description, or 'payee', of two transactions.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side).- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
compDateCheckNum
Compare two transactions by date.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side).useTaxDate- True if comparing tax dates, false if transaction date.- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
compDate
Compare the transaction date of two transactions.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side).- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
compTaxDate
Compare the tax date of two transactions.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side).- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
compDateDateEntered
-
compAccountDateEntered
-
compCategoryDateEntered
-
compCategoryOrAccount
Compare the category account for two transactions.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side). accounts.- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
getNonCategoryFromTxn
Return the non-category account from a transaction. If there is only category accounts on both sides of the transaction, or if it is in a category account with more than one split, returnnull.- Parameters:
txn- The transaction to check.- Returns:
- The non-category account for the transaction, or
null.
-
compDateEntered
-
compCheckNumBoth
Compare the check number field for both numeric only and also text values.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side).- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
compCheckNumBoth
Compare the check number field for both numeric only and also text values.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side).forceUseParent- True if always getting the check# from the parent, false otherwise.- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
compCheckNumId
-
compCheckNumParent
Compare the check number field, but only use the parent transaction's check number, do not use the check number for a split. This is used for sorting transactions for display to the user. At this time the user may not specify a check number for a split, so it is irrelevant and messes up the sort order.- Parameters:
t1- First transaction to compare (left hand side).t2- Second transaction to compare (right hand side).- Returns:
- 0 if they are the same, < 0 if left is less than right, > 0 otherwise.
-
compCheckNumAmt
Compare the two transactions based on their check number and then their amount if the check numbers are the same. @since build 566 -
compCheckIntId
-
isTransactionSorted
public static boolean isTransactionSorted(int index, AbstractTxn t, TxnSet transactions, TxnSortOrder sortedBy) -
isTransactionSorted
public static boolean isTransactionSorted(int index, AbstractTxn t, TxnSet transactions, int sortedBy) -
sortTransactions
-
getBalanceAsOfDate
Get a single account's balance as of a given date. Transactions for that date will be included, so it is the balance as of the end of the given date. The balance will be in the account's currency type. This method will return 0 if the account did not exist as of the given date.- Parameters:
book- The root account for all transactions.account- Account to obtain the balance for.asofDate- The date to obtain the balance for.- Returns:
- The balance (in the account's currency) of the given account as of the end of the given date.
-
getBalanceAsOfDate
public static long getBalanceAsOfDate(AccountBook book, Account account, int asofDate, boolean outOfDateAsZero)Get a single account's balance as of a given date. Transactions for that date will be included, so it is the balance as of the end of the given date. The balance will be in the account's currency type.- Parameters:
book- The root account for all transactions.account- Account to obtain the balance for.asofDate- The date to obtain the balance for.outOfDateAsZero- True if out-of-date returns a zero balance, false if it returns aLong.MIN_VALUEif the account did not exist.- Returns:
- The balance (in the account's currency) of the given account as of the end of the given date.
-
getBalancesAsOfDates
Get a single account's balance as of a list of given dates. The balances will be in the account's currency type. This method returns a zero balance if the given dates are before the earliest transaction and the account's start date.- Parameters:
book- The root account for all transactions.account- Account to obtain the balance for.asofDates- The dates to obtain the balance for.- Returns:
- The balances (in the account's currency) of the given account as of the end of the
corresponding given dates in
asofDates.
-
getBalancesAsOfDates
public static long[] getBalancesAsOfDates(AccountBook book, Account account, int[] asofDates, boolean outOfDateAsZero)Get a single account's balance as of a list of given dates. The balances will be in the account's currency type. If a given date is prior to both the earliest transaction and the account's start date, then returnLong.MIN_VALUEfor the balance. Transactions for the given date will be included, so it is the balance as of the end of the given date. IfoutOfDateAsZeroistrue, this is overridden and 0 is returned even if the date is too early.- Parameters:
book- The root account for all transactions.account- Account to obtain the balance for.asofDates- The dates to obtain the balance for.outOfDateAsZero- True if out-of-date returns a zero balance, false if it returns aLong.MIN_VALUEif the account did not exist.- Returns:
- The balances (in the account's currency) of the given account as of the end of the
corresponding given dates in
asofDates.
-
findAllReferencesToAccount
public static void findAllReferencesToAccount(java.util.List<MoneydanceSyncableItem> itemsWithReferences, Account acct)Adds to the list of all items that reference the given account. This is used to gather a list of items that must be deleted when the account is deleted. -
getCategoryFromTxn
-