Fix rc-unreleased regression - tax amount not loading
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 10 Nov 2023 06:23:48 +0000 (19:23 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 10 Nov 2023 06:27:56 +0000 (19:27 +1300)
CRM/Price/BAO/PriceSet.php

index 45fab04fa20e77a8a2f84a46281117bc8ceb3567..566ef3287a51da5bb93f2c9a18fd5a6c8754dca3 100644 (file)
@@ -801,9 +801,12 @@ WHERE  id = %1";
         ->addWhere('price_field_id', 'IN', array_keys($data['fields']))
         ->setSelect($select)
         ->execute();
+      $taxRates = CRM_Core_PseudoConstant::getTaxRates();
       foreach ($options as $option) {
         // Add in visibility because Smarty templates expect it and it is hard to adjust them to colon format.
         $option['visibility'] = $option['visibility_id:name'];
+        $option['tax_rate'] = (float) ($taxRates[$option['financial_type_id']] ?? 0);
+        $option['tax_amount'] = (float) ($option['tax_rate'] ? CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($option['amount'], $option['tax_rate'])['tax_amount'] : 0);
         $data['fields'][$option['price_field_id']]['options'][$option['id']] = $option;
       }
       $cache->set($cacheKey, $data);