New Transactions using Python
Ok, dug around and found a few things, but have some questions...
So starting with this:
https://infinitekind.tenderapp.com/discussions/moneydance-development/252-a-proper-way-to-add-an-uncomfirmed-transaction
It mentions setting a source account on the ParentTxn and target account on the SplitTxn.
Does 'source account' here mean the bank account and 'target account' mean the 'Category'?
Then found this:
https://infinitekind.tenderapp.com/discussions/moneydance-development/1363-jython-new-transaction-query
Looking at that code, it looks like it just sets 'categories'. Looking at that code I think it is missing the concept of a 'source account' (.i.e. bank acccount)...?
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
1 Posted by Jim on 24 Aug, 2020 01:54 AM
OK. So did some testing and I think I was correct. So I have this now which seems to work:
2 Posted by Jim on 24 Aug, 2020 01:57 AM
Could also change the first line to just:
Support Staff 3 Posted by Sean Reilly on 24 Aug, 2020 02:58 PM
Hi Jim,
Yes, in most cases the source account is the bank account, but we don't really use that terminology in moneydance itself. In Moneydance any transaction is a movement of value from one account to another (or to/from multiple others in the case of multi-split transactions). So each transaction must have at least two "sides". One side is always represented by the ParentTxn, which is usually the account in which the transaction was entered. Then there are one or more splits, where each split specifies the other account (or category) and the amount.
It gets more complicated with inter-currency transactions, cleared status, tags, etc, but that's the basics.
So to simplify the example you linked to...
```
txn = ParentTxn(book)
txn.setDescription("Example Transaction")
txn.setDateInt(20200824)
txn.setAccount(account1) // <- this is where your "bank" account is usually specified
txnSplit = SplitTxn(txn)
txnSplit.setAmount(555)
txnSplit.setAccount(account2) // <- this is where your category is usually specified
txn.syncItem() // <- saves the transaction
```
Thanks!
Sean
Support Staff 4 Posted by Sean Reilly on 24 Aug, 2020 02:58 PM
Oh yes! Sorry, you've got it right. I sent my last message before seeing your subsequent replies.
System closed this discussion on 23 Nov, 2020 03:00 PM.