create transaction with python

Bernhard's Avatar

Bernhard

21 Feb, 2019 04:35 PM

Hi,

just started my first steps into Moneydance scripting, having a simple request: Create an automated transaction with a single split. Unfortunately I fail and have no idea why.

Running the attached script I get the following message:

Beginning file /Users/bernhard/Documents/Moneydance-Extension/md-transaction.py at Thu Feb 21 17:35:09 CET 2019
PersonalFinances
[ParentTxn(null) desc=test desc; val=0; stat= ; #splits=0; chk=; acct=Forecast; date=20190225; dirty; splits=; ] Error running script: Traceback (most recent call last):
File "/Users/bernhard/Documents/Moneydance-Extension/md-transaction.py", line 21, in txnSplit = SplitTxn.makeSplitTxn(newTxn, amount, amount, 1.0, miscAccount, desc, -1, AbstractTxn.STATUS_UNRECONCILED ) at com.infinitekind.moneydance.model.AbstractTxn.setAccount(AbstractTxn.java:241) at com.infinitekind.moneydance.model.SplitTxn.makeSplitTxn(SplitTxn.java:414) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.NullPointerException: java.lang.NullPointerException
Traceback (most recent call last):
File "/Users/bernhard/Documents/Moneydance-Extension/md-transaction.py", line 21, in txnSplit = SplitTxn.makeSplitTxn(newTxn, amount, amount, 1.0, miscAccount, desc, -1, AbstractTxn.STATUS_UNRECONCILED ) at com.infinitekind.moneydance.model.AbstractTxn.setAccount(AbstractTxn.java:241) at com.infinitekind.moneydance.model.SplitTxn.makeSplitTxn(SplitTxn.java:414) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source)

java.lang.NullPointerException: java.lang.NullPointerException

Looking forward to someone how shows me my mistake

Thanks Bernhard

  1. Support Staff 1 Posted by Sean Reilly on 21 Feb, 2019 09:01 PM

    Sean Reilly's Avatar

    Hi Bernhard,

    It's great to see you getting into Moneydance scripting. In this case the NullPointerException is occurring because the miscAccount is null (or 'None' in the python world). It seems like you'll need to check for a missing account or category when creating the transaction.

    Hope this helps!

    Thanks,
    Sean

  2. 2 Posted by Bernhard on 22 Feb, 2019 07:50 AM

    Bernhard's Avatar

    Hi Sean,

    thanks for quick support.

    You are right. Now it works.

    Best regards

    Bernhard

    From: Sean Reilly <[email blocked]>
    Reply-To: <[email blocked]>

  3. System closed this discussion on 24 May, 2019 08:00 AM.

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

Keyboard shortcuts

Generic

? 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

Recent Discussions

14 Dec, 2024 07:05 PM
14 Dec, 2024 06:35 PM
14 Dec, 2024 06:22 PM
14 Dec, 2024 05:15 PM
14 Dec, 2024 03:08 PM