Author: jpepin Date: 2010-05-20 17:12:37 +0200 (Thu, 20 May 2010) New Revision: 2903 Url: http://chorem.org/repositories/revision/lima/2903 Log: Tri des donn?\195?\169es plan des comptes en ordre lexicographique, tri des donn?\195?\169es sur tableau des entr?\195?\169es. Ajout r?\195?\168gle sur modification des entr?\195?\169es. Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -68,7 +68,7 @@ * @param topiaTransaction * @throws LimaException */ - public void updateEntryRules(Entry entry, TopiaContext topiaTransaction) throws LimaException; + public void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException; /** * Financialperiod/entrybook rules Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -32,6 +32,7 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ejb.AccountServiceImpl; +import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.Entry; @@ -40,6 +41,7 @@ import org.chorem.lima.entity.EntryDAO; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.FinancialTransactionDAO; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.nuiton.topia.TopiaContext; @@ -107,26 +109,47 @@ } } + /** + * Rules on update entry : + * + * Two case : + * - first, the entry belong to a blocked financialperiod + * - second, the actual entry belong to a blocked closedPeriodicEntryBook + * - third, the new choice entrybook belong to a blocked closedPeriodicEntryBook + */ @Override - public void updateEntryRules(Entry entry, TopiaContext topiaTransaction) throws LimaException { + public void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException { + //first case if (entry.getFinancialTransaction().getFinancialPeriod().getLocked()){ - throw new LimaBusinessException("The financial period is blocked"); + throw new LimaBusinessException("1 - Can't update entry : The financial period is blocked"); } - ClosedPeriodicEntryBook closedPeriodicEntryBook = null; try { - EntryBook entryBook = entry.getEntryBook(); + //Get finacialperiodservice + FinancialPeriodService financialPeriodService = + (FinancialPeriodService) map.get(FinancialPeriodService.class); + if (financialPeriodService == null){ + financialPeriodService = new FinancialPeriodServiceImpl(); + } + FinancialPeriod financialPeriod = entry.getFinancialTransaction().getFinancialPeriod(); - FinancialPeriodService financialPeriodService = (FinancialPeriodService) map.get(FinancialPeriodService.class); + //second case + ClosedPeriodicEntryBook closedPeriodicEntryBook = + financialPeriodService.getClosedPeriodicEntryBook(entryOld.getEntryBook(), financialPeriod); + if (closedPeriodicEntryBook.getLocked()){ + throw new LimaBusinessException("2 - Can't update entry : financialperiod of this entrybook is closed"); + } - closedPeriodicEntryBook = - financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod); + //third case + ClosedPeriodicEntryBook closedPeriodicEntryBook2 = + financialPeriodService.getClosedPeriodicEntryBook(entry.getEntryBook(), financialPeriod); - // Check if closedperiodicentrybook is locked - if (closedPeriodicEntryBook.getLocked()){ - throw new LimaBusinessException("Can't update entry : financialperiod of this entrybook is closed"); + // Check 2 & 3 cases + if (closedPeriodicEntryBook2.getLocked()){ + throw new LimaBusinessException("3 - Can't update entry : financialperiod of this entrybook is closed"); } + } catch (LimaException eee) { doCatch(topiaTransaction, eee, log); @@ -201,6 +224,9 @@ for (EntryBook entryBook : entryBooks) { FinancialPeriodService financialPeriodService = (FinancialPeriodService) map.get(FinancialPeriodService.class); + if (financialPeriodService == null){ + financialPeriodService = new FinancialPeriodServiceImpl(); + } if(financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod).getLocked()){ closedEntryBooks.add(entryBook); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -197,9 +197,11 @@ try { // Get all closedperiod between for the period and entrybook - Date endDate = closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(); + Date endDate = closedPeriodicEntryBook. + getFinancialPeriod().getBeginDate(); endDate = DateUtils.addMonths(endDate, -1); - Date beginDate = closedPeriodicEntryBook.getFinancialPeriod().getFiscalPeriod().getBeginDate(); + Date beginDate = closedPeriodicEntryBook. + getFinancialPeriod().getFiscalPeriod().getBeginDate(); EntryBook entryBook = closedPeriodicEntryBook.getEntryBook(); ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = @@ -208,33 +210,29 @@ String closedPeriodicEntryBookDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); - query.add(closedPeriodicEntryBookDateProperty+" BETWEEN :beginDate AND :endDate") + query.add(closedPeriodicEntryBookDateProperty + +" BETWEEN :beginDate AND :endDate") .add(ClosedPeriodicEntryBook.ENTRY_BOOK, entryBook) .addParam("beginDate", beginDate) .addParam("endDate", endDate); - closedPeriodicEntryBooks.addAll(closedPeriodicEntryBookDAO.findAllByQuery(query)); - for (ClosedPeriodicEntryBook closedPeriodicEntryBook2 : closedPeriodicEntryBooks) { - log.debug(closedPeriodicEntryBook2.getEntryBook()+" "+closedPeriodicEntryBook2.getFinancialPeriod()); - } + closedPeriodicEntryBooks. + addAll(closedPeriodicEntryBookDAO.findAllByQuery(query)); int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size(); - log.debug("nbBlockedClosedPeriodicEntryBooks "+nbClosedPeriodicEntryBooks); // Get all closed between for the period, entrybook and are blocked query.add(ClosedPeriodicEntryBook.LOCKED, true); closedPeriodicEntryBooks.clear(); - closedPeriodicEntryBooks.addAll(closedPeriodicEntryBookDAO.findAllByQuery(query)); - for (ClosedPeriodicEntryBook closedPeriodicEntryBook2 : closedPeriodicEntryBooks) { - log.debug(closedPeriodicEntryBook2.getEntryBook()+" "+closedPeriodicEntryBook2.getFinancialPeriod()); - } - int nbBlockedClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size(); - log.debug("nbBlockedClosedPeriodicEntryBooks "+nbBlockedClosedPeriodicEntryBooks); + closedPeriodicEntryBooks. + addAll(closedPeriodicEntryBookDAO.findAllByQuery(query)); + int nbBlockedClosedPeriodicEntryBooks = + closedPeriodicEntryBooks.size(); //Check if the fiscal period to block is the oldest if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks){ throw new LimaBusinessException( - "The previous financial periods for this entrybook must be blocked before this."); + "The previous financial periods for this entrybook must be blocked before this."); } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -22,6 +22,7 @@ import static org.nuiton.i18n.I18n._; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.ListIterator; @@ -34,6 +35,7 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.utils.AccountComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.LimaCallaoDAOHelper; @@ -195,6 +197,8 @@ LimaCallaoDAOHelper.getAccountDAO(transaction); List<Account> accounts = accountDAO.findAll(); accountsList.addAll(accounts); + Collections.sort(accountsList, new AccountComparator()); + } catch (TopiaException ex) { doCatch(transaction, ex, log); @@ -234,8 +238,9 @@ query.add("masterAccount = :value or generalLedger = :value") .addParam("value", masterAccount); } + accountsList.addAll(accountDAO.findAllByQuery(query)); + Collections.sort(accountsList, new AccountComparator()); - accountsList.addAll(accountDAO.findAllByQuery(query)); } catch (TopiaException ex) { doCatch(transaction, ex, log); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -58,9 +58,11 @@ private TopiaContext rootContext; - protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl(); + protected FinancialTransactionServiceImpl financialTransactionService = + new FinancialTransactionServiceImpl(); - protected FinancialPeriodServiceImpl financialPeriodService = new FinancialPeriodServiceImpl(); + protected FinancialPeriodServiceImpl financialPeriodService = + new FinancialPeriodServiceImpl(); protected AccountingRules accountingRules; @@ -111,7 +113,8 @@ for (FinancialPeriod financialPeriod : financialPeriodService.getUnblockedFinancialPeriods()) { //new closed periodic entrybook - ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); + ClosedPeriodicEntryBook closedPeriodicEntryBook = + new ClosedPeriodicEntryBookImpl(); // set entrybook closedPeriodicEntryBook.setEntryBook(entryBook); // set financial period @@ -144,7 +147,8 @@ transaction = rootContext.beginTransaction(); // check if entrybook with is name already exist - EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction); + EntryBookDAO EntryBookDAO = + LimaCallaoDAOHelper.getEntryBookDAO(transaction); List<EntryBook> EntryBooks = EntryBookDAO.findAll(); EntryBooksList.addAll(EntryBooks); @@ -174,7 +178,8 @@ // TODO move it into JTA transaction = rootContext.beginTransaction(); - EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction); + EntryBookDAO entryBookDAO = + LimaCallaoDAOHelper.getEntryBookDAO(transaction); // creation du EntryBook entryBookDAO.update(entryBook); @@ -211,7 +216,8 @@ accountingRules.removeEntryBookRules(entryBook, topiaTransaction); //delete - EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction); + EntryBookDAO EntryBookDAO = + LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction); EntryBookDAO.delete(entryBook); // commit 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-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -21,7 +21,7 @@ import static org.nuiton.i18n.I18n._; -import java.util.Date; +import java.util.Collections; import java.util.List; import javax.ejb.Stateless; @@ -29,10 +29,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountingRules; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.FinancialTransactionService; +import org.chorem.lima.business.utils.AccountComparator; import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryDAO; @@ -40,6 +43,7 @@ import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FinancialTransactionDAO; +import org.hsqldb.lib.Sort; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; @@ -196,7 +200,7 @@ @Override public List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException { - List<FinancialTransaction> transactions = null; + List<FinancialTransaction> financialTransactions = null; TopiaContext topiaTransaction = null; try { topiaTransaction = rootContext.beginTransaction(); @@ -213,10 +217,10 @@ if (financialPeriod != null) { query.add("financialPeriod", financialPeriod); } - transactions = transactionDAO.findAllByQuery(query); + financialTransactions = transactionDAO.findAllByQuery(query); //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION - for (FinancialTransaction financialTransaction : transactions) { + for (FinancialTransaction financialTransaction : financialTransactions) { for (Entry entry : financialTransaction.getEntry()) { entry.getEntryBook(); @@ -233,7 +237,7 @@ doFinally(topiaTransaction, log); } - return transactions; + return financialTransactions; } @@ -326,11 +330,25 @@ // TODO move it into JTA topiaContext = rootContext.beginTransaction(); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + + Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId()); + //check rules - accountingRules.updateEntryRules(entry, topiaContext); - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - //delete - entryDAO.update(entry); + accountingRules.updateEntryRules(entry, entryOld, topiaContext); + + //TODO PEPIN 20100520 conflict object already instanciate + entryOld.setAccount(entry.getAccount()); + entryOld.setAmount(entry.getAmount()); + entryOld.setDebit(entry.getDebit()); + entryOld.setDescription(entry.getDescription()); + entryOld.setEntryBook(entry.getEntryBook()); + entryOld.setFinancialTransaction(entry.getFinancialTransaction()); + entryOld.setVoucher(entry.getVoucher()); + entryOld.setPosition(entry.getPosition()); + entryOld.setLettering(entry.getLettering()); + //update + entryDAO.update(entryOld); // commit topiaContext.commitTransaction(); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -21,7 +21,6 @@ import static org.nuiton.i18n.I18n._; -import java.util.Collection; import java.util.List; import javax.ejb.Stateless; @@ -33,8 +32,6 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; - -import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodDAO; import org.chorem.lima.entity.FiscalPeriod; @@ -44,9 +41,8 @@ import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; -import org.nuiton.topia.framework.TopiaQuery; -import org.nuiton.topia.framework.TopiaQuery.Op; + /** * Gestion des exercices. * Un exercice ne peut être supprimée et débloquée après cloture. @@ -59,9 +55,6 @@ private static final Log log = LogFactory.getLog(FiscalPeriodServiceImpl.class); private static TopiaContext rootContext; - - private FinancialPeriodServiceImpl financialPeriodService = - new FinancialPeriodServiceImpl(); protected AccountingRules accountingRules; Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java (rev 0) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -0,0 +1,32 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.business.utils; + +import java.util.Comparator; + +import org.chorem.lima.entity.Account; + +public class AccountComparator implements Comparator<Account>{ + + @Override + public int compare(Account o1, Account o2) { + return o1.getAccountNumber().compareTo(o2.getAccountNumber()); + } + +} Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java (rev 0) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -0,0 +1,32 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.business.utils; + +import java.util.Comparator; + +import org.chorem.lima.entity.Entry; + +public class EntryComparator implements Comparator<Entry>{ + + @Override + public int compare(Entry o1, Entry o2) { + return o1.getTopiaId().compareTo(o2.getTopiaId()); + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -313,7 +313,7 @@ public void showFinancialPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialPeriodView financialPeriodView = new FinancialPeriodView(mainView); - mainView.showTab(_("lima.financialperiod.management"), financialPeriodView); + mainView.showTab(_("lima.charts.financialperiod"), financialPeriodView); } /** Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -118,7 +118,6 @@ @Override public Object getChild(Object parent, int index) { - log.debug("GETCHILD_BEGIN"); Object result = null; if (parent == getRoot()) { try { @@ -143,7 +142,6 @@ e.printStackTrace(); } } - log.debug("GETCHILD_END"); return result; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -85,7 +85,6 @@ List<Account> result = new ArrayList<Account>(); try { result = accountService.getAllAccounts(); - Collections.sort(result, new AccountComparator()); } catch (LimaException eee) { // TODO Auto-generated catch block Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -1,32 +0,0 @@ -/* *##% Lima Swing - * Copyright (C) 2008 - 2010 CodeLutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * ##%*/ - -package org.chorem.lima.ui.combobox; - -import java.util.Comparator; - -import org.chorem.lima.entity.Account; - -public class AccountComparator implements Comparator<Account>{ - - @Override - public int compare(Account o1, Account o2) { - return o1.getAccountNumber().compareTo(o2.getAccountNumber()); - } - -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -1,40 +0,0 @@ -/* *##% Lima Swing - * Copyright (C) 2008 - 2010 CodeLutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * ##%*/ - -package org.chorem.lima.ui.financialperiod; - -import java.util.Comparator; - -import org.chorem.lima.entity.ClosedPeriodicEntryBook; - -public class ClosedPeriodicEntryBookComparator implements Comparator<ClosedPeriodicEntryBook>{ - - @Override - public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) { - - if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == -1) { - return -1; - } else if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == 1) { - return 1; - } else { - return 0; - } - - } - -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -22,7 +22,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.swing.table.AbstractTableModel; @@ -53,7 +52,8 @@ /** serialVersionUID. */ private static final long serialVersionUID = 77027335135838258L; - private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); + private static final Log log = + LogFactory.getLog(FinancialPeriodTableModel.class); /** services */ protected FiscalPeriodService fiscalPeriodService; @@ -64,9 +64,12 @@ protected List<ClosedPeriodicEntryBook> cacheDataList; public FinancialPeriodTableModel() { - fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService(); - entryBookService = LimaServiceFactory.getInstance().getEntryBookService(); - financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService(); + fiscalPeriodService = + LimaServiceFactory.getInstance().getFiscalPeriodService(); + entryBookService = + LimaServiceFactory.getInstance().getEntryBookService(); + financialPeriodService = + LimaServiceFactory.getInstance().getFinancialPeriodService(); } @@ -137,7 +140,8 @@ if (closedPeriodicEntryBook != null){ EntryBook entryBook = closedPeriodicEntryBook.getEntryBook(); - FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod(); + FinancialPeriod financialPeriod = + closedPeriodicEntryBook.getFinancialPeriod(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMMM yyyy"); @@ -164,20 +168,22 @@ } public void getDataList(){ - List<ClosedPeriodicEntryBook> results = new ArrayList<ClosedPeriodicEntryBook>(); + List<ClosedPeriodicEntryBook> results = + new ArrayList<ClosedPeriodicEntryBook>(); try { - results = financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod(); + results = financialPeriodService. + getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod(); } catch (LimaException eee){ if (log.isDebugEnabled()){ log.debug("Can't get closedperiodicentrybook list", eee ); } } - //Collections.sort(results, new ClosedPeriodicEntryBookComparator()); cacheDataList=results; } public void blockFinancialPeriod(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException { - financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook); + financialPeriodService. + blockClosedPeriodicEntryBook(closedPeriodicEntryBook); fireTableDataChanged(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-05-20 15:12:37 UTC (rev 2903) @@ -39,7 +39,7 @@ <row fill="horizontal" weightx="1" weighty="0" anchor="center"> <cell> - <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/> + <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> </cell> <cell> <JComboBox id="fiscalPeriodComboBox" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-05-19 16:38:02 UTC (rev 2902) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-05-20 15:12:37 UTC (rev 2903) @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -35,6 +36,7 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.FinancialTransactionService; +import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; @@ -70,7 +72,7 @@ .getLog(FinancialTransactionTableModel.class); /** Transaction service. */ - protected final FinancialTransactionService transactionService; + protected final FinancialTransactionService financialTransactionService; /** EntryBook service. */ protected final EntryBookService entryBookService; @@ -94,8 +96,7 @@ */ public FinancialTransactionTableModel() { /* Services */ - // recordService = LimaServiceFactory.getInstance().getRecordService(); - transactionService = LimaServiceFactory.getInstance() + financialTransactionService = LimaServiceFactory.getInstance() .getTransactionService(); entryBookService = LimaServiceFactory.getInstance(). getEntryBookService(); @@ -114,11 +115,13 @@ List<Object> results = new ArrayList<Object>(); try { List<FinancialTransaction> financialtransactions = - transactionService.getAllFinancialTransactionsForFinancialPeriod( + financialTransactionService.getAllFinancialTransactionsForFinancialPeriod( selectedFinancialPeriod); for (FinancialTransaction financialtransaction : financialtransactions) { results.add(financialtransaction); - results.addAll(financialtransaction.getEntry()); + List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); + Collections.sort(entries, new EntryComparator()); + results.addAll(entries); } } catch (LimaException eee) { @@ -371,7 +374,7 @@ // set date to the financial transaction financialTransaction.setTransactionDate(transactionDate); // create it - transactionService.createFinancialTransaction(financialTransaction); + financialTransactionService.createFinancialTransaction(financialTransaction); //on recharge la liste cacheDataList = getDataList(); int row = getDataList().indexOf(financialTransaction); @@ -403,7 +406,7 @@ } //create it entry.setFinancialTransaction(currentTransaction); - transactionService.createEntry(entry); + financialTransactionService.createEntry(entry); //on recharge la liste cacheDataList = getDataList(); fireTableDataChanged(); @@ -468,7 +471,7 @@ } // notify service for modification try { - transactionService. + financialTransactionService. updateFinancialTransaction(currentFinancialTransaction); } catch (LimaException e) { if (log.isDebugEnabled()){ @@ -504,7 +507,7 @@ break; } try { - transactionService.updateEntry(currentEntry); + financialTransactionService.updateEntry(currentEntry); } catch (LimaException e) { if (log.isDebugEnabled()){ log.debug("Can't update entry", e); @@ -545,11 +548,11 @@ if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = (FinancialTransaction)currentRow; - transactionService.removeFinancialTransaction(currentTransaction); + financialTransactionService.removeFinancialTransaction(currentTransaction); } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry)currentRow; - transactionService.removeEntry(currentEntry); + financialTransactionService.removeEntry(currentEntry); } //on recharge la liste cacheDataList = getDataList();