From 9e7be32a2acff2fedd99428f0287292b0f02a592 Mon Sep 17 00:00:00 2001 From: Omar Hussein Date: Sun, 26 Nov 2023 12:56:25 +0200 Subject: [PATCH] Set correct financial type when creating membership using price set with single line item --- CRM/Member/Form.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index f0a2ecba21..8779cfb41f 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -583,13 +583,27 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { $this->order = new CRM_Financial_BAO_Order(); $this->order->setForm($this); $this->order->setPriceSelectionFromUnfilteredInput($formValues); + if (isset($formValues['total_amount'])) { $this->order->setOverrideTotalAmount((float) $formValues['total_amount']); } - $this->order->setOverrideFinancialTypeID((int) $formValues['financial_type_id']); + + if ($this->isQuickConfig()) { + $this->order->setOverrideFinancialTypeID((int) $formValues['financial_type_id']); + } + return $formValues; } + /** + * Is the price set quick config. + * + * @return bool + */ + private function isQuickConfig(): bool { + return $this->_priceSetId && CRM_Price_BAO_PriceSet::isQuickConfig($this->_priceSetId); + } + /** * Wrapper function for unit tests. * -- 2.25.1