* Input as delivered from Payment Processor.
* @param array $ids
* Ids as Loaded by Payment Processor.
- * @param bool $loadAll
- * Load all related objects - even where id not passed in? (allows API to call this).
*
* @return bool
* @throws CRM_Core_Exception
*/
- public function loadRelatedObjects($input, &$ids, $loadAll = FALSE) {
+ public function loadRelatedObjects($input, &$ids) {
// @todo deprecate this function - the steps should be
// 1) add additional functions like 'getRelatedMemberships'
// 2) switch all calls that refer to ->_relatedObjects to
// 4) make ->_relatedObjects protected
// 5) hone up the individual functions to not use rely on this having been called
// 6) deprecate like mad
- if ($loadAll) {
- $ids = array_merge(self::getComponentDetails($this->id), $ids);
- if (empty($ids['contact']) && isset($this->contact_id)) {
- $ids['contact'] = $this->contact_id;
- }
- }
if (empty($this->_component)) {
if (!empty($ids['event'])) {
$this->_component = 'event';
* @throws Exception
*/
public function composeMessageArray(&$input, &$ids, &$values, $returnMessageText = TRUE) {
- $this->loadRelatedObjects($input, $ids, TRUE);
+ $ids = array_merge(self::getComponentDetails($this->id), $ids);
+ if (empty($ids['contact']) && isset($this->contact_id)) {
+ $ids['contact'] = $this->contact_id;
+ }
+ $this->loadRelatedObjects($input, $ids);
if (empty($this->_component)) {
$this->_component = $input['component'] ?? NULL;
$pendingStatusId = CRM_Utils_Array::key('Pending', $contributionStatusID);
$pdfFormat = CRM_Core_BAO_PdfFormat::getByName('default_invoice_pdf_format');
- foreach ($invoiceElements['details'] as $contribID => $detail) {
+ foreach ($invoiceElements['details'] as $contributionID => $detail) {
$input = $ids = [];
if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) {
continue;
$input['component'] = $detail['component'];
$ids['contact'] = $detail['contact'];
- $ids['contribution'] = $contribID;
+ $ids['contribution'] = $contributionID;
$ids['contributionRecur'] = NULL;
$ids['contributionPage'] = NULL;
$ids['membership'] = $detail['membership'] ?? NULL;
$ids['event'] = $detail['event'] ?? NULL;
$contribution = new CRM_Contribute_BAO_Contribution();
- $contribution->id = $contribID;
+ $contribution->id = $contributionID;
$contribution->fetch();
// @todo this is only used now to load the event title, it causes an enotice
// and calls deprecated code. If we decide a contribution title is a
// 'real thing' then we should create a token.
- $contribution->loadRelatedObjects($input, $ids, TRUE);
+ $ids = array_merge(CRM_Contribute_BAO_Contribution::getComponentDetails($contributionID), $ids);
+ $contribution->loadRelatedObjects($input, $ids);
$input['amount'] = $contribution->total_amount;
$input['invoice_id'] = $contribution->invoice_id;
$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_Core_BAO_FinancialTrxn::getTotalPayments($contributionID, TRUE);
$amountDue = ($input['amount'] - $amountPaid);
// retrieving the subtotal and sum of same tax_rate
$dataArray = [];
$subTotal = 0;
- $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contribID);
+ $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contributionID);
foreach ($lineItem as $taxRate) {
if (isset($dataArray[(string) $taxRate['tax_rate']])) {
$dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + CRM_Utils_Array::value('tax_amount', $taxRate);
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $this->_contributionId;
$contribution->find(TRUE);
- $contribution->loadRelatedObjects($this->input, $this->ids, TRUE);
+ $ids = array_merge(CRM_Contribute_BAO_Contribution::getComponentDetails($this->_contributionId), $this->ids);
+ $contribution->loadRelatedObjects($this->input, $ids);
$this->assertNotEmpty($contribution->_relatedObjects['membership']);
$this->assertArrayHasKey($this->_membershipId . '_' . $this->_membershipTypeID, $contribution->_relatedObjects['membership']);
$this->assertTrue(is_a($contribution->_relatedObjects['membership'][$this->_membershipId . '_' . $this->_membershipTypeID], 'CRM_Member_BAO_Membership'));
- $this->assertTrue(is_a($contribution->_relatedObjects['financialType'], 'CRM_Financial_BAO_FinancialType'));
$this->assertNotEmpty($contribution->_relatedObjects['contributionRecur']);
$this->assertNotEmpty($contribution->_relatedObjects['paymentProcessor']);
}