From 6e4150c0d18bfb901858b41efb1c9c06fb4042db Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Mon, 29 Jan 2024 16:44:34 +0100 Subject: [PATCH] fix #409: add option to preserve original receive_date --- CRM/Banking/PluginImpl/Matcher/DefaultOptions.php | 7 ++++++- CRM/Banking/PluginImpl/Matcher/ExistingContribution.php | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php b/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php index fd2e93dd..4521ced9 100644 --- a/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php +++ b/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php @@ -44,6 +44,7 @@ function __construct($config_name) { if (!isset($config->default_financial_type_id)) $config->default_financial_type_id = 1; if (!isset($config->createnew_value_propagation)) $config->createnew_value_propagation = array(); if (!isset($config->manual_default_financial_type_id)) $config->manual_default_financial_type_id = NULL; + if (!isset($config->preserve_receive_date)) $config->preserve_receive_date = 0; // Set to 1 to preserve the receive_date (instead of overwriting it with the booking_date). See issue #409. if (!isset($config->ignore_enabled)) $config->ignore_enabled = true; if (!isset($config->ignore_probability)) $config->ignore_probability = 0.1; @@ -123,6 +124,8 @@ public function match(CRM_Banking_BAO_BankTransaction $btx, CRM_Banking_Matcher_ * the bank transaction this is related to */ public function execute($suggestion, $btx) { + $config = $this->_plugin_config; + if ($suggestion->getId()==="manual") { $cids = $suggestion->getParameter('contribution_ids'); $contribution_count = 0; @@ -155,7 +158,9 @@ public function execute($suggestion, $btx) { } else { // ...otherwise, we close it $query['contribution_status_id'] = $completed_status; - $query['receive_date'] = date('YmdHis', strtotime($btx->booking_date)); + if (!$config->preserve_receive_date) { + $query['receive_date'] = date('YmdHis', strtotime($btx->booking_date)); + } } CRM_Banking_Helpers_IssueMitigation::mitigate358($query); diff --git a/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php b/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php index b02f9a87..b664467d 100644 --- a/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php +++ b/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php @@ -53,6 +53,7 @@ function __construct($config_name) { if (!isset($config->date_penalty)) $config->date_penalty = 1.0; if (!isset($config->payment_instrument_penalty)) $config->payment_instrument_penalty = 0.0; if (!isset($config->financial_type_penalty)) $config->financial_type_penalty = 0.0; + if (!isset($config->preserve_receive_date)) $config->preserve_receive_date = 0; // Set to 1 to preserve the receive_date (instead of overwriting it with the booking_date). See issue #409. // amount check / amount penalty if (!isset($config->amount_check)) $config->amount_check = "1"; @@ -415,7 +416,9 @@ public function execute($suggestion, $btx) { // depending on mode... if ($this->_plugin_config->mode != "cancellation") { $query['contribution_status_id'] = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed'); - $query['receive_date'] = date('YmdHis', strtotime($btx->booking_date)); + if (!$config->preserve_receive_date) { + $query['receive_date'] = date('YmdHis', strtotime($btx->booking_date)); + } } else { $query['contribution_status_id'] = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled'); $query['cancel_date'] = date('YmdHis', strtotime($btx->booking_date));