From 1788a9b9114b1592f2c92b7d760a8b31c6a69529 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 3 Feb 2021 14:48:37 +0000 Subject: [PATCH] Bug 23767: Total children only if parents not visible This patch changes the way to calculate the footer. It adds the budget and parent ids to the cell as custom data elements. When totaling we grab a list of all the rows we are showing - if a row has a parent and the parent is showing then we skip adding its value to the total. As the function is used on both acqui-home and aqbudgets I adjusted both templates To test: 1 - Follow the test plan on previous patch 2 - Try filtering the table so you see only the child funds 3 - Confirm the totals show the child alone when it is visible 4 - Confirm the child total is excluded when the parent is visible Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit 1f3152d453c8b5f2a366b916b50d3265d3ef135b) Signed-off-by: Fridolin Somers (cherry picked from commit fe191f17b8fa142e4430dfe05833b846658f148d) Signed-off-by: Andrew Fuerste-Henry --- .../prog/en/modules/acqui/acqui-home.tt | 12 ++------ .../prog/en/modules/admin/aqbudgets.tt | 30 +++++-------------- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 9 +++++- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt index b52d758533..15a9daa089 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt @@ -134,11 +134,7 @@ [% Branches.GetName( loop_budge.budget_branchcode ) | html %] - [% IF loop_budge.budget_parent_id %] - [% loop_budge.budget_amount | $Price %] - [% ELSE %] - [% loop_budge.budget_amount | $Price %] - [% END %] + [% loop_budge.budget_amount | $Price %] @@ -151,11 +147,7 @@ - [% IF loop_budge.budget_parent_id %] - [% loop_budge.budget_avail | $Price %] - [% ELSE %] - [% loop_budge.budget_avail | $Price %] - [% END %] + [% loop_budge.budget_avail | $Price %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt index 0fc2223de9..feeb1224a3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt @@ -103,11 +103,7 @@ [% budget.budget_code | html %] [% budget.budget_name | html %] - [% IF budget.budget_parent_id %] - [% budget.budget_amount | $Price %] - [% ELSE %] - [% budget.budget_amount | $Price %] - [% END %] + [% budget.budget_amount | $Price %] [% IF budget.budget_parent_id %] @@ -140,24 +136,14 @@ [% BLOCK colorcellvalue %] - [% IF parent %] - [% IF (value > 0) %] - - [% ELSIF (value < 0) %] - - [% ELSE %] - - [% END %] - [% ELSE %] - [% IF (value > 0) %] - - [% ELSIF (value < 0) %] - - [% ELSE %] - - [% END %] + [% IF (value > 0) %] + + [% ELSIF (value < 0) %] + + [% ELSE %] + [% END %] - [% value | $Price %] + [% value | $Price %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index f1594d4b07..5c6607820c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -485,8 +485,15 @@ function footer_column_sum( api, column_numbers ) { var total = 0; var cells = api.column( column_number, { page: 'current' } ).nodes().to$().find("span.total_amount"); + var budgets_totaled = []; + $(cells).each(function(){ budgets_totaled.push( $(this).data('self_id') ); }); $(cells).each(function(){ - total += intVal( $(this).html() ); + if( $(this).data('parent_id') && $.inArray( $(this).data('parent_id'), budgets_totaled) > -1 ){ + return; + } else { + total += intVal( $(this).html() ); + } + }); total /= 100; // Hard-coded decimal precision -- 2.39.5