Skip to content

Commit

Permalink
Merge pull request #65 from OpenLMIS/OLMIS-7991
Browse files Browse the repository at this point in the history
OLMIS-7991: Filtered out lots that not expired on Issue screeen
  • Loading branch information
mdulko-soldevelo authored Aug 28, 2024
2 parents 23ced0b + 72ee9b2 commit 6d19ebf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
==================
Expand Down
21 changes: 17 additions & 4 deletions src/stock-issue-creation/issue-creation.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6d19ebf

Please sign in to comment.