Budget items

davidcullen's Avatar


29 Jun, 2019 05:54 AM

I'm not into java, only python (jython).
I'm OK with txns - creating, editing etc but am now trying to access Budget items (querying, creating, sorting etc) but cannot seem to find how to start. Any guidance or pointers (python) would be much appreciated.

  1. 1 Posted by Tobias Goldston... on 07 Jul, 2019 03:00 AM

    Tobias Goldstone's Avatar

    I too am interested in this capability. Any preliminary guidance would be most appreciated.

  2. 2 Posted by Tobias Goldston... on 08 Jul, 2019 03:34 AM

    Tobias Goldstone's Avatar

    caveat: I'm just learning python so things won't be elegant for a while (if ever).

    Here's something I mashed together to pull current budget list items and print them.
    It looks like it defaults the display amount to the current interval/period.

    from com.infinitekind.moneydance.model import *

    budgetsList = moneydance_data.getBudgets()
    currentBudget = budgetsList.findCurrentBudget()
    items = currentBudget.getItemList()
    for item in items:
    amount = item.getAmount()/ 100
    interval = item.getInterval()
    dateRange = item.getDateRange()
    print 'Amount: $' + str(amount)
    print 'Interval: ' + str(interval)
    print 'Date Range: ' + str(dateRange)

    I'm interested in figuring out how close to any of my budgeted categories amount I am at any one time.



  3. 3 Posted by davidcullen on 16 Jul, 2019 04:12 AM

    davidcullen's Avatar

    Thanks, Tobias. This is helpful. However, little else to go on (api has no examples or tutorial).

  4. 4 Posted by Mike Bray (Quot... on 16 Jul, 2019 06:02 AM

    Mike Bray (Quote Loader Author)'s Avatar

    I don't know if this will help. I have written a budget generator extension in Java. In that extension I get the current actuals by reading through the transactions for the period and category and totalling them.

    In java terms this is getBook().getTransactionSet().getTransactions(filter) where the filter determines whether or not a transaction is to be included in the total.

    The filter basically is true when the account of the transaction equals the budget category and the transaction date is within the budget period. Remember MD contains 2 transactions per real transaction, one against the actual account (the parent) and one against the category(the split).

  5. 5 Posted by Toby Goldstone on 16 Jul, 2019 05:31 PM

    Toby Goldstone's Avatar

    It looks like within a budget there's a calculated actual that can be
    referenced along with the budgeting by category. Unfortunately I can't
    find a way to pull the data via Python.

    If there's anyone who could help provide a code snippet I'd love to see it.

    It would be nice to build extensions but it's proving super difficult
    without some additional guidance.


  6. 6 Posted by Mike Bray (Quot... on 18 Jul, 2019 01:02 PM

    Mike Bray (Quote Loader Author)'s Avatar

    I don't know python but the enclosed seems to work. I believe that you can use any of the defined classes/methods in the documentation within your python script

  7. 7 Posted by Mike Bray (Quot... on 18 Jul, 2019 01:09 PM

    Mike Bray (Quote Loader Author)'s Avatar

    Another approach is to look at the Calculate method and then interrogate the CalculationResult subclass (see: https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/mod...)

  8. 8 Posted by Toby Goldstone on 20 Jul, 2019 02:54 AM

    Toby Goldstone's Avatar

    Two questions… If I try to run that in version 2019.3 then there’s an undefined variable ‘book’. Would that be a reference to the AccountBook object?

    I don’t see where in your script book gets defined/referenced anywhere. I think it might be missing book = moneydance.getCurrentAccountBook()

    Also you’re using TxnSet in your function but I’m not sure where that’s getting defined and it does error out.

    allTrans = book.getTransactionSet().getAllTxns()
        def getAmount(TxnSet, item) :

    All this being said this particular class (if I can figure out how to reference it) perhaps holds the answer to an easy actual vs budget by category query: Class BudgetItemDetail

  9. 9 Posted by Mike Bray (Quot... on 20 Jul, 2019 07:05 AM

    Mike Bray (Quote Loader Author)'s Avatar

    sorry about that, there is a missing line

    book=moneydance_data which should be after line 1

    Obviously the indentation needs to be sorted out but I copied the file, added the above line and it ran.

  10. 10 Posted by Mike Bray (Quot... on 20 Jul, 2019 08:20 AM

    Mike Bray (Quote Loader Author)'s Avatar

    I have had a look at python within MD.

    The variable moneydance_data is the AccountBook object for the current file. From this you can get to any of the data within the file.

    Have a look at https://bitbucket.org/mikerb/moneydance-2019/wiki/Moneydance%20Obje...

    It will show you the structure of the data.

    From that variable you can use any of the API calls as defined in the core API (see https://infinitekind.com/dev/apidoc/index.html)

    I have created a quick test of the Budget.calcuate(from, to, showall,showzero) call. See enclosed.

    Hope this helps. You may want to look at the whole of my wiki, it has a number of extensions and information for MD (see https://bitbucket.org/mikerb/moneydance-2019/wiki/Home)

  11. 11 Posted by Toby Goldstone on 20 Jul, 2019 02:59 PM

    Toby Goldstone's Avatar

    Thanks! Your wiki information is great.

  12. System closed this discussion on 19 Oct, 2019 03:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac