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


##########
fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccrualBasedAccountingProcessorForLoan.java:
##########
@@ -229,14 +230,27 @@ private void createJournalEntriesForChargeOff(LoanDTO 
loanDTO, LoanTransactionDT
         final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
         final boolean isReversal = loanTransactionDTO.isReversed();
         GLAccountBalanceHolder glAccountBalanceHolder = new 
GLAccountBalanceHolder();
-        // principal payment
-        if (principalAmount != null && 
principalAmount.compareTo(BigDecimal.ZERO) > 0) {
-            if (isMarkedFraud) {
-                populateCreditDebitMaps(loanProductId, principalAmount, 
paymentTypeId, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
-                        
AccrualAccountsForLoan.CHARGE_OFF_FRAUD_EXPENSE.getValue(), 
glAccountBalanceHolder);
-            } else {
-                populateCreditDebitMaps(loanProductId, principalAmount, 
paymentTypeId, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
-                        AccrualAccountsForLoan.CHARGE_OFF_EXPENSE.getValue(), 
glAccountBalanceHolder);
+
+        // need to fetch if there are account mappings (always one)
+        Integer chargeOffReasonCode = loanDTO.getChargeOffReasonCode();

Review Comment:
   This is not a code, it is a code value



##########
fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccrualBasedAccountingProcessorForLoan.java:
##########
@@ -229,14 +230,27 @@ private void createJournalEntriesForChargeOff(LoanDTO 
loanDTO, LoanTransactionDT
         final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
         final boolean isReversal = loanTransactionDTO.isReversed();
         GLAccountBalanceHolder glAccountBalanceHolder = new 
GLAccountBalanceHolder();
-        // principal payment
-        if (principalAmount != null && 
principalAmount.compareTo(BigDecimal.ZERO) > 0) {
-            if (isMarkedFraud) {
-                populateCreditDebitMaps(loanProductId, principalAmount, 
paymentTypeId, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
-                        
AccrualAccountsForLoan.CHARGE_OFF_FRAUD_EXPENSE.getValue(), 
glAccountBalanceHolder);
-            } else {
-                populateCreditDebitMaps(loanProductId, principalAmount, 
paymentTypeId, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
-                        AccrualAccountsForLoan.CHARGE_OFF_EXPENSE.getValue(), 
glAccountBalanceHolder);
+
+        // need to fetch if there are account mappings (always one)
+        Integer chargeOffReasonCode = loanDTO.getChargeOffReasonCode();
+
+        ProductToGLAccountMapping mapping = 
helper.getChargeOffMappingByCode(chargeOffReasonCode);
+        if (mapping != null) {
+            GLAccount accountCredit = 
this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
+                    AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), 
paymentTypeId);
+            glAccountBalanceHolder.addToCredit(accountCredit, principalAmount);
+            // Resolve Debit

Review Comment:
   No need for this comment



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