VAT-415 The default receipts that the system sends out should be updated to show...
[civicrm-core.git] / CRM / Event / Form / Participant.php
index c1c54904a50c808a8521a6d49d7b5c4282b36cc3..06a73a5b26941f889aebf846f667206832cbd69f 100644 (file)
@@ -1630,6 +1630,28 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
         if ($this->_isPaidEvent) {
           // fix amount for each of participants ( for bulk mode )
           $eventAmount = array();
+          //add dataArray in the receipts in ADD and UPDATE condition
+          $totalTaxAmount = 0;
+          $dataArray = array();
+          if ($this->_action & CRM_Core_Action::ADD) {
+            $line = $lineItem[0];
+          }
+          elseif ($this->_action & CRM_Core_Action::UPDATE) {
+            $line = $this->_values['line_items'];
+          }
+          foreach ($line as $key => $value) {
+            if (isset($value['tax_amount'])) {
+              $totalTaxAmount += $value['tax_amount'];
+              if (isset($dataArray[$value['tax_rate']])) {
+                $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
+              }
+              else {
+                $dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
+              }
+            }
+          }
+          $this->assign('totalTaxAmount', $totalTaxAmount);
+          $this->assign('dataArray', $dataArray);
           if (!empty($additionalParticipantDetails)) {
             $params['amount_level'] = preg_replace('/\ 1/', '', $params['amount_level']) . ' - ' . $this->_contributorDisplayName;
           }