X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FPrice%2FBAO%2FLineItem.php;h=9c5b9bd58c0c5de7b6d4311742f958b0ea749742;hb=6b409353d19be6058cbd47fcc5916c8564aed6ff;hp=efa24b312bacbcd24f10b9b67db7a9aad7b6e19b;hpb=306a8600bda01b8478c6be87c528139817833bad;p=civicrm-core.git diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index efa24b312b..9c5b9bd58c 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -181,11 +181,10 @@ WHERE li.contribution_id = %1"; * @param bool $isQtyZero * @param bool $relatedEntity * - * @param bool $invoice * @return array * Array of line items */ - public static function getLineItems($entityId, $entity = 'participant', $isQuick = FALSE, $isQtyZero = TRUE, $relatedEntity = FALSE, $invoice = FALSE) { + public static function getLineItems($entityId, $entity = 'participant', $isQuick = FALSE, $isQtyZero = TRUE, $relatedEntity = FALSE) { $whereClause = $fromClause = NULL; $selectClause = " SELECT li.id, @@ -218,17 +217,7 @@ WHERE li.contribution_id = %1"; LEFT JOIN civicrm_line_item li ON ({$condition}) LEFT JOIN civicrm_price_field_value pfv ON ( pfv.id = li.price_field_value_id ) LEFT JOIN civicrm_price_field pf ON (pf.id = li.price_field_id )"; - $whereClause = " - WHERE %2.id = %1"; - - // CRM-16250 get additional participant's fee selection details only for invoice PDF (if any) - if ($entity == 'participant' && $invoice) { - $additionalParticipantIDs = CRM_Event_BAO_Participant::getAdditionalParticipantIds($entityId); - if (!empty($additionalParticipantIDs)) { - $whereClause = "WHERE %2.id IN (%1, " . implode(', ', $additionalParticipantIDs) . ")"; - } - } - + $whereClause = " WHERE %2.id = %1"; $orderByClause = " ORDER BY pf.weight, pfv.weight"; if ($isQuick) { @@ -353,21 +342,21 @@ WHERE li.contribution_id = %1"; $values[$oid] = [ 'price_field_id' => $fid, 'price_field_value_id' => $oid, - 'label' => CRM_Utils_Array::value('label', $options[$oid]), + 'label' => $options[$oid]['label'] ?? NULL, 'field_title' => $fieldTitle, - 'description' => CRM_Utils_Array::value('description', $options[$oid]), + 'description' => $options[$oid]['description'] ?? NULL, 'qty' => $qty, 'unit_price' => $price, 'line_total' => $qty * $price, 'participant_count' => $qty * $participantsPerField, - 'max_value' => CRM_Utils_Array::value('max_value', $options[$oid]), - 'membership_type_id' => CRM_Utils_Array::value('membership_type_id', $options[$oid]), - 'membership_num_terms' => CRM_Utils_Array::value('membership_num_terms', $options[$oid]), - 'auto_renew' => CRM_Utils_Array::value('auto_renew', $options[$oid]), + 'max_value' => $options[$oid]['max_value'] ?? NULL, + 'membership_type_id' => $options[$oid]['membership_type_id'] ?? NULL, + 'membership_num_terms' => $options[$oid]['membership_num_terms'] ?? NULL, + 'auto_renew' => $options[$oid]['auto_renew'] ?? NULL, 'html_type' => $fields['html_type'], - 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $options[$oid]), + 'financial_type_id' => $options[$oid]['financial_type_id'] ?? NULL, 'tax_amount' => CRM_Utils_Array::value('tax_amount', $options[$oid], 0), - 'non_deductible_amount' => CRM_Utils_Array::value('non_deductible_amount', $options[$oid]), + 'non_deductible_amount' => $options[$oid]['non_deductible_amount'] ?? NULL, ]; if ($values[$oid]['membership_type_id'] && empty($values[$oid]['auto_renew'])) { @@ -402,7 +391,7 @@ WHERE li.contribution_id = %1"; * Process price set and line items. * * @param int $entityId - * @param array $lineItem + * @param array $lineItems * Line item array. * @param object $contributionDetails * @param string $entityTable @@ -413,14 +402,14 @@ WHERE li.contribution_id = %1"; * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ - public static function processPriceSet($entityId, $lineItem, $contributionDetails = NULL, $entityTable = 'civicrm_contribution', $update = FALSE) { - if (!$entityId || !is_array($lineItem) - || CRM_Utils_System::isNull($lineItem) + public static function processPriceSet($entityId, $lineItems, $contributionDetails = NULL, $entityTable = 'civicrm_contribution', $update = FALSE) { + if (!$entityId || !is_array($lineItems) + || CRM_Utils_System::isNull($lineItems) ) { return; } - foreach ($lineItem as $priceSetId => &$values) { + foreach ($lineItems as $priceSetId => &$values) { if (!$priceSetId) { continue; } @@ -456,18 +445,18 @@ WHERE li.contribution_id = %1"; if (!empty($line['price_field_value_id']) && empty($line['financial_type_id'])) { $line['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $line['price_field_value_id'], 'financial_type_id'); } - $lineItems = CRM_Price_BAO_LineItem::create($line); + $createdLineItem = CRM_Price_BAO_LineItem::create($line); if (!$update && $contributionDetails) { - $financialItem = CRM_Financial_BAO_FinancialItem::add($lineItems, $contributionDetails); + $financialItem = CRM_Financial_BAO_FinancialItem::add($createdLineItem, $contributionDetails); $line['financial_item_id'] = $financialItem->id; if (!empty($line['tax_amount'])) { - CRM_Financial_BAO_FinancialItem::add($lineItems, $contributionDetails, TRUE); + CRM_Financial_BAO_FinancialItem::add($createdLineItem, $contributionDetails, TRUE); } } } } if (!$update && $contributionDetails) { - CRM_Core_BAO_FinancialTrxn::createDeferredTrxn($lineItem, $contributionDetails); + CRM_Core_BAO_FinancialTrxn::createDeferredTrxn($lineItems, $contributionDetails); } } @@ -604,7 +593,7 @@ WHERE li.contribution_id = %1"; * These are per the way the form processes them - ie * ['price_1' => 1, 'price_2' => 8] * This would mean price field id 1, option 1 (or 1 unit if using is_enter_qty). - * @param float|NULL $overrideAmount + * @param float|null $overrideAmount * Optional override of the amount. * * @param int|null $financialTypeID