adamsaghy commented on code in PR #3220:
URL: https://github.com/apache/fineract/pull/3220#discussion_r1217717032


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java:
##########
@@ -4484,6 +4485,67 @@ public BigDecimal getProposedPrincipal() {
         return this.proposedPrincipal;
     }
 
+    public List<Map<String, Object>> 
deriveAccountingBridgeDataForChargeOff(final String currencyCode,
+            final List<Long> existingTransactionIds, final List<Long> 
existingReversedTransactionIds, boolean isAccountTransfer) {
+
+        final List<Map<String, Object>> accountingBridgeData = new 
ArrayList<>();
+
+        final Map<String, Object> accountingBridgeDataGenericAttributes = new 
LinkedHashMap<>();
+        accountingBridgeDataGenericAttributes.put("loanId", getId());
+        accountingBridgeDataGenericAttributes.put("loanProductId", 
productId());
+        accountingBridgeDataGenericAttributes.put("officeId", getOfficeId());
+        accountingBridgeDataGenericAttributes.put("currencyCode", 
currencyCode);
+        accountingBridgeDataGenericAttributes.put("calculatedInterest", 
this.summary.getTotalInterestCharged());
+        
accountingBridgeDataGenericAttributes.put("cashBasedAccountingEnabled", 
isCashBasedAccountingEnabledOnLoanProduct());
+        
accountingBridgeDataGenericAttributes.put("upfrontAccrualBasedAccountingEnabled",
 isUpfrontAccrualAccountingEnabledOnLoanProduct());
+        
accountingBridgeDataGenericAttributes.put("periodicAccrualBasedAccountingEnabled",
+                isPeriodicAccrualAccountingEnabledOnLoanProduct());
+        accountingBridgeDataGenericAttributes.put("isAccountTransfer", 
isAccountTransfer);
+
+        // get map before charge-off
+        final Map<String, Object> accountingBridgeDataBeforeChargeOff = new 
LinkedHashMap<>(accountingBridgeDataGenericAttributes);
+        accountingBridgeDataBeforeChargeOff.put("isChargeOff", false);
+        accountingBridgeDataBeforeChargeOff.put("isFraud", false);
+
+        Predicate<LoanTransaction> isBeforeChargeOff = transaction -> 
transaction.getTransactionDate().isBefore(getChargedOffOnDate());
+        final List<Map<String, Object>> newLoanTransactionsBeforeChargeOff = 
new ArrayList<>();
+
+        getTransactionsForAccountingBridgeData(currencyCode, 
existingTransactionIds, existingReversedTransactionIds,
+                newLoanTransactionsBeforeChargeOff, isBeforeChargeOff);
+        accountingBridgeDataBeforeChargeOff.put("newLoanTransactions", 
newLoanTransactionsBeforeChargeOff);
+        accountingBridgeData.add(accountingBridgeDataBeforeChargeOff);
+
+        // get map after charge-off
+        final Map<String, Object> accountingBridgeDataAfterChargeOff = new 
LinkedHashMap<>(accountingBridgeDataGenericAttributes);
+        accountingBridgeDataAfterChargeOff.put("isChargeOff", isChargedOff());
+        accountingBridgeDataAfterChargeOff.put("isFraud", isFraud());
+
+        Predicate<LoanTransaction> isOnOrAfterChargeOff = transaction -> 
transaction.getTransactionDate().isEqual(getChargedOffOnDate())

Review Comment:
   I dont think this is right... technically it can happen a transaction 
happened on the same day as the charge-off and one it was before the charge off 
happened.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to