From 0c3f4c3e186ff16ac0107e48b64c18fe87f4c90f Mon Sep 17 00:00:00 2001 From: abijah Date: Fri, 14 Aug 2009 21:06:17 +0000 Subject: [PATCH] Fixed the currency function to always return in dollar amounts, and never in just cents, as the core currency function does. git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@557 97e9348a-65ac-dc4b-aefc-98561f571b83 --- views/helpers/format.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/views/helpers/format.php b/views/helpers/format.php index 226d9bc..4c84ce3 100644 --- a/views/helpers/format.php +++ b/views/helpers/format.php @@ -24,9 +24,18 @@ class FormatHelper extends AppHelper { return '-'; //return null; - $currency = self::$number->currency($amount, - isset($dollar_sign) ? $dollar_sign : 'USD', - $spans ? array('before'=>'', 'after'=>'') : array()); + // Use of the $number->currency() function results in the clever, + // but problematic, use of cents for amounts less than $1. For + // example, 50 cents is shown as '50c', not '$0.50'. We want to + // keep everything in terms of dollars, especially for the cases + // where this result is placed into a form for input. 50 cents + // will end up as 50 dollars upon submission :-( + $currency = self::$number->format + ($amount, + array('places' => 2, + 'before' => $spans ? '' : (isset($dollar_sign) ? $dollar_sign : '$'), + 'after' => $spans ? '' : null, + )); if ($spans) return ('$' .