From af65a20491f3faa9872d412776cc8d791dc3bdfb Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 4 Jul 2024 09:07:07 +0200 Subject: [PATCH 1/4] OLMIS-7954: Added fixes to improve performance on login page --- CHANGELOG.md | 5 +++++ .../source-destination.service.js | 12 ++++++------ src/stock-reason/stock-reason-cache.run.js | 15 ++++++++------- src/stock-reason/stock-reasons.factory.js | 16 ++++++++-------- .../destination-cache.run.js | 17 ++++++++++------- src/stock-valid-sources/source-cache.run.js | 17 ++++++++++------- 6 files changed, 47 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c7677a..27bcb0de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +2.1.6-SNAPSHOT / WIP +================== +Improvements: +* [OLMIS-7954](https://openlmis.atlassian.net/browse/OLMIS-7954): Added fixes to improve performance on login page + 2.1.5 / 2023-06-26 ================== Bug fixes: diff --git a/src/stock-adjustment-creation/source-destination.service.js b/src/stock-adjustment-creation/source-destination.service.js index 104b8dd5..667b3f7c 100644 --- a/src/stock-adjustment-creation/source-destination.service.js +++ b/src/stock-adjustment-creation/source-destination.service.js @@ -41,19 +41,19 @@ this.clearSourcesCache = clearSourcesCache; this.clearDestinationsCache = clearDestinationsCache; - function getSourceAssignments(programId, facilityId) { + function getSourceAssignments(programIds, facilityId) { var resource = $resource(stockmanagementUrlFactory('/api/validSources')); if (offlineService.isOffline()) { var sources = offlineSources.search({ - programId: programId, + programId: programIds, facilityId: facilityId }); return checkArrayAndGetData(sources); } return resource.get({ - programId: programId, + programId: programIds, facilityId: facilityId, page: 0, size: 2147483647 @@ -63,19 +63,19 @@ }); } - function getDestinationAssignments(programId, facilityId) { + function getDestinationAssignments(programIds, facilityId) { var resource = $resource(stockmanagementUrlFactory('/api/validDestinations')); if (offlineService.isOffline()) { var destinations = offlineDestinations.search({ - programId: programId, + programId: programIds, facilityId: facilityId }); return checkArrayAndGetData(destinations); } return resource.get({ - programId: programId, + programId: programIds, facilityId: facilityId, page: 0, size: 2147483647 diff --git a/src/stock-reason/stock-reason-cache.run.js b/src/stock-reason/stock-reason-cache.run.js index 56f171ee..74622a5a 100644 --- a/src/stock-reason/stock-reason-cache.run.js +++ b/src/stock-reason/stock-reason-cache.run.js @@ -27,19 +27,20 @@ loginService.registerPostLoginAction(function() { stockReasonsFactory.clearReasonsCache(); - var homeFacility, - reasons = []; + var homeFacility; return facilityFactory.getUserHomeFacility() .then(function(facility) { homeFacility = facility; var programs = homeFacility.supportedPrograms; - programs.forEach(function(program) { - reasons.push(stockReasonsFactory.getReasons( - program.id ? program.id : program, - homeFacility.type ? homeFacility.type.id : homeFacility - )); + var supportedProgramsIds = programs.map(function(program) { + return program.id ? program.id : program; }); + + return stockReasonsFactory.getReasons( + supportedProgramsIds, + homeFacility.type ? homeFacility.type.id : homeFacility + ); }) .catch(function() { return $q.resolve(); diff --git a/src/stock-reason/stock-reasons.factory.js b/src/stock-reason/stock-reasons.factory.js index 5264598d..99f8c424 100644 --- a/src/stock-reason/stock-reasons.factory.js +++ b/src/stock-reason/stock-reasons.factory.js @@ -143,8 +143,8 @@ * @param {Object} reasonType the reason type, can be an array * @return {Promise} the promise resolving to the list of reasons */ - function getReasons(program, facilityType, reasonType) { - return $q.resolve(getReasonsPromise(program, facilityType, reasonType) + function getReasons(programIds, facilityType, reasonType) { + return $q.resolve(getReasonsPromise(programIds, facilityType, reasonType) .then(function(reasonAssignments) { return reasonAssignments .filter(function(reasonAssignment) { @@ -155,17 +155,17 @@ result.push(reasonAssignment.reason); } if (!offlineService.isOffline()) { - cacheReasons(reasonAssignment, program, facilityType); + cacheReasons(reasonAssignment, programIds, facilityType); } return result; }, []); })); } - function getReasonsPromise(program, facilityType, reasonType) { + function getReasonsPromise(programIds, facilityType, reasonType) { if (offlineService.isOffline()) { var reasons = offlineReasons.search({ - programId: program, + programId: programIds, reasonType: reasonType, facilityType: facilityType }); @@ -177,17 +177,17 @@ return $q.resolve(reasons); } return new ValidReasonResource().query({ - program: program, + program: programIds, facilityType: facilityType, reasonType: reasonType }); } - function cacheReasons(reasonAssignment, programId, facilityType) { + function cacheReasons(reasonAssignment, programIds, facilityType) { var reason = angular.copy(reasonAssignment.reason); var reasonToCache = { id: reasonAssignment.id, - programId: programId, + programId: programIds, facilityType: facilityType, reasonType: reason.reasonType, reason: reason, diff --git a/src/stock-valid-destinations/destination-cache.run.js b/src/stock-valid-destinations/destination-cache.run.js index 32921f49..c3a8b243 100644 --- a/src/stock-valid-destinations/destination-cache.run.js +++ b/src/stock-valid-destinations/destination-cache.run.js @@ -27,19 +27,22 @@ loginService.registerPostLoginAction(function() { sourceDestinationService.clearDestinationsCache(); - var homeFacility, - destinations = []; + var homeFacility; return facilityFactory.getUserHomeFacility() .then(function(facility) { homeFacility = facility; var programs = homeFacility.supportedPrograms; - programs.forEach(function(program) { - destinations.push(sourceDestinationService.getDestinationAssignments( - program.id ? program.id : program, - homeFacility.id ? homeFacility.id : homeFacility - )); + var supportedProgramsIds = programs.map(function(program) { + return program.id ? program.id : program; }); + + var destinations = sourceDestinationService.getDestinationAssignments( + supportedProgramsIds, + homeFacility.id ? homeFacility.id : homeFacility + ); + + return destinations; }) .catch(function() { return $q.resolve(); diff --git a/src/stock-valid-sources/source-cache.run.js b/src/stock-valid-sources/source-cache.run.js index d2414298..f873ccfc 100644 --- a/src/stock-valid-sources/source-cache.run.js +++ b/src/stock-valid-sources/source-cache.run.js @@ -27,19 +27,22 @@ loginService.registerPostLoginAction(function() { sourceDestinationService.clearSourcesCache(); - var homeFacility, - sources = []; + var homeFacility; return facilityFactory.getUserHomeFacility() .then(function(facility) { homeFacility = facility; var programs = homeFacility.supportedPrograms; - programs.forEach(function(program) { - sources.push(sourceDestinationService.getSourceAssignments( - program.id ? program.id : program, - homeFacility.id ? homeFacility.id : homeFacility - )); + var supportedProgramsIds = programs.map(function(program) { + return program.id ? program.id : program; }); + + var sources = sourceDestinationService.getSourceAssignments( + supportedProgramsIds, + homeFacility.id ? homeFacility.id : homeFacility + ); + + return sources; }) .catch(function() { return $q.resolve(); From 72ee9b24fd6b70239068db4eaef6036a0cf670bc Mon Sep 17 00:00:00 2001 From: saleksandra Date: Wed, 28 Aug 2024 13:10:31 +0200 Subject: [PATCH 2/4] 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) { From 7c5e10f209c2319881359e61546ce1f73d1b3115 Mon Sep 17 00:00:00 2001 From: DominikNoga Date: Mon, 9 Sep 2024 15:05:47 +0200 Subject: [PATCH 3/4] OIS-24: improved styles that were not supporting RTL --- .../_physical-inventory-draft.scss | 6 +++--- src/stock-reasons-modal/_stock-reasons.scss | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stock-physical-inventory-draft/_physical-inventory-draft.scss b/src/stock-physical-inventory-draft/_physical-inventory-draft.scss index 538a31e6..e61c3846 100644 --- a/src/stock-physical-inventory-draft/_physical-inventory-draft.scss +++ b/src/stock-physical-inventory-draft/_physical-inventory-draft.scss @@ -1,10 +1,10 @@ .physical-inventory-draft-progress { - margin-left: 0; + @include margin-left(0); } .reasons-cell { - padding-right: 0.5em !important; + @include padding-right(0.5em); &:before { content: '' !important; @@ -13,6 +13,6 @@ .draft-indicator { display: block; - float: right; + @include float(right); margin-top: 1em; } diff --git a/src/stock-reasons-modal/_stock-reasons.scss b/src/stock-reasons-modal/_stock-reasons.scss index baf07035..894c809e 100644 --- a/src/stock-reasons-modal/_stock-reasons.scss +++ b/src/stock-reasons-modal/_stock-reasons.scss @@ -12,18 +12,18 @@ dl > dd { flex: 0 0 auto; white-space: nowrap; - text-align: right; + @include text-align(right); } } td stock-reasons > button { width: 100%; - text-align: left; + @include text-align(left); display: flex; justify-content: flex-start; &.add::before, &.edit::before { - text-align: left; + @include text-align(left); } &.edit { @@ -38,8 +38,8 @@ td stock-reasons > button { content: "\f06a"; font-family: FontAwesome; display: inline-block; - margin-left: 0.5em; + @include margin-left(0.5em); flex-grow: 1; - text-align: right; + @include text-align(right); } } From 1ffecac52dd9469928780d631ec0bc53d07bb80b Mon Sep 17 00:00:00 2001 From: saleksandra Date: Tue, 17 Sep 2024 11:11:39 +0200 Subject: [PATCH 4/4] OLMIS-7748: Fix filtering 'includeInactive' on the Physical Inventory page --- CHANGELOG.md | 3 ++ .../physical-inventory-draft.controller.js | 2 +- .../physical-inventory.service.js | 2 +- .../physical-inventory.service.spec.js | 29 ++++++++++++++----- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70e1ad3a..1f54e2e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ 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 +Bug fixes: +* [OLMIS-7748](https://openlmis.atlassian.net/browse/OLMIS-7748): Fix filtering 'includeInactive' on the Physical Inventory page + 2.1.5 / 2023-06-26 ================== Bug fixes: diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js index 4499cdd9..f4ee80a8 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js +++ b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js @@ -652,7 +652,7 @@ _.chain(displayLineItemsGroup).flatten() .each(function(item) { - if (!item.active) { + if (!item.active && item.stockOnHand === 0) { activeError = 'stockPhysicalInventoryDraft.submitInvalidActive'; } else if (vm.validateQuantity(item) || vm.validateUnaccountedQuantity(item)) { qtyError = 'stockPhysicalInventoryDraft.submitInvalid'; diff --git a/src/stock-physical-inventory/physical-inventory.service.js b/src/stock-physical-inventory/physical-inventory.service.js index 19dfc573..ea279fbc 100644 --- a/src/stock-physical-inventory/physical-inventory.service.js +++ b/src/stock-physical-inventory/physical-inventory.service.js @@ -171,7 +171,7 @@ if (!includeInactive) { result = _.filter(result, function(item) { - return item.active; + return item.active || item.stockOnHand !== 0; }); } diff --git a/src/stock-physical-inventory/physical-inventory.service.spec.js b/src/stock-physical-inventory/physical-inventory.service.spec.js index 3fd77588..0ae40896 100644 --- a/src/stock-physical-inventory/physical-inventory.service.spec.js +++ b/src/stock-physical-inventory/physical-inventory.service.spec.js @@ -40,6 +40,7 @@ describe('physicalInventoryService', function() { var orderable1 = new this.OrderableDataBuilder().withFullProductName('Streptococcus Pneumoniae Vaccine II') .build(), orderable2 = new this.OrderableDataBuilder().build(), + orderable3 = new this.OrderableDataBuilder().build(), lot = new this.LotDataBuilder().build(), stockAdjustments = [new this.PhysicalInventoryLineItemAdjustmentDataBuilder().build()]; @@ -48,13 +49,17 @@ describe('physicalInventoryService', function() { .withStockAdjustments(stockAdjustments) .buildAsAdded(), new this.PhysicalInventoryLineItemDataBuilder().withOrderable(orderable2) - .withStockOnHand(null) + .withStockOnHand(0) .withQuantity(4) .buildAsAdded(), new this.PhysicalInventoryLineItemDataBuilder().withOrderable(orderable2) .withLot(lot) - .withStockOnHand(null) + .withStockOnHand(0) .withQuantity(null) + .buildAsAdded(), + new this.PhysicalInventoryLineItemDataBuilder().withOrderable(orderable3) + .withStockOnHand(null) + .withQuantity(40) .buildAsAdded() ]; @@ -206,7 +211,7 @@ describe('physicalInventoryService', function() { it('should search by quantity', function() { expect(this.physicalInventoryService.search('4', this.physicalInventoryLineItems, null)) - .toEqual([this.physicalInventoryLineItems[1]]); + .toEqual([this.physicalInventoryLineItems[1], this.physicalInventoryLineItems[3]]); }); it('should search by lotCode', function() { @@ -219,7 +224,8 @@ describe('physicalInventoryService', function() { this.messageService.get.andReturn('No lot defined'); expect(this.physicalInventoryService.search('No lot defined', this.physicalInventoryLineItems, null)) - .toEqual([this.physicalInventoryLineItems[0], this.physicalInventoryLineItems[1]]); + .toEqual([this.physicalInventoryLineItems[0], this.physicalInventoryLineItems[1], + this.physicalInventoryLineItems[3]]); }); it('should search by expirationDate', function() { @@ -230,15 +236,21 @@ describe('physicalInventoryService', function() { it('should search by only active', function() { var lineItems = [ { - active: true + active: true, + stockOnHand: 20 }, { - active: false + active: false, + stockOnHand: 0 + }, + { + active: false, + stockOnHand: null } ]; expect(this.physicalInventoryService.search('', lineItems, false)) - .toEqual([lineItems[0]]); + .toEqual([lineItems[0], lineItems[2]]); }); it('should find include inactive', function() { @@ -272,10 +284,11 @@ describe('physicalInventoryService', function() { this.$httpBackend.flush(); this.$rootScope.$apply(); - expect(result.lineItems.length).toBe(3); + expect(result.lineItems.length).toBe(4); expect(result.lineItems[0].quantity).toBe(3); expect(result.lineItems[1].quantity).toBe(4); expect(result.lineItems[2].quantity).toBe(null); + expect(result.lineItems[3].quantity).toBe(40); }); //eslint-disable-next-line jasmine/missing-expect