diff --git a/CRM/Upgrade/Incremental/Base.php b/CRM/Upgrade/Incremental/Base.php index 883dc50e165e..bd8c34d7aae6 100644 --- a/CRM/Upgrade/Incremental/Base.php +++ b/CRM/Upgrade/Incremental/Base.php @@ -321,6 +321,57 @@ public static function updateGreetingOptions($ctx, string $old, string $new, $ve return TRUE; } + /** + * Updated a currency in civicrm_currency and related configurations + * + * @param CRM_Queue_TaskContext $ctx + * @param string $old_name + * @param string $new_name + * + * @return bool + */ + public static function updateCurrencyName($ctx, string $old_name, string $new_name): bool { + CRM_Core_DAO::executeQuery('UPDATE civicrm_currency SET name = %1 WHERE name = %2', [ + 1 => [$new_name, 'String'], + 2 => [$old_name, 'String'], + ]); + + $oid = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_option_group WHERE name = 'currencies_enabled'"); + if ($oid) { + CRM_Core_DAO::executeQuery('UPDATE civicrm_option_value SET value = %1 WHERE value = %2 AND option_group_id = %3', [ + 1 => [$new_name, 'String'], + 2 => [$old_name, 'String'], + 3 => [$oid, 'String'], + ]); + } + + $tables = [ + 'civicrm_contribution', + 'civicrm_contribution_page', + 'civicrm_contribution_recur', + 'civicrm_contribution_soft', + 'civicrm_event', + 'civicrm_financial_item', + 'civicrm_financial_trxn', + 'civicrm_grant', + 'civicrm_participant', + 'civicrm_pcp', + 'civicrm_pledge_payment', + 'civicrm_pledge', + 'civicrm_product', + ]; + + foreach ($tables as $table) { + CRM_Core_DAO::executeQuery('UPDATE %3 SET currency = %1 WHERE currency = %2', [ + 1 => [$new_name, 'String'], + 2 => [$old_name, 'String'], + 3 => [$table, 'MysqlColumnNameOrAlias'], + ]); + } + + return TRUE; + } + /** * Re-save any valid values from contribute settings into the normal setting * format. diff --git a/CRM/Upgrade/Incremental/php/FiveFortyThree.php b/CRM/Upgrade/Incremental/php/FiveFortyThree.php index db117ecd7300..9704238a580e 100644 --- a/CRM/Upgrade/Incremental/php/FiveFortyThree.php +++ b/CRM/Upgrade/Incremental/php/FiveFortyThree.php @@ -159,6 +159,8 @@ public function upgrade_5_43_alpha1(string $rev): void { ); $this->addTask('Set note_date field to NOT NULL', 'setNoteDateFieldNotNull'); + $this->addTask('Update currency symbols for Ghana', 'updateCurrencyName', 'GHC', 'GHS'); + $this->addTask('Update currency symbols for Belarus', 'updateCurrencyName', 'BYR', 'BYN'); } /** diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index 2b322fa1c9aa..ac87c98eed63 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -2577,7 +2577,7 @@ INSERT INTO `civicrm_currency` (`id`, `name`, `symbol`, `numeric_code`, `full_na (37,'BSD','$','044','Bahamian Dollar'), (38,'BTN',NULL,'064','Bhutan Ngultrum'), (39,'BWP','P','072','Botswana Pula'), - (40,'BYR','p.','974','Belarussian Rouble'), + (40,'BYN','p.','974','Belarussian Rouble'), (41,'BZD','BZ$','084','Belize Dollar'), (42,'CDF',NULL,'976','Franc Congolais'), (43,'CHE',NULL,'947','WIR Euro'), @@ -2604,7 +2604,7 @@ INSERT INTO `civicrm_currency` (`id`, `name`, `symbol`, `numeric_code`, `full_na (65,'FJD','$','242','Fiji Dollar'), (66,'FKP','£','238','Falkland Islands Pound'), (67,'GEL',NULL,'981','Georgian Lari'), - (68,'GHC','¢','288','Ghanaian Cedi'), + (68,'GHS','¢','288','Ghanaian Cedi'), (69,'GIP','£','292','Gibraltar Pound'), (70,'GMD',NULL,'270','Gambian Dalasi'), (71,'GNF',NULL,'324','Guinea Franc'), diff --git a/xml/templates/civicrm_currency.tpl b/xml/templates/civicrm_currency.tpl index a2f44d33570e..f2244ddbfa37 100644 --- a/xml/templates/civicrm_currency.tpl +++ b/xml/templates/civicrm_currency.tpl @@ -50,7 +50,7 @@ INSERT INTO civicrm_currency (id, name, symbol, numeric_code, full_name) VALUES ( 37, "BSD", "$", "044", "Bahamian Dollar"), ( 38, "BTN", NULL, "064", "Bhutan Ngultrum"), ( 39, "BWP", "P", "072", "Botswana Pula"), -( 40, "BYR", "p.", "974", "Belarussian Rouble"), +( 40, "BYN", "p.", "974", "Belarussian Rouble"), ( 41, "BZD","BZ$", "084", "Belize Dollar"), ( 42, "CDF", NULL, "976", "Franc Congolais"), ( 43, "CHE", NULL, "947", "WIR Euro"), @@ -77,7 +77,7 @@ INSERT INTO civicrm_currency (id, name, symbol, numeric_code, full_name) VALUES ( 65, "FJD", "$", "242", "Fiji Dollar"), ( 66, "FKP", "£", "238", "Falkland Islands Pound"), ( 67, "GEL", NULL, "981", "Georgian Lari"), -( 68, "GHC", "¢", "288", "Ghanaian Cedi"), +( 68, "GHS", "¢", "288", "Ghanaian Cedi"), ( 69, "GIP", "£", "292", "Gibraltar Pound"), ( 70, "GMD", NULL, "270", "Gambian Dalasi"), ( 71, "GNF", NULL, "324", "Guinea Franc"),