Fully remove the dataArray assign, notify via system check if still in use
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 17 Nov 2023 06:40:21 +0000 (19:40 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 19 Nov 2023 22:40:06 +0000 (11:40 +1300)
These were already removed from all templates except membership_online_receipt
which has just seen the back of them

CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Task/Invoice.php
CRM/Event/Form/Registration/Confirm.php
CRM/Member/Form/Membership.php
CRM/Utils/Token.php
tests/templates/message_templates/contribution_online_receipt_html.tpl
tests/templates/message_templates/event_online_receipt_text.tpl

index 1d604cffe8ccaffed404c5844a8678ee44c54f13..827f73e3e214959eaf280e42f36d6cc07a4e803c 100644 (file)
@@ -1429,23 +1429,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
 
       if (Civi::settings()->get('invoicing')) {
-        $dataArray = [];
-        // @todo - interrogate the line items passed in on the params array.
-        // No reason to assume line items will be set on the form.
-        foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
-          foreach ($lineItemValue as $key => $value) {
-            if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
-              if (isset($dataArray[$value['tax_rate']])) {
-                $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + $value['tax_amount'];
-              }
-              else {
-                $dataArray[$value['tax_rate']] = $value['tax_amount'];
-              }
-            }
-          }
-        }
         $smarty = CRM_Core_Smarty::singleton();
-        $smarty->assign('dataArray', $dataArray);
+        // @todo - probably this assign is no longer needed as we use a token.
         $smarty->assign('totalTaxAmount', $params['tax_amount'] ?? NULL);
       }
     }
@@ -2026,11 +2011,9 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     foreach ($lineItem as $key => $value) {
       foreach ($value as $v) {
         if (isset($taxRate[(string) CRM_Utils_Array::value('tax_rate', $v)])) {
-          $taxRate[(string) $v['tax_rate']] = $taxRate[(string) $v['tax_rate']] + ($v['tax_amount'] ?? 0);
         }
         else {
           if (isset($v['tax_rate'])) {
-            $taxRate[(string) $v['tax_rate']] = $v['tax_amount'] ?? NULL;
             $getTaxDetails = TRUE;
           }
         }
@@ -2039,14 +2022,13 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     if ($action & CRM_Core_Action::UPDATE) {
       $totalTaxAmount = $submittedValues['tax_amount'] ?? $this->_values['tax_amount'];
+      // Assign likely replaced by a token
       $this->assign('totalTaxAmount', $totalTaxAmount);
-      $this->assign('dataArray', $taxRate);
     }
     else {
       if (!empty($submittedValues['price_set_id'])) {
         $this->assign('totalTaxAmount', $submittedValues['tax_amount']);
         $this->assign('getTaxDetails', $getTaxDetails);
-        $this->assign('dataArray', $taxRate);
       }
       else {
         $this->assign('totalTaxAmount', CRM_Utils_Array::value('tax_amount', $submittedValues));
index ad9cd3bc7a6c5f8b478e489b3ec2b1da52f320fa..74aa0d7896ef3663d79c6fb8c06972cdeab3fb59 100644 (file)
@@ -1054,26 +1054,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
 
       $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
 
-      if (Civi::settings()->get('invoicing')) {
-        $dataArray = [];
-        // @todo - interrogate the line items passed in on the params array.
-        // No reason to assume line items will be set on the form.
-        foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
-          foreach ($lineItemValue as $key => $value) {
-            if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
-              if (isset($dataArray[$value['tax_rate']])) {
-                $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + $value['tax_amount'];
-              }
-              else {
-                $dataArray[$value['tax_rate']] = $value['tax_amount'];
-              }
-            }
-          }
-        }
-        $smarty = CRM_Core_Smarty::singleton();
-        $smarty->assign('dataArray', $dataArray);
-      }
-
       // lets store it in the form variable so postProcess hook can get to this and use it
       $form->_contributionID = $contribution->id;
     }
index f8b885edcbb6885a12acb190be8177e1762faf0b..a1e69e04ed2ada6fc639dbddf2c18b230d2fbf41 100644 (file)
@@ -282,16 +282,9 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
       $amountDue = ($input['amount'] - $amountPaid);
 
       // retrieving the subtotal and sum of same tax_rate
-      $dataArray = [];
       $subTotal = 0;
       $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contributionID);
       foreach ($lineItem as $taxRate) {
-        if (isset($dataArray[(string) $taxRate['tax_rate']])) {
-          $dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + ($taxRate['tax_amount'] ?? 0);
-        }
-        else {
-          $dataArray[(string) $taxRate['tax_rate']] = $taxRate['tax_amount'] ?? NULL;
-        }
         $subTotal += $taxRate['subTotal'] ?? 0;
       }
 
@@ -385,8 +378,6 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
         'notes' => $invoiceNotes,
         // @todo not used in shipped template from 5.53
         'lineItem' => $lineItem,
-        // @todo not used in shipped template from 5.53
-        'dataArray' => $dataArray,
         // @todo not used in shipped template from 5.52
         'refundedStatusId' => $refundedStatusId,
         // @todo not used in shipped template from 5.52
