Merge pull request #5292 from jitendrapurohit/CRM-15933
[civicrm-core.git] / CRM / Utils / Rule.php
index 65944518963515ecf2bedba812b9e32229f9b938..6526da977e10ff289952973b8856f442ba60963b 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -429,7 +429,8 @@ class CRM_Utils_Rule {
       'currency', array(
         'keyColumn' => 'name',
         'labelColumn' => 'symbol',
-      ));
+      )
+    );
     $value = str_replace($currencySymbols, '', $value);
 
     if ($config->monetaryThousandSeparator) {
@@ -442,7 +443,9 @@ class CRM_Utils_Rule {
     // ugly fix for CRM-6391: do not drop the thousand separator if
     // it looks like it’s separating decimal part (because a given
     // value undergoes a second cleanMoney() call, for example)
-    if ($mon_thousands_sep != '.' or substr($value, -3, 1) != '.') {
+    // CRM-15835 - in case the amount/value contains 0 after decimal
+    // eg 150.5 the following if condition will pass
+    if ($mon_thousands_sep != '.' or (substr($value, -3, 1) != '.' && substr($value, -2, 1) != '.')) {
       $value = str_replace($mon_thousands_sep, '', $value);
     }
 
@@ -555,8 +558,6 @@ class CRM_Utils_Rule {
    * See how file rules are written in HTML/QuickForm/file.php
    * Checks to make sure the uploaded file is ascii
    *
-   * @param array Uploaded file info (from $_FILES)
-   *
    * @return bool
    *   true if file has been uploaded, false otherwise
    */
@@ -572,8 +573,6 @@ class CRM_Utils_Rule {
   /**
    * Checks to make sure the uploaded file is in UTF-8, recodes if it's not
    *
-   * @param array Uploaded file info (from $_FILES)
-   *
    * @return bool
    *   whether file has been uploaded properly and is now in UTF-8
    */
@@ -602,8 +601,6 @@ class CRM_Utils_Rule {
    * See how file rules are written in HTML/QuickForm/file.php
    * Checks to make sure the uploaded file is html
    *
-   * @param array Uploaded file info (from $_FILES)
-   *
    * @return bool
    *   true if file has been uploaded, false otherwise
    */
@@ -617,14 +614,14 @@ class CRM_Utils_Rule {
   }
 
   /**
-   * Check if there is a record with the same name in the db
+   * Check if there is a record with the same name in the db.
    *
    * @param string $value
    *   The value of the field we are checking.
    * @param array $options
    *   The daoName and fieldName (optional ).
    *
-   * @return boolean
+   * @return bool
    *   true if object exists
    */
   public static function objectExists($value, $options) {
@@ -804,4 +801,5 @@ class CRM_Utils_Rule {
   public static function qfKey($key) {
     return ($key) ? CRM_Core_Key::valid($key) : FALSE;
   }
+
 }