[moneydance] moving a transaction to an account with different currency

Sean Reilly sreilly at seanreilly.com
Sat Dec 30 13:02:36 EST 2006


Hi Jill,

I think the best method to use to set both sides of the amount and the rate
at the same time would be:
  txn.setAmount(<categoryAmount>, <acctAmount>)
This assumes that txn is a SplitTxn and not a ParentTxn.  Every transaction
in Moneydance consists of:
 1) One ParentTxn that holds the value of the transaction in the account in
which it was entered as well as the date, memo, payee, etc.
 2) One or more SplitTxns that refers to a category (or other account),
amount, exchange rate, description, etc.

It sounds like you can scan all of the SplitTxns that touch one of the
categories you want to change and call:
  txn.setAccount(gbp_acct);
  txn.setAmount(-txn.getAmount(), -txn.getAmount());

After modifying any transaction that transaction will be dirty since it has
been modified since the file was last saved.  There currently isn't an undo
function to 'undirty' a transaction, but hopefully someday there will be.

Thanks,
Sean

On 12/30/06, Jill Lundquist <jill at chezns.org> wrote:
>
>
> I'm doing something wrong here and would greatly appreciate some clues on
> how to do it right, since I have hundreds of transactions I need to
> adjust.  I'm using release 554, though I saw the same behaviour in the
> previous release as well.
>
> The problem is that after moving from the US to the UK this year, I was
> still using a 'Train' expense account whose default currency was USD.  I am
> currently separating these transactions into 'Train USD' and 'Train GBP'
> categories.
>
> Here is a commented transcript of one approach I've tried in the jython
> interface:
> # Grab the accounts and show that they indeed have the currencies
> # I think they do.
> >>> rootaccount = moneydance.getRootAccount()
> >>> usd_acct = matchAccount(rootaccount, 'OldTransportation:Train USD')
> >>> usd_acct.getCurrencyType()
> US Dollar
> >>> gbp_acct = matchAccount(rootaccount, 'OldTransportation:Train GBP')
> >>> gbp_acct.getCurrencyType()
> British Pound
>
> # Drill down to find an example transaction.
> >>> txns = rootAccount.getTransactionSet
> ().getTransactionsForAccount(usd_acct)
> >>> txnEnum = txns.getAllTxns()
> >>> badTxn = txnEnum[0]
>
> # I bought a train ticket with cash for GBP 15.70, but it's being stored
> with
> # a rate (of currency exchange) and a val of USD 22.94.
> >>> badTxn
> [SplitTxn(2385) desc=train; val=2294; stat= ; acct=OldTransportation:Train
> USD; rate=1.4611464968152865; amt=-1570; val=2294;  ]
>
> # I would like at this point to do:
> #     badTxn.setRate(1.0)
> #     badTxn.setAccount(gbp_acct)
> # but what I get after the first is:
> >>> badTxn.setRate(1.0)
> >>> badTxn
> [SplitTxn(2385) desc=train; val=2294; stat= ; acct=OldTransportation:Train
> USD; rate=1.4611464968152865; amt=-1570; val=2294; dirty;  ]
> >>> badTxn.getParentTxn()
> [ParentTxn(2386) desc=train; val=-1570; stat= ; #splits=1; chk=;
> acct=Wallet:GBP Cash; date=20061120; splits=[SplitTxn(2385) desc=train;
> val=2294; stat= ; acct=OldTransportation:Train USD; rate=
> 1.4611464968152865; amt=-1570; val=2294; dirty;  ], ; ]
> >>>
>
> Is there a way for me to undirty this transaction, and will that cause
> Moneydance to reset the rate and recalculate the val?
>
> Or perhaps I am approaching this from the wrong angle entirely?  The only
> way I've been able to get what I want is to choose 'Tools/Edit Categories',
> double-click 'Train USD', ctrl-click a transaction and select 'Show Other
> Side', then change the category from 'Train USD' to 'Train GBP', which
> apparently forces a recalculation.  This procedure is of course fine for a
> few transactions but I would much rather do hundreds of them via jython if
> feasible.
>
> Many thanks,
>
>      Jill Lundquist
>
> _______________________________________________
> moneydance-info mailing list
> moneydance-info at moneydance.com
> http://moneydance.com/mailman/listinfo/moneydance-info
>



-- 
http://seanreilly.com


More information about the moneydance-info mailing list