index 733f9891a42994dce1ab6bf3f336fdfe70cdc74f..f6327f729a9f952608f655189fdb74e3a2a6a443 100644 (file)
@@ -681,7 +681,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
 
       $entityTable = 'civicrm_participant';
       $totalTaxAmount = 0;
-      $dataArray = [];
       foreach ($this->_lineItem as $key => $value) {
         if ($value == 'skip') {
           continue;
@@ -698,17 +697,10 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
           foreach ($value as $line) {
             if (isset($line['tax_amount']) && isset($line['tax_rate'])) {
               $totalTaxAmount = $line['tax_amount'] + $totalTaxAmount;
-              if (isset($dataArray[$line['tax_rate']])) {
-                $dataArray[$line['tax_rate']] = $dataArray[$line['tax_rate']] + ($line['tax_amount'] ?? 0);
-              }
-              else {
-                $dataArray[$line['tax_rate']] = $line['tax_amount'] ?? NULL;
-              }
             }
           }
         }
       }
-      $this->assign('dataArray', $dataArray);
       $this->assign('totalTaxAmount', $totalTaxAmount);
     }
 
@@ -888,8 +880,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
             }
             if (\Civi::settings()->get('invoicing')) {
               $individual = $this->get('individual');
-              $dataArray[key($dataArray)] = $individual[$participantNum]['totalTaxAmt'];
-              $this->assign('dataArray', $dataArray);
               $this->assign('totalAmount', $individual[$participantNum]['totalAmtWithTax']);
               $this->assign('totalTaxAmount', $individual[$participantNum]['totalTaxAmt']);
               $this->assign('individual', [$individual[$participantNum]]);
index deb1a582e133eb61c811cc8e75c1092a05361a6c..8b55eca6ece1267ffb26faf6fa4d7d264f1d43d8 100644 (file)
@@ -1253,21 +1253,6 @@ DESC limit 1");
           $priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A';
         }
       }
-      if (Civi::settings()->get('invoicing')) {
-        $dataArray = [];
-        foreach ($lineItem[$this->_priceSetId] as $value) {
-          if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
-            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']] = $value['tax_amount'] ?? NULL;
-            }
-          }
-        }
-
-        $this->assign('dataArray', $dataArray);
-      }
     }
     $this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
 
index b7373b897a2214099c4fc714cc5055fcdf27e2d9..7680c842f1be605a168748b572840c63be7f711f 100644 (file)
@@ -1762,17 +1762,23 @@ class CRM_Utils_Token {
       'WorkFlowMessageTemplates' => [
         'contribution_invoice_receipt' => [
           '$display_name' => 'contact.display_name',
+          '$dataArray' => ts('found within $taxBreakDown'),
         ],
         'contribution_online_receipt' => [
           '$contributeMode' => ts('no longer available / relevant'),
           '$first_name' => 'contact.first_name',
           '$last_name' => 'contact.last_name',
           '$displayName' => 'contact.display_name',
+          '$dataArray' => ts('found within $taxBreakDown'),
         ],
         'membership_offline_receipt' => [
           // receipt_text_renewal appears to be long gone.
           'receipt_text_renewal' => 'receipt_text',
           '$isAmountZero' => ts('no longer available / relevant'),
+          '$dataArray' => ts('found within $taxBreakDown'),
+        ],
+        'membership_online_receipt' => [
+          '$dataArray' => ts('found within $taxBreakDown'),
         ],
         'event_offline_receipt' => [
           '$contributeMode' => ts('no longer available / relevant'),
@@ -1800,6 +1806,7 @@ class CRM_Utils_Token {
         ],
         'event_online_receipt' => [
           '`$participant.id`' => 'participant.id',
+          '$dataArray' => ts('found within $taxBreakDown'),
         ],
         'pledge_acknowledgement' => [
           '$domain' => ts('no longer available / relevant'),
index 79ab58d53da84af4931a9fac181db4d2cc1dae56..d5e4e3a29c9a3964de1dc471b2be53e2cdd4c79a 100644 (file)
   {/foreach}
  {/foreach}
  {/if}
- {if !empty($dataArray)}
- {foreach from=$dataArray item=value key=priceset}
-    dataArray: priceset:::$priceset
-    dataArray: value:::$value
- {/foreach}
- {/if}
+
  {if !empty($honoreeProfile)}
  {foreach from=$honoreeProfile item=value key=label}
     honoreeProfile: label:::$label
index 502b901255c5fb13adf7c3071ef489b31e8b10a0..526ea892b597019ed9db77ad36314d94ec4e60fe 100644 (file)
@@ -70,10 +70,6 @@ part:::{foreach from=$part item=value key=key}
 {/foreach}
 {/if}
 
-{if !empty($dataArray)}
-dataArray:::{$dataArray}
-{/if}
-
 {if isset($totalTaxAmount)}
 totalTaxAmount:::{$totalTaxAmount}
 {/if}