r3013 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-callao/src/main/xmi lima-swing/src/main/assembly lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced lima-swing/src/main/resources/i18n
Author: jpepin Date: 2010-08-22 21:14:52 +0200 (Sun, 22 Aug 2010) New Revision: 3013 Url: http://chorem.org/repositories/revision/lima/3013 Log: Fonction recherche des ?\195?\169critures : affichage couple entr?\195?\169es/transactions ?\195?\169ditables Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialPeriodServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/assembly/bin.xml trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-08-22 19:14:52 UTC (rev 3013) @@ -20,12 +20,14 @@ package org.chorem.lima.business.ejb; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.ejb.Stateless; 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.chorem.lima.business.AccountingRules; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; @@ -590,44 +592,48 @@ @Override - public List<Entry> searchEntry(Date beginDate, Date endDate, String voucher, - String description, String letter, String accountsList, - Account account, EntryBook entryBook, - FinancialStatementWayEnum fStWayEnum, String operator, - String amount, String amount2) throws LimaException { - List<Entry> entries = null; + public List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException { + List<Object> result = new ArrayList<Object>(); + List<FinancialTransaction> financialTransactions = null; TopiaContext topiaContext = null; try { topiaContext = beginTransaction(); - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - TopiaQuery query = entryDAO.createQuery(); - String dateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); - String entryBookProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK); - String entryBookLabelProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK, EntryBook.LABEL); - String accountProperty = TopiaQuery.getProperty(Entry.ACCOUNT, Account.ACCOUNT_NUMBER); + FinancialTransactionDAO financialTransactionDAO = + LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); + TopiaQuery query = financialTransactionDAO.createQuery("T"); + + String dateProperty = TopiaQuery.getProperty(FinancialTransaction.TRANSACTION_DATE); + String accountNumberProperty = TopiaQuery.getProperty(Entry.ACCOUNT, Account.ACCOUNT_NUMBER); + query.addDistinct(); + query.addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true); //Load for lazy - query.addLoad(dateProperty) - .addLoad(entryBookLabelProperty) - .addLoad(accountProperty); + query.addLoad(FinancialTransaction.FINANCIAL_PERIOD); + Date beginDate = financialTransactionSearch.getBeginDate(); + Date endDate = financialTransactionSearch.getEndDate(); if (beginDate != null && endDate != null){ query.addBetween(dateProperty, beginDate, endDate); } else if (beginDate != null){ query.addEquals(dateProperty, beginDate); } + String voucher = financialTransactionSearch.getVoucher(); if (voucher != null){ - query.addWhere(Entry.VOUCHER, Op.LIKE, "%"+voucher+"%"); + query.addWhere("E.voucher", Op.LIKE, "%"+voucher+"%"); } + String description = financialTransactionSearch.getDescription(); if (description != null){ - query.addWhere(Entry.DESCRIPTION, Op.LIKE, "%"+description+"%"); + query.addWhere("E.description", Op.LIKE, "%"+description+"%"); } + String letter = financialTransactionSearch.getLetter(); if (letter != null){ - query.addWhere(Entry.LETTERING, Op.LIKE, "%"+letter+"%"); + query.addWhere("E.lettering", Op.LIKE, "%"+letter+"%"); } + Account account = financialTransactionSearch.getAccount(); + String accountsList = financialTransactionSearch.getAccountList(); if (account != null){ - query.addEquals(Entry.ACCOUNT, account); + query.addEquals("E.account", account); } else if (accountsList != null){ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); @@ -642,33 +648,51 @@ } } if (accounts.size() > 0){ - query.addWhere(accountProperty + " in (" + accountNumbers + ")"); + query.addWhere("E."+accountNumberProperty + " in (" + accountNumbers + ")"); } } + EntryBook entryBook = financialTransactionSearch.getEntryBook(); + String amount = financialTransactionSearch.getAmount(); + String amount2 = financialTransactionSearch.getAmount2(); + String operator = financialTransactionSearch.getOperator(); + FinancialStatementWayEnum fStWayEnum = financialTransactionSearch.getAmountWayEnum(); if (entryBook != null){ - query.addEquals(entryBookProperty, entryBook); + query.addEquals("T."+FinancialTransaction.ENTRY_BOOK, entryBook); } - else if (amount != null){ + if (amount != null){ if (amount2 != null){ BigDecimal value1 = new BigDecimal(amount); BigDecimal value2 = new BigDecimal(amount2); - query.addBetween(Entry.AMOUNT, value1, value2); + query.addBetween("E.amount", value1, value2); } else if (operator != null) { - query.addWhere(Entry.AMOUNT+" "+operator+" "+amount); + query.addWhere("E.amount"+" "+operator+" "+amount); } switch (fStWayEnum) { case CREDIT: - query.addEquals(Entry.DEBIT, false); + query.addEquals("E.debit", false); break; case DEBIT: - query.addEquals(Entry.DEBIT, true); + query.addEquals("E.debit", true); break; } } log.debug(query); - entries = entryDAO.findAllByQuery(query); + financialTransactions = financialTransactionDAO.findAllByQuery(query); + log.debug(financialTransactions); + + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + for (FinancialTransaction financialTransaction : financialTransactions) { + result.add(financialTransaction); + + TopiaQuery query2 = entryDAO.createQuery(); + query2.addEquals(Entry.FINANCIAL_TRANSACTION, financialTransaction); + //Load for lazy + query2.addLoad(Entry.ACCOUNT); + List<Entry> entries = entryDAO.findAllByQuery(query2); + result.addAll(entries); + } } catch (TopiaException ex) { doCatch(topiaContext, ex, log); @@ -676,7 +700,7 @@ finally { doFinally(topiaContext, log); } - return entries; + return result; } protected TopiaContext beginTransaction() throws TopiaException { Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2010-08-22 19:14:52 UTC (rev 3013) @@ -68,7 +68,7 @@ protected int port; - private static SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd"); + private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd"); public HttpServerServiceImpl() { path = LimaConfig.getInstance().getReportsDir(); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialPeriodServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialPeriodServiceLocal.java 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialPeriodServiceLocal.java 2010-08-22 19:14:52 UTC (rev 3013) @@ -41,7 +41,7 @@ public interface FinancialPeriodServiceLocal extends FinancialPeriodService { void createFinancialPeriodsWithTransaction(List<FinancialPeriod> financialPeriods, TopiaContext topiaContext) throws LimaException; - public void blockClosedPeriodicEntryBookWithTransaction(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaContext) throws LimaException; + void blockClosedPeriodicEntryBookWithTransaction(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaContext) throws LimaException; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2010-08-22 19:14:52 UTC (rev 3013) @@ -19,13 +19,10 @@ package org.chorem.lima.business.ejbinterface; -import java.util.Date; import java.util.List; -import java.util.Set; import javax.ejb.Remote; -import org.chorem.lima.FinancialStatementWayEnum; +import org.chorem.lima.beans.FinancialTransactionSearch; import org.chorem.lima.business.LimaException; -import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; @@ -82,5 +79,5 @@ void removeEntry(Entry entry) throws LimaException; - List<Entry> searchEntry(Date beginDate, Date endDate, String voucher, String description, String letter, String accountsList, Account account, EntryBook entryBook, FinancialStatementWayEnum fStWayEnum, String operator, String amount, String amount2) throws LimaException; + List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException; } Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/assembly/bin.xml =================================================================== --- trunk/lima-swing/src/main/assembly/bin.xml 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-swing/src/main/assembly/bin.xml 2010-08-22 19:14:52 UTC (rev 3013) @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<assembly xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.1.1.xsd"> +<assembly xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.1.1.xsd"> <id>bin</id> <formats> <format>zip</format> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-08-22 19:14:52 UTC (rev 3013) @@ -19,21 +19,16 @@ package org.chorem.lima.ui.financialtransactionsearch; import static org.nuiton.i18n.I18n._; - import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; import java.util.Date; import java.util.List; -import java.util.Set; - import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.beans.FinancialTransactionSearch; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ejbinterface.FinancialTransactionService; -import org.chorem.lima.business.utils.EntryComparator; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; @@ -57,8 +52,7 @@ * Last update : $Date: 2010-05-14 13:22:26 +0200 (ven. 14 mai 2010) $ * By : $Author: jpepin $ */ -public class FinancialTransactionSearchTableModel extends AbstractTableModel { - +public class FinancialTransactionSearchTableModel extends AbstractTableModel implements ServiceListener{ /** serialVersionUID. */ private static final long serialVersionUID = 3914954536809622358L; @@ -67,15 +61,67 @@ private static final Log log = LogFactory .getLog(FinancialTransactionSearchTableModel.class); + /** Transaction service. */ + protected final FinancialTransactionServiceMonitorable financialTransactionService; + /** selected financial period */ + protected FiscalPeriod selectedFiscalPeriod; + /** data cache */ - protected List<Entry> cacheDataList; + protected FinancialTransactionSearch financialTransactionSearch; + protected List<Object> cacheDataList; + - public void refresh(List<Entry> objects){ - cacheDataList = objects; + /** + * Model constructor. + * + * Just init service proxies. + */ + public FinancialTransactionSearchTableModel() { + /* Services */ + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addListener(this); + } + + /** + * Le model est une combinaison de Transaction/Entries. + * + * + * @return + */ + protected List<Object> getDataList(FinancialTransactionSearch financialTransactionSearch) { + List<Object> results = null; + //prevent to much result + if (financialTransactionSearch != null && (financialTransactionSearch.getVoucher() != null || financialTransactionSearch.getDescription() != null + || financialTransactionSearch.getLetter() != null || financialTransactionSearch.getAccountList() != null + || financialTransactionSearch.getAccount() != null || financialTransactionSearch.getEntryBook() != null + || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getOperator() != null) + || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getAmount2() != null))){ + try { + results = financialTransactionService.searchFinancialTransaction(financialTransactionSearch); + } + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.debug("Can't update model", eee); + } + + ErrorHelper.showErrorDialog("Can't get transaction list", eee); + } + } + + return results; + } + + + protected void refresh(FinancialTransactionSearch financialTransactionSearch) { + this.financialTransactionSearch = financialTransactionSearch; + cacheDataList = getDataList(financialTransactionSearch); fireTableDataChanged(); } + @Override public int getColumnCount() { return 9; @@ -174,67 +220,253 @@ // just prevent too much result if (cacheDataList != null) { - Entry currentRow = cacheDataList.get(row); - + result = cacheDataList.get(row); + + if (result instanceof FinancialTransaction) { + FinancialTransaction currentRow = (FinancialTransaction)result; + BigDecimal amountDebit = currentRow.getAmountDebit(); + BigDecimal amountCredit = currentRow.getAmountCredit(); + switch (column) { case 0: - result = currentRow.getFinancialTransaction().getTransactionDate(); + result = currentRow.getTransactionDate(); break; case 1: - EntryBook entryBook = - currentRow.getFinancialTransaction().getEntryBook(); - if (entryBook != null){ - result = entryBook.getCode(); + if (currentRow.getEntryBook() != null){ + result = currentRow.getEntryBook().getCode(); } else { result = null; } break; case 2: - result = currentRow.getVoucher(); + result = null; //entrybook break; + case 3: + result = null; // account + break; + case 4: + result = null; // description + break; + case 5 : + result = amountDebit; + break; + case 6: + result = amountCredit; + break; + case 7: + result = amountDebit.subtract(amountCredit); + break; + case 8: + result = null; + break; + } + } + else if (result instanceof Entry) { + Entry currentEntry = (Entry)result; + switch (column) { + case 0: + result = null; // date + break; + case 1 : // entry book + result = null; + break; + case 2: + result = currentEntry.getVoucher(); + break; case 3: // account - Account account = currentRow.getAccount(); - if (account != null){ - result = account.getAccountNumber(); + if (currentEntry.getAccount() != null){ + result = currentEntry.getAccount().getAccountNumber(); } else { result = null; } break; case 4: - result = currentRow.getDescription(); + result = currentEntry.getDescription(); break; case 5 : - result = currentRow.getDebit() ? currentRow.getAmount() : 0; + result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; break; case 6: - result = currentRow.getDebit() ? 0 : currentRow.getAmount(); + result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); break; case 7: - result = null; // balance + result = null; break; case 8: - result = currentRow.getLettering(); + result = currentEntry.getLettering(); break; } } + } return result; } + public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ + selectedFiscalPeriod = fiscalPeriod; + } + /** + * To set cells editable or not + * different condition for entry or financial transaction + */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - - return false; + boolean editableCell=false; + Object currentRow = cacheDataList.get(rowIndex); + // cells editable for the entry row, all cells exclude the date + if ((currentRow instanceof Entry) && !((columnIndex==0) || (columnIndex==1))) { + editableCell=true; + } + // cells editable for the financialtransaction row, no cells exclude the date + if ((currentRow instanceof FinancialTransaction) && ((columnIndex==0) || (columnIndex==1))){ + editableCell=true; + } + return editableCell; } + + /** + * @throws LimaException + */ + public void addEmptyEntry(Object value, int row) throws LimaException { + FinancialTransaction currentTransaction = null; + Object currentRow = cacheDataList.get(row); + Entry entry = new EntryImpl(); + entry.setAmount(new BigDecimal(0)); + //check if current row is a transaction or an entry + if (currentRow instanceof FinancialTransaction) { + currentTransaction = (FinancialTransaction)currentRow; + } + else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry)currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); + } + //create it + entry.setFinancialTransaction(currentTransaction); + financialTransactionService.createEntry(entry); + //on recharge la liste + cacheDataList = getDataList(financialTransactionSearch); + fireTableDataChanged(); + } + + /** + * to modifiy financialtransaction or entry + */ + @Override + public void setValueAt(Object value, int row, int column) { + int financialTransactionRow = 0; + // just prevent too much result + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof FinancialTransaction) { + FinancialTransaction currentFinancialTransaction = + (FinancialTransaction)currentRow; + switch (column) { + case 0: + //update + currentFinancialTransaction.setTransactionDate((Date)value); + break; + case 1 : + currentFinancialTransaction.setEntryBook((EntryBook)value); + break; + } + // notify service for modification + try { + financialTransactionService. + updateFinancialTransaction(currentFinancialTransaction); + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't update financial transaction", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + //update the financial transaction in entire + financialTransactionRow = + cacheDataList.indexOf(((FinancialTransaction) currentRow)); + } + else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry)currentRow; + switch (column) { + case 2 : + currentEntry.setVoucher((String)value); + break; + case 3: + currentEntry.setAccount((Account)value); + break; + case 4: + currentEntry.setDescription((String)value); + break; + case 5 : + currentEntry.setAmount((BigDecimal)value); + currentEntry.setDebit(true); + break; + case 6: + currentEntry.setAmount((BigDecimal)value); + currentEntry.setDebit(false); + break; + case 8: + currentEntry.setLettering((String)value); + break; + } + try { + financialTransactionService.updateEntry(currentEntry); + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't update entry", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + //update the financial transaction in entire + financialTransactionRow = + cacheDataList.indexOf(((Entry) currentRow). + getFinancialTransaction()); + } + //on recharge la liste + cacheDataList = getDataList(financialTransactionSearch); + fireTableDataChanged(); + } + public Object getElementAt(int row){ - Object currentRow = cacheDataList.get(row); return currentRow; } - + + + /** + * Delete selected row in table (could be transaction or entry). + * + * Called by model. + * @param Object, int + * @throws LimaException + */ + public void removeObject(Object object, int row) throws LimaException { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof FinancialTransaction) { + FinancialTransaction currentTransaction = + (FinancialTransaction)currentRow; + financialTransactionService.removeFinancialTransaction(currentTransaction); + } + else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry)currentRow; + financialTransactionService.removeEntry(currentEntry); + } + //on recharge la liste + cacheDataList = getDataList(financialTransactionSearch); + fireTableDataChanged(); + } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if ((serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") + || methodeName.contains("importAll")) && !methodeName.contains("search")){ + //on recharge la liste + cacheDataList = getDataList(financialTransactionSearch); + fireTableDataChanged(); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-08-22 19:14:52 UTC (rev 3013) @@ -18,11 +18,14 @@ package org.chorem.lima.ui.financialtransactionsearch; +import java.util.ArrayList; import java.util.Date; import java.util.List; 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.chorem.lima.beans.FinancialTransactionSearchImpl; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ejbinterface.FinancialTransactionService; @@ -59,19 +62,8 @@ /** Transaction service. */ protected final FinancialTransactionService financialTransactionService; - protected Date beginDate; - protected Date endDate; - protected String voucher; - protected String description; - protected String letter; - protected String accountsList; - protected Account account; - protected EntryBook entryBook; - protected FinancialStatementWayEnum amountWayEnum; - protected String operator; - protected String amount; - protected String amount2; - + /** data cache */ + protected FinancialTransactionSearch financialTransactionSearch; protected FinancialTransactionSearchViewHandler(FinancialTransactionSearchView view) { this.view = view; @@ -80,14 +72,17 @@ financialTransactionService = LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class); + + financialTransactionSearch = new FinancialTransactionSearchImpl(); + } public void setBeginDate(Date beginDate){ - this.beginDate = beginDate; + financialTransactionSearch.setBeginDate(beginDate); } public void setEndDate(Date endDate){ - this.endDate = endDate; + financialTransactionSearch.setEndDate(endDate); } public void setVoucher(String voucher){ @@ -96,7 +91,7 @@ if (!voucher.equals("")){ result = voucher; } - this.voucher=result; + financialTransactionSearch.setVoucher(result); } public void setDescription(String description){ @@ -104,7 +99,7 @@ if (!description.equals("")){ result = description; } - this.description=result; + financialTransactionSearch.setDescription(result); } public void setLetter(String letter){ @@ -112,11 +107,11 @@ if (!letter.equals("")){ result = letter; } - this.letter=result; + financialTransactionSearch.setLetter(result); } public String getAccountsList(){ - return this.accountsList; + return financialTransactionSearch.getAccountList(); } public void setAccountsList(String accountsList){ @@ -124,24 +119,24 @@ if (!accountsList.equals("")){ result = accountsList; } - this.accountsList=result; + financialTransactionSearch.setAccountList(result); } public Account getAccount(){ - return this.account; + return financialTransactionSearch.getAccount(); } public void setAccount(Account account){ - this.account=account; + financialTransactionSearch.setAccount(account); } public void setEntryBook(EntryBook entryBook){ - this.entryBook=entryBook; + financialTransactionSearch.setEntryBook(entryBook); } public String getAmount(){ - return this.amount; + return financialTransactionSearch.getAmount(); } public void setAmount(String amount){ @@ -149,11 +144,11 @@ if (!amount.equals("")){ result = amount; } - this.amount=result; + financialTransactionSearch.setAmount(result); } public String getAmount2(){ - return this.amount2; + return financialTransactionSearch.getAmount2(); } public void setAmount2(String amount2){ @@ -161,11 +156,11 @@ if (!amount2.equals("")){ result = amount2; } - this.amount2=result; + financialTransactionSearch.setAmount2(result); } public void setAmountWayEnum(FinancialStatementWayEnum amountWayEnum){ - this.amountWayEnum=amountWayEnum; + financialTransactionSearch.setAmountWayEnum(amountWayEnum); } public void setOperator(String operator){ @@ -173,39 +168,15 @@ if (!operator.equals("")){ result = operator; } - this.operator=result; + financialTransactionSearch.setOperator(result); } - + + public void refresh(){ tableModel = view.getFinancialTransactionSearchTableModel(); if (tableModel != null){ - log.debug(voucher+" " - +description+" "+letter+" "+accountsList+" " - +account+" "+entryBook+" "+amount); - tableModel.refresh(getDataList()); + tableModel.refresh(financialTransactionSearch); } } - protected List<Entry> getDataList() { - List<Entry> results = null; - //prevent to much result - if (voucher != null || description != null || letter != null || - accountsList != null || account != null || entryBook != null || - (amount != null && operator != null) || (amount != null && amount2 != null)){ - try { - results = financialTransactionService.searchEntry(beginDate, endDate, - voucher, description, letter, accountsList, account, - entryBook, amountWayEnum, operator, amount, amount2); - - } - catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); - } - ErrorHelper.showErrorDialog("Can't get transaction list", eee); - } - } - return results; - } - } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-08-22 19:14:52 UTC (rev 3013) @@ -19,20 +19,17 @@ package org.chorem.lima.ui.financialtransactionunbalanced; import static org.nuiton.i18n.I18n._; - import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; -import java.util.Set; - import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ejbinterface.FinancialTransactionService; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; @@ -57,7 +54,7 @@ * Last update : $Date: 2010-05-14 13:22:26 +0200 (ven. 14 mai 2010) $ * By : $Author: jpepin $ */ -public class FinancialTransactionUnbalancedTableModel extends AbstractTableModel { +public class FinancialTransactionUnbalancedTableModel extends AbstractTableModel implements ServiceListener{ /** serialVersionUID. */ private static final long serialVersionUID = 3914954536809622358L; @@ -67,7 +64,7 @@ .getLog(FinancialTransactionUnbalancedTableModel.class); /** Transaction service. */ - protected final FinancialTransactionService financialTransactionService; + protected final FinancialTransactionServiceMonitorable financialTransactionService; /** selected financial period */ protected FiscalPeriod selectedFiscalPeriod; @@ -88,6 +85,7 @@ financialTransactionService = LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class); + financialTransactionService.addListener(this); } /** @@ -430,8 +428,8 @@ getFinancialTransaction()); } //on recharge la liste - //TODO PEPIN 20100607 Get financial transaction of cachedatelist on replace it - fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); + cacheDataList = getDataList(); + fireTableDataChanged(); } } @@ -464,4 +462,10 @@ refresh(); } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-21 13:01:48 UTC (rev 3012) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-22 19:14:52 UTC (rev 3013) @@ -10,6 +10,8 @@ lima.account=Compte lima.account.label= lima.account.number= +lima.accountsreports.begincalendar= +lima.accountsreports.endcalendar= lima.action.commandline.help=Afficher l'aide en console lima.action.fullscreen=Plein Ecran lima.action.fullscreen.tip=Passer en mode plein \u00E9cran
participants (1)
-
jpepin@users.chorem.org