This topic is locked

Curency rounding

8/30/2007 10:59:38 PM
PHPRunner General questions
F
farago author

Hi
Have a calculated field - pr_member
/ pr_memb: if there's a member discount, list price minus member descount and discount /

CASE

WHEN disc_memb IS NULL THEN NULL

ELSE pr_list (1-(IfNull(disc,0)/100)) (1-(disc_memb/100))

END as pr_memb,


Need to round and display in 2 digit $currency format

When I format "pr_member" as curency I get what looks like rounding error.


any suggestions appreciated
Thanks!
Peter

Alexey admin 8/31/2007

Peter,
thank you for pointing me to this bug.

We'll fix it with the next update of PHPRunner.
To get your pages working properly modify locale.php file in C:\Program Files\PHPRunner4.1\source\include folder.

Find this snippet there:

function format_currency($val)

{

global $locale_info;

if(!is_numeric($val))

return $val;

and insert this line just after:

$val=round($val,$locale_info["LOCALE_ICURRDIGITS"]);



Then rebuild your project.

F
farago author 8/31/2007

Thanks!
Made the change -
[codebox]function format_number($val)

{

global $locale_info;

if(!is_numeric($val))

return $val;

$val=round($val,$locale_info["LOCALE_ICURRDIGITS"]);

if($val>=0)

{

$sign=1;

$int = floor($val);

$frac = $val-$int;[/codebox]
here is what we see.
When formated as curency:


when formated as number:


sorry to be confused - for now it seems like we should format as number to get rounding display - let me know if you feel this makes sense.
Thanks again Sergey