budaidev commented on code in PR #5075:
URL: https://github.com/apache/fineract/pull/5075#discussion_r2427159338


##########
fineract-e2e-tests-runner/src/test/resources/features/LoanWriteOff.feature:
##########
@@ -361,3 +361,103 @@
         | Type    | Account code | Account name               | Debit | Credit 
|
         | EXPENSE | 744037       | Credit Loss/Bad Debt-Fraud |       | 750.0  
|
         | EXPENSE | e4           | Written off                | 750.0 |        
|
+
+    @TestRailId:C4111
+    Scenario: Verify GL entries for Write Off reason mapping - UC1: Write off, 
LP with write off reason mapping, NO write off reason to expense account
+      When Admin sets the business date to "01 January 2025"
+      And Admin creates a client with random data
+      And Admin creates a fully customized loan with the following data:
+        | LoanProduct                                                      | 
submitted on date | with Principal | ANNUAL interest rate % | interest type     
| interest calculation period | amortization type  | loanTermFrequency | 
loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | 
numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | 
interest free period | Payment strategy            |
+        | LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_WRITE_OFF_REASON_MAP | 
01 January 2025   | 1000           | 12                      | 
DECLINING_BALANCE | DAILY                       | EQUAL_INSTALLMENTS | 4        
         | MONTHS                | 1              | MONTHS                 | 4  
                | 0                       | 0                      | 0          
          | ADVANCED_PAYMENT_ALLOCATION |
+      And Admin successfully approves the loan on "01 January 2025" with 
"1000" amount and expected disbursement date on "01 January 2025"
+      And Admin successfully disburse the loan on "01 January 2025" with 
"1000" EUR transaction amount
+      And Admin sets the business date to "02 January 2025"
+      And Admin runs inline COB job for Loan
+      And Admin does write-off the loan on "02 January 2025"
+      Then Loan status will be "CLOSED_WRITTEN_OFF"
+      And Loan Repayment schedule has 4 periods, with the following data for 
periods:
+        | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due    | Paid | In advance | Late 
| Outstanding |
+        |    |      | 01 January 2025  |                 | 1000.0          |   
            |          | 0.0  |           | 0.0    | 0.0  |            |      | 
            |
+        | 1  | 31   | 01 February 2025 | 02 January 2025 | 753.72          | 
246.28        | 10.0     | 0.0  | 0.0       | 256.28 | 0.0  | 0.0        | 0.0  
| 0.0         |
+        | 2  | 28   | 01 March 2025    | 02 January 2025 | 504.98          | 
248.74        | 7.54     | 0.0  | 0.0       | 256.28 | 0.0  | 0.0        | 0.0  
| 0.0         |
+        | 3  | 31   | 01 April 2025    | 02 January 2025 | 253.75          | 
251.23        | 5.05     | 0.0  | 0.0       | 256.28 | 0.0  | 0.0        | 0.0  
| 0.0         |
+        | 4  | 30   | 01 May 2025      | 02 January 2025 | 0.0             | 
253.75        | 2.54     | 0.0  | 0.0       | 256.29 | 0.0  | 0.0        | 0.0  
| 0.0         |
+      And Loan Repayment schedule has the following data in Total row:
+        | Principal due | Interest | Fees | Penalties | Due     | Paid | In 
advance | Late | Outstanding |
+        | 1000          | 25.13    | 0    | 0         | 1025.13 | 0    | 0     
     | 0    | 0.0         |
+      And Loan Transactions tab has the following data:
+        | Transaction date | Transaction Type       | Amount  | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+        | 01 January 2025  | Disbursement           | 1000.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 1000.0       | false    | false    |
+        | 02 January 2025  | Close (as written-off) | 1025.13 | 1000.0    | 
25.13    | 0.0  | 0.0       | 0.0          | false    | false    |
+      And Loan Transactions tab has a "WRITE_OFF" transaction with date "02 
January 2025" which has the following Journal entries:
+        | Type    | Account code | Account name            | Debit   | Credit |
+        | ASSET   | 112601       | Loans Receivable        |         | 1000.0 |
+        | ASSET   | 112603       | Interest/Fee Receivable |         | 25.13  |
+        | EXPENSE | e4           | Written off             | 1025.13 |        |
+
+    @temp3

Review Comment:
   Probably not needed, but please check this



##########
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:
   is it possible to have mapping but no glAcccount? What happens in this case?



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