From e61acc8e77559ebe927d2de6aefe97afeb630791 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 6 Oct 2021 07:52:17 +1300 Subject: [PATCH] Call line item pre hook after tax amount is set --- CRM/Price/BAO/LineItem.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 59868a458b..c5c5120351 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -33,12 +33,6 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { */ public static function create(&$params) { $id = $params['id'] ?? NULL; - if ($id) { - CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params); - } - else { - CRM_Utils_Hook::pre('create', 'LineItem', $id, $params); - } // unset entity table and entity id in $params // we never update the entity table and entity id during update mode @@ -56,6 +50,13 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { $params['tax_amount'] = self::getTaxAmountForLineItem($params); } + // Call the hooks after tax is set in case hooks wish to alter it. + if ($id) { + CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params); + } + else { + CRM_Utils_Hook::pre('create', 'LineItem', $id, $params); + } $lineItemBAO = new CRM_Price_BAO_LineItem(); $lineItemBAO->copyValues($params); -- 2.25.1