Register patch question

Derek Atkins warlord at MIT.EDU
Thu Sep 11 09:06:21 EDT 2008


Herbert Thoma <herbert.thoma at iis.fraunhofer.de> writes:

> Hi Charles,
>
> why do you need such a flag?
>
> Can't we prevent the zero setting of the excahnge rate? I.e.
> instead of setting the rate to zero, pop up the exchange
> rate dialog (possibly augmented with some explaination about
> the different currencies in the other acount)?
>
> What am I missing?

You can't pop up the dialog when the account changes, because
the user might also change the amount of the Split.  So you have
to wait until after the user exist the amount cell, too (which
effectively is the same as when they leave the split).

Only at that time do you have enough information to open the exch rate
dialog..  But you need to remember whether or not to open it.

The code I originally wrote for this used a zeroized exch rate as
the key to open the dialog.  But obviously this doesn't really work
right for gain/loss splits (when looking from the Checking account).

>  Herbert.

-derek

> Charles Day schrieb:
>> I've figured out the source of bug 436342 and bug 340041, but I have a
>> question about how to fix it. I'm hoping someone can point me in the right
>> direction.
>> 
>> The problem occurs when you edit an existing transaction in a register. If
>> you change the account on one of the split lines, and the new account uses a
>> different currency than the old account, the exchange rate dialog never pops
>> up to ask you the exchange rate. Instead, the exchange rate is saved as
>> zero.
>> 
>> The reason this happens is that when the code figures out that you've
>> changed the account, it resets the exchange rate to zero. Later on, a
>> different part of the code sees the zero exchange rate and *assumes* that
>> the user deliberately approved an exchange rate of zero. So the split gets
>> saved that way. This is actually appropriate in some situations, such as
>> when the user wants to enter capital or currency gain/loss splits. However,
>> in this case it was the register code that set the rate to zero, not the
>> user. So the assumption is wrong, and that causes the bug.
>> 
>> Now my question: since the two phases of this problem (1. setting the rate
>> to zero, 2. saving the transaction) occur in different functions, in
>> different files, I need a way to store a flag somewhere that indicates
>> whether the zero exchange rate was set by the user (or not). Where could I
>> store such a flag? I was thinking of adding it to the register's private
>> SRInfo data structure (see the definition of sr_info in
>> ledger-core/split-register-p.h). Would this be an appropriate place?
>> 
>> Any other hints/suggestions?
>> 
>> Cheers,
>> Charles
>> _______________________________________________
>> gnucash-devel mailing list
>> gnucash-devel at gnucash.org
>> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>> 
>
> -- 
> !!! Please note new phone and fax numbers !!!
> Herbert Thoma
> Head of Video Group
> Multimedia Realtime Systems Department
> Fraunhofer IIS
> Am Wolfsmantel 33, 91058 Erlangen, Germany
> Phone: +49-9131-776-6130
> Fax:   +49-9131-776-6099
> email: tma at iis.fhg.de
> www: http://www.iis.fhg.de/
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
>

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list