From 1ccdb46bdbc1a701573ef3d50c63329d6c536c0a Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp <85277674+olayiwola-compucorp@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:24:38 +0100 Subject: [PATCH] PROD-147: Resolve Issue with Payment Allocation to Contribution Line Item Included In: https://github.com/civicrm/civicrm-core/pull/29350 --- CRM/Financial/BAO/Payment.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index 79edf0baa97d..5b4a2b55b511 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -606,6 +606,16 @@ protected static function getAmountOfLineItemPaid($lineItemID) { $paid += $entityFinancialTrxn['amount']; } } + + $lineItem = \Civi\Api4\LineItem::get(FALSE) + ->addWhere('id', '=', $lineItemID) + ->execute() + ->first(); + if (!empty($lineItem['tax_amount']) && $paid > 0) { + $total = floatval($lineItem['line_total']); + $tax = floatval($lineItem['tax_amount']); + $paid = ($total * $paid) / ($tax + $total); + } return (float) $paid; }