diff --git a/health-services/stock/src/main/java/org/egov/stock/service/FacilityService.java b/health-services/stock/src/main/java/org/egov/stock/service/FacilityService.java index 2951b21e031..6e6fba70328 100644 --- a/health-services/stock/src/main/java/org/egov/stock/service/FacilityService.java +++ b/health-services/stock/src/main/java/org/egov/stock/service/FacilityService.java @@ -21,6 +21,7 @@ import org.egov.common.models.stock.SenderReceiverType; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockReconciliation; +import org.egov.common.models.stock.TransactionType; import org.egov.stock.config.StockConfiguration; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -96,10 +97,10 @@ public Map> validateProjectFacilityMappings(List ent Stock stock = (Stock) entity; - if (SenderReceiverType.WAREHOUSE.equals(stock.getSenderType())) { - facilityIds.add(stock.getSenderId()); - } - if (SenderReceiverType.WAREHOUSE.equals(stock.getReceiverType())) { + if (SenderReceiverType.WAREHOUSE.equals(stock.getSenderType()) && TransactionType.DISPATCHED.equals(stock.getTransactionType())) { + facilityIds.add(stock.getSenderId()); + } + if (SenderReceiverType.WAREHOUSE.equals(stock.getReceiverType()) && TransactionType.RECEIVED.equals(stock.getTransactionType())) { facilityIds.add(stock.getReceiverId()); } } diff --git a/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java b/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java index d71f92cda2d..cbebacdcb67 100644 --- a/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java +++ b/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java @@ -13,6 +13,7 @@ import org.egov.common.models.stock.SenderReceiverType; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockReconciliation; +import org.egov.common.models.stock.TransactionType; import org.egov.common.service.UserService; import org.egov.stock.service.FacilityService; import org.egov.tracer.model.CustomException; @@ -140,7 +141,7 @@ private static void validateAndEnrichStaffIds(RequestInfo requestInfo, UserServi /** * Private method to enrich facility id and staff id - * + * * @param validStockEntities * @param facilityIds * @param staffIds @@ -166,9 +167,9 @@ private static void enrichFaciltyAndStaffIdsFromStock(List validStockEnti } /** - * + * * creates the error map from the stock objects with invalid party ids - * + * * @param errorDetailsMap * @param validStockEntities * @param invalidStaffIds @@ -205,7 +206,7 @@ private static void enrichErrorMapFromInvalidPartyIds(Map> er /** * method to populate error details map - * + * * @param * @param errorDetailsMap * @param entity @@ -218,7 +219,7 @@ private static void getIdForErrorFromMethod(Map> errorDetails } /** - * + * * @param * @param * @param request @@ -269,13 +270,17 @@ private static void enrichErrorForStock(List validEntities, String receiverId = stock.getReceiverId(); List facilityIds = ProjectFacilityMappingOfIds.get(stock.getReferenceId()); + if (!(SenderReceiverType.WAREHOUSE.equals(stock.getSenderType()) && TransactionType.DISPATCHED.equals(stock.getTransactionType())) + && !(SenderReceiverType.WAREHOUSE.equals(stock.getReceiverType()) && TransactionType.RECEIVED.equals(stock.getTransactionType()))) { + continue; + } if (!CollectionUtils.isEmpty(facilityIds)) { - if (SenderReceiverType.WAREHOUSE.equals(stock.getSenderType()) && !facilityIds.contains(senderId)) { + if (SenderReceiverType.WAREHOUSE.equals(stock.getSenderType()) && !facilityIds.contains(senderId) && TransactionType.DISPATCHED.equals(stock.getTransactionType())) { populateErrorForStock(stock, senderId, errorDetailsMap); } - if (SenderReceiverType.WAREHOUSE.equals(stock.getReceiverType()) && !facilityIds.contains(receiverId)) + if (SenderReceiverType.WAREHOUSE.equals(stock.getReceiverType()) && !facilityIds.contains(receiverId)&& TransactionType.RECEIVED.equals(stock.getTransactionType())) populateErrorForStock(stock, receiverId, errorDetailsMap); } else { populateErrorForStock(stock, senderId + " and " + receiverId, errorDetailsMap); @@ -309,7 +314,7 @@ private static void enrichErrorForStockReconciliation(List void populateErrorForStockReconciliation(StockReconciliation stockReconciliation, Map> errorDetailsMap) {