From 42a8f480fd0631639ed5d0506e0cd8f79d7f78ce Mon Sep 17 00:00:00 2001 From: Matthew Wire <mjw@mjwconsult.co.uk> Date: Mon, 1 May 2023 14:45:40 +0100 Subject: [PATCH] Handle adding custom fields when stripe is loaded before mjwshared --- managed/stripecustomdata.mgd.php | 189 +++++++++++++++---------------- 1 file changed, 89 insertions(+), 100 deletions(-) diff --git a/managed/stripecustomdata.mgd.php b/managed/stripecustomdata.mgd.php index 311b333f..3948b794 100644 --- a/managed/stripecustomdata.mgd.php +++ b/managed/stripecustomdata.mgd.php @@ -8,107 +8,96 @@ use \CRM_Stripe_ExtensionUtil as E; -return [/* - [ - 'name' => 'cg_extend_objects:FinancialTrxn', - 'entity' => 'OptionValue', - 'cleanup' => 'always', - 'update' => 'always', - 'params' => [ - 'version' => 4, - 'values' => [ - 'option_group_id.name' => 'cg_extend_objects', - 'label' => E::ts('Financial Transaction (Payment)'), - 'value' => 'FinancialTrxn', - 'name' => 'civicrm_financial_trxn', - 'is_reserved' => TRUE, - 'is_active' => TRUE, +// Group is added by mjwshared +$customGroup = \Civi\Api4\CustomGroup::get(FALSE) + ->addWhere('name', '=', 'Payment_details') + ->execute() + ->first(); +if (!empty($customGroup)) { + return [ + [ + 'name' => 'CustomGroup_Payment_details_CustomField_available_on', + 'entity' => 'CustomField', + 'cleanup' => 'never', + 'update' => 'always', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Payment_details', + 'name' => 'available_on', + 'label' => E::ts('Available On'), + 'data_type' => 'Date', + 'html_type' => 'Select Date', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => TRUE, + 'is_search_range' => FALSE, + 'help_pre' => E::ts('If there is a delay between your payment provider receiving the payment and it arriving in your bank account this is the date that it should be available in your account.'), + 'help_post' => NULL, + 'attributes' => NULL, + 'is_active' => TRUE, + 'is_view' => TRUE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => 'yy-mm-dd', + 'time_format' => 2, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'available_on', + 'option_group_id' => NULL, + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + 'fk_entity' => NULL, + ], + 'match' => [ + 'name', + ], ], ], - ],*/ - - [ - 'name' => 'CustomGroup_Payment_details_CustomField_available_on', - 'entity' => 'CustomField', - 'cleanup' => 'never', - 'update' => 'always', - 'params' => [ - 'version' => 4, - 'values' => [ - 'custom_group_id.name' => 'Payment_details', - 'name' => 'available_on', - 'label' => E::ts('Available On'), - 'data_type' => 'Date', - 'html_type' => 'Select Date', - 'default_value' => NULL, - 'is_required' => FALSE, - 'is_searchable' => TRUE, - 'is_search_range' => FALSE, - 'help_pre' => E::ts('If there is a delay between your payment provider receiving the payment and it arriving in your bank account this is the date that it should be available in your account.'), - 'help_post' => NULL, - 'attributes' => NULL, - 'is_active' => TRUE, - 'is_view' => TRUE, - 'options_per_line' => NULL, - 'text_length' => 255, - 'start_date_years' => NULL, - 'end_date_years' => NULL, - 'date_format' => 'yy-mm-dd', - 'time_format' => 2, - 'note_columns' => 60, - 'note_rows' => 4, - 'column_name' => 'available_on', - 'option_group_id' => NULL, - 'serialize' => 0, - 'filter' => NULL, - 'in_selector' => FALSE, - 'fk_entity' => NULL, - ], - 'match' => [ - 'name', - ], - ], - ], - [ - 'name' => 'CustomGroup_Payment_details_CustomField_Exchange_Rate', - 'entity' => 'CustomField', - 'cleanup' => 'never', - 'update' => 'always', - 'params' => [ - 'version' => 4, - 'values' => [ - 'custom_group_id.name' => 'Payment_details', - 'name' => 'Exchange_Rate', - 'label' => E::ts('Exchange Rate'), - 'data_type' => 'Float', - 'html_type' => 'Text', - 'default_value' => NULL, - 'is_required' => FALSE, - 'is_searchable' => TRUE, - 'is_search_range' => FALSE, - 'help_pre' => NULL, - 'help_post' => NULL, - 'attributes' => NULL, - 'is_active' => TRUE, - 'is_view' => FALSE, - 'options_per_line' => NULL, - 'text_length' => 255, - 'start_date_years' => NULL, - 'end_date_years' => NULL, - 'date_format' => NULL, - 'time_format' => NULL, - 'note_columns' => 60, - 'note_rows' => 4, - 'column_name' => 'exchange_rate', - 'option_group_id' => NULL, - 'serialize' => 0, - 'filter' => NULL, - 'in_selector' => FALSE, - 'fk_entity' => NULL, - ], - 'match' => [ - 'name', + [ + 'name' => 'CustomGroup_Payment_details_CustomField_Exchange_Rate', + 'entity' => 'CustomField', + 'cleanup' => 'never', + 'update' => 'always', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Payment_details', + 'name' => 'Exchange_Rate', + 'label' => E::ts('Exchange Rate'), + 'data_type' => 'Float', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => TRUE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'attributes' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'exchange_rate', + 'option_group_id' => NULL, + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + 'fk_entity' => NULL, + ], + 'match' => [ + 'name', + ], ], ], - ], -]; + ]; +} \ No newline at end of file -- GitLab