[md-dev] Programmatically creating transactions

Sean Reilly sreilly at seanreilly.com
Fri Apr 28 05:05:48 EDT 2006


On Apr 27, 2006, at 11:54 PM, Mike Hunsicker wrote:

> Thanks for the reply. I'm not getting any exceptions when I add it.  
> But the transaction gets a date of 07/06/0020, which is totally  
> invalid.

Which setDate function are you using?  There are two ways of setting  
the date on a transaction:
  1) The old way: txn.setDate(long) which takes the milliseconds (as  
returned from new java.util.Date().getTime())
  2) The new way: txn.setDateInt(int) which takes the date encoded as  
an integer with the value YYYYMMDD.

It sounds like you might be mixing up the two methods and their  
parameters and the date is rolling on over to the year 0020 (which  
would be a negative number).

> Then after creating the transaction, my plugin iterates through the  
> transactions via rootAccount.getTransactionSet 
> ().getTransactionsForAccount( account ).getAllTxns() and then it  
> gets a class cast exception because there's a split transaction in  
> there. It may be a wrong assumption on my part, but so far, that  
> function has never returned split transactions so I'm just casting  
> them to ParentTxns. Any thoughts?

That enumeration is only supposed to return AbstractTxns, so you  
should do an instanceof check before casting, or (to simplify) just  
work with the AbstractTxn interface.


Thanks,
Sean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2560 bytes
Desc: not available
Url : http://moneydance.com/pipermail/moneydance-dev/attachments/20060428/d6b1fd08/smime.bin


More information about the moneydance-dev mailing list