Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: civicrm/civicrm-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 240849f692fd95eacf6b781bb0bcedcfbb010278
Choose a base ref
..
head repository: civicrm/civicrm-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b3a1c34f0d1d62ffaed5ffe1e46a147108f6598a
Choose a head ref
Showing with 17 additions and 117 deletions.
  1. +0 −48 CRM/Contribute/BAO/Contribution.php
  2. +17 −0 CRM/Contribute/BAO/FinancialProcessor.php
  3. +0 −69 tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
48 changes: 0 additions & 48 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
@@ -992,23 +992,6 @@ protected static function handleMembershipIDOverride($contributionID, $input) {
}
}

/**
* Update all financial items related to the line item tto have a status of paid.
*
* @param int $lineItemID
*/
private static function updateFinancialItemForLineItemToPaid($lineItemID) {
$fparams = [
1 => [
CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialItem', 'status_id', 'Paid'),
'Integer',
],
2 => [$lineItemID, 'Integer'],
];
$query = "UPDATE civicrm_financial_item SET status_id = %1 WHERE entity_id = %2 and entity_table = 'civicrm_line_item'";
CRM_Core_DAO::executeQuery($query, $fparams);
}

/**
* Get transaction information about the contribution.
*
@@ -4503,37 +4486,6 @@ public static function allowUpdateRevenueRecognitionDate($contributionId) {
return $flag;
}

/**
* Calculate financial item amount when contribution is updated.
*
* @param array $params
* contribution params
* @param array $amountParams
*
* @param string $context
*
* @return float
*/
public static function calculateFinancialItemAmount($params, $amountParams, $context) {
if (!empty($params['is_quick_config'])) {
$amount = $amountParams['item_amount'];
if (!$amount) {
$amount = $params['total_amount'];
if ($context === NULL) {
$amount -= CRM_Utils_Array::value('tax_amount', $params, 0);
}
}
}
else {
$amount = $amountParams['line_total'];
if ($context == 'changedAmount') {
$amount -= $amountParams['previous_line_total'];
}
$amount *= $amountParams['diff'];
}
return $amount;
}

/**
* Retrieve Sales Tax Financial Accounts.
*
17 changes: 17 additions & 0 deletions CRM/Contribute/BAO/FinancialProcessor.php
Original file line number Diff line number Diff line change
@@ -343,6 +343,23 @@ public static function updateFinancialAccountsOnContributionStatusChange(&$param
return TRUE;
}

/**
* Update all financial items related to the line item tto have a status of paid.
*
* @param int $lineItemID
*/
private static function updateFinancialItemForLineItemToPaid($lineItemID) {
$fparams = [
1 => [
CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialItem', 'status_id', 'Paid'),
'Integer',
],
2 => [$lineItemID, 'Integer'],
];
$query = "UPDATE civicrm_financial_item SET status_id = %1 WHERE entity_id = %2 and entity_table = 'civicrm_line_item'";
CRM_Core_DAO::executeQuery($query, $fparams);
}

/**
* Create Accounts Receivable financial trxn entry for Completed Contribution.
*
69 changes: 0 additions & 69 deletions tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
Original file line number Diff line number Diff line change
@@ -931,75 +931,6 @@ public function testAllowUpdateRevenueRecognitionDate() {
$this->assertFalse($allowUpdate);
}

/**
* Test calculateFinancialItemAmount().
*/
public function testcalculateFinancialItemAmount() {
$testParams = [
[
'params' => [],
'amountParams' => [
'line_total' => 100,
'previous_line_total' => 300,
'diff' => 1,
],
'context' => 'changedAmount',
'expectedItemAmount' => -200,
],
[
'params' => [],
'amountParams' => [
'line_total' => 100,
'previous_line_total' => 100,
'diff' => -1,
],
// Most contexts are ignored. Removing refs to change payment instrument so placeholder.
'context' => 'not null',
'expectedItemAmount' => -100,
],
[
'params' => [
'is_quick_config' => TRUE,
'total_amount' => 110,
'tax_amount' => 10,
],
'amountParams' => [
'item_amount' => 100,
],
'context' => 'changedAmount',
'expectedItemAmount' => 100,
],
[
'params' => [
'is_quick_config' => TRUE,
'total_amount' => 110,
'tax_amount' => 10,
],
'amountParams' => [
'item_amount' => NULL,
],
'context' => 'changedAmount',
'expectedItemAmount' => 110,
],
[
'params' => [
'is_quick_config' => TRUE,
'total_amount' => 110,
'tax_amount' => 10,
],
'amountParams' => [
'item_amount' => NULL,
],
'context' => NULL,
'expectedItemAmount' => 100,
],
];
foreach ($testParams as $params) {
$itemAmount = CRM_Contribute_BAO_Contribution::calculateFinancialItemAmount($params['params'], $params['amountParams'], $params['context']);
$this->assertEquals($itemAmount, $params['expectedItemAmount'], 'Invalid Financial Item amount.');
}
}

/**
* Test recording of amount with comma separator.
*