From 360e696c1f2ed0f68d2dfa2cef2a16a151168a58 Mon Sep 17 00:00:00 2001 From: Muhammad Shahrukh <> Date: Thu, 20 Mar 2025 16:54:36 +0500 Subject: [PATCH] CIVIMM-296: Fix total amount calculation Core PR: https://lab.civicrm.org/extensions/lineitemedit/-/merge_requests/76 --- templates/CRM/Lineitemedit/Form/AddLineItems.tpl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/templates/CRM/Lineitemedit/Form/AddLineItems.tpl b/templates/CRM/Lineitemedit/Form/AddLineItems.tpl index 3e10d0b..e37a012 100644 --- a/templates/CRM/Lineitemedit/Form/AddLineItems.tpl +++ b/templates/CRM/Lineitemedit/Form/AddLineItems.tpl @@ -173,7 +173,15 @@ CRM.$(function($) { } let total_amount = 0; - if ($('input[id="total_amount"]').length) { + + if (lineItemRows.length > 0) { + lineItemTable.rows.forEach(lineItem => { + if (lineItem.total_price) { + total_amount += parseFloat((lineItem.total_price.replace(thousandMarker,'') || 0)); + } + }); + } + else if ($('input[id="total_amount"]').length) { total_amount = parseFloat(($('input[id="total_amount"]').val().replace(thousandSeparator,'') || 0)); }