'financial_type_id' => $financialTypeID,
'receive_date' => !empty($params['receive_date']) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'),
'tax_amount' => $params['tax_amount'] ?? NULL,
- 'amount_level' => $params['amount_level'] ?? NULL,
+ 'amount_level' => $this->getMainContributionAmountLevel(),
'invoice_id' => $params['invoiceID'],
'currency' => $params['currencyID'],
'is_pay_later' => $params['is_pay_later'] ?? 0,
return $amount;
}
+ /**
+ * Get the amount level description for the main contribution.
+ *
+ * If there is a separate membership contribution this is the 'other one'. Otherwise there
+ * is only one.
+ *
+ * @return string
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function getMainContributionAmountLevel(): string {
+ $amountLevel = [];
+ if ($this->getSecondaryMembershipContributionLineItems()) {
+ // This is really only needed transitionally because the
+ // test ConfirmTest::testSeparatePaymentConfirm has some set up configuration
+ // issues that will take a bit longer to work through (the labels
+ // should be Contribution Amount or Other Amount but in that test set up they are not.
+ return '';
+ }
+ foreach ($this->getMainContributionLineItems() as $lineItem) {
+ if ($lineItem['label'] !== ts('Contribution Amount') && $lineItem['label'] !== ts('Other Amount')) {
+ $amountLevel[] = $lineItem['label'] . ' - ' . (float) $lineItem['qty'];
+ }
+ }
+ return empty($amountLevel) ? '' : CRM_Utils_Array::implodePadded($amountLevel);
+ }
+
/**
* Wrapper for processAmount that also sets autorenew.
*