From 603f76237cdc3a3558566f58eab5dde7319b3011 Mon Sep 17 00:00:00 2001 From: michaldev0 <125133223+michaldev0@users.noreply.github.com> Date: Thu, 18 Jun 2026 10:20:46 +0200 Subject: [PATCH] OLMIS-8183: Fix NaN in total losses and adjustments Undefined total losses value now defaults to zero instead of displaying NaN in packs mode. --- CHANGELOG.md | 2 ++ .../losses-and-adjustments.controller.js | 2 +- .../losses-and-adjustments.controller.spec.js | 34 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6619ab99..f367d2ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ 7.0.18-SNAPSHOT (WIP) ================== +Bug fixes: +* [OLMIS-8183](https://openlmis.atlassian.net/browse/OLMIS-8183): Fix NaN displayed in total losses and adjustments cell for new requisitions in packs mode. 7.0.17 / 2026-06-09 ================== diff --git a/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.js b/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.js index 19ca48f0..344b18ab 100644 --- a/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.js +++ b/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.js @@ -172,7 +172,7 @@ function getDisplayedQuantity() { return quantityUnitCalculateService.recalculateSOHQuantity( - vm.lineItem.totalLossesAndAdjustments, vm.lineItem.orderable.netContent, + vm.lineItem.totalLossesAndAdjustments || 0, vm.lineItem.orderable.netContent, $scope.requisition.showInDoses() ); } diff --git a/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.spec.js b/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.spec.js index 286c9558..eb1c1039 100644 --- a/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.spec.js +++ b/src/requisition-losses-and-adjustments/losses-and-adjustments.controller.spec.js @@ -134,6 +134,40 @@ describe('LossesAndAdjustmentsController', function() { expect(vm.lineItem).toEqual($scope.lineItem); }); + describe('getDisplayedQuantity', function() { + beforeEach(function() { + $scope.lineItem = { + id: 'line-item-id', + stockAdjustments: [], + orderable: { + netContent: 10 + } + }; + $scope.requisition.showInDoses = function() { + return true; + }; + vm.$onInit(); + }); + + it('should return 0 when totalLossesAndAdjustments is undefined', function() { + vm.lineItem.totalLossesAndAdjustments = undefined; + + expect(vm.getDisplayedQuantity()).toEqual(0); + }); + + it('should return 0 when totalLossesAndAdjustments is null', function() { + vm.lineItem.totalLossesAndAdjustments = null; + + expect(vm.getDisplayedQuantity()).toEqual(0); + }); + + it('should return value when totalLossesAndAdjustments is set', function() { + vm.lineItem.totalLossesAndAdjustments = 12; + + expect(vm.getDisplayedQuantity()).toEqual(12); + }); + }); + describe('showModal', function() { beforeEach(function() { spyOn(adjustmentsModalService, 'open').andReturn($q.when());