You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2020/09/02 02:04:57 UTC

[GitHub] [fineract] ptuomola commented on a change in pull request #1264: FINERACT-1052 global config loan overpayment leaving situation as is

ptuomola commented on a change in pull request #1264:
URL: https://github.com/apache/fineract/pull/1264#discussion_r481547873



##########
File path: fineract-provider/config/swagger/fineract-input.yaml
##########
@@ -0,0 +1,37 @@
+openapi: 3.0.3
+info:
+  version: release-1.4.0-561-g9bad487-dirty
+  title: Apache Fineract

Review comment:
       We should not check in this file as it is autogenerated

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
##########
@@ -168,6 +180,16 @@ public LoanTransaction makeRepayment(final Loan loan, final CommandProcessingRes
         final List<Long> existingReversedTransactionIds = new ArrayList<>();
 
         final Money repaymentAmount = Money.of(loan.getCurrency(), transactionAmount);
+
+        // customization configure ability to overpay loan
+        final Money outstandingBalance = Money.of(loan.getCurrency(), loan.getSummary().getTotalOutstanding());
+        if (outstandingBalance.minus(repaymentAmount).isLessThanZero() && !isLoanOverpaymentEnabled) {
+            baseDataValidator.reset().failWithCode("Repayment exceeding outstanding balance");

Review comment:
       failWithCode should take as parameter the error code property, not freetext - you can take a look at the other calls to it in this file

##########
File path: fineract-provider/src/main/resources/sql/migrations/core_db/V362__Loan_Overpayment_Global_Configuration.sql
##########
@@ -0,0 +1,23 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+--adding new configuration to enable/disable loan over payment
+
+INSERT INTO `c_configuration` (`name`, `enabled`,`description`)
+VALUES ('Enable-Loan-Overpayment',TRUE, 'configuration to enable loan payment beyond outstanding balance');

Review comment:
       As per my comments, shouldn't we have this as FALSE by default to retain the current behaviour as-is - unless configured otherwise

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
##########
@@ -168,6 +180,16 @@ public LoanTransaction makeRepayment(final Loan loan, final CommandProcessingRes
         final List<Long> existingReversedTransactionIds = new ArrayList<>();
 
         final Money repaymentAmount = Money.of(loan.getCurrency(), transactionAmount);
+
+        // customization configure ability to overpay loan
+        final Money outstandingBalance = Money.of(loan.getCurrency(), loan.getSummary().getTotalOutstanding());
+        if (outstandingBalance.minus(repaymentAmount).isLessThanZero() && !isLoanOverpaymentEnabled) {
+            baseDataValidator.reset().failWithCode("Repayment exceeding outstanding balance");
+            if (!dataValidationErrors.isEmpty()) {
+                throw new PlatformApiDataValidationException(dataValidationErrors);
+            }

Review comment:
       To be consistent with the other exceptions thrown in this class, there are a couple of other parameters that should be passed to PlatformApiDataValidationException - take a look at the other throws




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

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