Skip to content

Commit

Permalink
Merge branch 'master' into OLMIS-7987
Browse files Browse the repository at this point in the history
  • Loading branch information
mdulko-soldevelo authored Sep 24, 2024
2 parents d3ecf24 + 8953ec8 commit e141926
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 57 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
2.1.6-SNAPSHOT / WIP
==================
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

New functionalities that are backwards-compatible:
* [OLMIS-7987](https://openlmis.atlassian.net/browse/OLMIS-7987): Move Submit Requisitionless Orders functionalities from Angola to Core instance

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:
Expand Down
12 changes: 6 additions & 6 deletions src/stock-adjustment-creation/source-destination.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
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
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,6 +13,6 @@

.draft-indicator {
display: block;
float: right;
@include float(right);
margin-top: 1em;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/stock-physical-inventory/physical-inventory.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@

if (!includeInactive) {
result = _.filter(result, function(item) {
return item.active;
return item.active || item.stockOnHand !== 0;
});
}

Expand Down
29 changes: 21 additions & 8 deletions src/stock-physical-inventory/physical-inventory.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()];

Expand All @@ -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()
];

Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions src/stock-reason/stock-reason-cache.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions src/stock-reason/stock-reasons.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
});
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/stock-reasons-modal/_stock-reasons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
}
17 changes: 10 additions & 7 deletions src/stock-valid-destinations/destination-cache.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
17 changes: 10 additions & 7 deletions src/stock-valid-sources/source-cache.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e141926

Please sign in to comment.