This is similar to https://github.com/civicrm/civicrm-core/pull/18284 - it differs in that the totals are calculated by iterating
through the line item array afterwards, rather than expecting the 'getLine' function to calculate totals. Some
obvious follow ups suggest themselves but I will look against master.
This is difficult to test (Karin gave it a really good shot) because of the weird way it's calculated in Main and thenn
used in Confirm. Cleanup should resolve the testability issue too
$lineItems
) {
$entityTable = "civicrm_" . $entity;
+ $newLineItems = [];
CRM_Price_BAO_PriceSet::processAmount($feeBlock,
- $params, $lineItems
+ $params, $newLineItems
);
// initialize empty Lineitem instance to call protected helper functions
$lineItemObj = new CRM_Price_BAO_LineItem();
continue;
}
- list($params, $lineItem, $totalTax, $totalPrice) = self::getLine($params, $lineItem, $priceSetID, $field, $id, $totalPrice);
+ list($params, $lineItem) = self::getLine($params, $lineItem, $priceSetID, $field, $id, $totalPrice);
}
$amount_level = [];
$totalParticipant = 0;
if (is_array($lineItem)) {
foreach ($lineItem as $values) {
+ $totalPrice += $values['line_total'] + $values['tax_amount'];
+ $totalTax += $values['tax_amount'];
$totalParticipant += $values['participant_count'];
// This is a bit nasty. The logic of 'quick config' was because price set configuration was
// (and still is) too difficult to replace the 'quick config' price set configuration on the contribution
}
break;
}
- return [$params, $lineItem, $totalTax, $totalPrice];
+ return [$params, $lineItem];
}
}
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
$this->assertEquals($this->_expensiveFee, $lineItem[1]['line_total']);
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
- $this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount', 'id', $this->_cheapFee, "Total Amount equals " . $this->_expensiveFee);
+ $this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount', 'id', $this->_cheapFee, 'Total Amount equals ' . $this->_expensiveFee);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'contribution_status_id', 'id', $pendingRefundStatusId, 'Contribution must be refunding');
$priceSetParams['price_' . $this->priceSetFieldID] = $this->expensiveFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
* Check if the related contribuion is also updated if the minimum_fee didn't match
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testContributionUpdateOnMembershipTypeChange() {
// Step 1: Create a Membership via backoffice whose with 50.00 payment