Topic: Error with currency conversion

I am using two currencies - selling in USD and buying in TWD, and my base currency is set to TWD.

I'm seeing errors in the general ledger which in think may be related to the currency conversion of sales invoices. This causes my trial balances to be out.

These are very small amounts, but I would like to know if anyone has a suggestion for me.

Here's an example:

General Ledger Transaction Details     Reference     Date     Person/Item
Sales Invoice #3892                             SI891            02/17/2013    
Payment Status: Completed Amount: 104.56 USD

Account Code     Account Name                    Debit             Credit    
4010             Sales                                                 836.038821    
4010             Sales                                                 488.649855    
4510             Discounts Given        97.729971        
4010             Sales                                                 893.697341    
4010             Sales                                                 288.289000    
4510             Discounts Given        288.289000        
4010             Sales                                                 893.697341    
1200             Accounts Receivables 3,014.353388        
Total                                                3,400.372359     3,400.372358

2 (edited by ckrosco 05/10/2013 08:44:45 pm)

Re: Error with currency conversion

After experimenting a bit, I can see that this is the result of a rounding error.

I can overcome this by increasing the number of decimal places on prices from 6 to 8.

Is there another solution?

3 (edited by ckrosco 05/10/2013 08:44:30 pm)

Re: Error with currency conversion

Actually the problem is still showing up with 8 decimal places - the example above is now showing as:

         Debit                         Credit

3,400.37235861     3,400.37235862

I suppose I can use 8 decimal places when invoicing and switch back to 6 for everything else, but isn't there a better solution?

Re: Error with currency conversion

Is any reason why you use 6 or 8 decimals? Rounding errors are normal in floating point arithmetic, and are acceptable as long as they do not amplificate somehow.  Normally having 2 decimal places for price type amounts is enough, and in some countries there are further rounding used.
Janusz

Re: Error with currency conversion

My product is priced in grams, so we need the 6 decimal places for accuracy when converting to USD.

We've decided to just ignore these small errors showing on the trial balance.

The question came up because we have been using this system for a couple of years now, always with a perfect trial balance, even at 6 decimal places, but since February of this year, we have noticed these small errors.

Re: Error with currency conversion

I guess this is related to some change in php itself.
Janusz