Skip to content

Commit

Permalink
fix Project60#409: add option to preserve original receive_date
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcMichalsky committed Jan 29, 2024
1 parent 71738e3 commit 6e4150c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CRM/Banking/PluginImpl/Matcher/DefaultOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion CRM/Banking/PluginImpl/Matcher/ExistingContribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 6e4150c

Please sign in to comment.