-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stock sender receiver validation changes #957
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<Stock> 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 <T> void enrichErrorMapFromInvalidPartyIds(Map<T, List<Error>> er | |
|
||
/** | ||
* method to populate error details map | ||
* | ||
* | ||
* @param <T> | ||
* @param errorDetailsMap | ||
* @param entity | ||
|
@@ -218,7 +219,7 @@ private static <T> void getIdForErrorFromMethod(Map<T, List<Error>> errorDetails | |
} | ||
|
||
/** | ||
* | ||
* | ||
* @param <R> | ||
* @param <T> | ||
* @param request | ||
|
@@ -269,13 +270,17 @@ private static <T> void enrichErrorForStock(List<Stock> validEntities, | |
String receiverId = stock.getReceiverId(); | ||
|
||
List<String> 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; | ||
} | ||
Comment on lines
+273
to
+276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) LGTM with suggestion: Transaction type checks added, but consider logic refinement. The addition of transaction type checks in the Consider refactoring the logic to ensure all valid combinations are checked. For example: if (SenderReceiverType.WAREHOUSE.equals(stock.getSenderType()) && TransactionType.DISPATCHED.equals(stock.getTransactionType())) {
if (!facilityIds.contains(senderId)) {
populateErrorForStock(stock, senderId, errorDetailsMap);
}
} else if (SenderReceiverType.WAREHOUSE.equals(stock.getReceiverType()) && TransactionType.RECEIVED.equals(stock.getTransactionType())) {
if (!facilityIds.contains(receiverId)) {
populateErrorForStock(stock, receiverId, errorDetailsMap);
}
} This approach ensures that all relevant checks are performed without potentially skipping valid scenarios. Also applies to: 279-283 |
||
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 <T> void enrichErrorForStockReconciliation(List<StockReconciliati | |
populateErrorForStockReconciliation(stockReconciliation, errorDetailsMap); | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider removing unnecessary blank line. The added blank line doesn't significantly improve readability as it's between two method definitions that are already separated. Consider removing this line to maintain consistent spacing throughout the file. |
||
@SuppressWarnings("unchecked") | ||
private static <T> void populateErrorForStockReconciliation(StockReconciliation stockReconciliation, | ||
Map<T, List<Error>> errorDetailsMap) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Handle case when
facilityIds
is empty to prevent unnecessary service callIf
facilityIds
is empty,searchLimit
will be zero, and the service request may return no results or might not behave as expected. This could lead to unnecessary service calls or unexpected responses.Consider adding a check to handle the case when
facilityIds
is empty before proceeding with the service request to avoid unnecessary calls:Would you like assistance in implementing this change or opening a GitHub issue to track this task?