From 598e828c7176e5f1a0264e6e94aa285be8344f93 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 12 Mar 2021 10:14:48 +1300 Subject: [PATCH] [REF] Very minor simplification ContributionParams is mostly passed in to processContribution but a few parametrs are added to it within that function This adds 2 of them to the passed in values for a very minor simplification. Note that params['total_amount'] was set using order->getTotalAmount and this will return a consistent result from anywhere in the postProcess function (after line 1002) --- CRM/Member/Form/Membership.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 8822cb3e37..cf01671909 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1251,10 +1251,13 @@ DESC limit 1"); 'financial_type_id' => $this->getFinancialTypeID(), 'receive_date' => CRM_Utils_Time::date('YmdHis'), 'tax_amount' => $params['tax_amount'] ?? NULL, + 'total_amount' => $this->order->getTotalAmount(), 'invoice_id' => $this->getInvoiceID(), 'currency' => $this->getCurrency(), 'is_pay_later' => $params['is_pay_later'] ?? 0, 'skipLineItem' => $params['skipLineItem'] ?? 0, + 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'), + 'receipt_date' => $this->getSubmittedValue('send_receipt') ? date('YmdHis') : NULL, ] ); @@ -1826,21 +1829,10 @@ DESC limit 1"); $params['payment_instrument_id'] = $contributionParams['payment_instrument_id'] ?? NULL; $recurringContributionID = $this->legacyProcessRecurringContribution($params, $contactID); - if ($this->getSubmittedValue('send_receipt')) { - $contributionParams += [ - 'receipt_date' => CRM_Utils_Time::date('YmdHis'), - ]; - } - if ($recurringContributionID) { $contributionParams['contribution_recur_id'] = $recurringContributionID; } - $contributionParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'); - - // @todo this is the wrong place for this - it should be done as close to form submission - // as possible - $contributionParams['total_amount'] = $params['amount']; $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams); // lets store it in the form variable so postProcess hook can get to this and use it -- 2.25.1