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 2022/03/29 16:31:48 UTC

[GitHub] [fineract] fynmanoj commented on a change in pull request #2215: (Fineract-1553): Lien configured at product level

fynmanoj commented on a change in pull request #2215:
URL: https://github.com/apache/fineract/pull/2215#discussion_r837660276



##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java
##########
@@ -130,6 +135,9 @@ public String retrieveOne(@PathParam("savingsId") final Long savingsId, @PathPar
     @POST
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON })
+    @RequestBody(required = true, content = @Content(schema = @Schema(implementation = SavingsAccountTransactionsApiResourceSwagger.PostSavingsAccountTransactionsRequest.class)))
+    @ApiResponses({

Review comment:
       Please confirm if this swagger API documentation has the command parameter

##########
File path: fineract-client/src/main/resources/java/template/build.gradle.mustache
##########
@@ -1,22 +1,20 @@
 {{!
-/**
- * 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.
- */
+    Licensed to the Apache Software Foundation (ASF) under one

Review comment:
       These  changes doesn't look relevant 

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionData.java
##########
@@ -73,6 +73,7 @@
     private final boolean isManualTransaction;
     private final Boolean isReversal;
     private final Long originalTransactionId;
+    private final boolean lienAllowed;

Review comment:
       This flag should be "isLien" /isLienTransaction  not isLienAllowed

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductDataValidator.java
##########
@@ -340,6 +343,18 @@ public void validateForCreate(final String json) {
             baseDataValidator.reset().parameter(minBalanceForInterestCalculationParamName).value(minBalanceForInterestCalculation)
                     .ignoreIfNull().zeroOrPositiveAmount();
         }
+        Boolean isLienAllowed=this.fromApiJsonHelper.parameterExists(lienAllowedParamName,element);
+        Boolean isOverdraftAllowed = this.fromApiJsonHelper.parameterExists(allowOverdraftParamName,element);
+
+        if(isLienAllowed){
+            if(isOverdraftAllowed){
+                BigDecimal overdraftLimit = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(overdraftLimitParamName, element);
+                BigDecimal lienAllowedLimit = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(maxAllowedLienLimitParamName,element);

Review comment:
       Also check for the validity of the data. Should be Positive amount

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProduct.java
##########
@@ -179,6 +181,12 @@
     @Column(name = "min_required_balance", scale = 6, precision = 19, nullable = true)
     private BigDecimal minRequiredBalance;
 
+    @Column(name = "is_lien_allowed")
+    private boolean lienAllowed;
+
+    @Column(name = "max_Allowed_Lien_Limit", scale = 6, precision = 19, nullable = true)

Review comment:
       Use the column name all lowercase 

##########
File path: fineract-provider/src/main/resources/db/changelog/tenant/parts/0009_lien_allowed_on_savings_account_products.xml
##########
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+
+            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.
+
+        -->
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
+<changeSet author="fineract" id="1">
+    <addColumn tableName="m_savings_account">
+        <column defaultValueComputed="NULL" name="max_Allowed_Lien_Limit" type="DECIMAL(19, 6)"/>

Review comment:
       Use all lowercase for column name 

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionDataValidator.java
##########
@@ -232,25 +238,64 @@ public SavingsAccountTransaction validateHoldAndAssembleForm(final String json,
             baseDataValidator.reset().parameter(SavingsApiConstants.statusParamName)
                     .failWithCodeNoParameterAddedToErrorCode(SavingsApiConstants.ERROR_MSG_SAVINGS_ACCOUNT_NOT_ACTIVE);
         }
-        account.holdAmount(amount);
-
-        if (account.getEnforceMinRequiredBalance()) {
-            if (account.getWithdrawableBalance().compareTo(BigDecimal.ZERO) < 0) {
-                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("insufficient balance", account.getId());
-            }
-        }
 
-        Boolean lien = false;
 
-        if (this.fromApiJsonHelper.parameterExists(lienParamName, element)) {
-            lien = this.fromApiJsonHelper.extractBooleanNamed(lienParamName, element);
-            if (!lien) {
-                if (account.getWithdrawableBalanceWithoutMinimumBalance().compareTo(BigDecimal.ZERO) < 0) {
+        Boolean isEnforceMinRequiredBalanceEnabled = account.getEnforceMinRequiredBalance();
+        Boolean isAccountLienEnabled = account.isLienAllowed();
+        Boolean isOverdraftEnabled = account.isAllowOverdraft();
+
+        Boolean lienAllowed = false;
+        if (this.fromApiJsonHelper.parameterExists(lienAllowedParamName, element)) {
+            lienAllowed = this.fromApiJsonHelper.extractBooleanNamed(lienAllowedParamName, element);
+            if (lienAllowed) {
+                if (isAccountLienEnabled) {
+                    if (isOverdraftEnabled) {
+                        if (account.getOverdraftLimit().compareTo(account.getMaxAllowedLienLimit()) > 0) {

Review comment:
       Error code should be words seperateed with dots. These codes will be trancelated at clientside

##########
File path: fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java
##########
@@ -402,7 +402,7 @@ public InteropTransferResponseData prepareTransfer(@NotNull JsonCommand command)
                     null);
             SavingsAccountTransaction holdTransaction = SavingsAccountTransaction.holdAmount(savingsAccount, savingsAccount.office(),
                     paymentDetail, transactionDate.toLocalDate(), Money.of(savingsAccount.getCurrency(), total), new Date(),
-                    getLoginUser());
+                    getLoginUser(), savingsAccount.isLienAllowed());

Review comment:
       This isLien flag should be taken from the API body , not from account configuration.
   This flag is to differentiate Lien from other hold transaction 

##########
File path: package-lock.json
##########
@@ -0,0 +1,6 @@
+{

Review comment:
       This file not required 

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionDataValidator.java
##########
@@ -6,9 +6,9 @@
  * 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
- *
+ * <p>
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>

Review comment:
       Why this change?

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
##########
@@ -290,6 +292,12 @@
     @Column(name = "min_required_balance", scale = 6, precision = 19, nullable = true)
     private BigDecimal minRequiredBalance;
 
+    @Column(name = "is_lien_allowed")
+    private boolean lienAllowed;

Review comment:
       Use Boolean to make it null safe

##########
File path: fineract-provider/src/main/resources/db/changelog/tenant/parts/0001_initial_schema.xml
##########
@@ -3713,6 +3713,7 @@
             <column defaultValueBoolean="false" name="enforce_min_required_balance" type="boolean">
                 <constraints nullable="false"/>
             </column>
+

Review comment:
       Donot update existing migration scripts , it may cause check sum missmatch




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