Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wrong decimal places and approximation
02-18-2015, 06:42 AM, (This post was last modified: 02-18-2015, 06:44 AM by giusba71.)
#1
Wrong decimal places and approximation
Entering a new line in a PO, the default price is loaded with all decimal places as per System Parameters (4 digits in our case).
   
   
Entering a price with more than 2 decimal places appear to be possible, but after an "Update Order Lines" this is approximated to 2 digits.
   
After another "Update Order Lines" or "Process Order", the row total becomes quantity x approximated price and so the order total.
The same in printed PO.
   
With prices lower than 1 this doesn't occur and the approximation appear to be correct.
Try with 1000 pcs at price 1.1234.

Giusba



Reply
02-18-2015, 11:31 PM,
#2
RE: Wrong decimal places and approximation
Look at lines 738-744 of PO_Items.php. It uses the currency # of decimal places when the price > 1, otherwise 4 decimals.
You can change this code to always use 4, or always use th standard cost decimal places parameter
// Note if the price is greater than 1 use 2 decimal place, if the price is a fraction of 1, use 4 decimal places
// This should help display where item-price is a fraction
if ($POLine->Price > 1) {
$DisplayPrice = locale_number_format($POLine->Price,$_SESSION['PO'.$identifier]->CurrDecimalPlaces);
$SuppPrice = locale_number_format(round(($POLine->Price *$POLine->ConversionFactor),$_SESSION['PO'.$identifier]->CurrDecimalPlaces),$_SESSION['PO'.$identifier]->CurrDecimalPlaces);
} else {
$DisplayPrice = locale_number_format($POLine->Price,4);
$SuppPrice = locale_number_format(round(($POLine->Price *$POLine->ConversionFactor),4),4);
}

I changed the above to this code: Note a '//' is a comment and makes that code not fire.
// Note if the price is greater than 1 use 2 decimal place, if the price is a fraction of 1, use 4 decimal places
// This should help display where item-price is a fraction
//if ($POLine->Price > 1) {
// $DisplayPrice = locale_number_format($POLine->Price,$_SESSION['PO'.$identifier]->CurrDecimalPlaces);
// $SuppPrice = locale_number_format(round(($POLine->Price *$POLine->ConversionFactor),$_SESSION['PO'.$identifier]->CurrDecimalPlaces),$_SESSION['PO'.$identifier]->CurrDecimalPlaces);
//} else {
$DisplayPrice = locale_number_format($POLine->Price,$_SESSION['StandardCostDecimalPlaces']);
$SuppPrice = locale_number_format(round(($POLine->Price *$POLine->ConversionFactor),$_SESSION['StandardCostDecimalPlaces']),$_SESSION['StandardCostDecimalPlaces']);
//}
Reply
02-20-2015, 04:54 AM,
#3
RE: Wrong decimal places and approximation
I found the code and commented the "if", leaving the "else" core uncommented. It works !!!
Many thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)