From 2069ded369f5f0c3994768d0f89144a726bcb1ef Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Tue, 10 Apr 2018 11:40:35 -0400 Subject: [PATCH] LP#1746300: Fix circulation counts in Item Status Details Currently, the "Total Circs -Current Year" and "Total Circs - Prev Year" numbers are seemingly randomly incorrect. This is caused by pulling the numbers from the "circbyyr" fieldmapper object, which results in an array of 2 rows (one for renewals and one for new circs). The current JS only displays the count for the first item in the array, ignoring the other. This branch totals the two, resulting in the right result for each year's circulations. Signed-off-by: Chris Sharp --- Open-ILS/web/js/ui/default/staff/cat/item/app.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js index 33e5358112..6ab27e46e2 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -789,15 +789,29 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore , return c.year() == new Date().getFullYear(); }); - $scope.total_circs_this_year = - this_year.length ? (Number(this_year[0].count()) + Number(this_year[1].count())) : 0; + $scope.total_circs_this_year = (function() { + total = 0; + if (this_year.length == 2) { + total = (Number(this_year[0].count()) + Number(this_year[1].count())); + } else if (this_year.length == 1) { + total = Number(this_year[0].count()); + } + return total; + })(); var prev_year = counts.filter(function(c) { return c.year() == new Date().getFullYear() - 1; }); - $scope.total_circs_prev_year = - prev_year.length ? (Number(prev_year[0].count()) + Number(prev_year[1].count())) : 0; + $scope.total_circs_prev_year = (function() { + total = 0; + if (prev_year.length == 2) { + total = (Number(prev_year[0].count()) + Number(prev_year[1].count())); + } else if (prev_year.length == 1) { + total = Number(prev_year[0].count()); + } + return total; + })(); }); } -- 2.11.0