From 737bd87c577641305476feb17f2e318e78862920 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 12 Sep 2020 18:37:51 +1200 Subject: [PATCH] [REF] Folllow up cleanup - remove now unused param In a recent regression fix we stopped returning from getLine. This fully removes the, now unused, parameter. The functions that call getLine calculate the total now --- CRM/Financial/BAO/Order.php | 2 +- CRM/Price/BAO/PriceSet.php | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/CRM/Financial/BAO/Order.php b/CRM/Financial/BAO/Order.php index 80cf3b66ec..ffe8af8ff9 100644 --- a/CRM/Financial/BAO/Order.php +++ b/CRM/Financial/BAO/Order.php @@ -238,7 +238,7 @@ class CRM_Financial_BAO_Order { } $throwAwayArray = []; // @todo - still using getLine for now but better to bring it to this class & do a better job. - $newLines = CRM_Price_BAO_PriceSet::getLine($params, $throwAwayArray, $this->getPriceSetID(), $this->getPriceFieldSpec($fieldID), $fieldID, 0)[1]; + $newLines = CRM_Price_BAO_PriceSet::getLine($params, $throwAwayArray, $this->getPriceSetID(), $this->getPriceFieldSpec($fieldID), $fieldID)[1]; foreach ($newLines as $newLine) { $lineItems[$newLine['price_field_value_id']] = $newLine; } diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 7481dd09fa..4bbf042d6c 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -673,7 +673,7 @@ WHERE id = %1"; continue; } - list($params, $lineItem) = self::getLine($params, $lineItem, $priceSetID, $field, $id, $totalPrice); + list($params, $lineItem) = self::getLine($params, $lineItem, $priceSetID, $field, $id); } $amount_level = []; @@ -1694,11 +1694,10 @@ WHERE ct.id = cp.financial_type_id AND * @param int $priceSetID * @param array $field * @param int $id - * @param float $totalPrice * * @return array */ - public static function getLine(&$params, &$lineItem, $priceSetID, $field, $id, $totalPrice): array { + public static function getLine(&$params, &$lineItem, $priceSetID, $field, $id): array { $totalTax = 0; switch ($field['html_type']) { case 'Text': @@ -1718,7 +1717,6 @@ WHERE ct.id = cp.financial_type_id AND if (!empty($field['options'][$optionValueId]['tax_rate'])) { $lineItem = self::setLineItem($field, $lineItem, $optionValueId, $totalTax); } - $totalPrice += $lineItem[$firstOption['id']]['line_total'] + CRM_Utils_Array::value('tax_amount', $lineItem[key($field['options'])]); break; case 'Radio': @@ -1748,7 +1746,6 @@ WHERE ct.id = cp.financial_type_id AND $lineItem[$optionValueId]['line_total'] = $lineItem[$optionValueId]['unit_price'] = CRM_Utils_Rule::cleanMoney($lineItem[$optionValueId]['line_total'] - $lineItem[$optionValueId]['tax_amount']); } } - $totalPrice += $lineItem[$optionValueId]['line_total'] + CRM_Utils_Array::value('tax_amount', $lineItem[$optionValueId]); break; case 'Select': @@ -1759,7 +1756,6 @@ WHERE ct.id = cp.financial_type_id AND if (!empty($field['options'][$optionValueId]['tax_rate'])) { $lineItem = self::setLineItem($field, $lineItem, $optionValueId, $totalTax); } - $totalPrice += $lineItem[$optionValueId]['line_total'] + CRM_Utils_Array::value('tax_amount', $lineItem[$optionValueId]); break; case 'CheckBox': @@ -1769,7 +1765,6 @@ WHERE ct.id = cp.financial_type_id AND if (!empty($field['options'][$optionId]['tax_rate'])) { $lineItem = self::setLineItem($field, $lineItem, $optionId, $totalTax); } - $totalPrice += $lineItem[$optionId]['line_total'] + CRM_Utils_Array::value('tax_amount', $lineItem[$optionId]); } break; } -- 2.25.1