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


##########
fineract-investor/src/main/java/org/apache/fineract/investor/service/AccountingServiceImpl.java:
##########
@@ -171,82 +175,91 @@ private void 
createMappingToTransfer(ExternalAssetOwnerTransfer transfer, List<J
         });
     }
 
-    private List<JournalEntry> createJournalEntries(Loan loan, Long 
transactionId, LocalDate transactionDate, BigDecimal principalAmount,
-            BigDecimal interestAmount, BigDecimal feesAmount, BigDecimal 
penaltiesAmount, BigDecimal overPaymentAmount,
-            boolean isReversalOrder) {
-        Long loanProductId = loan.productId();
-        Long loanId = loan.getId();
-        Office office = loan.getOffice();
-        String currencyCode = loan.getCurrencyCode();
-        List<JournalEntry> journalEntryList = new ArrayList<>();
+    private List<JournalEntry> createJournalEntries(final Loan loan, final 
Long transactionId, final LocalDate transactionDate,
+            final BigDecimal principalAmount, final BigDecimal interestAmount, 
final BigDecimal feesAmount,
+            final BigDecimal penaltiesAmount, final BigDecimal 
overPaymentAmount, final boolean isReversalOrder) {
+        final Long loanProductId = loan.productId();
+        final Long loanId = loan.getId();
+        final Office office = loan.getOffice();
+        final String currencyCode = loan.getCurrencyCode();
+        final List<JournalEntry> journalEntryList = new ArrayList<>();
         BigDecimal totalDebitAmount = BigDecimal.ZERO;
-        Map<GLAccount, BigDecimal> accountMap = new LinkedHashMap<>();
+        final Map<GLAccount, BigDecimal> accountMap = new LinkedHashMap<>();
         // principal entry
-        if (principalAmount != null && 
principalAmount.compareTo(BigDecimal.ZERO) > 0) {
-            AccountingConstants.AccrualAccountsForLoan accrualAccount = 
AccountingConstants.AccrualAccountsForLoan.LOAN_PORTFOLIO;
+        if (MathUtil.isGreaterThanZero(principalAmount)) {
+            totalDebitAmount = totalDebitAmount.add(principalAmount);
+            GLAccount account;
             if (loan.isChargedOff()) {
-                if (loan.isFraud()) {
-                    accrualAccount = 
AccountingConstants.AccrualAccountsForLoan.CHARGE_OFF_FRAUD_EXPENSE;
+                final Long chargeOffReasonId = loan.fetchChargeOffReasonId();
+                final ProductToGLAccountMapping mapping = chargeOffReasonId != 
null
+                        ? helper.getChargeOffMappingByCodeValue(loanProductId, 
PortfolioProductType.LOAN, chargeOffReasonId)
+                        : null;
+                if (mapping != null) {
+                    account = mapping.getGlAccount();

Review Comment:
   No, if there was a charge-off mapping (charge-off reason was mapped to a 
specific GL account) that precedes the fraud flag mapping.
   
   Priority of evaluation:
   1. Advanced accounting mappings, like "Charge-off reason code to GL account
   2. Flags, like "Fraud"



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