From b0a9575b84466d8156104e95a147d7a3560a8034 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Tue, 15 Apr 2014 16:43:55 +0530 Subject: [PATCH] CRM-13973 : #comment-59450 fix --- CRM/Event/BAO/Participant.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 5932e51f3b..af05c2870b 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1787,6 +1787,7 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2"; $submittedFieldId[] = CRM_Utils_Array::retrieveValueRecursive($submittedLineItems, 'price_field_id'); } $insertLines = $submittedLineItems; + $submittedFieldValueIds = array_keys($submittedLineItems); $updateLines = array(); foreach ($previousLineItems as $id => $previousLineItem) { @@ -1796,7 +1797,7 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2"; // if submitted line items are existing don't fire INSERT query unset($insertLines[$previousLineItem['price_field_value_id']]); // for updating the line items i.e. use-case - once deselect-option selecting again - if ($previousLineItem['qty'] == 0) { + if ($previousLineItem['line_total'] != $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total']) { $updateLines[$previousLineItem['price_field_value_id']]['qty'] = $submittedLineItems[$previousLineItem['price_field_value_id']]['qty']; $updateLines[$previousLineItem['price_field_value_id']]['line_total'] = $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total']; } @@ -1805,6 +1806,7 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2"; $submittedFields = implode(', ', $submittedFieldId); $submittedFieldValues = implode(', ', $submittedFieldValueIds); + if (!empty($submittedFields) && !empty($submittedFieldValues)) { $updateLineItem = "UPDATE civicrm_line_item li INNER JOIN civicrm_financial_item fi @@ -1928,6 +1930,12 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI ); $adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues); } + else { + // update the financial trxn amount as well, as the fee selections has been updated + if ($balanceAmt != $ftDetail['total_amount']) { + CRM_Core_DAO::setFieldValue('CRM_Core_BAO_FinancialTrxn', $ftDetail['trxn_id'], 'total_amount', $balanceAmt); + } + } } } -- 2.25.1