r3576 - in trunk: lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/resources
Author: mallon Date: 2012-08-08 15:55:42 +0200 (Wed, 08 Aug 2012) New Revision: 3576 Url: http://chorem.org/repositories/revision/lima/3576 Log: refs #747 Correction conernant le probleme de format sur les BigDecimal, pour le montant recherche. Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java trunk/lima-swing/src/main/resources/log4j.properties Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-08-08 13:37:46 UTC (rev 3575) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-08-08 13:55:42 UTC (rev 3576) @@ -26,12 +26,16 @@ package org.chorem.lima.entity; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.lima.FinancialStatementWayEnum; import org.chorem.lima.beans.FinancialTransactionSearch; import org.hibernate.HibernateException; import org.nuiton.topia.TopiaException; import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.ParsePosition; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -47,6 +51,8 @@ */ public class FinancialTransactionDAOImpl<E extends FinancialTransaction> extends FinancialTransactionDAOAbstract<FinancialTransaction> { + private static final Log log = LogFactory.getLog(FinancialTransactionDAOImpl.class); + /** * FIXME echatellier, remove this method when implemented in topia * just overriden to use merge() instead of saveOrUpdate() @@ -274,7 +280,7 @@ List<Account> accounts) throws TopiaException { String query = "SELECT T FROM " + FinancialTransaction.class.getName() + " T"+ " LEFT JOIN T.entry AS E" + - " WHERE TRUE "; // to not manage first where in all condition + " WHERE 1=1 "; // to not manage first where in all condition List<Object> args = new ArrayList<Object>(); @@ -320,7 +326,7 @@ // accounts Account account = financialTransactionSearch.getAccount(); - String accountsList = financialTransactionSearch.getAccountList(); + //String accountsList = financialTransactionSearch.getAccountList(); if (account != null) { query += " AND E.account = :account"; args.add("account"); @@ -353,18 +359,26 @@ String operator = financialTransactionSearch.getOperator(); FinancialStatementWayEnum fStWayEnum = financialTransactionSearch.getAmountWayEnum(); if (amount != null) { + DecimalFormat decimalFormat = new DecimalFormat(); + BigDecimal amountBigDecimal = new BigDecimal(decimalFormat.parse(amount, new ParsePosition(0)).toString()); + if (log.isDebugEnabled()) { + log.debug("Value of first amount : " + amount); + log.debug("Value of first amount - BigDecimal : " + amountBigDecimal); + } if (amount2 != null) { - BigDecimal value1 = new BigDecimal(amount); - BigDecimal value2 = new BigDecimal(amount2); + BigDecimal secondAmountBigDecimal = new BigDecimal(decimalFormat.parse(amount2, new ParsePosition(0)).toString()); + if (log.isDebugEnabled()) { + log.debug("Value of second amount : " + secondAmountBigDecimal); + } query += " AND :amount <= E.amount AND E.amount <= :amount2"; args.add("amount"); - args.add(amount); + args.add(amountBigDecimal); args.add("amount2"); - args.add(amount2); + args.add(secondAmountBigDecimal); } else if (operator != null) { query += " AND E.amount " + operator + " :amount"; args.add("amount"); - args.add(amount); + args.add(amountBigDecimal); } switch (fStWayEnum) { case CREDIT: Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-08 13:37:46 UTC (rev 3575) +++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-08 13:55:42 UTC (rev 3576) @@ -49,4 +49,5 @@ log4j.logger.org.chorem.lima.business.ui.celleditor.BigDecimalTableCellEditor=DEBUG log4j.logger.org.chorem.lima.business.ui.financialtransaction.FinancialTransactionTableModel=DEBUG log4j.logger.org.chorem.lima.entity.EntryDAOImpl=DEBUG -log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionViewHandler=DEBUG \ No newline at end of file +log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionViewHandler=DEBUG +log4j.logger.org.chorem.lima.entity.FinancialTransactionDAOImpl=DEBUG \ No newline at end of file
participants (1)
-
mallon@users.chorem.org