Class SplitTxn

All Implemented Interfaces:
Txn, com.infinitekind.tiksync.SyncableItem

public final class SplitTxn
extends AbstractTxn
Concrete class that represents the destination side of a transaction. The destination side of the transaction is associated with exactly one source (or parent) transactions. The amount of a SplitTxn is stored in terms of the currency of the account for the associated ParentTxn.
  • Constructor Details

    • SplitTxn

      public SplitTxn​(ParentTxn parentTxn)
      Creates a SplitTxn attached to the given ParentTxn
  • Method Details

    • isSyncable

      protected boolean isSyncable()
      Overrides:
      isSyncable in class MoneydanceSyncableItem
    • 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 AbstractTxn
    • 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 AbstractTxn
    • deleteItem

      public boolean deleteItem()
      Deletes this item by removing it from the parent. The parent will then need to be saved (syncItem()) in order to commit the change.
      Overrides:
      deleteItem in class MoneydanceSyncableItem
    • getParentTxn

      public ParentTxn getParentTxn()
      Get the ParentTxn for which this is a split.
      Specified by:
      getParentTxn in interface Txn
      Specified by:
      getParentTxn in class AbstractTxn
    • getDateEntered

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

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

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

      public long getParentAmount()
      Get the amount of this transaction in terms of the currency of the parent transaction.
    • getParentValue

      public long getParentValue()
      Get the amount of this transaction in terms of the currency of the parent transaction.
    • getAmount

      public long getAmount()
      Get the amount of this transaction in terms of the currency of the parent transaction.
    • getValue

      public long getValue()
      Get the amount that this transaction affects the account of the this transaction.
      Specified by:
      getValue in interface Txn
      Specified by:
      getValue in class AbstractTxn
    • isTransferTo

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

      public double getRate()
      Get the rate for the transaction. This is the rate used to calculate the amount in the source account. For example, the amount of this transaction, divided by the rate will yield the amount subtracted from the source account.
    • getTransferType

      public 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
      Specified by:
      getTransferType in class AbstractTxn
    • setParentAmount

      public void setParentAmount​(double newRate, long newParentAmount)
      Set the amount of the transaction in the parent account. The newRate value indicates the rate that should be used to calculate the amount of the transaction in the split account.
    • negateAmount

      public void negateAmount()
      Reverses the sign of the amount of the split
    • takeAmounts

      public void takeAmounts​(SplitTxn split)
      Take the amount and rates from the given split.
    • takeValuesFrom

      public final void takeValuesFrom​(SplitTxn otherTxn)
    • setAmount

      public void setAmount​(long newSplitAmount, long newParentAmount)
      Set the amounts for this transaction, including the amount of the transaction in the split account, and the amount of the transaction in the account of the parent transaction.
    • setAmount

      public void setAmount​(long newSplitAmount, double newRate, long newParentAmount)
      Set the amounts for this transaction, including the amount of the transaction in the split account, the rate, and the amount of the transaction in the account of the parent transaction. newParentAmount must equal -Math.round(newSplitAmount * rate). The rate is ignored unless newParentAmount or newSplitAmount are zero (thus invalidating the above equation.
    • setAmount

      public void setAmount​(long splitAmount)
      Set the amount that this split affects the -other- side of the transaction.
    • getCheckNumber

      public final java.lang.String getCheckNumber()
      Description copied from class: AbstractTxn
      Get the checknumber associated with this transaction.
      Specified by:
      getCheckNumber in interface Txn
      Specified by:
      getCheckNumber in class AbstractTxn
    • setCheckNumber

      public final void setCheckNumber​(java.lang.String newCheckNumber)
    • getClearedStatus

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

      public int getOtherTxnCount()
      Return the number of "other transactions".
      Specified by:
      getOtherTxnCount in interface Txn
      Specified by:
      getOtherTxnCount in class AbstractTxn
    • getOtherTxn

      public AbstractTxn getOtherTxn​(int i)
      Return the "other transaction" for this split.
      Specified by:
      getOtherTxn in interface Txn
      Specified by:
      getOtherTxn in class AbstractTxn
    • getFlipSide

      public Txn getFlipSide()
      Return the 'flip side' of this split transaction. This is experimental, so please don't use it for any extensions yet. Basically, this returns the ParentTxn if this split is the only split. Otherwise, this returns a cached anonymous inner class that has the normal AbstractTxn methods mapped to return a value for the "other side" of just this split.
      Since:
      Moneydance build 744
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • makeSplitTxn

      public static SplitTxn makeSplitTxn​(ParentTxn parentTxn, long parentAmount, long splitAmount, double rate, Account account, java.lang.String description, long txnId, byte status)
      Creates a SplitTxn with the parentAmount having a negative effect on the account of parentTxn, and splitAmount having a positive effect on the account of this SplitTxn. The given rate is only used if the parentAmount or splitAmount are zero.
    • makeSplitTxn

      public static SplitTxn makeSplitTxn​(ParentTxn parentTxn, long parentAmount, double rate, Account account, java.lang.String description, long txnId, byte status)
      Deprecated.
      please use the other makeSplitTxn call as the amounts will not be subject to floating point inaccuracies
      Creates a SplitTxn with the parentAmount having a negative effect on the account of parentTxn, and splitAmount having a positive effect on the account of this SplitTxn.