Programmatically creating new transactions via Python

John's Avatar

John

15 Jan, 2011 05:57 PM

Several people seem to have asked how to programmatically create a new transaction, but none of the posts have been answered. Can someone please explain how this works? I basically want to create new transactions in a Credit Card account via the Python interface.

  1. 1 Posted by alani on 16 Jan, 2011 02:33 PM

    alani's Avatar

    Hi John,

    I agree with you, the developer documentation could be much better. I have written a CSV importer for my Bankstatement using the python interface. It took some time but in the end i figured out. Even with matching of existing transactions. I am not really happy with it but, it works somehow. :-) See a quick extract below.

    I hope this helps.

    regards,

    Alain

    account = findAccountByAccountNum(ra,accountnum)
    ra = moneydance.getRootAccount()
    transactionId = ra.getTransactionSet().getTransactionCount() + 1
    txn = ParentTxn(parrentT['date'], parrentT['date'], parrentT['date'], "", act,    parrentT['desc'], "memo", transactionId, ParentTxn.STATUS_UNRECONCILED )
    txn.setFiTxnId(1,parrentT['FiTxnId']) #use Protocoll ID 1 = OFX
    txn.addSplit(splitTxn)
    ra.getTransactionSet().addNewTxn(txn)
    ra.refreshAccountBalances()
    
    def findAccountByAccountNum(acc,accountNum):
      subAccounts = acc.getSubAccounts()
      for account in subAccounts:
        bankId = account.getParameter('ofx_bank_id')
        if accountNum == bankId.translate(all, nodigs):
          return account
        else:
          if account.getSubAccountCount() > 0:
            return findAccountByAccountNum(account,accountNum)
    
  2. System closed this discussion on 31 Mar, 2015 03:35 PM.

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