fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edca...@apache.org
Subject [fineract] branch 1.4.0 updated: FINERACT-1141: Backport FINERACT-1135 to 1.4.0 Error at Loan Repayments - SQLSyntaxErrorException
Date Fri, 04 Sep 2020 15:53:43 GMT
This is an automated email from the ASF dual-hosted git repository.

edcable pushed a commit to branch 1.4.0
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/1.4.0 by this push:
     new f5757a7  FINERACT-1141: Backport FINERACT-1135 to 1.4.0 Error at Loan Repayments
- SQLSyntaxErrorException
     new ee99f30  Merge pull request #1314 from vidakovic/feature/FINERACT-1141
f5757a7 is described below

commit f5757a7b115787e81cd136c39ba0ba3bec25ddc4
Author: Aleksandar Vidakovic <cheetah@monkeysintown.com>
AuthorDate: Thu Sep 3 09:16:35 2020 +0200

    FINERACT-1141: Backport FINERACT-1135 to 1.4.0 Error at Loan Repayments - SQLSyntaxErrorException
---
 .../service/LoanReadPlatformServiceImpl.java       | 43 +++++++++++-----------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
index 87ec1a0..a1eb9d7 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
@@ -431,7 +431,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
         this.context.authenticatedUser();
 
         RepaymentTransactionTemplateMapper mapper = new RepaymentTransactionTemplateMapper();
-        String sql = "select " + mapper.schema() + " where l.id =?";
+        String sql = "select " + mapper.schema();
         LoanTransactionData loanTransactionData = this.jdbcTemplate.queryForObject(sql, mapper,
LoanTransactionType.REPAYMENT.getValue(),
                 loanId, loanId);
         final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
