Merge pull request #19605 from eileenmcnaughton/money
authorMonish Deb <monish.deb@jmaconsulting.biz>
Mon, 22 Feb 2021 00:59:37 +0000 (06:29 +0530)
committerGitHub <noreply@github.com>
Mon, 22 Feb 2021 00:59:37 +0000 (06:29 +0530)
dev/translation#65 Further remove moneyValueFormat

CRM/Admin/Form/Setting/Localization.php
CRM/Utils/Money.php
api/v3/examples/Setting/GetFields.ex.php
templates/CRM/Admin/Form/Setting/Localization.tpl

index 9dc3ae7c5031465e74f0ff58fba187c0e6b63215..037e3aee6adc6bc607df3e2015be4e4dde59c09d 100644 (file)
@@ -35,7 +35,6 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting {
     'monetaryThousandSeparator' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
     'monetaryDecimalPoint' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
     'moneyformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
-    'moneyvalueformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
     'provinceLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
     'uiLanguages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
   ];
index 786fccd64c0bbc4e4981a5bf3b9a48c30a09217e..08119a54023318098484e5a8afeca9654e4dd4db 100644 (file)
@@ -43,14 +43,12 @@ class CRM_Utils_Money {
    * @param string $format
    *   The desired currency format.
    * @param bool $onlyNumber
-   * @param string $valueFormat
-   *   The desired monetary value display format (e.g. '%!i').
    *
    * @return string
    *   formatted monetary string
    *
    */
-  public static function format($amount, $currency = NULL, $format = NULL, $onlyNumber = FALSE, $valueFormat = NULL) {
+  public static function format($amount, $currency = NULL, $format = NULL, $onlyNumber = FALSE) {
 
     if (CRM_Utils_System::isNull($amount)) {
       return '';
@@ -62,14 +60,6 @@ class CRM_Utils_Money {
       $format = $config->moneyformat;
     }
 
-    if (!$valueFormat) {
-      $valueFormat = $config->moneyvalueformat;
-    }
-
-    if (!empty($valueFormat) && $valueFormat !== '%!i') {
-      CRM_Core_Error::deprecatedWarning('Having a Money Value format other than %!i is deprecated, please report this on the GitLab Issue https://lab.civicrm.org/dev/core/-/issues/1494 with the relevant moneyValueFormat you use.');
-    }
-
     if (!$currency) {
       $currency = $config->defaultCurrency;
     }
@@ -96,7 +86,7 @@ class CRM_Utils_Money {
       CRM_Core_Error::deprecatedWarning('Passing empty currency to CRM_Utils_Money::format is deprecated if you need it for display without currency call CRM_Utils_Money::formatLocaleNumericRounded');
     }
 
-    $amount = self::formatNumericByFormat($amount, $valueFormat);
+    $amount = self::formatNumericByFormat($amount);
     // If it contains tags, means that HTML was passed and the
     // amount is already converted properly,
     // so don't mess with it again.
@@ -181,10 +171,7 @@ class CRM_Utils_Money {
    * @return string
    */
   protected static function formatLocaleNumeric($amount) {
-    if (CRM_Core_Config::singleton()->moneyvalueformat !== '%!i') {
-      CRM_Core_Error::deprecatedWarning('Having a Money Value format other than !%i is deprecated, please report this on GitLab with the relevant moneyValueFormat you use.');
-    }
-    return self::formatNumericByFormat($amount, CRM_Core_Config::singleton()->moneyvalueformat);
+    return self::formatNumericByFormat($amount);
   }
 
   /**
@@ -304,7 +291,7 @@ class CRM_Utils_Money {
    *
    * @return string
    */
-  protected static function formatNumericByFormat($amount, $valueFormat) {
+  protected static function formatNumericByFormat($amount, $valueFormat = '%!i') {
     // money_format() exists only in certain PHP install (CRM-650)
     // setlocale() affects native gettext (CRM-11054, CRM-9976)
     if (is_numeric($amount) && function_exists('money_format')) {
index 19b17e6e5aee3a793cc25350ca780df8ad411ce0..b906e47d3f0808e91d15095a99554c613a5e5dd8 100644 (file)
@@ -1774,21 +1774,6 @@ function setting_getfields_expectedresult() {
         'description' => '',
         'help_text' => '',
       ],
-      'moneyvalueformat' => [
-        'group_name' => 'Localization Preferences',
-        'group' => 'localization',
-        'name' => 'moneyvalueformat',
-        'type' => 'String',
-        'quick_form_type' => 'Element',
-        'html_type' => 'text',
-        'default' => '%!i',
-        'add' => '4.3',
-        'title' => 'Monetary Value Display',
-        'is_domain' => 1,
-        'is_contact' => 0,
-        'description' => '',
-        'help_text' => '',
-      ],
       'defaultCurrency' => [
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
index 9666278ac60c6b92c21f3eef5741973b6273a65a..be6d4b5c9ade51ec09ea0ba215028a823bbe903c 100644 (file)
                 <td class="label">{$form.moneyformat.label} {help id='moneyformat' title=$form.moneyformat.label}</td>
                 <td>{$form.moneyformat.html}</td>
             </tr>
-            <tr class="crm-localization-form-block-moneyvalueformat">
-                <td class="label">{$form.moneyvalueformat.label} {help id='moneyvalueformat' title=$form.moneyvalueformat.label}</td>
-                <td>{$form.moneyvalueformat.html}<br> Note that this setting is proposed to be deprecated as per this <a href="https://lab.civicrm.org/dev/core/-/issues/1494">Gitlab Issue</a></td>
-            </tr>
-            <tr class="crm-localization-form-block-customTranslateFunction">
+                      <tr class="crm-localization-form-block-customTranslateFunction">
                 <td class="label">{$form.customTranslateFunction.label} {help id='customTranslateFunction' title=$form.customTranslateFunction.label}</td>
                 <td>{$form.customTranslateFunction.html}</td>
             </tr>