From a14cbb3681b72d6c4cebe3e8090eb79a904d2406 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Fri, 7 Jan 2022 02:03:32 +0000 Subject: [PATCH] Move CRM_Core_BAO_FinancialTrxn to CRM_Financial_BAO_FinancialTrxn --- CRM/Contribute/BAO/Contribution.php | 36 +++++++++---------- CRM/Contribute/BAO/FinancialProcessor.php | 6 ++-- CRM/Contribute/Form/AbstractEditPayment.php | 4 +-- CRM/Contribute/Form/AdditionalInfo.php | 2 +- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Contribute/Form/Contribution/Confirm.php | 2 +- CRM/Contribute/Form/ContributionBase.php | 4 +-- CRM/Contribute/Form/ContributionView.php | 4 +-- CRM/Contribute/Form/Task/Invoice.php | 2 +- CRM/Core/CodeGen/GenerateData.php | 2 +- CRM/Core/DAO.php | 6 ---- CRM/Event/BAO/Participant.php | 2 +- CRM/Financial/BAO/FinancialItem.php | 2 +- CRM/{Core => Financial}/BAO/FinancialTrxn.php | 12 +++---- CRM/Financial/BAO/Payment.php | 16 ++++----- CRM/Financial/BAO/PaymentProcessor.php | 2 +- CRM/Member/Form.php | 2 +- CRM/Price/BAO/LineItem.php | 10 +++--- .../Form/Contribute/DeferredRevenue.php | 2 +- api/v3/FinancialTrxn.php | 2 +- .../CRM/Contribute/BAO/ContributionTest.php | 18 +++++----- .../CRM/Contribute/Form/ContributionTest.php | 6 ++-- .../CRM/Contribute/Form/SearchTest.php | 14 ++++---- .../CRM/Event/BAO/AdditionalPaymentTest.php | 4 +-- .../Event/Form/Registration/ConfirmTest.php | 2 +- .../BAO/FinancialTrxnTest.php | 22 ++++++------ tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- tests/phpunit/api/v3/ContributionTest.php | 2 +- tests/phpunit/api/v3/PaymentTest.php | 16 ++++----- 29 files changed, 100 insertions(+), 106 deletions(-) rename CRM/{Core => Financial}/BAO/FinancialTrxn.php (98%) rename tests/phpunit/CRM/{Core => Financial}/BAO/FinancialTrxnTest.php (92%) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 4601737ae03b..11e16d07eea2 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -1022,10 +1022,10 @@ protected static function getContributionTransactionInformation($contributionId, $statuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'); while ($resultDAO->fetch()) { - $paidByLabel = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id); - $paidByName = CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id); + $paidByLabel = CRM_Core_PseudoConstant::getLabel('CRM_Financial_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id); + $paidByName = CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id); if ($resultDAO->card_type_id) { - $creditCardType = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $resultDAO->card_type_id); + $creditCardType = CRM_Core_PseudoConstant::getLabel('CRM_Financial_BAO_FinancialTrxn', 'card_type_id', $resultDAO->card_type_id); $pantruncation = ''; if ($resultDAO->pan_truncation) { $pantruncation = ": {$resultDAO->pan_truncation}"; @@ -1263,7 +1263,7 @@ public static function deleteContribution($id) { $participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $id, 'participant_id', 'contribution_id'); // delete any related entity_financial_trxn, financial_trxn and financial_item records. - CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn($id); + CRM_Financial_BAO_FinancialTrxn::deleteFinancialTrxn($id); if ($participantId) { CRM_Price_BAO_LineItem::deleteLineItems($participantId, 'civicrm_participant'); @@ -3076,7 +3076,7 @@ public static function isSubscriptionCancelled($contributionId) { * Contribution object, line item array and params for trxn. * * - * @return null|\CRM_Core_BAO_FinancialTrxn + * @return null|\CRM_Financial_BAO_FinancialTrxn */ public static function recordFinancialAccounts(&$params) { $skipRecords = $return = FALSE; @@ -3238,7 +3238,7 @@ public static function recordFinancialAccounts(&$params) { $params['prevContribution']->financial_type_id, $accountRelationship); } else { - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['prevContribution']->id, 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($params['prevContribution']->id, 'DESC'); if (!empty($lastFinancialTrxnId['financialTrxnId'])) { $params['trxnParams']['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $lastFinancialTrxnId['financialTrxnId'], 'to_financial_account_id'); } @@ -3250,7 +3250,7 @@ public static function recordFinancialAccounts(&$params) { $line['financial_type_id'] = $params['financial_type_id']; } } - CRM_Core_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE, 'changeFinancialType'); + CRM_Financial_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE, 'changeFinancialType'); /* $params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id']; */ $params['financial_account_id'] = $newFinancialAccount; $params['total_amount'] = $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = $trxnParams['total_amount']; @@ -3259,7 +3259,7 @@ public static function recordFinancialAccounts(&$params) { $params['trxnParams']['fee_amount'] = $params['fee_amount']; } CRM_Contribute_BAO_FinancialProcessor::updateFinancialAccounts($params); - CRM_Core_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE); + CRM_Financial_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE); $params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id']; $updated = TRUE; $params['deferred_financial_account_id'] = $newFinancialAccount; @@ -3281,7 +3281,7 @@ public static function recordFinancialAccounts(&$params) { $callUpdateFinancialAccounts = CRM_Contribute_BAO_FinancialProcessor::updateFinancialAccountsOnContributionStatusChange($params); if ($callUpdateFinancialAccounts) { CRM_Contribute_BAO_FinancialProcessor::updateFinancialAccounts($params, 'changedStatus'); - CRM_Core_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE, 'changedStatus'); + CRM_Financial_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE, 'changedStatus'); } $updated = TRUE; } @@ -3296,7 +3296,7 @@ public static function recordFinancialAccounts(&$params) { $params['trxnParams']['check_number'] = $params['check_number'] ?? NULL; if (CRM_Contribute_BAO_FinancialProcessor::isPaymentInstrumentChange($params, $pendingStatus)) { - $updated = CRM_Core_BAO_FinancialTrxn::updateFinancialAccountsOnPaymentInstrumentChange($params); + $updated = CRM_Financial_BAO_FinancialTrxn::updateFinancialAccountsOnPaymentInstrumentChange($params); } //if Change contribution amount @@ -3310,7 +3310,7 @@ public static function recordFinancialAccounts(&$params) { //Update Financial Records $params['trxnParams']['from_financial_account_id'] = NULL; CRM_Contribute_BAO_FinancialProcessor::updateFinancialAccounts($params, 'changedAmount'); - CRM_Core_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE, 'changedAmount'); + CRM_Financial_BAO_FinancialTrxn::createDeferredTrxn(CRM_Utils_Array::value('line_item', $params), $params['contribution'], TRUE, 'changedAmount'); $updated = TRUE; } @@ -3322,7 +3322,7 @@ public static function recordFinancialAccounts(&$params) { // the data fix scenario. // CRM-17751. if (isset($params['refund_trxn_id'])) { - $refundIDs = CRM_Core_BAO_FinancialTrxn::getRefundTransactionIDs($params['id']); + $refundIDs = CRM_Financial_BAO_FinancialTrxn::getRefundTransactionIDs($params['id']); if (!empty($refundIDs['financialTrxnId']) && $refundIDs['trxn_id'] != $params['refund_trxn_id']) { civicrm_api3('FinancialTrxn', 'create', [ 'id' => $refundIDs['financialTrxnId'], @@ -3332,7 +3332,7 @@ public static function recordFinancialAccounts(&$params) { } $cardType = $params['card_type_id'] ?? NULL; $panTruncation = $params['pan_truncation'] ?? NULL; - CRM_Core_BAO_FinancialTrxn::updateCreditCardDetails($params['contribution']->id, $panTruncation, $cardType); + CRM_Financial_BAO_FinancialTrxn::updateCreditCardDetails($params['contribution']->id, $panTruncation, $cardType); } } @@ -3342,7 +3342,7 @@ public static function recordFinancialAccounts(&$params) { CRM_Contribute_BAO_FinancialProcessor::recordAlwaysAccountsReceivable($trxnParams, $params); $trxnParams['pan_truncation'] = $params['pan_truncation'] ?? NULL; $trxnParams['card_type_id'] = $params['card_type_id'] ?? NULL; - $return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams); + $return = $financialTxn = CRM_Financial_BAO_FinancialTrxn::create($trxnParams); $params['entity_id'] = $financialTxn->id; } } @@ -3364,7 +3364,7 @@ public static function recordFinancialAccounts(&$params) { // when a fee is charged if (!empty($params['fee_amount']) && (empty($params['prevContribution']) || $params['contribution']->fee_amount != $params['prevContribution']->fee_amount) && $skipRecords) { - CRM_Core_BAO_FinancialTrxn::recordFees($params); + CRM_Financial_BAO_FinancialTrxn::recordFees($params); } if (!empty($params['prevContribution']) && $entityTable == 'civicrm_participant' @@ -3597,10 +3597,10 @@ public static function getPaymentInfo($id, $component = 'contribution', $getTrxn // The balance used to be calculated this way - we really want to remove this 'oldCalculation' // but need to unpick the whole trxn_id it's returning first. - $oldCalculation = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId); + $oldCalculation = CRM_Financial_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId); $baseTrxnId = !empty($oldCalculation['trxn_id']) ? $oldCalculation['trxn_id'] : NULL; if (!$baseTrxnId) { - $baseTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId); + $baseTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contributionId); $baseTrxnId = $baseTrxnId['financialTrxnId']; } $total = CRM_Price_BAO_LineItem::getLineTotal($contributionId); @@ -3651,7 +3651,7 @@ public static function getContributionBalance($contributionId, $contributionTota return (float) CRM_Utils_Money::subtractCurrencies( $contributionTotal, - CRM_Core_BAO_FinancialTrxn::getTotalPayments($contributionId, TRUE), + CRM_Financial_BAO_FinancialTrxn::getTotalPayments($contributionId, TRUE), CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'currency') ); } diff --git a/CRM/Contribute/BAO/FinancialProcessor.php b/CRM/Contribute/BAO/FinancialProcessor.php index 475caa8165cc..23df1a290930 100644 --- a/CRM/Contribute/BAO/FinancialProcessor.php +++ b/CRM/Contribute/BAO/FinancialProcessor.php @@ -215,7 +215,7 @@ public static function updateFinancialAccounts(&$params, $context = NULL) { $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = ($params['total_amount'] - $params['prevContribution']->total_amount); } - $trxn = CRM_Core_BAO_FinancialTrxn::create($params['trxnParams']); + $trxn = CRM_Financial_BAO_FinancialTrxn::create($params['trxnParams']); // @todo we should stop passing $params by reference - splitting this out would be a step towards that. $params['entity_id'] = $trxn->id; @@ -312,7 +312,7 @@ public static function updateFinancialAccountsOnContributionStatusChange(&$param $params['trxnParams']['currency'] = CRM_Utils_Array::value('currency', $params, $params['prevContribution']->currency); $transactionIDs[] = CRM_Contribute_BAO_FinancialProcessor::recordAlwaysAccountsReceivable($params['trxnParams'], $params); - $trxn = CRM_Core_BAO_FinancialTrxn::create($params['trxnParams']); + $trxn = CRM_Financial_BAO_FinancialTrxn::create($params['trxnParams']); // @todo we should stop passing $params by reference - splitting this out would be a step towards that. $params['entity_id'] = $transactionIDs[] = $trxn->id; @@ -393,7 +393,7 @@ public static function recordAlwaysAccountsReceivable(&$trxnParams, $contributio $params['to_financial_account_id'] = $arAccountId; $params['status_id'] = array_search('Pending', $contributionStatuses); $params['is_payment'] = FALSE; - $trxn = CRM_Core_BAO_FinancialTrxn::create($params); + $trxn = CRM_Financial_BAO_FinancialTrxn::create($params); $trxnParams['from_financial_account_id'] = $params['to_financial_account_id']; return $trxn->id; } diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index cde9b1ea0aa8..8cf1d269b03a 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -285,7 +285,7 @@ public function buildValuesAndAssignOnline_Note_Type($id, &$values) { //Check if this is an online transaction (financial_trxn.payment_processor_id NOT NULL) $this->_online = FALSE; - $fids = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($id); + $fids = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($id); if (!empty($fids['financialTrxnId'])) { $this->_online = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $fids['financialTrxnId'], 'payment_processor_id'); } @@ -581,7 +581,7 @@ public static function formatCreditCardDetails(&$params) { $params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($params); } if (!empty($params['credit_card_type'])) { - $params['card_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $params['credit_card_type']); + $params['card_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialTrxn', 'card_type_id', $params['credit_card_type']); } if (!empty($params['credit_card_number']) && empty($params['pan_truncation'])) { $params['pan_truncation'] = substr($params['credit_card_number'], -4); diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 442bc286c465..b831730e80fb 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -226,7 +226,7 @@ public static function processPremium($params, $contributionID, $premiumID = NUL $premiumParams['oldPremium']['product_id'] = $ContributionProduct->product_id; $premiumParams['oldPremium']['contribution_id'] = $ContributionProduct->contribution_id; } - CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($premiumParams); + CRM_Financial_BAO_FinancialTrxn::createPremiumTrxn($premiumParams); } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 703ad2912630..f69cf610eccf 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -436,7 +436,7 @@ public function setDefaultValues() { // Historically not 'Cancelled' hence not using CRM_Contribute_BAO_Contribution::isContributionStatusNegative. ['Refunded', 'Chargeback'] )) { - $defaults['refund_trxn_id'] = CRM_Core_BAO_FinancialTrxn::getRefundTransactionTrxnID($this->_id); + $defaults['refund_trxn_id'] = CRM_Financial_BAO_FinancialTrxn::getRefundTransactionTrxnID($this->_id); } else { $defaults['refund_trxn_id'] = $defaults['trxn_id'] ?? NULL; diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index f1a1536dc91f..53f887984f80 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -997,7 +997,7 @@ protected function postProcessPremium($premiumParams, $contribution) { 'financial_type_id' => $params['financial_type_id'], 'contributionId' => $contribution->id, ]; - CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($trxnParams); + CRM_Financial_BAO_FinancialTrxn::createPremiumTrxn($trxnParams); } } elseif ($selectProduct === 'no_thanks') { diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 22eb615be898..feb70faeecec 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -802,9 +802,9 @@ public function assignPaymentFields() { } elseif ($paymentField === 'credit_card_type') { $this->assign('credit_card_type', CRM_Core_PseudoConstant::getLabel( - 'CRM_Core_BAO_FinancialTrxn', + 'CRM_Financial_BAO_FinancialTrxn', 'card_type_id', - CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $this->_params['credit_card_type']) + CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialTrxn', 'card_type_id', $this->_params['credit_card_type']) )); } else { diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index 64f4c1473c85..f2276643a690 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -70,7 +70,7 @@ public function preProcess() { } // get received into i.e to_financial_account_id from last trxn - $financialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($values['contribution_id'], 'DESC'); + $financialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($values['contribution_id'], 'DESC'); $values['to_financial_account'] = ''; if (!empty($financialTrxnId['financialTrxnId'])) { $values['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'to_financial_account_id'); @@ -151,7 +151,7 @@ public function preProcess() { $values['campaign'] = $campaigns[$campaignId]; } if ($values['contribution_status'] == 'Refunded') { - $this->assign('refund_trxn_id', CRM_Core_BAO_FinancialTrxn::getRefundTransactionTrxnID($id)); + $this->assign('refund_trxn_id', CRM_Financial_BAO_FinancialTrxn::getRefundTransactionTrxnID($id)); } // assign values to the template diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index 9cc366f0507a..c7c47f635691 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -274,7 +274,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $dueDatePeriodSetting = Civi::settings()->get('invoice_due_date_period'); $dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $dueDateSetting . "" . $dueDatePeriodSetting)); - $amountPaid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribID, TRUE); + $amountPaid = CRM_Financial_BAO_FinancialTrxn::getTotalPayments($contribID, TRUE); $amountDue = ($input['amount'] - $amountPaid); // retrieving the subtotal and sum of same tax_rate diff --git a/CRM/Core/CodeGen/GenerateData.php b/CRM/Core/CodeGen/GenerateData.php index 3cb8516288d5..2ecd5001b3f6 100644 --- a/CRM/Core/CodeGen/GenerateData.php +++ b/CRM/Core/CodeGen/GenerateData.php @@ -2197,7 +2197,7 @@ private function addFinancialItem($result, $financialAccountId) { 'check_number' => $result->check_number, 'is_payment' => 1, ]; - $trxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams); + $trxn = CRM_Financial_BAO_FinancialTrxn::create($trxnParams); $financialItem = [ 'transaction_date' => CRM_Utils_Date::processDate($result->receive_date), 'amount' => $result->total_amount, diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 2d28ec7ffe1e..9f1a7d3f9729 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -2271,12 +2271,6 @@ public static function createTestObject( // Prefer to instantiate BAO's instead of DAO's (when possible) // so that assignTestValue()/assignTestFK() can be overloaded. $baoName = str_replace('_DAO_', '_BAO_', $daoName); - if ($baoName === 'CRM_Financial_BAO_FinancialTrxn') { - // OMG OMG OMG this is so incredibly bad. The BAO is insanely named. - // @todo create a new class called what the BAO SHOULD be - // that extends BAO-crazy-name.... migrate. - $baoName = 'CRM_Core_BAO_FinancialTrxn'; - } if (class_exists($baoName)) { $daoName = $baoName; } diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 537142a2805a..94e208987285 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1724,7 +1724,7 @@ public static function createDiscountTrxn($eventID, $contributionParams, $feeLev $transactionParams['trxnParams']['trxn_id'] = NULL; $transactionParams['trxnParams']['net_amount'] = NULL; $transactionParams['trxnParams']['fee_amount'] = NULL; - CRM_Core_BAO_FinancialTrxn::create($transactionParams); + CRM_Financial_BAO_FinancialTrxn::create($transactionParams); } } } diff --git a/CRM/Financial/BAO/FinancialItem.php b/CRM/Financial/BAO/FinancialItem.php index 15879bd854d5..838f1939551c 100644 --- a/CRM/Financial/BAO/FinancialItem.php +++ b/CRM/Financial/BAO/FinancialItem.php @@ -96,7 +96,7 @@ public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId } if (empty($trxnId)) { if (empty($trxnId['id'])) { - $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE); + $trxn = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE); $trxnId['id'] = $trxn['financialTrxnId']; } } diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Financial/BAO/FinancialTrxn.php similarity index 98% rename from CRM/Core/BAO/FinancialTrxn.php rename to CRM/Financial/BAO/FinancialTrxn.php index 0e1499e20809..fbad32310579 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Financial/BAO/FinancialTrxn.php @@ -14,7 +14,7 @@ * @package CRM * @copyright CiviCRM LLC https://civicrm.org/licensing */ -class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { +class CRM_Financial_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { /** * Class constructor. * @@ -354,7 +354,7 @@ public static function createPremiumTrxn($params) { 'entity_table' => 'civicrm_contribution', 'entity_id' => $params['contributionId'], ]; - CRM_Core_BAO_FinancialTrxn::create($financialtrxn); + CRM_Financial_BAO_FinancialTrxn::create($financialtrxn); } if (!empty($params['oldPremium'])) { @@ -370,7 +370,7 @@ public static function createPremiumTrxn($params) { 'contributionId' => $params['oldPremium']['contribution_id'], 'isDeleted' => TRUE, ]; - CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($params); + CRM_Financial_BAO_FinancialTrxn::createPremiumTrxn($params); } } @@ -409,7 +409,7 @@ public static function recordFees($params) { $params['trxnParams']['is_payment'] = FALSE; $trxn = self::create($params['trxnParams']); if (empty($params['entity_id'])) { - $financialTrxnID = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['trxnParams']['contribution_id'], 'DESC'); + $financialTrxnID = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($params['trxnParams']['contribution_id'], 'DESC'); $params['entity_id'] = $financialTrxnID['financialTrxnId']; } $fItemParams @@ -629,7 +629,7 @@ public static function createDeferredTrxn($lineItems, $contributionDetails, $upd foreach ($deferredRevenue['revenue'] as $revenue) { $trxnParams['total_amount'] = $trxnParams['net_amount'] = $revenue['amount']; $trxnParams['trxn_date'] = CRM_Utils_Date::isoToMysql($revenue['revenue_date']); - $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams); + $financialTxn = CRM_Financial_BAO_FinancialTrxn::create($trxnParams); $entityParams = [ 'entity_id' => $deferredRevenue['financial_item_id'], 'entity_table' => 'civicrm_financial_item', @@ -718,7 +718,7 @@ public static function updateFinancialAccountsOnPaymentInstrumentChange($inputPa $lastFinancialTrxn['fee_amount'] = -$inputParams['trxnParams']['fee_amount']; $lastFinancialTrxn['contribution_id'] = $prevContribution->id; foreach ([$lastFinancialTrxn, $inputParams['trxnParams']] as $financialTrxnParams) { - $trxn = CRM_Core_BAO_FinancialTrxn::create($financialTrxnParams); + $trxn = CRM_Financial_BAO_FinancialTrxn::create($financialTrxnParams); $trxnParams = [ 'total_amount' => $trxn->total_amount, 'contribution_id' => $currentContribution->id, diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index e24a4dfebcbf..20bb1b96a6bd 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -74,7 +74,7 @@ public static function create(array $params): CRM_Financial_DAO_FinancialTrxn { $paymentTrxnParams['from_financial_account_id'] = $accountsReceivableAccount; if ($params['total_amount'] > 0) { - $paymentTrxnParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'status_id', 'Completed'); + $paymentTrxnParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialTrxn', 'status_id', 'Completed'); } elseif ($params['total_amount'] < 0) { $paymentTrxnParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded'); @@ -91,11 +91,11 @@ public static function create(array $params): CRM_Financial_DAO_FinancialTrxn { 'is_payment' => 0, 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'), ]); - CRM_Core_BAO_FinancialTrxn::create($ftParams); + CRM_Financial_BAO_FinancialTrxn::create($ftParams); $contributionStatus = 'Pending'; self::updateContributionStatus($contribution['id'], $contributionStatus); } - $trxn = CRM_Core_BAO_FinancialTrxn::create($paymentTrxnParams); + $trxn = CRM_Financial_BAO_FinancialTrxn::create($paymentTrxnParams); if ($params['total_amount'] < 0 && !empty($params['cancelled_payment_id'])) { self::reverseAllocationsFromPreviousPayment($params, $trxn->id); @@ -194,9 +194,9 @@ public static function create(array $params): CRM_Financial_DAO_FinancialTrxn { 'payment_processor_id' => $paymentTrxnParams['payment_processor_id'] ?? NULL, ]); // Get the trxn - $trxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $trxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $ftParams = ['id' => $trxnId['financialTrxnId']]; - $trxn = CRM_Core_BAO_FinancialTrxn::retrieve($ftParams); + $trxn = CRM_Financial_BAO_FinancialTrxn::retrieve($ftParams); } } elseif ($contributionStatus === 'Pending' && $params['total_amount'] > 0) { @@ -209,7 +209,7 @@ public static function create(array $params): CRM_Financial_DAO_FinancialTrxn { civicrm_api3('Participant', 'create', ['id' => $participantPayment['participant_id'], 'status_id' => 'Partially paid']); } } - elseif ($contributionStatus === 'Completed' && ((float) CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribution['id'], TRUE) === 0.0)) { + elseif ($contributionStatus === 'Completed' && ((float) CRM_Financial_BAO_FinancialTrxn::getTotalPayments($contribution['id'], TRUE) === 0.0)) { // If the contribution has previously been completed (fully paid) and now has total payments adding up to 0 // change status to refunded. self::updateContributionStatus($contribution['id'], 'Refunded'); @@ -404,7 +404,7 @@ public static function getConfirmationTemplateParameters($entities) { 'paymentAmount' => $entities['payment']['total_amount'], 'checkNumber' => $entities['payment']['check_number'] ?? NULL, 'receive_date' => $entities['payment']['trxn_date'], - 'paidBy' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $entities['payment']['payment_instrument_id']), + 'paidBy' => CRM_Core_PseudoConstant::getLabel('CRM_Financial_BAO_FinancialTrxn', 'payment_instrument_id', $entities['payment']['payment_instrument_id']), 'isShowLocation' => (!empty($entities['event']) ? $entities['event']['is_show_location'] : FALSE), 'location' => $entities['location'] ?? NULL, 'event' => $entities['event'] ?? NULL, @@ -539,7 +539,7 @@ protected static function getPayableLineItems($params): array { $ratio = $params['total_amount'] / $outstandingBalance; } elseif ($params['total_amount'] < 0) { - $ratio = $params['total_amount'] / (float) CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id'], TRUE); + $ratio = $params['total_amount'] / (float) CRM_Financial_BAO_FinancialTrxn::getTotalPayments($params['contribution_id'], TRUE); } else { // Help we are making a payment but no money is owed. We won't allocate the overpayment to any line item. diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index f455c5e7fcdf..062b0ce0e6df 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -121,7 +121,7 @@ public static function buildOptions($fieldName, $context = NULL, $props = []) { $params = []; if ($fieldName === 'financial_account_id') { // Pseudo-field - let's help out. - return CRM_Core_BAO_FinancialTrxn::buildOptions('to_financial_account_id', $context, $props); + return CRM_Financial_BAO_FinancialTrxn::buildOptions('to_financial_account_id', $context, $props); } return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); } diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 9ec7b8be7a7e..220e5af39219 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -588,7 +588,7 @@ protected function getPanTruncation(): ?int { * @return int|null */ protected function getCardTypeID(): ?int { - return CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $this->getSubmittedValue('credit_card_type')); + return CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialTrxn', 'card_type_id', $this->getSubmittedValue('credit_card_type')); } } diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index ab096b848d4a..53057ca7dd50 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -427,7 +427,7 @@ public static function processPriceSet($entityId, $lineItems, $contributionDetai } } if (!$update && $contributionDetails) { - CRM_Core_BAO_FinancialTrxn::createDeferredTrxn($lineItems, $contributionDetails); + CRM_Financial_BAO_FinancialTrxn::createDeferredTrxn($lineItems, $contributionDetails); } } @@ -714,7 +714,7 @@ public static function changeFeeSelections( 'entity_id' => $newFinancialItem->id, 'entity_table' => 'civicrm_financial_item', ]); - $reverseTrxn = CRM_Core_BAO_FinancialTrxn::create($updateFinancialItemInfoValues); + $reverseTrxn = CRM_Financial_BAO_FinancialTrxn::create($updateFinancialItemInfoValues); // record reverse entity financial trxn linked to membership's related contribution civicrm_api3('EntityFinancialTrxn', 'create', [ 'entity_table' => "civicrm_contribution", @@ -1149,10 +1149,10 @@ protected function _getRelatedCancelFinancialTrxn($financialItemID) { * @param int $taxAmount * @param bool $updateAmountLevel * - * @return bool|\CRM_Core_BAO_FinancialTrxn + * @return bool|\CRM_Financial_BAO_FinancialTrxn */ protected function _recordAdjustedAmt($updatedAmount, $contributionId, $taxAmount = NULL, $updateAmountLevel = NULL) { - $paidAmount = (float) CRM_Core_BAO_FinancialTrxn::getTotalPayments($contributionId); + $paidAmount = (float) CRM_Financial_BAO_FinancialTrxn::getTotalPayments($contributionId); $balanceAmt = $updatedAmount - $paidAmount; $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); @@ -1199,7 +1199,7 @@ protected function _recordAdjustedAmt($updatedAmount, $contributionId, $taxAmoun 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency, ]; - $adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues); + $adjustedTrxn = CRM_Financial_BAO_FinancialTrxn::create($adjustedTrxnValues); } // CRM-17151: Update the contribution status to completed if balance is zero, // because due to sucessive fee change will leave the related contribution status incorrect diff --git a/CRM/Report/Form/Contribute/DeferredRevenue.php b/CRM/Report/Form/Contribute/DeferredRevenue.php index 49ff34962a21..c38207ba3040 100644 --- a/CRM/Report/Form/Contribute/DeferredRevenue.php +++ b/CRM/Report/Form/Contribute/DeferredRevenue.php @@ -493,7 +493,7 @@ public function alterDisplay(&$rows) { // convert transaction status id to status name if ($status = CRM_Utils_Array::value('civicrm_financial_trxn_status_id', $row)) { - $row['civicrm_financial_trxn_status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'status_id', $status); + $row['civicrm_financial_trxn_status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Financial_BAO_FinancialTrxn', 'status_id', $status); $entryFound = TRUE; } diff --git a/api/v3/FinancialTrxn.php b/api/v3/FinancialTrxn.php index 033e26339e42..cbb7b1c1da72 100644 --- a/api/v3/FinancialTrxn.php +++ b/api/v3/FinancialTrxn.php @@ -27,7 +27,7 @@ function civicrm_api3_financial_trxn_create($params) { throw new API_Exception("Mandatory key(s) missing from params array: both contribution_id and entity_id are missing"); } - return _civicrm_api3_basic_create('CRM_Core_BAO_FinancialTrxn', $params, 'FinancialTrxn'); + return _civicrm_api3_basic_create('CRM_Financial_BAO_FinancialTrxn', $params, 'FinancialTrxn'); } /** diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 8cad0ad89ff5..f1ea05c64da6 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -566,7 +566,7 @@ public function testIsPaymentFlag() { 'is_payment' => 1, ]; $defaults = []; - $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); + $financialTrxn = CRM_Financial_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); $this->assertEquals(1, $financialTrxn->N, 'Mismatch count for is payment flag.'); //update contribution amount $params['id'] = $contribution['id']; @@ -580,10 +580,10 @@ public function testIsPaymentFlag() { 'is_payment' => 1, ]; $defaults = []; - $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); + $financialTrxn = CRM_Financial_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); $this->assertEquals(2, $financialTrxn->N, 'Mismatch count for is payment flag.'); $trxnArray['is_payment'] = 0; - $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); + $financialTrxn = CRM_Financial_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); $this->assertEquals(1, $financialTrxn->N, 'Mismatch count for is payment flag.'); } @@ -623,10 +623,10 @@ public function testIsPaymentFlagForPending() { 'is_payment' => 0, ]; $defaults = []; - $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); + $financialTrxn = CRM_Financial_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); $this->assertEquals(2, $financialTrxn->N, 'Mismatch count for is payment flag.'); $trxnArray['is_payment'] = 1; - $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); + $financialTrxn = CRM_Financial_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); $this->assertEquals(NULL, $financialTrxn, 'Mismatch count for is payment flag.'); //update contribution amount $params['id'] = $contribution['id']; @@ -641,10 +641,10 @@ public function testIsPaymentFlagForPending() { 'is_payment' => 1, ]; $defaults = []; - $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); + $financialTrxn = CRM_Financial_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); $this->assertEquals(1, $financialTrxn->N, 'Mismatch count for is payment flag.'); $trxnArray['is_payment'] = 0; - $financialTrxn = CRM_Core_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); + $financialTrxn = CRM_Financial_BAO_FinancialTrxn::retrieve($trxnArray, $defaults); $this->assertEquals(2, $financialTrxn->N, 'Mismatch count for is payment flag.'); } @@ -953,7 +953,7 @@ public function testCommaSeparatorAmount() { ]; $contribution = $this->callAPISuccess('Order', 'create', $params); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ @@ -1113,7 +1113,7 @@ public function testProportionallyAssignedForPIChange() { 'payment_instrument_id' => 3, ]; $this->callAPISuccess('Contribution', 'create', $params); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $eftParams = [ 'entity_table' => 'civicrm_financial_item', 'financial_trxn_id' => $lastFinancialTrxnId['financialTrxnId'], diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 77f3933fc589..e9140e59b1e3 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -1289,7 +1289,7 @@ public function testCardTypeAndPanTruncation(): void { 'return' => ['id'], ] ); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ @@ -1351,7 +1351,7 @@ public function testContributionBasePreProcess(): void { * function to test card_type and pan truncation. */ public function testCardTypeAndPanTruncationLiveMode(): void { - $visaID = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', 'Visa'); + $visaID = CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialTrxn', 'card_type_id', 'Visa'); $this->submitContributionForm( [ 'total_amount' => 50, @@ -1387,7 +1387,7 @@ public function testCardTypeAndPanTruncationLiveMode(): void { ], NULL, 'live' ); $contribution = $this->callAPISuccessGetSingle('Contribution', ['contact_id' => $this->_individualId]); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ diff --git a/tests/phpunit/CRM/Contribute/Form/SearchTest.php b/tests/phpunit/CRM/Contribute/Form/SearchTest.php index 60df89f99e51..bbbfb6425a01 100644 --- a/tests/phpunit/CRM/Contribute/Form/SearchTest.php +++ b/tests/phpunit/CRM/Contribute/Form/SearchTest.php @@ -175,7 +175,7 @@ public function testCardTypeFilter() { 'card_type_id' => 1, 'total_amount' => 100, ]; - CRM_Core_BAO_FinancialTrxn::create($params); + CRM_Financial_BAO_FinancialTrxn::create($params); $this->callAPISuccess('Contribution', 'create', [ 'financial_type_id' => 1, 'total_amount' => 150, @@ -200,7 +200,7 @@ public function testCardTypeFilter() { 'card_type_id' => 2, 'total_amount' => 200, ]; - CRM_Core_BAO_FinancialTrxn::create($params); + CRM_Financial_BAO_FinancialTrxn::create($params); $useCases = [ // Case 1: Search for ONLY those contributions which have card type @@ -278,7 +278,7 @@ public function testCardNumberFilter() { 'total_amount' => 100, 'pan_truncation' => 1234, ]; - CRM_Core_BAO_FinancialTrxn::create($params); + CRM_Financial_BAO_FinancialTrxn::create($params); $this->callAPISuccess('Contribution', 'create', [ 'financial_type_id' => 1, 'total_amount' => 150, @@ -304,7 +304,7 @@ public function testCardNumberFilter() { 'total_amount' => 200, 'pan_truncation' => 5678, ]; - CRM_Core_BAO_FinancialTrxn::create($params); + CRM_Financial_BAO_FinancialTrxn::create($params); $useCases = [ // Case 1: Search for ONLY those contributions which have card number @@ -531,7 +531,7 @@ protected function setUpRecurringContributions() { 'card_type_id' => 1, 'total_amount' => 11, ]; - CRM_Core_BAO_FinancialTrxn::create($params); + CRM_Financial_BAO_FinancialTrxn::create($params); // Create a normal contribution $Contribution1 = $this->callAPISuccess('Contribution', 'create', [ 'financial_type_id' => 'Donation', @@ -551,7 +551,7 @@ protected function setUpRecurringContributions() { 'card_type_id' => 1, 'total_amount' => 11, ]; - CRM_Core_BAO_FinancialTrxn::create($params); + CRM_Financial_BAO_FinancialTrxn::create($params); // "Completed" recurring contribution for contactID2 $ContributionRecur2 = $this->callAPISuccess('ContributionRecur', 'create', [ 'sequential' => 1, @@ -585,7 +585,7 @@ protected function setUpRecurringContributions() { 'card_type_id' => 1, 'total_amount' => 22, ]; - CRM_Core_BAO_FinancialTrxn::create($params); + CRM_Financial_BAO_FinancialTrxn::create($params); } /** diff --git a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php index 689ee060b3ed..9613ea6b4586 100644 --- a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php +++ b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php @@ -187,7 +187,7 @@ public function testPaymentWithCustomPaymentInstrument() { // check payment info again and see if the payment is completed $contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contributionID]); $this->assertEquals($feeAmt, $contribution['total_amount'], 'Total amount recorded is not proper'); - $this->assertEquals($feeAmt, CRM_Core_BAO_FinancialTrxn::getTotalPayments($contributionID), 'Amount paid is not correct'); + $this->assertEquals($feeAmt, CRM_Financial_BAO_FinancialTrxn::getTotalPayments($contributionID), 'Amount paid is not correct'); $this->assertEquals(CRM_Contribute_BAO_Contribution::getContributionBalance($contributionID), 0, 'Balance amount is not proper'); $this->assertEquals('Completed', $contribution['contribution_status'], 'Contribution status is not correct'); @@ -204,7 +204,7 @@ public function testAddPartialPayment() { $amtPaid = (float) 60; $balance = (float) 40; $result = $this->addParticipantWithPayment($feeAmt, $amtPaid); - $amountPaid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($result['contribution']['id']); + $amountPaid = CRM_Financial_BAO_FinancialTrxn::getTotalPayments($result['contribution']['id']); $contributionBalance = CRM_Contribute_BAO_Contribution::getContributionBalance($result['contribution']['id']); $this->assertEquals($feeAmt, $this->callAPISuccess('Contribution', 'getvalue', ['return' => 'total_amount', 'id' => $result['contribution']['id']]), 'Total amount recorded is not correct'); diff --git a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php index 2f57e086fdb9..7062513ad18f 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -178,7 +178,7 @@ public function testPaidSubmit($thousandSeparator) { $this->assertEquals(7999, $contribution['net_amount']); $this->assertNotEmpty($contribution['receipt_date']); $this->assertNotContains(' (multiple participants)', $contribution['amount_level']); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ diff --git a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialTrxnTest.php similarity index 92% rename from tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php rename to tests/phpunit/CRM/Financial/BAO/FinancialTrxnTest.php index 178a46dba5b1..940478cd95b9 100644 --- a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialTrxnTest.php @@ -10,10 +10,10 @@ */ /** - * Class CRM_Core_BAO_FinancialTrxnTest + * Class CRM_Financial_BAO_FinancialTrxnTest * @group headless */ -class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase { +class CRM_Financial_BAO_FinancialTrxnTest extends CiviUnitTestCase { /** * Check method create(). @@ -38,9 +38,9 @@ public function testCreate() { 'payment_processor' => 'Dummy', 'trxn_id' => 'test_01014000', ]; - $FinancialTrxn = CRM_Core_BAO_FinancialTrxn::create($params); + $FinancialTrxn = CRM_Financial_BAO_FinancialTrxn::create($params); - $result = $this->assertDBNotNull('CRM_Core_BAO_FinancialTrxn', $FinancialTrxn->id, + $result = $this->assertDBNotNull('CRM_Financial_BAO_FinancialTrxn', $FinancialTrxn->id, 'total_amount', 'id', 'Database check on updated financial trxn record.' ); @@ -78,7 +78,7 @@ public function testGetTotalPayments() { $contribution = $this->callAPISuccess('Contribution', 'create', $params); $contribution = $contribution['values'][$contribution['id']]; - $totalPaymentAmount = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribution['id']); + $totalPaymentAmount = CRM_Financial_BAO_FinancialTrxn::getTotalPayments($contribution['id']); $this->assertEquals(0, $totalPaymentAmount, 'Amount not matching.'); $params['id'] = $contribution['id']; @@ -86,7 +86,7 @@ public function testGetTotalPayments() { $contribution = $this->callAPISuccess('Contribution', 'create', $params); - $totalPaymentAmount = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribution['id']); + $totalPaymentAmount = CRM_Financial_BAO_FinancialTrxn::getTotalPayments($contribution['id']); $this->assertEquals('200.00', $totalPaymentAmount, 'Amount not matching.'); } @@ -102,7 +102,7 @@ public function testGetTotalPaymentsParticipantOrder() { 'total_amount' => 100.00, ]; $this->callAPISuccess('Payment', 'create', $params); - $totalPaymentAmount = CRM_Core_BAO_FinancialTrxn::getTotalPayments($orderID); + $totalPaymentAmount = CRM_Financial_BAO_FinancialTrxn::getTotalPayments($orderID); $this->assertEquals('250.00', $totalPaymentAmount, 'Amount does not match.'); } @@ -132,7 +132,7 @@ public function testCreateDeferredTrxn() { $contributionObj = $this->getContributionObject($contribution['id']); $contributionObj->revenue_recognition_date = date('Ymd', strtotime('+1 month')); - CRM_Core_BAO_FinancialTrxn::createDeferredTrxn($lineItems, $contributionObj); + CRM_Financial_BAO_FinancialTrxn::createDeferredTrxn($lineItems, $contributionObj); $trxn = $this->callAPISuccess('FinancialTrxn', 'get', ['total_amount' => 622, 'id' => ['NOT IN' => [$trxn['id']]]]); $this->assertEquals(date('Ymd', strtotime($trxn['values'][$trxn['id']]['trxn_date'])), date('Ymd', strtotime('+1 month'))); @@ -152,7 +152,7 @@ public function testUpdateCreditCardDetailsUsingContributionAPI() { 'financial_type_id' => 1, ]; $contribution = $this->callAPISuccess('Contribution', 'create', $params); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ @@ -193,7 +193,7 @@ public function testUpdateCreditCardDetails() { 'financial_type_id' => 1, ]; $contribution = $this->callAPISuccess('Contribution', 'create', $params); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ @@ -203,7 +203,7 @@ public function testUpdateCreditCardDetails() { ); $this->assertEquals(CRM_Utils_Array::value('card_type_id', $financialTrxn), NULL); $this->assertEquals(CRM_Utils_Array::value('pan_truncation', $financialTrxn), NULL); - CRM_Core_BAO_FinancialTrxn::updateCreditCardDetails($contribution['id'], 4567, 2); + CRM_Financial_BAO_FinancialTrxn::updateCreditCardDetails($contribution['id'], 4567, 2); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index bf0ca8949bb2..6cc2a97d47b8 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2875,7 +2875,7 @@ public function _checkFinancialRecords($params, $context) { 'total_amount' => 50, 'status_id' => 1, ]; - $trxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['id'], 'DESC'); + $trxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($params['id'], 'DESC'); $this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams, $compareParams); $fitemParams = [ 'entity_id' => $trxnId['financialTrxnId'], diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 87981fa8e9e0..fd54eed112d6 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -4627,7 +4627,7 @@ public function testCardTypeAndPanTruncation() { 'pan_truncation' => 4567, ]; $contribution = $this->callAPISuccess('contribution', 'create', $params); - $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $lastFinancialTrxnId = CRM_Financial_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $financialTrxn = $this->callAPISuccessGetSingle( 'FinancialTrxn', [ diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index fa0de30c329e..7baaa2898d70 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -370,7 +370,7 @@ public function testRefundEmailReceipt(string $thousandSeparator): void { 'from_financial_account_id' => 7, 'to_financial_account_id' => 6, 'total_amount' => -30, - 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'status_id', 'Refunded'), + 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialTrxn', 'status_id', 'Refunded'), 'is_payment' => 1, ]; foreach ($expected as $key => $value) { @@ -1189,14 +1189,14 @@ public function testPaymentWithProcessorWithOddFinancialAccount(): void { $this->callAPISuccess('Payment', 'create', ['payment_processor_id' => $processor->getID(), 'total_amount' => 6, 'contribution_id' => $order['id']]); $this->callAPISuccess('Payment', 'create', ['payment_processor_id' => $processor2->getID(), 'total_amount' => 15, 'contribution_id' => $order['id']]); $payments = $this->callAPISuccess('Payment', 'get', ['sequential' => 1, 'contribution_id' => $order['id']])['values']; - $this->assertEquals('Deposit Bank Account', CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'to_financial_account_id', $payments[0]['to_financial_account_id'])); - $this->assertEquals('Payment Processor Account', CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'to_financial_account_id', $payments[1]['to_financial_account_id'])); - $this->assertEquals('Accounts Receivable', CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'from_financial_account_id', $payments[0]['from_financial_account_id'])); - $this->assertEquals('Accounts Receivable', CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'from_financial_account_id', $payments[1]['from_financial_account_id'])); - $this->assertEquals('Cash', CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $payments[0]['payment_instrument_id'])); - $this->assertEquals('EFT', CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $payments[1]['payment_instrument_id'])); + $this->assertEquals('Deposit Bank Account', CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'to_financial_account_id', $payments[0]['to_financial_account_id'])); + $this->assertEquals('Payment Processor Account', CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'to_financial_account_id', $payments[1]['to_financial_account_id'])); + $this->assertEquals('Accounts Receivable', CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'from_financial_account_id', $payments[0]['from_financial_account_id'])); + $this->assertEquals('Accounts Receivable', CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'from_financial_account_id', $payments[1]['from_financial_account_id'])); + $this->assertEquals('Cash', CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'payment_instrument_id', $payments[0]['payment_instrument_id'])); + $this->assertEquals('EFT', CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'payment_instrument_id', $payments[1]['payment_instrument_id'])); // $order = $this->callAPISuccessGetSingle('Order', ['id' => $processor->getID()]); - // $this->assertEquals('Cash', CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $order['payment_instrument_id'])); + // $this->assertEquals('Cash', CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_FinancialTrxn', 'payment_instrument_id', $order['payment_instrument_id'])); } /**