'toName' => $form->_contributorDisplayName,
'toEmail' => $form->_contributorEmail,
'PDFFilename' => ts('receipt') . '.pdf',
- 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('is_email_pdf'),
+ 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf'),
'contributionId' => $formValues['contribution_id'],
'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW),
]
$this->_priceSet,
$formValues
);
- if (empty($formValues['financial_type_id'])) {
- $formValues['financial_type_id'] = $this->_priceSet['financial_type_id'];
- }
-
+ $formValues['financial_type_id'] = $this->getFinancialTypeID();
$membershipTypeValues = [];
foreach ($this->_memTypeSelected as $memType) {
$membershipTypeValues[$memType]['membership_type_id'] = $memType;
if (!empty($formValues['record_contribution'])) {
$recordContribution = [
'total_amount',
- 'financial_type_id',
'payment_instrument_id',
'trxn_id',
'contribution_status_id',
foreach ($recordContribution as $f) {
$params[$f] = $formValues[$f] ?? NULL;
}
+ $params['financial_type_id'] = $this->getFinancialTypeID();
if (empty($formValues['source'])) {
$params['contribution_source'] = ts('%1 Membership: Offline signup (by %2)', [
//insert financial type name in receipt.
$formValues['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType',
- $formValues['financial_type_id']
+ $this->getFinancialTypeID()
);
}
//CRM-20264 : Store CC type and number (last 4 digit) during backoffice or online payment
$params['card_type_id'] = $this->_params['card_type_id'] ?? NULL;
$params['pan_truncation'] = $this->_params['pan_truncation'] ?? NULL;
-
- if (!$isQuickConfig) {
- $params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet',
- $this->_priceSetId,
- 'financial_type_id'
- );
- }
- else {
- $params['financial_type_id'] = $formValues['financial_type_id'] ?? NULL;
- }
+ $params['financial_type_id'] = $this->getFinancialTypeID();
//get the payment processor id as per mode. Try removing in favour of beginPostProcess.
$params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$formValues['currencyID'] = $this->getCurrency();
$formValues['description'] = ts("Contribution submitted by a staff person using member's credit card for signup");
$formValues['invoiceID'] = $this->getInvoiceID();
- $formValues['financial_type_id'] = $params['financial_type_id'];
+ $formValues['financial_type_id'] = $this->getFinancialTypeID();
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
'campaign_id' => $paymentParams['campaign_id'] ?? NULL,
'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)),
'payment_instrument_id' => $paymentInstrumentID,
- 'financial_type_id' => $params['financial_type_id'],
+ 'financial_type_id' => $this->getFinancialTypeID(),
'receive_date' => CRM_Utils_Time::date('YmdHis'),
'tax_amount' => $params['tax_amount'] ?? NULL,
'invoice_id' => $this->getInvoiceID(),
$contactID = $contributionParams['contact_id'];
// add these values for the recurringContrib function ,CRM-10188
- $params['financial_type_id'] = $contributionParams['financial_type_id'];
-
- $params['is_email_receipt'] = (bool) $this->getSubmittedValue('send_receipt');
+ $params['financial_type_id'] = $this->getFinancialTypeID();
$params['is_recur'] = TRUE;
$params['payment_instrument_id'] = $contributionParams['payment_instrument_id'] ?? NULL;
$recurringContributionID = $this->legacyProcessRecurringContribution($params, $contactID);
- $now = CRM_Utils_Time::date('YmdHis');
- $receiptDate = $params['receipt_date'] ?? NULL;
- if ($params['is_email_receipt']) {
- $receiptDate = $now;
- }
-
if ($this->getSubmittedValue('send_receipt')) {
$contributionParams += [
- 'receipt_date' => $receiptDate,
+ 'receipt_date' => CRM_Utils_Time::date('YmdHis'),
];
}
$recurParams['frequency_unit'] = $params['frequency_unit'] ?? NULL;
$recurParams['frequency_interval'] = $params['frequency_interval'] ?? NULL;
$recurParams['installments'] = $params['installments'] ?? NULL;
- $recurParams['financial_type_id'] = $params['financial_type_id'];
+ $recurParams['financial_type_id'] = $this->getFinancialTypeID();
$recurParams['currency'] = $params['currency'] ?? NULL;
$recurParams['payment_instrument_id'] = $params['payment_instrument_id'];
return ($this->_mode === 'test') ? TRUE : FALSE;
}
+ /**
+ * Get the financial type id relevant to the contribution.
+ *
+ * Financial type id is optional when price sets are in use.
+ * Otherwise they are required for the form to submit.
+ *
+ * @return int
+ */
+ protected function getFinancialTypeID(): int {
+ return (int) $this->getSubmittedValue('financial_type_id') ?: $this->order->getFinancialTypeID();
+ }
+
}