You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "reluxa (via GitHub)" <gi...@apache.org> on 2023/08/03 14:55:30 UTC

[GitHub] [fineract] reluxa commented on a diff in pull request #3348: FINERACT-1905: Same day repayment + charge handling improvement

reluxa commented on code in PR #3348:
URL: https://github.com/apache/fineract/pull/3348#discussion_r1283328824


##########
fineract-provider/src/test/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/DuePenFeeIntPriInAdvancePriPenFeeIntLoanRepaymentScheduleTransactionProcessorTest.java:
##########
@@ -542,39 +349,77 @@ public void duePaymentOfHigherPenaltyAndHigherFeeAsInAdvanceTransaction() {
         underTest.handleTransactionThatIsPaymentInAdvanceOfInstallment(installment, null, loanTransaction, transactionAmount,
                 transactionMappings, charges);
 
-        // Calculated eleven, overridden by Unprocessed (ten)
-        Mockito.verify(installment, Mockito.times(1)).payPenaltyChargesComponent(eq(transactionDate), refEq(ten));
-        // Calculated eleven, overridden by Unprocessed (six)
-        Mockito.verify(installment, Mockito.times(1)).payFeeChargesComponent(eq(transactionDate), refEq(six));
-        // In advance with value of 4, and 2 is outstanding of principal
-        Mockito.verify(installment, Mockito.times(1)).payPrincipalComponent(eq(transactionDate), refEq(four));
-        // In advance with value of 2, and 2 is outstanding of interest
-        Mockito.verify(installment, Mockito.times(1)).payInterestComponent(eq(transactionDate), refEq(two));
-
         // Principal 2, interest 2, fee 2, penalty 4
         Mockito.verify(loanTransaction, Mockito.times(1)).updateComponents(refEq(two), refEq(two), refEq(two), refEq(four));
     }
 
+    @Test
+    public void inAdvancePaymentOfPrincipalAndPenaltyWherePenaltyIsSameDayButLaterThanRepayment() {
+        LoanCharge loanCharge1 = createLoanCharge(transactionDate, true, one, null);
+        LoanCharge loanCharge2 = createLoanCharge(transactionDate, true, three, OffsetDateTime.of(2023, 1, 1, 1, 1, 1, 2, ZoneOffset.UTC));
+        Mockito.when(charges.stream()).thenReturn(Stream.of(loanCharge1, loanCharge2));
+        Money transactionAmount = four;
+        LoanRepaymentScheduleInstallment installment = Mockito
+                .spy(new LoanRepaymentScheduleInstallment(loan, 1, firstInstallmentToDate, firstInstallmentDueDate, BigDecimal.valueOf(3L),
+                        BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.valueOf(4L), false, null, BigDecimal.ZERO));
+        LoanTransaction loanTransaction = Mockito
+                .spy(LoanTransaction.repayment(office, transactionAmount, null, transactionDate, ExternalId.empty()));
+        Mockito.when(loanTransaction.getCreatedDate()).thenReturn(Optional.of(OffsetDateTime.of(2023, 1, 1, 1, 1, 1, 1, ZoneOffset.UTC)));

Review Comment:
   Do we have testcase where the repayment is added after a charge an both has on created time?



-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org