ledger123 / runmyaccounts

SQL-Ledger Customizations by Run My Accounts
GNU General Public License v2.0
16 stars 9 forks source link

[IBP-1212] Issue with GL transactions with foreign currency #554

Closed TomaszKrolczyk closed 2 months ago

TomaszKrolczyk commented 2 months ago

Hello,

German users of our system are facing issues with GL transactions with foreign currency. I analyzed the problem and it looks like we have two rather small issues that combined make a real mess with the numbers: 1) When we edit the GL transaction and manually modify the exchange rate, after "Post as new" the buy value overwrites the value of the exchange rate 2) When it happens, the value read from the database is not formatted in line with users' preferences. If an exchange rate is stored as 1.0345 and a user has the following formatting: dot as a thousand separator and a comma as a decimal, the exchange rate is parsed in a wrong way which implicits wrong calculations.

Better description & steps to reproduce:

  1. Add new GL transaction with foreign currency and manually modify the exchange rate image
  2. Find the transaction. At this moment everything looks good. Post this transaction as new. (I changed the reference for easier identification) image
  3. Find the new one. The exchange rate was overwritten. This is the first issue image
  4. Now let's find a user with the following number formatting: image
  5. This is how he sees the transaction image
  6. Now let's try to post another transaction as new (using this user). I changed the reference and exchange rate image
  7. And this is the second issue. Numbers are crazy because of the huge exchange rate. image image

I dig a little into the code and I think the issue is in bin\mozilla\gl.pl in update function: image The exchange rate is read from the database (the original put by a user is overwritten - the first issue) but it is not formatted with user settings. When a user has formatting with dots as thousands separator a new value is wrongly parsed as a dot is used in the database as a decimal separator. I managed to solve the issue locally by adding the lines that are commented out in the screen above but I am not aware of the possible implications of such a change so it would be great if someone experienced with the system could take a look at it. image And the result (the value of exchange rate is still overwritten but calculations are ok): image image

Thank you in advance for looking into that

ledger123 commented 2 months ago

Hi @TomaszKrolczyk , issue is resolved and commit is attached to the script in its branch.

Thanks for such detailed issue reporting. This helped resolve the issue quickly.

Please test and confirm all is ok. I am here all day for quick resolution if you still find some problem.

Regards

ledger123 commented 2 months ago

Hi,

I have fixed the issue and set the precision without any number just like it is in other places.

Regards

TomaszKrolczyk commented 2 months ago

I have a confirmation for German users that the issue is solved. Thank you for your quick response and fix. The issue can be closed.