FINERACT-2457: Share transaction chronological validation incorrectly blocks new transactions based on rejected/reversed transactions#5403
Conversation
| Set<ShareAccountTransaction> transactions = account.getShareAccountTransactions(); | ||
| for (ShareAccountTransaction transaction : transactions) { | ||
| if (!transaction.isChargeTransaction()) { | ||
| if (!transaction.isChargeTransaction() && transaction.isActive()) { |
There was a problem hiding this comment.
Can you please tell me what is the current object for transaction rejected and reversed transaction, I think we can add unit tests for these case where when we perform transaction with reversed and rejected transaction it will work.
91b2211 to
d1b37ba
Compare
| ShareAccountTransactionHelper.updateShareAccount(shareAccountId, updateShareAccountJsonString, requestSpec, responseSpec); | ||
|
|
||
| // Approve share Account | ||
| Map<String, Object> approveMap = new HashMap<>(); |
There was a problem hiding this comment.
This Share Account Approval Note logic seems to be duplicated in both tests, i think a helper function can be extracted especially this part
Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note");
approveMap.put("dateFormat", "dd MMMM yyyy");
approveMap.put("approvedDate", "01 March 2016");
approveMap.put("locale", "en");
String approve = new Gson().toJson(approveMap);
ShareAccountTransactionHelper.postCommand("approve", ...);
Map<String, Object> activateMap = new HashMap<>();
activateMap.put("dateFormat", "dd MMMM yyyy");
activateMap.put("activatedDate", "01 March 2016");
activateMap.put("locale", "en");
String activateJson = new Gson().toJson(activateMap);
ShareAccountTransactionHelper.postCommand("activate", ...);
for (Map<String, Object> transaction : transactions) {
Map<String, Object> transactionTypeMap = (Map<String, Object>) transaction.get("type");
List dateList = (List) transaction.get("purchasedDate");
Calendar cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date date = cal.getTime();
String transactionType = (String) transactionTypeMap.get("code");
String transactionDate = simple.format(date);
if (transactionType.equals(...) && transactionDate.equals(...)) {
...
break;
}
}
Map<String, List<Map<String, Object>>> rejectMap = new HashMap<>();
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> idsMap = new HashMap<>();
idsMap.put("id", additionalSharesRequestId);
list.add(idsMap);
rejectMap.put("requestedShares", list);
String rejectJson = new Gson().toJson(rejectMap);
ShareAccountTransactionHelper.postCommand("rejectadditionalshares", ...);
Aman-Mittal
left a comment
There was a problem hiding this comment.
There’s significant duplication across both tests: account setup, approve/activate flow, transaction lookup by date, rejection logic, and Calendar-based date extraction are repeated multiple times. I would Suggest extracting helpers for creating active share accounts, finding transactions by LocalDate, rejecting transactions, and approving/activating accounts. This would reduce test size substantially and improve readability and maintainability.
d1b37ba to
ba15779
Compare
| Set<ShareAccountTransaction> transactions = account.getShareAccountTransactions(); | ||
| for (ShareAccountTransaction transaction : transactions) { | ||
| if (!transaction.isChargeTransaction()) { | ||
| if (!transaction.isChargeTransaction() && transaction.isActive() && !transaction.isPurchaseRejectedTransaction()) { |
There was a problem hiding this comment.
Please filter the account.getShareAccountTransactions() result first and then iterate over them.
| Set<ShareAccountTransaction> transactions = account.getShareAccountTransactions(); | ||
| for (ShareAccountTransaction transaction : transactions) { | ||
| if (!transaction.isChargeTransaction()) { | ||
| if (!transaction.isChargeTransaction() && transaction.isActive() && !transaction.isPurchaseRejectedTransaction()) { |
… blocks new transactions based on rejected/reversed transactions
ba15779 to
361b128
Compare
Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.