Skip to content

Commit

Permalink
removed disabled wards from soh
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikNoga committed Jun 18, 2024
1 parent bb59c02 commit 2bfd452
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
}

Expand Down
65 changes: 41 additions & 24 deletions src/stock-adjustment-creation/adjustment-creation.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 2bfd452

Please sign in to comment.