fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [2/3] incubator-fineract git commit: corrected type while fethcing data from metadata
Date Tue, 16 Feb 2016 12:50:15 GMT
corrected type while fethcing data from metadata


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/b5dc6b2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/b5dc6b2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/b5dc6b2b

Branch: refs/heads/develop
Commit: b5dc6b2b5bec2bb4f9681b66a862939f6cdfbadd
Parents: a13a807
Author: pramod <pramod@confluxtechnologies.com>
Authored: Tue Feb 16 12:21:30 2016 +0530
Committer: pramod <pramod@confluxtechnologies.com>
Committed: Tue Feb 16 12:21:30 2016 +0530

----------------------------------------------------------------------
 .../data/ResultsetColumnHeaderData.java         | 53 +++++++-----
 .../portfolio/loanaccount/domain/Loan.java      | 88 ++++++++++----------
 2 files changed, 79 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/b5dc6b2b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
index e84149c..75f0eb8 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
@@ -68,21 +68,9 @@ public final class ResultsetColumnHeaderData {
         this.columnValues = columnValues;
         this.columnCode = columnCode;
 
-        if("NEWDECIMAL".equalsIgnoreCase(this.columnType)) {
-        	this.columnType = "DECIMAL" ;
-        	//Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
-        }
-        
-        if("CLOB".equalsIgnoreCase(this.columnType)) {
-        	this.columnType = "varchar" ;
-        	//Drizzle is returning some of the String data a CLOB
-        }
-        
-        if("LONGLONG".equalsIgnoreCase(this.columnType) || "LONG".equalsIgnoreCase(this.columnType))
{
-        	this.columnType = "bigint" ;
-        	//Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
-        }
-        
+        // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
+        adjustColumnTypes();
+
         String displayType = null;
         if (this.columnCode == null) {
             if (isString()) {
@@ -97,7 +85,7 @@ public final class ResultsetColumnHeaderData {
                 displayType = "DECIMAL";
             } else if (isAnyText()) {
                 displayType = "TEXT";
-            } else if(isBit()) {
+            } else if (isBit()) {
                 displayType = "BOOLEAN";
             } else {
                 throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type",
"Invalid Lookup Type:" + this.columnType
@@ -118,6 +106,33 @@ public final class ResultsetColumnHeaderData {
         this.columnDisplayType = displayType;
     }
 
+    private void adjustColumnTypes() {
+        switch (this.columnType) {
+            case "NEWDECIMAL":
+                this.columnType = "DECIMAL";
+            break;
+            case "CLOB":
+            case "ENUM":
+            case "SET":
+                this.columnType = "varchar";
+            break;
+            case "LONGLONG":
+                this.columnType = "bigint";
+            break;
+            case "SHORT":
+                this.columnType = "smallint";
+            break;
+            case "TINY":
+                this.columnType = "tinyint";
+            break;
+            case "INT24":
+                this.columnType = "int";
+            break;
+            default:
+            break;
+        }
+    }
+
     public boolean isNamed(final String columnName) {
         return this.columnName.equalsIgnoreCase(columnName);
     }
@@ -144,7 +159,7 @@ public final class ResultsetColumnHeaderData {
 
     private boolean isDecimal() {
         return "decimal".equalsIgnoreCase(this.columnType) || "NEWDECIMAL".equalsIgnoreCase(this.columnType);
-        //Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
+        // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
     }
 
     private boolean isDate() {
@@ -190,10 +205,10 @@ public final class ResultsetColumnHeaderData {
     private boolean isBigInt() {
         return "bigint".equalsIgnoreCase(this.columnType);
     }
-    
+
     private boolean isLong() {
         return "LONG".equalsIgnoreCase(this.columnType) || "LONGLONG".equalsIgnoreCase(this.columnType);
-        //Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
+        // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
     }
 
     private boolean isBit() {

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/b5dc6b2b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
index b59d4dc..ac4aa45 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
@@ -1599,11 +1599,11 @@ public class Loan extends AbstractPersistable<Long> {
         BigDecimal chargeAmt = BigDecimal.ZERO;
         BigDecimal totalChargeAmt = BigDecimal.ZERO;
         if (loanCharge.getChargeCalculation().isPercentageBased()) {
-        	 if (loanCharge.isOverdueInstallmentCharge()) {
-                 amount = calculateOverdueAmountPercentageAppliedTo(loanCharge, penaltyWaitPeriod);
-             } else {
-                 amount = calculateAmountPercentageAppliedTo(loanCharge);
-             }
+            if (loanCharge.isOverdueInstallmentCharge()) {
+                amount = calculateOverdueAmountPercentageAppliedTo(loanCharge, penaltyWaitPeriod);
+            } else {
+                amount = calculateAmountPercentageAppliedTo(loanCharge);
+            }
             chargeAmt = loanCharge.getPercentage();
             if (loanCharge.isInstalmentFee()) {
                 totalChargeAmt = calculatePerInstallmentChargeAmount(loanCharge);
@@ -2337,7 +2337,8 @@ public class Loan extends AbstractPersistable<Long> {
     }
 
     public void regenerateScheduleOnDisbursement(final ScheduleGeneratorDTO scheduleGeneratorDTO,
final boolean recalculateSchedule,
-            final LocalDate actualDisbursementDate, BigDecimal emiAmount, final AppUser currentUser,
LocalDate nextPossibleRepaymentDate, Date rescheduledRepaymentDate) {
+            final LocalDate actualDisbursementDate, BigDecimal emiAmount, final AppUser currentUser,
LocalDate nextPossibleRepaymentDate,
+            Date rescheduledRepaymentDate) {
         boolean isEmiAmountChanged = false;
         if ((this.loanProduct.isMultiDisburseLoan() || this.loanProduct.canDefineInstallmentAmount())
&& emiAmount != null
                 && emiAmount.compareTo(retriveLastEmiAmount()) != 0) {
@@ -2352,11 +2353,12 @@ public class Loan extends AbstractPersistable<Long> {
             }
             isEmiAmountChanged = true;
         }
-        if(rescheduledRepaymentDate != null && this.loanProduct.isMultiDisburseLoan()){
-        	 final boolean isSpecificToInstallment = false;
-        	 LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.DUE_DATE.getValue(),
-        			 nextPossibleRepaymentDate.toDate(), emiAmount, rescheduledRepaymentDate, isSpecificToInstallment,
this, LoanStatus.ACTIVE.getValue());
-             this.loanTermVariations.add(loanVariationTerms);
+        if (rescheduledRepaymentDate != null && this.loanProduct.isMultiDisburseLoan())
{
+            final boolean isSpecificToInstallment = false;
+            LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.DUE_DATE.getValue(),
+                    nextPossibleRepaymentDate.toDate(), emiAmount, rescheduledRepaymentDate,
isSpecificToInstallment, this,
+                    LoanStatus.ACTIVE.getValue());
+            this.loanTermVariations.add(loanVariationTerms);
         }
 
         if (isRepaymentScheduleRegenerationRequiredForDisbursement(actualDisbursementDate)
|| recalculateSchedule || isEmiAmountChanged) {
@@ -4771,7 +4773,7 @@ public class Loan extends AbstractPersistable<Long> {
     }
 
     public ChangedTransactionDetail updateDisbursementDateAndAmountForTranche(final LoanDisbursementDetails
disbursementDetails,
-            final JsonCommand command,final Map<String, Object> actualChanges, final
ScheduleGeneratorDTO scheduleGeneratorDTO, 
+            final JsonCommand command, final Map<String, Object> actualChanges, final
ScheduleGeneratorDTO scheduleGeneratorDTO,
             final AppUser currentUser) {
         final Locale locale = command.extractLocale();
         validateAccountStatus(LoanEvent.LOAN_EDIT_MULTI_DISBURSE_DATE);
@@ -4965,8 +4967,8 @@ public class Loan extends AbstractPersistable<Long> {
             for (LoanTransaction loanTransaction : allNonContraTransactionsPostDisbursement)
{
                 copyTransactions.add(LoanTransaction.copyTransactionProperties(loanTransaction));
             }
-            loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
copyTransactions,
-                    getCurrency(), this.repaymentScheduleInstallments, charges());
+            loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
copyTransactions, getCurrency(),
+                    this.repaymentScheduleInstallments, charges());
 
             updateLoanSummaryDerivedFields();
         }
@@ -5551,11 +5553,11 @@ public class Loan extends AbstractPersistable<Long> {
         actualDisbursementDate = lastTransactionDate;
         updateLoanToLastDisbursalState(actualDisbursementDate);
         for (Iterator<LoanTermVariations> iterator = this.loanTermVariations.iterator();
iterator.hasNext();) {
-        	LoanTermVariations loanTermVariations = iterator.next();
-			if (loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate)) {
-				iterator.remove();
-			}
-		}
+            LoanTermVariations loanTermVariations = iterator.next();
+            if (loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate)) {
+                iterator.remove();
+            }
+        }
         reverseExistingTransactionsTillLastDisbursal(actualDisbursementDate);
         loan.recalculateScheduleFromLastTransaction(scheduleGeneratorDTO, existingTransactionIds,
existingReversedTransactionIds,
                 currentUser);
@@ -5638,11 +5640,11 @@ public class Loan extends AbstractPersistable<Long> {
     }
 
     public int fetchNumberOfInstallmensAfterExceptions() {
-        if(this.repaymentScheduleInstallments.size() > 0){
+        if (this.repaymentScheduleInstallments.size() > 0) {
             int numberOfInstallments = 0;
             for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments)
{
-                if(!installment.isRecalculatedInterestComponent()){
-                    numberOfInstallments++; 
+                if (!installment.isRecalculatedInterestComponent()) {
+                    numberOfInstallments++;
                 }
             }
             return numberOfInstallments;
@@ -5653,27 +5655,27 @@ public class Loan extends AbstractPersistable<Long> {
     public void setExpectedFirstRepaymentOnDate(Date expectedFirstRepaymentOnDate) {
         this.expectedFirstRepaymentOnDate = expectedFirstRepaymentOnDate;
     }
-    
+
     /*
- 	* get the next repayment date for rescheduling at the time of disbursement
- 	*/
-     public LocalDate getNextPossibleRepaymentDateForRescheduling(){
-     	Set<LoanDisbursementDetails> loanDisbursementDetails = this.disbursementDetails;
-     	LocalDate nextRepaymentDate = new LocalDate();
-     	for(LoanDisbursementDetails loanDisbursementDetail : loanDisbursementDetails){
-     		if(loanDisbursementDetail.actualDisbursementDate() == null){
-     			for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments)
{
- 		            if (installment.getDueDate().isEqual(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
|| 
- 		            		installment.getDueDate().isAfter(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())

- 		            		&& installment.isNotFullyPaidOff()) {
- 		            	nextRepaymentDate = installment.getDueDate();
- 		                break;
- 		            }   
- 		        }
- 			 break;
-     		}
-     	}
- 		return nextRepaymentDate;
-     }
+     * get the next repayment date for rescheduling at the time of disbursement
+     */
+    public LocalDate getNextPossibleRepaymentDateForRescheduling() {
+        Set<LoanDisbursementDetails> loanDisbursementDetails = this.disbursementDetails;
+        LocalDate nextRepaymentDate = new LocalDate();
+        for (LoanDisbursementDetails loanDisbursementDetail : loanDisbursementDetails) {
+            if (loanDisbursementDetail.actualDisbursementDate() == null) {
+                for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments)
{
+                    if (installment.getDueDate().isEqual(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
+                            || installment.getDueDate().isAfter(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
+                            && installment.isNotFullyPaidOff()) {
+                        nextRepaymentDate = installment.getDueDate();
+                        break;
+                    }
+                }
+                break;
+            }
+        }
+        return nextRepaymentDate;
+    }
 
 }


Mime
View raw message