SearchKit - Update to newer money formatting function
authorColeman Watts <coleman@civicrm.org>
Fri, 16 Sep 2022 11:53:24 +0000 (07:53 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 16 Sep 2022 11:53:24 +0000 (07:53 -0400)
ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php
ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunTest.php
release-notes/5.18.0.md

index 1dfb5d75d08ab9e387bc4e3b5b1a67db65cec431..ff47e6d8d1b0ab65de44c17dbeba4ad5d9d135da 100644 (file)
@@ -775,7 +775,8 @@ abstract class AbstractRunAction extends \Civi\Api4\Generic\AbstractAction {
 
       case 'Money':
         $currencyField = $this->getCurrencyField($key);
-        $formatted = \CRM_Utils_Money::format($rawValue, $data[$currencyField] ?? NULL);
+        $currency = is_string($data[$currencyField] ?? NULL) ? $data[$currencyField] : NULL;
+        $formatted = \Civi::format()->money($rawValue, $currency);
         break;
 
       case 'Date':
index b7f3e9d2519d213150ae26b166d7a427492dc751..a3e7c7d41dd2ddb3ae234992f39055ad015d9d76 100644 (file)
@@ -1389,13 +1389,13 @@ class SearchRunTest extends Api4TestBase implements TransactionalInterface {
 
     // Currency should have been fetched automatically and used to format the value
     $this->assertEquals('GBP', $result[0]['data']['currency']);
-    $this->assertEquals('£ 100.00', $result[0]['columns'][0]['val']);
+    $this->assertEquals('£100.00', $result[0]['columns'][0]['val']);
 
     $this->assertEquals('USD', $result[1]['data']['currency']);
-    $this->assertEquals('$ 200.00', $result[1]['columns'][0]['val']);
+    $this->assertEquals('$200.00', $result[1]['columns'][0]['val']);
 
     $this->assertEquals('JPY', $result[2]['data']['currency']);
-    $this->assertEquals('¥ 500.00', $result[2]['columns'][0]['val']);
+    $this->assertEquals('¥500', $result[2]['columns'][0]['val']);
 
     // Now do a search for the contribution line-items
     $params['savedSearch'] = [
@@ -1412,13 +1412,13 @@ class SearchRunTest extends Api4TestBase implements TransactionalInterface {
 
     // An automatic join should have been added to fetch the contribution currency
     $this->assertEquals('GBP', $result[0]['data']['contribution_id.currency']);
-    $this->assertEquals('£ 100.00', $result[0]['columns'][0]['val']);
+    $this->assertEquals('£100.00', $result[0]['columns'][0]['val']);
 
     $this->assertEquals('USD', $result[1]['data']['contribution_id.currency']);
-    $this->assertEquals('$ 200.00', $result[1]['columns'][0]['val']);
+    $this->assertEquals('$200.00', $result[1]['columns'][0]['val']);
 
     $this->assertEquals('JPY', $result[2]['data']['contribution_id.currency']);
-    $this->assertEquals('¥ 500.00', $result[2]['columns'][0]['val']);
+    $this->assertEquals('¥500', $result[2]['columns'][0]['val']);
   }
 
 }
index 03ff156b4f0e9148a876ec512a8d636fbd57052a..a8ce0ed811f357ba5ec0c7312bd87cd211864f30 100644 (file)
@@ -259,7 +259,7 @@ Released October 2, 2019
   ([dev/core#1188](https://lab.civicrm.org/dev/core/issues/1188):
   [15043](https://github.com/civicrm/civicrm-core/pull/15043))**
 
-  Ensures that the Psalm Autoloader can find `CiviCRM_API3_Exception`.
+  Ensures that the Psalm Autoloader can find `CRM_Core_Exception`.
 
 - **File attachment uploads - pptx issue
   ([dev/core#1190](https://lab.civicrm.org/dev/core/issues/1190):