From 72ee9b24fd6b70239068db4eaef6036a0cf670bc Mon Sep 17 00:00:00 2001 From: saleksandra Date: Wed, 28 Aug 2024 13:10:31 +0200 Subject: [PATCH] OLMIS-7991: Filtered out lots that not expired on Issue screeen --- CHANGELOG.md | 1 + .../issue-creation.routes.js | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27bcb0de..70e1ad3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ================== Improvements: * [OLMIS-7954](https://openlmis.atlassian.net/browse/OLMIS-7954): Added fixes to improve performance on login page +* [OLMIS-7991](https://openlmis.atlassian.net/browse/OLMIS-7991): Filtered out lots that not expired on Issue screeen 2.1.5 / 2023-06-26 ================== diff --git a/src/stock-issue-creation/issue-creation.routes.js b/src/stock-issue-creation/issue-creation.routes.js index 35dca5dc..fc5bfc8f 100644 --- a/src/stock-issue-creation/issue-creation.routes.js +++ b/src/stock-issue-creation/issue-creation.routes.js @@ -20,9 +20,9 @@ .module('stock-issue-creation') .config(routes); - routes.$inject = ['$stateProvider', 'STOCKMANAGEMENT_RIGHTS', 'SEARCH_OPTIONS', 'ADJUSTMENT_TYPE']; + routes.$inject = ['$stateProvider', 'STOCKMANAGEMENT_RIGHTS', 'SEARCH_OPTIONS', 'ADJUSTMENT_TYPE', 'moment']; - function routes($stateProvider, STOCKMANAGEMENT_RIGHTS, SEARCH_OPTIONS, ADJUSTMENT_TYPE) { + function routes($stateProvider, STOCKMANAGEMENT_RIGHTS, SEARCH_OPTIONS, ADJUSTMENT_TYPE, moment) { $stateProvider.state('openlmis.stockmanagement.issue.creation', { isOffline: true, url: '/:programId/create?page&size&keyword', @@ -63,9 +63,22 @@ orderableGroups: function($stateParams, program, facility, existingStockOrderableGroupsFactory) { if (!$stateParams.orderableGroups) { $stateParams.orderableGroups = existingStockOrderableGroupsFactory - .getGroupsWithNotZeroSoh($stateParams, program, facility); + .getGroupsWithNotZeroSoh($stateParams, program, facility) + .then(function(orderableGroups) { + var currentDate = moment(new Date()).format('YYYY-MM-DD'); + var filteredGroups = []; + orderableGroups.forEach(function(orderableGroup) { + var group = orderableGroup.filter(function(orderable) { + return orderable.lot === null || + moment(orderable.lot.expirationDate).format('YYYY-MM-DD') >= currentDate; + }); + if (group.length !== 0) { + filteredGroups.push(group); + } + }); + return filteredGroups; + }); } - return $stateParams.orderableGroups; }, displayItems: function($stateParams, registerDisplayItemsService) {