Where is the NetWorthCalculator?

edcasillas's Avatar


13 Feb, 2024 05:47 AM

In the docs included with the development kit, I see there should be a class com.infinitekind.moneydance.model.NetWorthCalculator... only it is not included in the API.

I want to get the net worth, and currently I'm calculating it myself by iterating through all accounts where shouldBeIncludedInNetWorth() is true... but I figured there should be something already in place to calculate it.

  1. 1 Posted by Stuart Beesley ... on 13 Feb, 2024 06:51 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    OK, I was about to say there isn't one... But you are right... It magically appeared in MD2023.3(5064). So you need to be on this version... It does seem, to be half there in build 5007, but stick with 5064.

    This code will get you started:

    from com.infinitekind.moneydance.model import NetWorthCalculator, Account, CurrencyType
    print "-----"
    base=book.getCurrencies().getBaseType()                # Optional
    nwc=NetWorthCalculator(book)                     # Defaults are: currency:base, balanceType:CURRENT, ignoreInactiveAccounts:true, observeAccountSpecificNetWorthFlags:true
    nwc.setCurrency(base)                                                        # Optional
    nwc.setBalanceType(Account.BalanceType.NORMAL)   # Optional - Account.BalanceType.NORMAL, CURRENT, CLEARED, CONFIRMED, UNCONFIRMED
    nwc.setIgnoreInactiveAccounts(True)                                # Optional
    nwc.setObserveAccountSpecificNetWorthFlags(True) # Optional
    result = nwc.calculateTotal()                                        # type: TotalAmount
    print "Currency:", result.getCurrency(), "balType:", nwc.getBalanceType(), "raw:", result.getAmount(), "NW result:", c.formatFancy(result.getAmount(), dec)
    print "-----"
    I just played with currency conversions, and that's not really complete... so needs fixing.....
  2. 2 Posted by Stuart Beesley ... on 13 Feb, 2024 07:05 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    FYI - I've suggested a couple of tweaks to make currency conversions easier too.. But in the meantime, you can just create a new instance for new currency conversions...

  3. 3 Posted by edcasillas on 14 Feb, 2024 02:14 AM

    edcasillas's Avatar

    Thanks! I was trying to do something like your suggestion, but the NetWorthCalculator class is not in the moneydance-dev.jar library I downloaded from https://infinitekind.com/dev/moneydance-devkit-5.1.tar.gz

    I have MD2023.3(5064) installed, but after reading your response I'm not sure if v5.1 of the dev kit matches the installed app.

    (attaching a partial list of the classes and interfaces included in moneydance-dev.jar as shown in IntelliJ, sorted alphabetically... none of them even starts with N)

  4. 4 Posted by edcasillas on 15 Feb, 2024 01:00 AM

    edcasillas's Avatar

    So... as I was saying in this other thread: https://infinitekind.tenderapp.com/discussions/moneydance-developme...

    Replacing the moneydance-dev.jar with moneydance.jar from the contents of the app gets me access to these missing classes, including NetWorthCalculator :D

  5. edcasillas closed this discussion on 15 Feb, 2024 01:46 AM.

  6. Stuart Beesley (Mr Toolbox) re-opened this discussion on 15 Feb, 2024 08:26 AM

  7. 5 Posted by Stuart Beesley ... on 15 Feb, 2024 08:26 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Yup. Basically nothing uses this class and prior to 5007 (Kotlin), only used classes were compiled into MD. Hence back then when the dev Ali jar was created, it didn’t exist. Since 5007, all classes are compiled and hence it’s now in the live MD jar.

    Again, nice spot. I’m also going to use this class now. We also upgraded it for the next release.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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