Wiki
Clone wikiMoneydance-2019 / Objects
Home>Moneydance>Objects
Moneydance Objects
First read Traversing the Data for information about the main objects. The information here is about the other objects.
MoneydanceSyncableItem
This is a new class that seems to have been introduced to facilitate the synchronizing of data. Each of the main objects are extensions of this class. The classes are:
- AbstractTxn
- Account
- AddressBookEntry
- Budget
- BudgetItem
- CurrencySnapShot
- CurrencySplit
- CurrencyType
- OnlineMailList
- OnlinePayeeList
- OnlinePaymentsList
- OnlineService
- OnlineTxnList
- Reminder
- ReportSpec
According to the documentation for this class (see API Index) to update a particular object instance you call setEditingMode() prior to updating and then calling syncItem() once it is complete. I have not tried this yet.
AccountBook
The AccountBook holds details of the current file and where it is located within the file system. There are a number of methods to manipulate the files.
Accounts
All types of Accounts are held in the same structure (see Traversing Data). There is a nested class of the Account class which gives the type of Account, these are:
- Asset
- Bank
- CreditCard
- Investment
- Liability
- Loan
- Security
In addition the Income and Expense categories are also held as Accounts. This allows transactions to be standardized, i.e. a transfer between two or more accounts.
The two classes are: * Expense * Income
Lastly therre is Root which is the specific RootAccount
JDateField/CustomDateFormat
JDateField is a general object for entering a displaying dates.
You set the date format when you create the JDateField by passing an instance of CustomDateField. JDateField will put up a picker for the date when clicked on. You can enter the date but it must be in the precise format as the CustomDateFormat.
The format of dates is not defined in the documentation but using the normal dd, /, mm and yyyy seems to work.
Transactions
The transactions within your file are accessed via the AccountBook as shown in Traversing the Data. Typically a transaction will have a ParentTxn transaction and one SplitTxn. However, some transactions, such as Investment Dividend or Miscellaneous income/expense have two. What transactions are needed needs to be investigated using a tool such as the File Display extension. In addition you need to look at the Tags generated by Moneydance as if you miss these when creating transactions it will cause problems.
To create a transaction you need to:
- Create ParentTxn
- Create SplitTxn(1 or mote)
- Add SplitTxn(s) to the ParentTxn with
#!Java parentTxn.addSplit(splitTxn);
#!Java txnSet.txnModified(parentTxn);
A few examples of transactions are given below:
Investment Dividend
A Dividend transaction has two splits.
- Parent - TXN : Dividend amount against the Investment Account holding the security
- Split - TXN 1 : Dividend amount against the Investment Income category where you wish to record dividend
- Split - TXN 2 : A zero amount transaction against the Security Account that received the dividend.
You need to set the Transfer Type to TRANSFER_TYPE_DIVIDEND with:
#!Java case AbstractTxn.TRANSFER_TYPE_DIVIDEND : GenerateTransaction objLine2 = modTrans.getLine(i+1); GenerateTransaction objLine3 = modTrans.getLine(i+2); ParentTxn ptTran = new ParentTxn(Main.acctBook); ptTran.setDateInt(objLine.getDate()); ptTran.setTaxDateInt(objLine.getDate()); ptTran.setCheckNumber(objLine.getCheque()); ptTran.setAccount(objLine.getAccount()); ptTran.setDescription(objLine.getDesc()); ptTran.setMemo(""); ptTran.setTransferType(objLine.getTType()); ptTran.setParameter(Constants.TAGGEN, objLine.getRef()); /* * Amount needs to be negative as SplitTxn will negate parent amount * */ SplitTxn stTran1 = new SplitTxn(ptTran); stTran1.setCheckNumber(objLine2.getCheque()); stTran1.setAccount(objLine2.getAccount()); stTran1.setDescription(objLine2.getDesc()); stTran1.setAmount(0); stTran1.setParameter(AbstractTxn.TAG_INVST_SPLIT_TYPE, AbstractTxn.TAG_INVST_SPLIT_SEC); ptTran.addSplit(stTran1); SplitTxn stTran2 = new SplitTxn(ptTran); stTran2.setCheckNumber(objLine3.getCheque()); stTran2.setAmount(objLine3.getAmount(),1.0D,objLine.getAmount()); stTran2.setAccount(objLine3.getAccount()); stTran2.setDescription(objLine3.getDesc()); stTran2.setParameter(AbstractTxn.TAG_INVST_SPLIT_TYPE, AbstractTxn.TAG_INVST_SPLIT_INC); ptTran.addSplit(stTran2); objLine.setIndex(i); objLine2.setIndex(i+1); objLine3.setIndex(i+1); i+=3; Main.tsTrans.txnModified(ptTran); ptTran.syncItem(); stTran1.syncItem(); stTran2.syncItem();
Investment income/expense
Same as Dividend though the Transfer Type is TRANSFER_TYPE_MISCINCEXP and the Account on Split TXN 1 is the income/expense category as required.
Updated