From: Chris Sharp <csharp@georgialibraries.org> Date: Tue, 10 Apr 2018 15:40:35 +0000 (-0400) Subject: LP#1746300: Fix circulation counts in Item Status Details X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ef03a9607d240263c20e55dd063c70ab8a8f35e7;p=contrib%2FConifer.git 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 <csharp@georgialibraries.org> Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca> Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org> --- 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 1effdca985..cededcde68 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 @@ -865,15 +865,29 @@ console.debug($scope.copy_alert_count); return c.year() == new Date().getFullYear(); }); - $scope.total_circs_this_year = - this_year.length ? this_year[0].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 ? prev_year[0].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; + })(); }); }