Author: mallon Date: 2012-07-03 16:36:31 +0200 (Tue, 03 Jul 2012) New Revision: 3486 Url: http://chorem.org/repositories/revision/lima/3486 Log: - Interface, via jaxx, r?\195?\169alis?\195?\169e; - Chargement du tableau des ?\195?\169critures, ?\195?\160 l'ouverture, selon les deux dates par d?\195?\169faut, le compte et le filtre sur le lettrage; - Mod?\195?\168le d'UI cr?\195?\169?\195?\169 : gestion de l'affichage des composants en cours; - Chargement de la date et du journal, auparavant absents, de chaque ?\195?\169criture dans le tableau; - Affichage selon le compte et les dates s?\195?\169lectionn?\195?\169es; - Affichage par d?\195?\169faut des non-lettr?\195?\169es et du compte 4; Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.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-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 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 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-07-03 14:36:31 UTC (rev 3486) @@ -1,7 +1,7 @@ /* * #%L * Lima business - * + * * $Id$ * $HeadURL$ * %% @@ -9,15 +9,15 @@ * %% * 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 3 of the + * published by the Free Software Foundation, either version 3 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 + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -42,7 +42,6 @@ import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.FinancialPeriodService; import org.chorem.lima.business.api.FinancialTransactionService; -import org.chorem.lima.business.api.FiscalPeriodService; import org.chorem.lima.business.api.OptionsService; import org.chorem.lima.business.api.ReportService; import org.chorem.lima.entity.Account; @@ -72,7 +71,7 @@ @EJB protected FinancialPeriodService financialPeriodService; - + @EJB protected ReportService reportService; @@ -119,6 +118,42 @@ return financialTransactions; } + /** Find the last three letters used + * and increment them + * */ + @Override + public String getNewLetters() throws LimaException { + String lastActualLetters = ""; + List<Entry> entries = new ArrayList<Entry>(); + + try { + EntryDAO entryDAO = getDaoHelper().getEntryDAO(); + lastActualLetters = entryDAO.findLetters().get(0); + } catch (Exception ex) { + throw new LimaException("Can't get new letters", ex); + } + + String nextThirdLetter ="A"; + String nextSecondLetter = "A"; + String nextFirstLetter = "A"; + + if (lastActualLetters.length() > 2 && lastActualLetters.charAt(2) != 'Z'){ + nextThirdLetter = incrementLetter(2, lastActualLetters); + }else if (lastActualLetters.length() > 1 && lastActualLetters.charAt(1) != 'Z'){ + nextSecondLetter = incrementLetter(1, lastActualLetters); + }else if (lastActualLetters.charAt(0) != 'Z'){ + nextFirstLetter = incrementLetter(0, lastActualLetters); + } + + return nextFirstLetter + nextSecondLetter + nextThirdLetter; + } + + /**Increment letter alphabetically*/ + protected String incrementLetter(int indiceLetter, String lastActualLetters){ + int valueLetter = lastActualLetters.charAt(indiceLetter); + return String.valueOf( (char) (valueLetter + 1)); + } + /** * Return the list of all financial transaction of a financial period. */ @@ -127,7 +162,7 @@ FinancialPeriod period) throws LimaException { return getAllFinancialTransactions(period, null); } - + /** * Return the list of all financial transaction of a fiscal period. */ @@ -155,7 +190,7 @@ try { FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO(); - + if (entryBook != null) { financialTransactions = transactionDAO.findAllByDates(financialPeriod.getBeginDate(), financialPeriod.getEndDate(), entryBook); @@ -229,31 +264,31 @@ */ @Override public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException { - + AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules(); try { - + //FIXME mallon 22/06/2012 : Revoir l'utilisation du rattachement à la session et celle des deux objets 'financialTransactionOld' //et 'financialTransaction' FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO(); FinancialTransaction financialTransactionOld = transactionDAO.findByTopiaId(financialTransaction.getTopiaId()); - accountingRules.updateFinancialTransactionDateRules(financialTransaction, financialTransactionOld); - - Date financialTransactionOldDate = financialTransactionOld.getTransactionDate(); - Date financialTransactionDate = financialTransaction.getTransactionDate(); - + accountingRules.updateFinancialTransactionDateRules(financialTransaction, financialTransactionOld); + + Date financialTransactionOldDate = financialTransactionOld.getTransactionDate(); + Date financialTransactionDate = financialTransaction.getTransactionDate(); + if (log.isDebugEnabled()) { - log.debug("Date de la transaction (Old) : " + financialTransactionOldDate); + log.debug("Date de la transaction (Old) : " + financialTransactionOldDate); } if (log.isDebugEnabled()) { - log.debug("Date de la transaction (New) : " + financialTransactionDate); + log.debug("Date de la transaction (New) : " + financialTransactionDate); } - + financialTransactionOld.setEntryBook(financialTransaction.getEntryBook()); financialTransactionOld.setTransactionDate(financialTransactionDate); - + transactionDAO.update(financialTransactionOld); } catch (TopiaException ex) { throw new LimaException("Can't update financial transaction", ex); @@ -272,11 +307,11 @@ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction); try { - + FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO(); FinancialTransaction financialTransactionOld = transactionDAO.findByTopiaId(financialTransaction.getTopiaId()); transactionDAO.delete(financialTransactionOld); - + } catch (Exception ex) { throw new LimaException("Can't remove financial transaction", ex); } 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 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-07-03 14:36:31 UTC (rev 3486) @@ -1,7 +1,7 @@ /* * #%L * Lima business - * + * * $Id$ * $HeadURL$ * %% @@ -9,15 +9,15 @@ * %% * 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 3 of the + * published by the Free Software Foundation, either version 3 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 + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -59,7 +59,6 @@ import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; -import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryImpl; @@ -131,11 +130,11 @@ // udpate result = fiscalPeriodDAO.update(result); - + } catch (TopiaException ex) { throw new LimaException("Can't create period", ex); } - + return result; } @@ -157,7 +156,7 @@ return result; } - + /** * return all blocked fiscal periods. */ @@ -194,12 +193,6 @@ return result; } - public String findLastActualLetters() throws LimaException { - List<FiscalPeriod> fiscalPeriods = getAllUnblockedFiscalPeriods(); - - return null; - } - @Override public FiscalPeriod getLastFiscalPeriod() throws LimaException { FiscalPeriod result = null; @@ -216,7 +209,7 @@ return result; } - + /** * to block a fiscal period * <p/> @@ -342,7 +335,7 @@ while (itr.hasNext()) { lastFPeriod = itr.next(); } - + if (lastFPeriod.getLocked()) { throw new LimaBusinessException(_("lima-business.fiscalperiod.previousfiscalperiodalreadyblocked")); } @@ -411,7 +404,7 @@ //Account class from 1 to 5 and only non zero amount if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6 && !report.getAmountSolde().equals(BigDecimal.ZERO)) { - //close accounts by removing amounts from all class 1 to 5 accounts + //close accounts by removing amounts from all class 1 to 5 accounts Entry beginEntry = new EntryImpl(); beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")"); beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher")); @@ -462,33 +455,33 @@ */ public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException { - + AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules(); - try { + try { try { //get entities with DAO - FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO(); - - // re-attach entities to current session - FiscalPeriod localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId()); - + FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO(); + + // re-attach entities to current session + FiscalPeriod localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId()); + //check rules - accountingRules.deleteFiscalPeriodRules(localFiscalPeriod); - + accountingRules.deleteFiscalPeriodRules(localFiscalPeriod); + //all "ClosedPeriodicEntryBooks" for the fiscal period ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO(); - List<ClosedPeriodicEntryBook> closedPeriodicEntryBookDAOList = closedPeriodicEntryBookDAO.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod); - + List<ClosedPeriodicEntryBook> closedPeriodicEntryBookDAOList = closedPeriodicEntryBookDAO.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod); + //delete closedPeriodicEntryBook before fiscal period for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookDAOList) { // fix : ObjectDeletedException: deleted object would be re-saved by cascade (Need to delete association between entryBook and financial period via closedPeriodEntityBook) closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook); - closedPeriodicEntryBookDAO.delete(closedPeriodicEntryBook); - } - - fiscalPeriodDAO.delete(localFiscalPeriod); - + closedPeriodicEntryBookDAO.delete(closedPeriodicEntryBook); + } + + fiscalPeriodDAO.delete(localFiscalPeriod); + } catch (TopiaException ex) { throw new LimaException("Can't find fiscal period", ex); } Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-07-03 14:36:31 UTC (rev 3486) @@ -1,7 +1,7 @@ /* * #%L * Lima business - * + * * $Id$ * $HeadURL$ * %% @@ -9,15 +9,15 @@ * %% * 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 3 of the + * published by the Free Software Foundation, either version 3 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 + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -25,6 +25,9 @@ package org.chorem.lima.business.api; +import java.util.Date; +import java.util.List; + import org.chorem.lima.beans.FinancialTransactionSearch; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Entry; @@ -33,9 +36,6 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; -import java.util.Date; -import java.util.List; - /** * Transaction service. * @@ -55,7 +55,7 @@ void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; - List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period) throws LimaException; + List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period) throws LimaException; List<FinancialTransaction> getAllFinancialTransactions(Date beginDate, Date endDate) throws LimaException; @@ -66,7 +66,7 @@ List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException; List<FinancialTransaction> getAllFinancialTransactions(FiscalPeriod period) throws LimaException; - + List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException; Entry createEntry(Entry entry) throws LimaException; @@ -74,4 +74,6 @@ void updateEntry(Entry entry) throws LimaException; void removeEntry(Entry entry) throws LimaException; + + String getNewLetters() throws LimaException; } Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-07-03 14:36:31 UTC (rev 3486) @@ -1,7 +1,7 @@ /* * #%L * Lima business - * + * * $Id$ * $HeadURL$ * %% @@ -9,15 +9,15 @@ * %% * 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 3 of the + * published by the Free Software Foundation, either version 3 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 + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -25,12 +25,12 @@ package org.chorem.lima.business.api; +import java.util.List; + import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FiscalPeriod; -import java.util.List; - /** * Fiscal period service. * @@ -53,12 +53,10 @@ FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException; FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException; - + void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException; void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear, EntryBook entryBook) throws LimaException; - - String findLastActualLetters()throws LimaException; } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-03 14:36:31 UTC (rev 3486) @@ -1,7 +1,7 @@ /* * #%L * Lima callao - * + * * $Id$ * $HeadURL$ * %% @@ -9,15 +9,15 @@ * %% * 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 3 of the + * published by the Free Software Foundation, either version 3 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 + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -35,7 +35,7 @@ /** * Requete generique qui recupere les entrees equilibrées portant entre * deux dates. - * + * * @param account account * @param beginDate begin date * @param endDate end date @@ -54,12 +54,12 @@ /** * Query for find entries for accountsreports and balancereports * Just exact and balanced transaction are calculated. - * + * * @param account account * @param beginDate begin date * @param endDate end date * @return entries - * @throws TopiaException + * @throws TopiaException */ public List<Entry> findAllEntryOfBalancedTransaction(Account account, Date beginDate, Date endDate) throws TopiaException { @@ -76,12 +76,12 @@ /** * Retourne la somme des entrées des transaction equilibrées entre * deux dates pour un compte donné. - * + * * @param account account * @param beginDate bebin date * @param endDate end date * @return list boolean,int (une ligne pour le debit true, une ligne pour le credit) - * @throws TopiaException + * @throws TopiaException */ public List<Object[]> getDebitCreditOfBalancedTransaction(Account account, Date beginDate, Date endDate) throws TopiaException { @@ -90,7 +90,7 @@ // concerne le compte " AND E.account = :account" + " GROUP BY E.debit"; - + List<Object[]> result = context.findAll(query, "beginDate", beginDate, "endDate", endDate, "account", account); return result; @@ -99,11 +99,11 @@ /** * Retourne les entrees des transaction equlibrées entre deux dates pour * un journal. - * + * * @param entryBook entry book * @param beginDate begin date * @param endDate end date - * @throws TopiaException + * @throws TopiaException */ public List<Entry> findAllEntryOfBalancedTransaction(EntryBook entryBook, Date beginDate, Date endDate) throws TopiaException { @@ -117,16 +117,24 @@ "endDate", endDate, "entryBook", entryBook); return entries; } - + + public List<String> findLetters() throws TopiaException{ + String query = "Select E.LETTERING FROM " + Entry.class.getName() + " E" + + " order by E.LETTERING desc"; + + List<String> letters = context.findAll(query); + return letters; + } + /** * Retourne la somme des entrées des transaction equilibrées entre * deux dates pour un journal donné. - * + * * @param entryBook entry book * @param beginDate bebin date * @param endDate end date * @return list boolean,int (une ligne pour le debit true, une ligne pour le credit) - * @throws TopiaException + * @throws TopiaException */ public List<Object[]> getDebitCreditOfBalancedTransaction(EntryBook entryBook, Date beginDate, Date endDate) throws TopiaException { @@ -135,20 +143,20 @@ // concerne le journal " AND E.financialTransaction.entryBook = :entryBook" + " GROUP BY E.debit"; - + List<Object[]> result = context.findAll(query, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook); return result; } - + /** * Retourne les entrees des transaction entre deux dates pour * un journal. - * + * * @param entryBook entry book * @param beginDate begin date * @param endDate end date - * @throws TopiaException + * @throws TopiaException */ public List<Entry> findAllEntryOfTransaction(EntryBook entryBook, Date beginDate, Date endDate) throws TopiaException { @@ -163,16 +171,16 @@ "endDate", endDate, "entryBook", entryBook); return entries; } - + /** * Retourne la somme des entrées des transaction entre * deux dates pour un journal donné. - * + * * @param entryBook entry book * @param beginDate bebin date * @param endDate end date * @return list boolean,int (une ligne pour le debit true, une ligne pour le credit) - * @throws TopiaException + * @throws TopiaException */ public List<Object[]> getDebitCreditOfTransaction(EntryBook entryBook, Date beginDate, Date endDate) throws TopiaException { @@ -184,7 +192,7 @@ // concerne le journal " AND E.financialTransaction.entryBook = :entryBook" + " GROUP BY E.debit"; - + List<Object[]> result = context.findAll(query, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook); return result; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-03 14:36:31 UTC (rev 3486) @@ -1,7 +1,7 @@ /* * #%L * Lima Swing - * + * * $Id$ * $HeadURL$ * %% @@ -9,15 +9,15 @@ * %% * 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 3 of the + * published by the Free Software Foundation, either version 3 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 + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -28,8 +28,6 @@ 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; @@ -40,12 +38,8 @@ import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.ImportService; -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; -import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; /** @@ -77,7 +71,7 @@ /** EndDate. */ protected Date selectedEndDate; - + protected List<Entry> entries; protected List<Date> datesEntree; protected List<String> entryBooks; @@ -93,33 +87,31 @@ */ public LetteringTableModel() { /* Services */ - financialTransactionService = - LimaServiceFactory.getService( - FinancialTransactionService.class); + financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); LimaServiceFactory.addServiceListener(FinancialTransactionService.class,this); LimaServiceFactory.addServiceListener(ImportService.class, this); } - + public List<Entry> getEntries(){ return entries; } - + public void updateEntries(List<Entry> entries,List<Date> datesEntree, List<String> entryBooks) { - + this.entries = entries; setDate(datesEntree); setJournal(entryBooks); - fireTableDataChanged(); + fireTableDataChanged(); } - + protected void setDate(List<Date> datesEntree){ this.datesEntree=datesEntree; } - + protected void setJournal(List<String> entryBooks){ this.entryBooks = entryBooks; } - + public void setSelectedBeginDate(Date date) { selectedBeginDate = date; } @@ -144,7 +136,7 @@ Entry result = entries.get(row); return result; } - + @Override public Class<?> getColumnClass(int column) { @@ -207,9 +199,9 @@ } @Override - public int getRowCount() { + public int getRowCount() { if (entries != null){ - return entries.size(); + return entries.size(); } return 0; } @@ -252,7 +244,7 @@ */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - + return false; } @@ -260,24 +252,32 @@ public Object getElementAt(int row) { return entries.get(row); } - - //add one entry + + /**add one entry*/ public void addEntry(Entry entry) { entries.add(entry); int row = entries.indexOf(entry); fireTableRowsInserted(row, row); } - //add a list of Entry + /**add a list of Entry*/ public void addEntries(List<Entry> entries) { for (Entry entry : entries){ addEntry(entry); - } + } } - + + /**update selected entries*/ + public void updateLettersSelectedEntries(int[] entries, String letters) { + for (int rowEntry : entries){ + getEntryAt(rowEntry).setLettering(letters); + } + fireTableDataChanged(); + } + /** to modifiy letter entry */ - @Override - public void setValueAt(Object value, int row, int column) { + /* @Override + public void setValueAt(Object value, int row, int column) {*/ //TODO /*int financialTransactionRow = 0; if (cacheDataList != null) { @@ -300,7 +300,7 @@ //on recharge la liste fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1); }*/ - } + //} @Override public void notifyMethod(String serviceName, String methodeName) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-03 14:36:31 UTC (rev 3486) @@ -64,12 +64,12 @@ <JPanel id="panelAccountComboBox"> <org.chorem.lima.ui.common.AccountComboBoxModel id="accountComboBoxModel"/> <JComboBox id="accountComboBox" model="{accountComboBoxModel}" - renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> + renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" + onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> <JButton id="backCount" text="lima.ui.account.buttonback" - onActionPerformed="handler.back(accountComboBox)"/> + onActionPerformed="handler.back(accountComboBox)"/> <JButton id="nextCount" text="lima.ui.account.buttonnext" - onActionPerformed="handler.next(accountComboBox)"/> + onActionPerformed="handler.next(accountComboBox)"/> </JPanel> </cell> <cell anchor="center" weightx="1"> @@ -81,7 +81,7 @@ </cell> <cell> <JXDatePicker id="pickerDebut" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> + onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> </cell> </row> <row> @@ -90,7 +90,7 @@ </cell> <cell> <JXDatePicker id="pickerFin" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> + onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> </cell> </row> </Table> @@ -102,7 +102,7 @@ <row> <cell> <JRadioButton id="lettredEntryCheckBox" buttonGroup="letteredCheckGroup" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> + onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> </cell> <cell> <JLabel text="lima.ui.lettering.checkLettredEntry"/> @@ -111,7 +111,7 @@ <row> <cell> <JRadioButton id="noLettredEntryCheckBox" selected="true" buttonGroup="letteredCheckGroup" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> + onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> </cell> <cell> <JLabel text="lima.ui.lettering.checkNoLettredEntry"/> @@ -120,7 +120,7 @@ <row> <cell> <JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> + onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/> </cell> <cell> <JLabel text="lima.ui.lettering.checkAll"/> @@ -150,11 +150,11 @@ </cell> <cell fill="horizontal" weightx="0.25"> <JTextField id="debitTexttField" editable="false" text="{getModelUi().getDebit()}" - focusable="false"/> + focusable="false"/> </cell> <cell fill="horizontal" weightx="0.25"> <JTextField id="creditTextField" editable="false" text="{getModelUi().getCredit()}" - focusable="false"/> + focusable="false"/> </cell> <cell fill="horizontal" weightx="0.25"> <JTextField id="soldeTextField" editable="false" text="{getModelUi().getSolde()}" @@ -171,10 +171,10 @@ <JPanel id="actionsPanel"> <JButton id="lettered" text="lima.ui.lettering.buttonLettered" enabled="{getModelUi().isLettrer()}" - onActionPerformed="handler.lettrer()"/> + onActionPerformed="handler.addLetter()"/> <JButton id="noLettered" text="lima.ui.lettering.buttonNoLettered" enabled="{getModelUi().isDelettrer()}" - onActionPerformed="handler.delettrer()"/> + onActionPerformed="handler.removeLetter()"/> </JPanel> </cell> </row> @@ -183,7 +183,8 @@ <JScrollPane> <LetteringTable id="table" sortable="false" rowHeight="22" - constructorParams="getTableModel()" + constructorParams="getTableModel()" + selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}" selectionModel="{modelUi}" /> </JScrollPane> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-03 11:54:09 UTC (rev 3485) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-03 14:36:31 UTC (rev 3486) @@ -1,7 +1,7 @@ /* * #%L * Lima Swing - * + * * $Id$ * $HeadURL$ * %% @@ -9,15 +9,15 @@ * %% * 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 3 of the + * published by the Free Software Foundation, either version 3 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 + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -88,21 +88,21 @@ public LetteringViewHandler(LetteringView view) { this.view = view; - + financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); accountService = LimaServiceFactory.getService(AccountService.class); financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); entryBookService = LimaServiceFactory.getService(EntryBookService.class); - } - + } + /** * Init all combo box in view. */ - public void init() { + public void init() { loadComboAndRows(); LetteringModelUI modelUi = view.getModelUi(); - modelUi.addPropertyChangeListener(LetteringModelUI.SELECTED_ENTRY_PROPERTY, new PropertyChangeListener() { + modelUi.addPropertyChangeListener(LetteringModelUI.SELECTED_ENTRY_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource(); @@ -110,59 +110,59 @@ loadCurrentSelection(modelUiPropChange, selectedEntry); } }); - + } - + public void loadComboAndRows(){ log.debug("loadComboAndRows"); - + List<Account> allAccounts = accountService.getAllAccounts(); - view.getAccountComboBoxModel().setObjects(allAccounts); - + view.getAccountComboBoxModel().setObjects(allAccounts); + log.debug("loadComboAndRows"); - + if (!allAccounts.isEmpty()) { - + view.getAccountComboBox().setSelectedItem(allAccounts.get(0)); - } - + } + if (log.isDebugEnabled()) { log.debug("1er item comptes : " + allAccounts.get(0)); } - - //By default, we have the beginning of the fiscal period (Or of current + + //By default, we have the beginning of the fiscal period (Or of current //date if no fiscal period) and the end of the current date FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); Date defaultDateBegFiscalPeriod; - + Calendar calendar = Calendar.getInstance(); int dernierJourMoisCourant = calendar.getActualMaximum(Calendar.DATE); int premierJourMoisCourant = calendar.getActualMinimum(Calendar.DATE); - + if (fiscalPeriod != null){ defaultDateBegFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod().getBeginDate(); }else{ - defaultDateBegFiscalPeriod = DateUtils.setDays(new Date(), premierJourMoisCourant); - } - - Date defaultDateEndCurrent = DateUtils.setDays(new Date(), dernierJourMoisCourant); - + defaultDateBegFiscalPeriod = DateUtils.setDays(new Date(), premierJourMoisCourant); + } + + Date defaultDateEndCurrent = DateUtils.setDays(new Date(), dernierJourMoisCourant); + if (log.isDebugEnabled()) { log.debug("Date de debut : " + defaultDateBegFiscalPeriod); log.debug("Date de fin : " + defaultDateEndCurrent); } - + view.getPickerDebut().setDate(defaultDateBegFiscalPeriod); view.getPickerFin().setDate(defaultDateEndCurrent); - + log.debug("Val select letter : " + view.getLetteredCheckGroup().getSelectedButton().getName()); - + //Load entry with the default dates, default account 4 and with no letter updateAllEntries(defaultDateBegFiscalPeriod, defaultDateEndCurrent, view.getAccountComboBoxModel().getSelectedItem(), view.getLetteredCheckGroup().getSelectedButton().getName()); } - + protected List<Entry> findAllEntries(Date selectedBeginDate, Date selectedEndDate, Object compte, String filtreLettre){ - + List<Entry> entries = new ArrayList<Entry>(); List<Entry> entriesAccount = new ArrayList<Entry>(); if (selectedBeginDate != null && selectedEndDate != null) { @@ -176,7 +176,7 @@ log.debug("entry.getLettering() : " + entry.getLettering()); log.debug("name radioButton : " + filtreLettre); //0 for lettered, 1 for no-lettered and 2 for all entries - if (compte.equals(entry.getAccount()) && ( (filtreLettre.equals("noLettredEntryCheckBox") & entry.getLettering() == null)) + if (compte.equals(entry.getAccount()) && ( (filtreLettre.equals("noLettredEntryCheckBox") & entry.getLettering() == null)) || (filtreLettre.equals("lettredEntryCheckBox") & entry.getLettering() != null) || filtreLettre.equals("allCheckBox")){ entriesAccount.add(entry); } @@ -187,41 +187,41 @@ } return entries; } - + public void updateAllEntries(Date selectedBeginDate, Date selectedEndDate, Object compte, String filtreLettre) { - + if (selectedBeginDate != null && selectedEndDate != null){ log.debug("updateAllEntries"); List<Entry> entries = findAllEntries(selectedBeginDate, selectedEndDate, compte, filtreLettre); List<String> journalEntrees = new ArrayList<String>(); List<Date> datesEntree = new ArrayList<Date>(); - + for (Entry entry : entries){ datesEntree.add(entry.getFinancialTransaction().getTransactionDate()); journalEntrees.add(entry.getFinancialTransaction().getEntryBook().getLabel()); } - + view.getTableModel().updateEntries(entries, datesEntree, journalEntrees); } } - + public void loadCurrentSelection(LetteringModelUI modelUi, Entry selectedEntry){ financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); - + boolean enableLettring = false; - boolean enableDelettring = false; - - if (selectedEntry != null){ + boolean enableDelettring = false; + + if (selectedEntry != null){ modelUi.setDebit(selectedEntry.getDebit() ? selectedEntry.getAmount() : BigDecimal.ZERO); modelUi.setCredit(selectedEntry.getDebit() ? BigDecimal.ZERO : selectedEntry.getAmount()); - + if (modelUi.getDebit().equals("0")){ modelUi.setSolde(modelUi.getCredit()); }else{ modelUi.setSolde(modelUi.getDebit()); } - modelUi.setSolde(modelUi.getSolde()); - if (selectedEntry.getLettering() != null && ! selectedEntry.getLettering().isEmpty()){ + modelUi.setSolde(modelUi.getSolde()); + if (selectedEntry.getLettering() != null && ! selectedEntry.getLettering().isEmpty()){ enableDelettring = true; }else{ enableLettring = true; @@ -230,28 +230,10 @@ modelUi.setLettrer(enableLettring); modelUi.setDelettrer(enableDelettring); } - - /**Add a group of three letters to n entries*/ - public void lettrer(){ - - - int[] entrieSelected = view.getTable().getSelectedRows(); - for (int rowEntry : entrieSelected){ - view.getTableModel().getEntryAt(rowEntry); - - } - - //String lastActualLetters = fiscalPeriodService.findLastActualLetters(); - } - - /**Remove a group of three letters to n entries*/ - public void delettrer(List<Entry> entries){ - - } - + /** * Select previous value in combo box. - * + * * @param comboBox combo box */ public void back(JComboBox comboBox) { @@ -264,7 +246,7 @@ /** * Select next value in combo box. - * + * * @param comboBox combo box */ public void next(JComboBox comboBox) { @@ -275,7 +257,7 @@ comboBox.setSelectedIndex(row + 1); } } - + public void setBeginDate(Date date) { view.getTableModel().setSelectedBeginDate(date); } @@ -284,49 +266,14 @@ view.getTableModel().setSelectedEndDate(date); } + /**Add a group of three letters to n entries*/ public void addLetter() { - /*Boolean valid = true; - - table = view.getTable(); - tableModel = view.getTableModel(); - - AddLetterForm addLetterForm = new AddLetterForm(); - JTextField newLetterTextField = addLetterForm.getNewLetterTextField(); - - try { - letter = financialTransactionService.getNewLetter(); - newLetterTextField.setText(letter.getCode()); - } catch (LimaException eee) { - log.error("Can't get new letter", eee); - } - - addLetterForm.setLocationRelativeTo(view); - addLetterForm.setVisible(true); - - //false = cancel Action - if (addLetterForm.validOk) { - Object object = addLetterForm.getRadioButtons().getSelectedValue(); - if (!(Boolean) object) { - JComboBox comboBox = addLetterForm.getLetterListComboBox(); - Object selectedObject = comboBox.getSelectedItem(); - if (selectedObject instanceof Letter) { - letter = (Letter) selectedObject; - } else { - DialogHelper.showMessageDialog(_("lima.entries.lettering.noletterselected")); - valid = false; - } - } - if (valid) { - //addLetters - int[] rows = table.getSelectedRows(); - for (int i : rows) { - tableModel.setLetter(i, letter); - } - tableModel.refresh(); - } - }*/ + String newLetters = financialTransactionService.getNewLetters(); + int[] entrieSelected = view.getTable().getSelectedRows(); + view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters); } + /**Remove a group of three letters to n entries*/ public void removeLetter() { //TODO //removeLetters @@ -336,7 +283,7 @@ } view.getTableModel().updateRows();*/ } - + @Override public void notifyMethod(String serviceName, String methodeName) { }