@@ -2176,35 +2176,36 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
         public String schema() {
             StringBuilder sqlBuilder = new StringBuilder();
 
-            sqlBuilder.append("if(max(tr.transaction_date)>ls.dueDate,max(tr.transaction_date),ls.dueDate)
as transactionDate,");
+            sqlBuilder.append("if(max(tr.transaction_date)>ls.dueDate,max(tr.transaction_date),ls.dueDate)
as transactionDate, ");
             sqlBuilder.append(
-                    "ls.principal_amount - IFNULL(ls.principal_writtenoff_derived,0) - IFNULL(ls.principal_completed_derived,0)
as principalDue,");
+                    "ls.principal_amount - IFNULL(ls.principal_writtenoff_derived,0) - IFNULL(ls.principal_completed_derived,0)
as principalDue, ");
             sqlBuilder.append(
-                    "ls.interest_amount - IFNULL(ls.interest_completed_derived,0) - IFNULL(ls.interest_waived_derived,0)
- IFNULL(ls.interest_writtenoff_derived,0) as interestDue,");
+                    "ls.interest_amount - IFNULL(ls.interest_completed_derived,0) - IFNULL(ls.interest_waived_derived,0)
- IFNULL(ls.interest_writtenoff_derived,0) as interestDue, ");
             sqlBuilder.append(
-                    "ls.fee_charges_amount - IFNULL(ls.fee_charges_completed_derived,0) -
IFNULL(ls.fee_charges_writtenoff_derived,0) - IFNULL(ls.fee_charges_waived_derived,0) as feeDue,");
+                    "ls.fee_charges_amount - IFNULL(ls.fee_charges_completed_derived,0) -
IFNULL(ls.fee_charges_writtenoff_derived,0) - IFNULL(ls.fee_charges_waived_derived,0) as feeDue,
");
             sqlBuilder.append(
-                    "ls.penalty_charges_amount - IFNULL(ls.penalty_charges_completed_derived,0)
- IFNULL(ls.penalty_charges_writtenoff_derived,0) - IFNULL(ls.penalty_charges_waived_derived,0)
as penaltyDue,");
+                    "ls.penalty_charges_amount - IFNULL(ls.penalty_charges_completed_derived,0)
- IFNULL(ls.penalty_charges_writtenoff_derived,0) - IFNULL(ls.penalty_charges_waived_derived,0)
as penaltyDue, ");
             sqlBuilder.append(
-                    " l.currency_code as currencyCode, l.currency_digits as currencyDigits,
l.currency_multiplesof as inMultiplesOf, rc.`name` as currencyName, ");
-            sqlBuilder.append(" rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code
as currencyNameCode ");
-            sqlBuilder.append(" FROM m_loan l");
+                    "l.currency_code as currencyCode, l.currency_digits as currencyDigits,
l.currency_multiplesof as inMultiplesOf, rc.`name` as currencyName, ");
+            sqlBuilder.append("rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code
as currencyNameCode ");
+            sqlBuilder.append("FROM m_loan l ");
             sqlBuilder.append(
-                    " LEFT JOIN m_loan_transaction tr ON tr.loan_id = l.id AND tr.transaction_type_enum
= ? and tr.is_reversed = 0");
-            sqlBuilder.append(" join m_currency rc on rc.`code` = l.currency_code ");
-            sqlBuilder.append(" JOIN m_loan_repayment_schedule ls ON ls.loan_id = l.id AND
ls.completed_derived = 0 ");
-            sqlBuilder.append(" join( ");
-            sqlBuilder.append(" (select min(ls.duedate) datedue,ls.loan_id from m_loan_repayment_schedule
ls  ");
-            sqlBuilder.append(" where ls.loan_id = ? and  ls.completed_derived = 0)");
-            sqlBuilder.append(" )asq on asq.loan_id = ls.loan_id and asq.datedue = ls.duedate");
-            sqlBuilder.append(" GROUP BY ls.duedate");
-            sqlBuilder.append(",ls.principal_amount,ls.principal_completed_derived,ls.principal_writtenoff_derived");
+                    "LEFT JOIN m_loan_transaction tr ON tr.loan_id = l.id AND tr.transaction_type_enum
= ? and tr.is_reversed = 0 ");
+            sqlBuilder.append("join m_currency rc on rc.`code` = l.currency_code ");
+            sqlBuilder.append("JOIN m_loan_repayment_schedule ls ON ls.loan_id = l.id AND
ls.completed_derived = 0 ");
+            sqlBuilder.append("join( ");
+            sqlBuilder.append("(select min(ls.duedate) datedue,ls.loan_id from m_loan_repayment_schedule
ls ");
+            sqlBuilder.append("where ls.loan_id = ? and ls.completed_derived = 0) )asq ");
+            sqlBuilder.append("on asq.loan_id = ls.loan_id and asq.datedue = ls.duedate ");
+            sqlBuilder.append("WHERE l.id = ? ");
+            sqlBuilder.append("GROUP BY ls.duedate, ");
+            sqlBuilder.append("ls.principal_amount,ls.principal_completed_derived,ls.principal_writtenoff_derived,
");
             sqlBuilder
-                    .append(",ls.interest_amount,ls.interest_completed_derived,ls.interest_waived_derived,ls.interest_writtenoff_derived");
+                    .append("ls.interest_amount,ls.interest_completed_derived,ls.interest_waived_derived,ls.interest_writtenoff_derived,
");
             sqlBuilder.append(
-                    ",ls.fee_charges_amount,ls.fee_charges_completed_derived, ls.fee_charges_writtenoff_derived,
ls.fee_charges_waived_derived");
+                    "ls.fee_charges_amount,ls.fee_charges_completed_derived, ls.fee_charges_writtenoff_derived,
ls.fee_charges_waived_derived, ");
             sqlBuilder.append(
-                    ",ls.penalty_charges_amount, ls.penalty_charges_completed_derived, ls.penalty_charges_writtenoff_derived,
ls.penalty_charges_waived_derived");
+                    "ls.penalty_charges_amount, ls.penalty_charges_completed_derived, ls.penalty_charges_writtenoff_derived,
ls.penalty_charges_waived_derived ");
             return sqlBuilder.toString();
 
         }


Mime
View raw message