Class AbstractTxn

java.lang.Object
com.infinitekind.moneydance.model.MoneydanceSyncableItem
com.infinitekind.moneydance.model.AbstractTxn
All Implemented Interfaces:
Txn, com.infinitekind.tiksync.SyncableItem
Direct Known Subclasses:
ParentTxn, SplitTxn

public abstract class AbstractTxn
extends MoneydanceSyncableItem
implements Txn
This is the base class for all types of transactions. Each transaction is assigned to one account and has an amount that adds to, or subtracts from the value of the account. Each transaction can also have an associated set of 'tags'. Tags are arbitrary key-value pairs of String objects. Typically a transaction will have two sides 1) a "parent" transaction, and 2) one or more "split" transactions. The value of the parent transaction is defined by the sum of the values of the split transactions (possibly adjusted by the rate of each of the split transactions).
  • Field Details

  • Constructor Details

    • AbstractTxn

      public AbstractTxn​(AccountBook book)
      Construct a transaction with the given account, description, transaction ID (-1 for a new transaction) and status.
  • Method Details

    • itemWasUpdated

      protected void itemWasUpdated()
      Description copied from class: MoneydanceSyncableItem
      This is called after an item is updated by calling itemWasUpdated(SyncRecord). This can occur from the syncing process or from being loaded locally. Override this method to be notified.
      Overrides:
      itemWasUpdated in class MoneydanceSyncableItem
    • itemWillSync

      protected void itemWillSync()
      Description copied from class: MoneydanceSyncableItem
      This is called just before an item will be stored and/or synced when itemWillSync(SyncRecord) is called. Override this method to be notified or if you'd like to store anything into the info record to be synced.
      Overrides:
      itemWillSync in class MoneydanceSyncableItem
    • autoSyncsChanges

      protected boolean autoSyncsChanges()
      transactions are explicitly updated when recording a transaction
      Overrides:
      autoSyncsChanges in class MoneydanceSyncableItem
    • getOldTxnID

      public long getOldTxnID()
    • getDateEntered

      public abstract long getDateEntered()
      Get the date that this transaction was entered.
      Specified by:
      getDateEntered in interface Txn
    • getDateInt

      public abstract int getDateInt()
      Get the date of this transaction
      Specified by:
      getDateInt in interface Txn
    • getTaxDateInt

      public abstract int getTaxDateInt()
      Get the date of this transaction for tax purposes.
      Specified by:
      getTaxDateInt in interface Txn
    • getValue

      public abstract long getValue()
      Get the value of this transaction, in the currency assigned to the account for this transaction.
      Specified by:
      getValue in interface Txn
    • getParentTxn

      public abstract ParentTxn getParentTxn()
      Get the ParentTxn of this transfer.
      Specified by:
      getParentTxn in interface Txn
    • getOtherTxnCount

      public abstract int getOtherTxnCount()
      Get the number of transactions from the "other side" of this transaction. For splits, this will always be 1. For ParentTxns, this will be the number of splits.
      Specified by:
      getOtherTxnCount in interface Txn
    • getOtherTxn

      public abstract AbstractTxn getOtherTxn​(int i)
      Get the transaction that make up the other side of this transaction at the specified index. For SplitTxns, this index should always be 0 because there is only one "other transaction". for ParentTxns, this will return the split at the specified index.
      Specified by:
      getOtherTxn in interface Txn
    • isTransferTo

      public abstract boolean isTransferTo​(Account acct)
      Check whether or not this transaction includes a transfer to the given account.
      Specified by:
      isTransferTo in interface Txn
    • getTransferType

      public abstract java.lang.String getTransferType()
      Get the type of transaction. Usually only used in the investment register to differentiate between buy, sell, and stock split transactions.
      Specified by:
      getTransferType in interface Txn
    • getAccount

      public final Account getAccount()
      Get the account associated with this transaction.
      Specified by:
      getAccount in interface Txn
    • setAccount

      public final void setAccount​(Account newAccount)
      Set the account associated with this transaction.
    • getDescription

      public final java.lang.String getDescription()
      Get the description associated with this transaction.
      Specified by:
      getDescription in interface Txn
    • setDescription

      public final void setDescription​(java.lang.String newDescription)
      Set the description associated with this transaction.
    • getStatusChar

      public final char getStatusChar()
      Get a character that indicates the status of this transaction
      Specified by:
      getStatusChar in interface Txn
    • getStatus

      public final byte getStatus()
      Get the status associated with this transaction.
      Specified by:
      getStatus in interface Txn
    • getClearedStatus

      public AbstractTxn.ClearedStatus getClearedStatus()
      Description copied from interface: Txn
      Get the status associated with this transaction.
      Specified by:
      getClearedStatus in interface Txn
    • setClearedStatus

      public final void setClearedStatus​(AbstractTxn.ClearedStatus newStatus)
      Set the status associated with this transaction.
      Specified by:
      setClearedStatus in interface Txn
    • setStatus

      public final void setStatus​(byte newStatusByte)
      Set the status associated with this transaction.
      Specified by:
      setStatus in interface Txn
    • getCheckNumber

      public abstract java.lang.String getCheckNumber()
      Get the checknumber associated with this transaction.
      Specified by:
      getCheckNumber in interface Txn
    • getCheckNumAsInt

      public int getCheckNumAsInt()
      Get the check number as an integer (returns 0 if it's not an integer)
      Specified by:
      getCheckNumAsInt in interface Txn
    • getCheckNumAsLong

      public long getCheckNumAsLong()
      Get the check number as a long (returns 0 if it's not an integer value)
    • getFiTxnId

      public final java.lang.String getFiTxnId​(int protocolId)
      Return the ID that the financial institution uses to identify this transaction. Specific to the protocolId which is defined in OnlineTxn.
    • setFiTxnId

      public final void setFiTxnId​(int protocolId, java.lang.String fitid)
      Set the ID that the financial institution uses to identify this transaction. The TID is specific to the protocol type which is defined in OnlineTxn.
    • getFIID

      public final java.lang.String getFIID()
      Returns the identifier for the financial institution from which this transaction was downloaded, or null if no financial institution information has been provided.
    • setFIID

      public final void setFIID​(java.lang.String fiID)
      Sets the identifier for the financial institution from which this transaction was downloaded. If null is provided then the FI ID is removed from this tranaction.
    • wasDownloaded

      public final boolean wasDownloaded()
      Return true iff this transaction has a FI transaction ID associated with it. This method is only avaialable as of build 551
    • isNew

      public boolean isNew()
      Returns whether or not this transaction should be considered "unread" since having been downloaded
      Specified by:
      isNew in interface Txn
    • setIsNew

      public void setIsNew​(boolean isNew)
      Sets whether or not this transaction should be considered "unread" since having been downloaded
    • isDirty

      public boolean isDirty()
      Returns true if this transaction has been modified since it was last saved.
    • setDirty

      public final void setDirty()
      Mark this transaction as modified, and needing to be saved.
      Overrides:
      setDirty in class MoneydanceSyncableItem
    • resetDirty

      public final void resetDirty()
      Mark this transaction as unmodified. This should be called only after being saved.
    • getTags

      public final com.infinitekind.tiksync.SyncRecord getTags()
    • loadFromStorage

      public final void loadFromStorage​(java.util.Map<java.lang.String,​java.lang.String> newTags)
      Set the TagSet associated with this object. This should only be called when initially constructing this object by the system. In other words, DON'T USE THIS!
    • getAddress

      public AddressBookEntry getAddress()
      Returns the address book entry (if any) that is associated with this transaction.
      Overrides:
      getAddress in class MoneydanceSyncableItem
    • needsToBePrinted

      public final boolean needsToBePrinted()
      Returns true if this transaction has been marked as to-be-printed.
    • getAttachmentTag

      public java.lang.String getAttachmentTag​(java.lang.String tagName)
      Return the storage location, if any, that is associated with the given tag name. The resulting file can be retrieved by calling one of the file reading methods on the account book's local storage interface: InputStream attachmentIn = transaction.getBook().getLocalStorage().openFileForReading(transaction.getAttachmentTag(tagName));
    • setAttachmentTag

      public void setAttachmentTag​(java.lang.String tagName, java.io.File file) throws java.lang.Exception
      Set the file that is associated with the given tag name, copying the file into the data set's internal storage.
      Throws:
      java.lang.Exception
    • removeAttachmentTag

      public void removeAttachmentTag​(java.lang.String tagName)
      Remove the specified attachment tag, along with the file that it contains
    • hasAttachments

      public boolean hasAttachments()
      Return true if if this transaction has any attachments
    • getAttachmentKeys

      public java.util.List<java.lang.String> getAttachmentKeys()
      Return a list of tag names for attachments to this object
    • getOriginalOnlineTxn

      public OnlineTxn getOriginalOnlineTxn()
      Return a copy of the OnlineTxn that was used to record a local transaction, if any. The OnlineTxn will contain information such as the date the transaction was posted as well as the original description and memo fields as downloaded from the bank.
      Since:
      Moneydance build 1525 (v2017)
    • setOriginalOnlineTxn

      public void setOriginalOnlineTxn​(OnlineTxn onlineTxn)
      Set the online transaction information as received from the bank's online interface, or null to clear the online information for this transaction.
      Since:
      Moneydance build 1525 (v2017)
    • getDatePostedOnline

      public int getDatePostedOnline()
      Return the date that this transaction was posted or cleared with the bank, if available, from the online information. If no online information is available for this transaction then this returns the results of getDateInt().
      Since:
      Moneydance build 1525 (v2017)