1 (edited by nucreativa 02/16/2010 08:54:50 am)

Topic: Bug in the calculation of foreign exchange gains

I'm sorry if my english not good. there is a bug in the frontaccounting, more precisely in the calculation of foreign exchange gains.

This error occurs when conducting transactions related to different currencies.

in my case, I change the default currency to rupiah (Indonesian currency). and I made a USD bank account. current assets and petty cash in rupiah. then I deposit my money into the account USD. more details follow the steps below.

1. deposit USD 10,000, with the exchange rate of 10,000 rupiah per USD on 1 January.
2. deposit USD 1000, with the exchange rate of 9,500 rupiah per USD at the date of January 10.
3. deposit USD 100, with the exchange rate of 9,500 rupiah per USD on the same date (10 January).

The first and second steps were correct. but the third step produces the wrong value. I question why foreign exchange gain is still in the calculations? if it still must be calculated to produce the wrong balance sheet. because the foreign exchange loss recorded two times in the general ledger.

Please response as soon as possible smile

Ary Wibowo

Re: Bug in the calculation of foreign exchange gains

I think you have an extreme high exchange rate against the USD. Maybe you should increase the exchange rate digits to 6 or 8 to get a better calculation.

/Joe

Re: Bug in the calculation of foreign exchange gains

no joe, in Indonesia, 1 USD is more than 9000 in IDR. I'll try your suggestion first. thanks

Ary Wibowo

Re: Bug in the calculation of foreign exchange gains

joe, I made some changes to the gl_db_banking.inc. I've improved foreign exchange gain formulas. I think this new formula to resolve this issue. where I had to send files of this improvement.

Ary Wibowo

Re: Bug in the calculation of foreign exchange gains

You can send the code to contributions mail box (you will find eml address on site Contact page).
Thanks.
Janusz

Re: Bug in the calculation of foreign exchange gains

I've sent it

Ary Wibowo

Re: Bug in the calculation of foreign exchange gains

We have received it, thanks. We will look into it asap.
Janusz

Re: Bug in the calculation of foreign exchange gains

Hello, nucreativa,
Unfortunately your code will not work. You know that there can be several bank accounts belonging to the same GL account. So we can not just calculate the sum from the same period in the GL account. This may fetch to many rows that should not be calculated.
But I have sent you some more check to the former sql statement and asked you to test this.
I guess it will work with these new added checks.

/Joe

Re: Bug in the calculation of foreign exchange gains

Hello,
This bug is now fixed and the CVS Main repository is updated. Affected file:
/gl/includes/db/gl_db_banking.inc

If you need this fix asap you can download it here:



/Joe

Re: Bug in the calculation of foreign exchange gains

thaks for the update... you've made a great software. kept trying to make it better smile

Ary Wibowo

Re: Bug in the calculation of foreign exchange gains

joe... i've found another bug. i just sent an email to you about this bug

Ary Wibowo

Re: Bug in the calculation of foreign exchange gains

Yes we have to make more check. CVS Main is updated. I sent you an updated file. You can also fetch it here:

----------------- OBS! New File (final rerun) ------------------


We now recalculate all the currency bank accounts belonging to the same GL account. This makes the algorithm much cleaner and easier and safe and the performance should be improved too. So the GL account will always be updated when payments or transfer are done.

/Joe