diff --git a/src/openlmis-facility-program-select/openlmis-facility-program-select.controller.js b/src/openlmis-facility-program-select/openlmis-facility-program-select.controller.js index b45c8b8..7af2b26 100644 --- a/src/openlmis-facility-program-select/openlmis-facility-program-select.controller.js +++ b/src/openlmis-facility-program-select/openlmis-facility-program-select.controller.js @@ -77,12 +77,13 @@ zoneId: facility.geographicZone.id, sort: 'code,asc', type: WARDS_CONSTANTS.WARD_TYPE_CODE - }; return wardService.getWardsByFacility(searchParams) .then(function(response) { - return response.content; + return response.content.filter(function(ward) { + return ward.enabled; + }); }); } diff --git a/src/stock-adjustment-creation/adjustment-creation.controller.js b/src/stock-adjustment-creation/adjustment-creation.controller.js index dce3c40..ea033f8 100644 --- a/src/stock-adjustment-creation/adjustment-creation.controller.js +++ b/src/stock-adjustment-creation/adjustment-creation.controller.js @@ -1019,35 +1019,52 @@ }); // OAM-5: ends here - if (adjustmentType.state === ADJUSTMENT_TYPE.RECEIVE.state) { - wardService.getWardsByFacility({ - zoneId: vm.facility.geographicZone.id, - type: WARDS_CONSTANTS.WARD_TYPE_CODE - }).then(function(response) { - var wards = response.content; - vm.homeFacilityWards = wards.filter(function(ward) { - return ward.enabled; - }); + setUpWards(); + vm.showVVMStatusColumn = orderableGroupService.areOrderablesUseVvm(vm.orderableGroups); + vm.hasPermissionToAddNewLot = hasPermissionToAddNewLot; + vm.canAddNewLot = false; + initiateNewLotObject(); + } - vm.displayWardSelect = vm.homeFacilityWards.length > 0; + function setUpWards() { + if (!vm.facility.geographicZone) { + return; + } - if (vm.displayWardSelect) { - 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); - }); + wardService.getWardsByFacility({ + zoneId: vm.facility.geographicZone.id, + sort: 'code,asc', + type: WARDS_CONSTANTS.WARD_TYPE_CODE + }).then(function(response) { + var wards = response.content; + var disabledWardsNames = []; + + vm.homeFacilityWards = wards.filter(function(ward) { + if (ward.enabled) { + return true; } + disabledWardsNames.push(ward.name); + return false; }); - } - vm.showVVMStatusColumn = orderableGroupService.areOrderablesUseVvm(vm.orderableGroups); - vm.hasPermissionToAddNewLot = hasPermissionToAddNewLot; - vm.canAddNewLot = false; - initiateNewLotObject(); + vm.displayWardSelect = vm.homeFacilityWards.length > 0; + + if (vm.displayWardSelect) { + var wardNames = vm.homeFacilityWards.map(function(ward) { + return ward.name; + }); + + vm.srcDstAssignments = vm.srcDstAssignments.filter(function(assignment) { + return !disabledWardsNames.includes(assignment.name); + }); + + wardNames.push(vm.facility.name); + vm.wardsValidSources = vm.srcDstAssignments + .filter(function(assignment) { + return wardNames.includes(assignment.name); + }); + } + }); } function initiateNewLotObject() { diff --git a/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js b/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js index 91a26fe..3b11880 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js +++ b/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js @@ -76,7 +76,10 @@ describe('StockCardSummaryListController', function() { this.vm.$onInit(); this.vm.facility = { - id: 'facility' + id: 'facility', + geographicZone: { + id: '123' + } }; this.vm.program = { id: 'program'