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


##########
fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccrualBasedAccountingProcessorForLoan.java:
##########
@@ -246,46 +237,53 @@ private void 
createJournalEntriesForCapitalizedIncomeAdjustment(final LoanDTO lo
             }
 
             // Resolve Debit
-            GLAccount accountIncomeFromCapitalization = 
this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
-                    
AccrualAccountsForLoan.INCOME_FROM_CAPITALIZATION.getValue(), paymentTypeId);
             GLAccount accountDeferredIncome = 
this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
                     
AccrualAccountsForLoan.DEFERRED_INCOME_LIABILITY.getValue(), paymentTypeId);
 
-            Optional<LoanTransaction> transactionOpt = 
loanTransactionRepository.findById(Long.parseLong(transactionId));
-            if (transactionOpt.isEmpty()) {
-                throw new 
PlatformDataIntegrityException("transaction.for.accounting.not.found", 
"Transaction for accounting not found");
-            }
-            Optional<LoanTransactionRelation> relationToOriginalTransactionOpt 
= transactionOpt.get().getLoanTransactionRelations().stream()//
-                    .filter(rel -> 
LoanTransactionRelationTypeEnum.REPLAYED.equals(rel.getRelationType()))//
-                    
.min(Comparator.comparing(AbstractPersistableCustom::getId));
-            if (relationToOriginalTransactionOpt.isPresent()) {
-                // Reverse-replay case
-                final LoanTransaction originalTransaction = 
relationToOriginalTransactionOpt.get().getToTransaction();
-                final List<JournalEntry> originalJournalEntries = 
this.journalEntryRepository.findJournalEntries(
-                        AccountingProcessorHelper.LOAN_TRANSACTION_IDENTIFIER 
+ originalTransaction.getId(),
-                        PortfolioProductType.LOAN.getValue());
-
-                for (JournalEntry originalJournalEntry : 
originalJournalEntries) {
-                    if (originalJournalEntry.isDebitEntry()) {
-                        if 
(accountIncomeFromCapitalization.getId().equals(originalJournalEntry.getGlAccount().getId()))
 {
-                            
glAccountBalanceHolder.addToDebit(accountIncomeFromCapitalization, 
originalJournalEntry.getAmount());
-                        } else if 
(accountDeferredIncome.getId().equals(originalJournalEntry.getGlAccount().getId()))
 {
-                            
glAccountBalanceHolder.addToDebit(accountDeferredIncome, 
originalJournalEntry.getAmount());
-                        }
-                    }
-                }
-            } else {
-                LoanCapitalizedIncomeBalance capitalizedIncomeBalance = 
loanCapitalizedIncomeBalanceRepository
-                        
.findBalanceForAdjustment(Long.parseLong(loanTransactionDTO.getTransactionId()));
-                if (MathUtil.isGreaterThan(transactionAmount, 
capitalizedIncomeBalance.getUnrecognizedAmount())) {
-                    BigDecimal amortizedAmount = 
transactionAmount.subtract(capitalizedIncomeBalance.getUnrecognizedAmount());
-
-                    
glAccountBalanceHolder.addToDebit(accountIncomeFromCapitalization, 
amortizedAmount);
-                    glAccountBalanceHolder.addToDebit(accountDeferredIncome, 
transactionAmount.subtract(amortizedAmount));
-                } else {
-                    glAccountBalanceHolder.addToDebit(accountDeferredIncome, 
transactionAmount);
-                }
-            }
+            glAccountBalanceHolder.addToDebit(accountDeferredIncome, 
transactionAmount);
+
+            // GLAccount accountIncomeFromCapitalization = 
this.helper.getLinkedGLAccountForLoanProduct(loanProductId,

Review Comment:
   Remove if not needed



-- 
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