Skip to content

Commit

Permalink
Merge pull request #146 from OpenLMIS-Angola/OAM-241
Browse files Browse the repository at this point in the history
OAM-241: Added home facility as valid source for receive
  • Loading branch information
DominikNoga authored Jul 2, 2024
2 parents e5ea461 + df2f408 commit 54255e4
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/stock-adjustment-creation/adjustment-creation.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// AO-805: Allow users with proper rights to edit product prices
'OrderableResource', 'permissionService', 'ADMINISTRATION_RIGHTS', 'authorizationService',
// AO-805: Ends here
'unitOfOrderableService', 'wardService', 'orderableGroupsByWard', 'WARDS_CONSTANTS'
'unitOfOrderableService', 'wardService', 'orderableGroupsByWard', 'WARDS_CONSTANTS', 'sourceDestinationService'
];

function controller($scope, $state, $stateParams, $filter, confirmDiscardService, program,
Expand All @@ -54,7 +54,7 @@
// AO-805: Allow users with proper rights to edit product prices
accessTokenFactory, $window, stockmanagementUrlFactory, OrderableResource, permissionService,
ADMINISTRATION_RIGHTS, authorizationService, unitOfOrderableService, wardService,
orderableGroupsByWard, WARDS_CONSTANTS) {
orderableGroupsByWard, WARDS_CONSTANTS, sourceDestinationService) {
// ANGOLASUP-717: ends here
// AO-805: Ends here
var vm = this;
Expand Down Expand Up @@ -1010,6 +1010,7 @@
vm.orderableGroups.forEach(function(group) {
vm.hasLot = vm.hasLot || orderableGroupService.lotsOf(group, hasPermissionToAddNewLot).length > 0;
});

// OAM-5: Lot code filter UI improvements.
var collator = new Intl.Collator('pt', {
numeric: true,
Expand Down Expand Up @@ -1053,21 +1054,29 @@
adjustmentType.state === ADJUSTMENT_TYPE.RECEIVE.state;

if (vm.homeFacilityWards.length > 0) {
var wardNames = vm.homeFacilityWards.map(function(ward) {
return ward.name;
});
setUpWardsValidSources(disabledWardsNames);
}
});
}

vm.srcDstAssignments = vm.srcDstAssignments.filter(function(assignment) {
return !disabledWardsNames.includes(assignment.name);
});
function setUpWardsValidSources(disabledWardsNames) {
var wardNames = vm.homeFacilityWards.map(function(ward) {
return ward.name;
});

wardNames.push(vm.facility.name);
vm.wardsValidSources = vm.srcDstAssignments
.filter(function(assignment) {
return wardNames.includes(assignment.name);
});
}
vm.srcDstAssignments = vm.srcDstAssignments.filter(function(assignment) {
return !disabledWardsNames.includes(assignment.name);
});

wardNames.push(vm.facility.name);

sourceDestinationService
.getSourceAssignments(program.id, vm.homeFacilityWards[0].id)
.then(function(wardsValidSources) {
vm.wardsValidSources = wardsValidSources.filter(function(assignment) {
return wardNames.includes(assignment.name);
});
});
}

function initiateNewLotObject() {
Expand Down

0 comments on commit 54255e4

Please sign in to comment.