Class TxnUtil
java.lang.Object
com.infinitekind.moneydance.model.TxnUtil
public class TxnUtil
extends java.lang.Object
-
Field Summary
-
Method Summary
Modifier and Type Method Description static void
applyVAT(ParentTxn ptxn)
Apply any VAT/GST transformation (ie adding/adjusting splits) to the given transaction.static java.util.Comparator<AbstractTxn>
comparatorForField(int field)
static void
copyFromSimilarPreviousTxn(ParentTxn target, ParentTxn source, boolean adjustAmounts)
Copies the descriptions/memos, categories and amounts from the given source transaction, optionally adjusting the amounts to match the current target transaction value.static void
copyVATInfo(AbstractTxn fromTxn, AbstractTxn toTxn)
Copy any VAT/GST-related tags from one split to another.static SplitTxn
findVATGSTSplit(ParentTxn txn, SplitTxn split)
Find the matching VAT/GST split, if any, for the given split under the given parent txn.static SplitTxn
getCommissionPart(ParentTxn ptxn)
Get the part of the transaction that doesn't go to a security.static AbstractTxn
getCorrespondingDuplicate(ParentTxn dupTxn, AbstractTxn txn)
static SplitTxn
getExpensePart(ParentTxn ptxn)
Get the part of the transaction that is expense.static SplitTxn
getIncomePart(ParentTxn ptxn)
Get the part of the transaction that is income.static InvestTxnType
getInvestTxnType(ParentTxn ptxn)
Deprecated.as of Moneydance 2017.7 build 1662 use ParentTxn.getInvestTxnType()static int
getInvstTxnType(ParentTxn ptxn)
static java.lang.String
getKeywordsAsString(java.util.List<java.lang.String> keywords)
static java.util.List<java.lang.String>
getListOfAllNonNumericCheckNumbers(AccountBook book, Account accountFilter)
Return a list of non-numeric string values that have appeared in the check number field for transactions in the given account, or if accountFilter is null then in any account.static java.util.List<java.lang.String>
getListOfAllNonNumericCheckNumbers(AccountBook book, Account accountFilter, int maximumAmount)
Return a list of non-numeric string values that have appeared in the check number field for transactions in the given account, or if accountFilter is null then in any account.static java.util.List<java.lang.String>
getListOfAllUsedTransactionTags(TxnSet txns)
static long
getNumShares(SplitTxn split)
As of Build 256.static long
getNumShares(TxnSet txnSet, SplitTxn split)
As of Build 256.static TxnSearch
getSearch(Account account, DateRange range)
static TxnSearch
getSearch(DateRange range)
static SplitTxn
getSecurityPart(ParentTxn ptxn)
Get the part of the transaction that goes to a security account.static AbstractTxn
getTxnByID(TransactionSet txnSet, java.lang.String txnID)
static AbstractTxn
getTxnByID(TxnSet txnSet, java.lang.String txnID)
static SplitTxn
getXfrPart(ParentTxn ptxn)
Get the part of the transaction that goes to another bank account.static void
markOnlineTxnsAsOf(java.util.Iterator<AbstractTxn> txns, int asOfDate, byte statusFlag)
Mark transactions in the given enumeration with the given status flag if they fall on or before the given date.static MediaType
mediaTypeForFilename(java.lang.String filename)
Return the best guess for the kind of media contained in the given filestatic java.util.Hashtable<java.lang.String,java.lang.Long>
parseCostBasisTag(SplitTxn split)
This is only available on Build 256 and up.static void
setCommissionPart(SplitTxn commSplit)
Tag the given split as the commission/fee part of its investment transaction.static void
setExpensePart(SplitTxn secSplit)
Tag the given split as the expense part of its investment transaction.static void
setIncomePart(SplitTxn secSplit)
Tag the given split as the income part of its investment transaction.static void
setInvstTxnType(ParentTxn ptxn, InvestTxnType txnType)
Deprecated.as of Moneydance 2017.7 build 1662 use ParentTxn.setInvestTxnType(InvestTxnType)static void
setRatesInTxn(AbstractTxn txn)
If the given transaction contains any inter-currency (or security to/from currency) elements, adjust the rates based on the the currency and security rate/price tables at the time of the transaction.static void
setSecurityPart(SplitTxn secSplit)
Tag the given split as the security part of its investment transaction.static void
setXfrPart(SplitTxn xfrSplit)
Tag the given split as the transfer part of its investment transaction.static boolean
txnIsClearedForArchiving(AbstractTxn txn)
Return whether all parts of the given transaction are cleared for archiving.static boolean
txnTouchesInvestment(AbstractTxn txn)
Return true iff this transaction is a transfer to, from or within an investment account.static boolean
wasTxnDownloaded(AbstractTxn txn)
Returns true if the given transaction was downloaded, or imported from a downloaded file.
-
Field Details
-
DEBUG
public static boolean DEBUG -
DATE_COMPARATOR
-
DATE_ENTERED_COMPARATOR
-
DESCRIPTION_COMPARATOR
-
ACCOUNT_THEN_DATE_COMPARATOR
-
CATEGORY_THEN_DATE_COMPARATOR
-
ACCOUNT_JUST_NAME_COMPARATOR
-
CATEGORY_COMPARATOR
-
DATE_THEN_AMOUNT_COMPARATOR
-
DATE_THEN_AMOUNT_TXN_COMPARATOR
-
DATE_THEN_STATUS_COMPARATOR
-
AMOUNT_COMPARATOR
-
DATE_THEN_CHECKNUM_COMPARATOR
-
TAXDATE_THEN_CHECKNUM_COMPARATOR
-
CHECKNUM_COMPARATOR
-
CHECKNUM_PARENT_COMPARATOR
-
CHECKNUM_NUMERIC_COMPARATOR
-
STATUS_CHECKNUM_COMPARATOR
-
STATUS_THEN_DATE_ENTERED_COMPARATOR
-
DEFAULT_COMPARATOR
-
TXN_TYPE_BUY
@Deprecated public static final int TXN_TYPE_BUYDeprecated.UseInvestTxnType.BUY
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_SELL
@Deprecated public static final int TXN_TYPE_SELLDeprecated.UseInvestTxnType.SELL
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_BUY_XFER
@Deprecated public static final int TXN_TYPE_BUY_XFERDeprecated.UseInvestTxnType.BUY_XFER
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_SELL_XFER
@Deprecated public static final int TXN_TYPE_SELL_XFERDeprecated.UseInvestTxnType.SELL_XFER
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_BANK
@Deprecated public static final int TXN_TYPE_BANKDeprecated.UseInvestTxnType.BANK
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_DIVIDEND
@Deprecated public static final int TXN_TYPE_DIVIDENDDeprecated.UseInvestTxnType.DIVIDEND
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_SHORT
@Deprecated public static final int TXN_TYPE_SHORTDeprecated.UseInvestTxnType.SHORT
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_COVER
@Deprecated public static final int TXN_TYPE_COVERDeprecated.UseInvestTxnType.COVER
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_DIVIDENDXFR
@Deprecated public static final int TXN_TYPE_DIVIDENDXFRDeprecated.UseInvestTxnType.DIVIDENDXFR
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_MISCINC
@Deprecated public static final int TXN_TYPE_MISCINCDeprecated.UseInvestTxnType.MISCINC
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_MISCEXP
@Deprecated public static final int TXN_TYPE_MISCEXPDeprecated.UseInvestTxnType.MISCEXP
instead.- See Also:
- Constant Field Values
-
TXN_TYPE_DIVIDEND_REINVEST
@Deprecated public static final int TXN_TYPE_DIVIDEND_REINVESTDeprecated.UseInvestTxnType.DIVIDEND_REINVEST
instead.- See Also:
- Constant Field Values
-
ALL_TXN_TYPES
public static final int[] ALL_TXN_TYPESDeprecated.UseInvestTxnType.ALL_TXN_TYPES
instead.
-
-
Method Details
-
getSearch
-
getSearch
-
comparatorForField
-
setInvstTxnType
Deprecated.as of Moneydance 2017.7 build 1662 use ParentTxn.setInvestTxnType(InvestTxnType)Tag the given (investment) transaction with the given transaction type -
getKeywordsAsString
public static java.lang.String getKeywordsAsString(java.util.List<java.lang.String> keywords) -
getInvstTxnType
-
getInvestTxnType
Deprecated.as of Moneydance 2017.7 build 1662 use ParentTxn.getInvestTxnType()- Returns:
- The investment transaction type for the given transaction
-
applyVAT
Apply any VAT/GST transformation (ie adding/adjusting splits) to the given transaction. -
copyVATInfo
Copy any VAT/GST-related tags from one split to another. This should only be used when duplicating transactions (ie for auto-completion) for which you would like the VAT/GST status to also be transferred. -
findVATGSTSplit
Find the matching VAT/GST split, if any, for the given split under the given parent txn. Note: Available as of build 312. -
copyFromSimilarPreviousTxn
public static final void copyFromSimilarPreviousTxn(ParentTxn target, ParentTxn source, boolean adjustAmounts)Copies the descriptions/memos, categories and amounts from the given source transaction, optionally adjusting the amounts to match the current target transaction value.- Parameters:
target
- the transaction to modify based on the categories and descriptions of the sourcesource
- the transaction from which to get the split information such as descriptions, categories, etcadjustAmounts
- if true, adjust all split amounts proportionally to match the current target txn value- Since:
- Moneydance build 895
-
getSecurityPart
Get the part of the transaction that goes to a security account. -
getXfrPart
Get the part of the transaction that goes to another bank account. -
getIncomePart
Get the part of the transaction that is income. -
getExpensePart
Get the part of the transaction that is expense. -
getCommissionPart
Get the part of the transaction that doesn't go to a security. (ie. the commission expense). -
parseCostBasisTag
public static final java.util.Hashtable<java.lang.String,java.lang.Long> parseCostBasisTag(SplitTxn split)This is only available on Build 256 and up. This returns the set of buy transactions matched with the given sell transaction. The key is a string with the transaction ID, the value is the number of shares from that transaction. -
getTxnByID
-
getTxnByID
-
getNumShares
As of Build 256. This method returns the number of shares accounted for. -
getNumShares
As of Build 256. This method returns the number of shares accounted for. -
setXfrPart
Tag the given split as the transfer part of its investment transaction. This also un-tags any other splits as the transfer part of the same transaction. [Added in build 302] -
setCommissionPart
Tag the given split as the commission/fee part of its investment transaction. This also un-tags any other splits as the commission part of the same transaction. [Added in build 302] -
setSecurityPart
Tag the given split as the security part of its investment transaction. This also un-tags any other splits as the security part of the same transaction. [Added in build 302] -
setIncomePart
Tag the given split as the income part of its investment transaction. This also un-tags any other splits as the income part of the same transaction. [Added in build 302] -
setExpensePart
Tag the given split as the expense part of its investment transaction. This also un-tags any other splits as the expense part of the same transaction. [Added in build 302] -
wasTxnDownloaded
Returns true if the given transaction was downloaded, or imported from a downloaded file. -
txnTouchesInvestment
Return true iff this transaction is a transfer to, from or within an investment account.- Since:
- Moneydance build 860
-
txnIsClearedForArchiving
Return whether all parts of the given transaction are cleared for archiving.- Since:
- Moneydance build 860
-
markOnlineTxnsAsOf
public static final void markOnlineTxnsAsOf(java.util.Iterator<AbstractTxn> txns, int asOfDate, byte statusFlag)Mark transactions in the given enumeration with the given status flag if they fall on or before the given date. Note: This method fires a txn-modified event for every transaction that is changed. -
getCorrespondingDuplicate
-
setRatesInTxn
If the given transaction contains any inter-currency (or security to/from currency) elements, adjust the rates based on the the currency and security rate/price tables at the time of the transaction. Note: This is only available in build 794 and later. -
getListOfAllUsedTransactionTags
-
getListOfAllNonNumericCheckNumbers
public static final java.util.List<java.lang.String> getListOfAllNonNumericCheckNumbers(AccountBook book, Account accountFilter, int maximumAmount)Return a list of non-numeric string values that have appeared in the check number field for transactions in the given account, or if accountFilter is null then in any account. This will return no more than maximumAmount entries.- Since:
- Moneydance 2020 (build 1916)
-
getListOfAllNonNumericCheckNumbers
public static final java.util.List<java.lang.String> getListOfAllNonNumericCheckNumbers(AccountBook book, Account accountFilter)Return a list of non-numeric string values that have appeared in the check number field for transactions in the given account, or if accountFilter is null then in any account. This will return no more than 200 entries.- Since:
- Moneydance 2019 (build 1908 or so)
-
mediaTypeForFilename
Return the best guess for the kind of media contained in the given file
-