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)); }