Topic: Supplier Payment Entry(Rounding Problem)

When making a Payment to a Supplier, The bank Amount is rounded to 2 Digits. Example:
A payment of 100.555 is rounded to 100.560,  this is fine for currency with 2 digits, but our currency is 3 digits.


The rounding error happens only for the the (Bank Amount - entry) whereas the (Bank Charge - entry) is fine.

Any Help.

Re: Supplier Payment Entry(Rounding Problem)

I managed to fix the problem by changing one Line
The original source is:
    if ($bank_currency != $supplier_currency)
    {
        amount_row(_("Bank Amount:"), 'bank_amount', null, '', $bank_currency, 2);
    }

Changed to (Just removed the ',2':
    if ($bank_currency != $supplier_currency)
    {
        amount_row(_("Bank Amount:"), 'bank_amount', null, '', $bank_currency);
    }

Re: Supplier Payment Entry(Rounding Problem)

Instead, just change the Decimal Places for Prices/Amounts to 3 in Setup => Display Setup.

Post's attachments

2015-11-26_221302.png 11.5 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Supplier Payment Entry(Rounding Problem)

I already had the Decimal Places for Prices/Amounts set to 3, but it did solve the problem,this happens only for the bank amount field,the remaining fields are fine.

5 (edited by apmuthu 12/08/2015 04:09:34 pm)

Re: Supplier Payment Entry(Rounding Problem)

Line 310 in purchasing/supplier_payment.php is hardcoded with number of decimals and hence it did not use the chosen 3 decimal places you set in the preferences for Prices/Amounts.

This appears to be the only hardcoded place left in FA 2.3.

Omitting the last argument ($dec) will automatically take the preference value set when the function amount_row() which finally calls the function amount_cells_ex() is executed. These functions are defined in includes/ui/ui_input.inc file.

Hence Line 310 in purchasing/supplier_payment.php :

        amount_row(_("Bank Amount:"), 'bank_amount', null, '', $bank_currency, 2);

should be changed to:

        amount_row(_("Bank Amount:"), 'bank_amount', null, '', $bank_currency);

It stands committed in FAMods in my unofficial FA 2.3 repo.

@joe: Kindly do the needful in FA 2.3 and in Line 304 in FA 2.4.

Re: Supplier Payment Entry(Rounding Problem)

Speaking of includes/ui/ui_input.inc, what's this supposed to do?

//JAM  Allow entered unit prices to be fractional
function unit_amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
{
    if (!isset($dec))
          $dec = user_price_dec()+2;
    amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec+2);
}

Re: Supplier Payment Entry(Rounding Problem)

This is possibly done to increase the precision for computing to avoid rounding errors / deltas where unit amounts are computed from large quantities based bulk pricing.

Re: Supplier Payment Entry(Rounding Problem)

This ugly  bastard is now fixed in both 2.3.24 and 2.4 Beta.

/Joe

Re: Supplier Payment Entry(Rounding Problem)

Thanks @joe.

FA 2.3 commit
FA 2.4 commit