alberto-art3ch commented on code in PR #5075:
URL: https://github.com/apache/fineract/pull/5075#discussion_r2428974294


##########
fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccrualBasedAccountingProcessorForLoan.java:
##########
@@ -1913,8 +1913,20 @@ private void createJournalEntriesForLoanWriteOffs(final 
LoanDTO loanDTO, final L
          * Single DEBIT transaction for write-offs
          ***/
         if (MathUtil.isGreaterThanZero(totalDebitAmount)) {
-            this.helper.createDebitJournalEntryForLoan(office, currencyCode, 
AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(),
-                    loanProductId, paymentTypeId, loanId, transactionId, 
transactionDate, totalDebitAmount);
+            final AdvancedMappingtDTO writeAdvancedMappingtDTO = 
loanDTO.getWriteOffReasonAdvancedMappingData();
+            final ProductToGLAccountMapping mapping = 
(writeAdvancedMappingtDTO != null
+                    && writeAdvancedMappingtDTO.getReferenceValueId() != null)
+                            ? 
helper.getWriteOffMappingByCodeValue(loanProductId, PortfolioProductType.LOAN,
+                                    
writeAdvancedMappingtDTO.getReferenceValueId())
+                            : null;
+
+            if (mapping == null) {
+                this.helper.createDebitJournalEntryForLoan(office, 
currencyCode, AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(),
+                        loanProductId, paymentTypeId, loanId, transactionId, 
transactionDate, totalDebitAmount);
+            } else {
+                this.helper.createDebitJournalEntryForLoan(office, 
currencyCode, mapping.getGlAccount(), loanId, transactionId,

Review Comment:
   If you have a mapping you must to have a GLAccount



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