Skip to content

Commit

Permalink
SearchKit - Update to newer money formatting function
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Sep 16, 2022
1 parent 4201ec3 commit 191fe52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ protected function formatViewValue($key, $rawValue, $data) {

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':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,13 +1389,13 @@ public function testContributionCurrency():void {

// 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'] = [
Expand All @@ -1412,13 +1412,13 @@ public function testContributionCurrency():void {

// 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']);
}

}
2 changes: 1 addition & 1 deletion release-notes/5.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 191fe52

Please sign in to comment.