r2881 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/service lima-swing/src/main/java/org/chorem/lima/ui/transaction lima-swing/src/main/java/org/chorem/lima/ui/transaction/model lima-swing/src/main/java/org/chorem/lima/ui/transaction/table lima-swing/src/main/java/org/chorem/lima/widgets lima-swing/sr
Author: jpepin Date: 2010-04-30 13:21:57 +0200 (Fri, 30 Apr 2010) New Revision: 2881 Url: http://chorem.org/repositories/revision/lima/2881 Log: Modification d'entr?\195?\169e dans la fonction de saisie. Suppression des lazy false. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx Removed: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.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/FilesServiceImpl.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/xmi/accounting.properties trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -21,7 +21,9 @@ import java.util.List; +import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; +import org.nuiton.topia.TopiaException; /** * Entry book service. @@ -36,7 +38,7 @@ public interface EntryBookService { List<EntryBook> getAllEntryBooks() throws LimaException; - + void createEntryBook(EntryBook entryBook) throws LimaException; void updateEntryBook(EntryBook entryBook) throws LimaException; Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -1,33 +0,0 @@ -/* *##% Lima Business - * 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; - -import org.chorem.lima.entity.Entry; - - -public interface EntryService { - - void createEntry(Entry entry) throws LimaException; - - void updateEntry(Entry entry) throws LimaException; - - void removeEntry(Entry entry) throws LimaException; - -} Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -21,9 +21,11 @@ import java.util.List; +import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransaction; +import org.nuiton.topia.TopiaException; /** * Transaction service. @@ -72,4 +74,17 @@ void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; + + /** + * Methodes for create, update and remove the entry + * @param entry + * @throws LimaException + */ + + void createEntry(Entry entry) throws LimaException; + + void updateEntry(Entry entry) throws LimaException; + + void removeEntry(Entry entry) throws LimaException; + } 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-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -39,6 +39,7 @@ import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryDAO; +import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.IdentityDAO; import org.chorem.lima.entity.LimaCallaoDAOHelper; @@ -63,6 +64,8 @@ private TopiaContext rootContext; + protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl(); + //private ConvertAccount convertAccount = new ConvertAccount(); public AccountServiceImpl() { @@ -456,32 +459,6 @@ */ @Override public List<Account> getAllAccounts() throws LimaException { - /*ArrayList<AccountDTO> listAccountDTO = new ArrayList<AccountDTO>(); - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - AccountDAO accountDAO = LimaCallaoDAOHelper - .getAccountDAO(topiaContext); - // Recherche des comptes enfants - List<Account> listAccount = accountDAO.findAll(); - // Pour chaque compte - // Converti entity en DTO - convertAccount.setTransaction(topiaContext); - for (Account account : listAccount) { - // Pour les comptes sans père - if (account.getMasterAccount() == null) { - AccountDTO accountDTO = convertAccount.accountEntityToDto( - account, null); - listAccountDTO.add(accountDTO); - } - } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return listAccountDTO;*/ List<Account> accountsList = new ArrayList<Account>(); @@ -493,6 +470,11 @@ LimaCallaoDAOHelper.getAccountDAO(transaction); List<Account> accounts = accountDAO.findAll(); accountsList.addAll(accounts); + for (Account account : accounts) { + for (Account subaccount : getChildrenAccounts(account)) { + + } + } } catch (TopiaException ex) { doCatch(transaction, ex, log); @@ -582,87 +564,11 @@ * ATTENTION : si il existe une entrée comptable associée au numéro de * compte, il est alors impossible de supprimer le compte. * - * Si un compte contient des sous comptes la fonction retourne -1 * @param account * @throws LimaException */ @Override public void removeAccount(Account account) throws LimaException { - /*String result = ServiceHelper.RESPOND_ERROR; - Account deleteAccount = searchAccount(accountNumber); - // Si le compte n'existe pas - if (deleteAccount == null) { - if (log.isWarnEnabled()) { - log.warn("Le compte numéro " + accountNumber - + " n'existe pas !"); - } - result = ServiceHelper.ACCOUNT_NOT_EXIST; - } else // Sinon on efface le compte - { - // Vérifie si une entrée ne possède pas ce numéro de compte. - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper - .getEntryDAO(topiaContext); - // Recherche au moins une entry avec ce compte. - Entry entry = entryDAO.findByAccount(deleteAccount); - // Il existe au moins une entrée - if (entry != null) { - if (log.isWarnEnabled()) { - log.warn("Le compte numéro " + accountNumber - + " possède des entrées comptable !"); - } - result = ServiceHelper.ACCOUNT_WITH_ENTRIES; - } else { - // On efface tous les comptes enfants - List<Account> listAccountChild = searchListChildAccount(deleteAccount); - boolean ErrorRemoveChild = false; - for (Account accountChild : listAccountChild) { - // Si on souhaite supprimer les comptes enfants - result = removeAccount(accountChild.getAccountNumber()); - if (result.equals(ServiceHelper.RESPOND_ERROR)) { - ErrorRemoveChild = true; - if (log.isErrorEnabled()) { - log.error("Le compte fils numéro " - + accountChild.getAccountNumber() - + " n'a pas été supprimé !"); - } - } - // - // Si on ne souhaite pas supprimer les comptes enfants, tous les - // comptes enfants se retrouvent sans père. Commenter removeAccountChildTest - // dans le fichier AccountServiceImplTest dans ce cas. - - //modifyAccount(accountChild.getAccountNumber(),accountChild.getLabel(),null); - } - // Si il n'a jamais eu d'erreur pour supprimer ses fils - if (!ErrorRemoveChild) { - - //// Efface le compte père - - // Chargement du DAO - AccountDAO accountDAO = LimaCallaoDAOHelper - .getAccountDAO(topiaContext); - // Supprime le compte - accountDAO.delete(deleteAccount); - // Création BDD - topiaContext.commitTransaction(); - // Fermeture BDD - topiaContext.closeContext(); - result = ServiceHelper.RESPOND_SUCCESS; - if (log.isInfoEnabled()) { - log.info("Le compte numéro " + accountNumber - + " a ete supprimé avec succès."); - } - } - } - } catch (TopiaException e) { - log.error(e); - } - } - return result;*/ int result = 0; TopiaContext transaction = null; try { @@ -676,6 +582,13 @@ throw new LimaBusinessException("Can't delete account with entries"); } + // Vérifie si une transaction n'appartient pas à ce compte. + //FIXME fonctionne pas + Entry entry = financialTransactionService.findByAccount(transaction, account); + if (entry != null) { + throw new LimaBusinessException("Can't delete Account with entries"); + } + //Check if the account is not empty if (account.getSubAccounts().size() > 0){ throw new LimaBusinessException("Account not empty"); 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-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -32,14 +32,17 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookDAO; +import org.chorem.lima.entity.FinancialTransactionDAO; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.entity.FinancialTransaction; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.topia.framework.TopiaQuery; /** * Implémente la fonction multi-EntryBook. Il est possible de créer ici le @@ -301,54 +304,7 @@ * @throws LimaException */ public void removeEntryBook(EntryBook entryBook) throws LimaException { - /*String result = ServiceHelper.RESPOND_ERROR; - EntryBook EntryBookDelete = searchEntryBookWithTopiaId(topiaId); - // Si le EntryBook n'existe pas - if (EntryBookDelete == null) { - if (log.isWarnEnabled()) { - log.warn("Le EntryBook " + topiaId + " n'existe pas !"); - } - result = ServiceHelper.EntryBook_NOT_EXIST; - } else // Sinon on efface le EntryBook - { - // Vérifie si une transaction n'appartient pas à ce EntryBook. - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - TransactionDAO transactionDAO = LimaCallaoDAOHelper - .getTransactionDAO(topiaContext); - // Recherche au moins une transaction avec ce EntryBook. - Transaction transaction = transactionDAO - .findByEntryBook(EntryBookDelete); - // Il existe au moins une transaction - if (transaction != null) { - if (log.isWarnEnabled()) { - log.warn("Le EntryBook " + topiaId - + " possède des transactions comptables !"); - } - result = ServiceHelper.EntryBook_WITH_TRANSACTIONS; - } else { - - // Efface le EntryBook - // Chargement du DAO - EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper - .getEntryBookDAO(topiaContext); - // Supprime le EntryBook - EntryBookDAO.delete(EntryBookDelete); - // Création BDD - topiaContext.commitTransaction(); - // Fermeture BDD - topiaContext.closeContext(); - result = ServiceHelper.RESPOND_SUCCESS; - } - } catch (TopiaException e) { - log.error(e); - } - } - return result;*/ - TopiaContext topiaTransaction = null; try { // basic check done, make check in database Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -1,445 +0,0 @@ -/* *##% Lima Business - * 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.ejb; - -import javax.ejb.Stateless; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.EntryService; -import org.chorem.lima.business.LimaConfig; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.EntryDAO; -import org.chorem.lima.entity.LimaCallaoDAOHelper; -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.TopiaContextFactory; -import org.nuiton.topia.TopiaException; -import org.nuiton.topia.TopiaNotFoundException; - -/** - * Cette classe permet de contrôler les différentes saisies possibles dans - * Callao. Ces saisies sont transmises à la base de données par la classe - * Entry. Chaque action sur une entrée déclenche une création d'un log. - * Chaque opération comptable doit faire appel également au contrôl de la - * période comptable sur laquelle l'entry repose. Ainsi il n'est possible - * d'ajouter/modifier/supprimer une entrée si la période est bloquée. - * - * @author Rémi Chapelet - */ -@Stateless -public class EntryServiceImpl extends AbstractLimaService implements EntryService { - - private static final Log log = LogFactory.getLog(EntryServiceImpl.class); - - private TopiaContext rootContext; - - public EntryServiceImpl() { - LimaConfig config = LimaConfig.getInstance(); - try { - rootContext = TopiaContextFactory.getContext(config.getOptions()); - } catch (TopiaNotFoundException ex) { - if (log.isErrorEnabled()) { - log.error("Can't init topia context", ex); - } - } - } - - - @Override - public void removeEntry(Entry entry) throws LimaException { - TopiaContext topiaContext = null; - try { - // basic check done, make check in database - // TODO move it into JTA - topiaContext = rootContext.beginTransaction(); - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - //delete - entryDAO.delete(entry); - // commit - topiaContext.commitTransaction(); - } - catch (TopiaException ex) { - doCatch(topiaContext, ex, log); - } - finally { - doFinally(topiaContext, log); - } - } - - @Override - public void updateEntry(Entry entry) throws LimaException { - TopiaContext topiaContext = null; - try { - // TODO move it into JTA - topiaContext = rootContext.beginTransaction(); - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - //delete - entryDAO.update(entry); - // commit - topiaContext.commitTransaction(); - } - catch (TopiaException ex) { - doCatch(topiaContext, ex, log); - } - finally { - doFinally(topiaContext, log); - } - } - - /** - * Création d'une entrée comptable. - * La période ne doit PAS être bloquée. - * - * @return - */ - - @Override - public void createEntry(Entry entry /*String description, String amount, boolean debit, - String lettering, String detail, Transaction transaction, - Account account*/) throws LimaException { - /*String result = isCorrectEntry(transaction, account); - if (result.equals(ServiceHelper.RESPOND_SUCCESS)) { - result = ServiceHelper.RESPOND_ERROR; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper - .getEntryDAO(topiaContext); - // Creation de l'entrée comptable - Entry newEntry = entryDAO.create(); - newEntry.setDescription(description); - // On formate le nombre - newEntry.setAmount(numberUtil.format(amount)); - newEntry.setDebit(debit); - newEntry.setLettering(lettering); - newEntry.setDetail(detail); - newEntry.setTransaction(transaction); - newEntry.setAccount(account); - // Création BDD - topiaContext.commitTransaction(); - // Fermeture BDD - topiaContext.closeContext(); - if (log.isInfoEnabled()) { - log.info("Ajout avec succes de l'entrée comptable."); - } - // Création du log - Date logDate = new Date(); - logServiceImpl.addLog(logDate, transaction.getTransDate(), - ServiceHelper.LOG_ADD, transaction.getVoucherRef(), - transaction.getDescription(), detail, amount, debit, - lettering); - - // Il renvoie soit l'identifiant topiaId ou SUCCESS. - result = newEntry.getTopiaId(); - //result = ServiceHelper.RESPOND_SUCCESS; - } catch (TopiaException e) { - log.error(e); - } - } - return result;*/ - - TopiaContext topiaContext = null; - try { - // basic check done, make check in database - // TODO move it into JTA - topiaContext = rootContext.beginTransaction(); - - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - entryDAO.create(entry); - - // commit - topiaContext.commitTransaction(); - } - catch (TopiaException ex) { - doCatch(topiaContext, ex, log); - } - finally { - doFinally(topiaContext, log); - } - } - - /* - * Permet de créer une entrée comptable à partir de son DTO. - * @param entryDTO - * @return - * - public String createEntry(EntryDTO entryDTO) { - // Recherche TransactionDTO - TransactionDTO transactonDTO = entryDTO.getTransactionDTO(); - Transaction transaction = transactionServiceImpl - .searchTransactionWithTopiaId(transactonDTO); - // Recherche AccountDTO - AccountDTO accountDTO = entryDTO.getAccountDTO(); - Account account = accountServiceImpl.searchAccount(accountDTO - .getAccountNumber()); - // Création entry - String result = createEntry(entryDTO.getDescription(), entryDTO - .getAmount(), entryDTO.isDebit(), entryDTO.getLettering(), - entryDTO.getDetail(), transaction, account); - return result; - }*/ - - /* - * Vérifie que les objets transaction et account ne sont pas nulls. - * @param transaction - * @param account - * @return - * - public String isCorrectEntry(Transaction transaction, Account account) { - String result = ServiceHelper.RESPOND_SUCCESS; - // Vérification si timeSpan et Journal existe bien - if (account == null) { - if (log.isErrorEnabled()) { - log.error("Création entry : Le account n'existe pas."); - } - result = ServiceHelper.ACCOUNT_NOT_EXIST; - } - if (transaction == null) { - if (log.isErrorEnabled()) { - log.error("Création entry : La transaction n'existe pas."); - } - result = ServiceHelper.TRANSACTION_NOT_EXIST; - } - return result; - }*/ - - /* - * Recherche toutes les entrées comptables d'une transaction. - * @param transaction - * @return - * - public List<Entry> searchEntryWithTransaction(Transaction transaction) { - List<Entry> listEntry = null; - if (transaction != null) { - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper - .getEntryDAO(topiaContext); - // Recherche - listEntry = entryDAO.findAllByTransaction(transaction); - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - } - return listEntry; - }*/ - - /* - * Recherche toutes les entrées comptables d'une transaction, et renvoie - * au format DTO. - * @param transaction - * @return - * - public List<EntryDTO> searchEntryDTOWithTransaction(Transaction transaction) { - List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>(); - // Si la transaction est trouvée - if (transaction != null) { - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper - .getEntryDAO(topiaContext); - // Recherche toutes les entrées comptables de la transaction - List<Entry> listEntry = entryDAO - .findAllByTransaction(transaction); - // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO - convertEntry.setTransaction(topiaContext); - for (Entry entry : listEntry) { - EntryDTO entryDTO = convertEntry.entryEntityToDto(entry); - // On ajoute le nouvel DTO - listEntryDTO.add(entryDTO); - } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - } - return listEntryDTO; - }*/ - - /* - * Recherche les entrées comptables pour une transaction donnée au format DTO. - * @param transactionTopiaId identifiant de la transaction - * @return - * - public List<EntryDTO> searchEntryDTOWithTransaction( - String transactionTopiaId) { - List<EntryDTO> listEntryDTO = new ArrayList<EntryDTO>(); - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - // Recherche de la transaction - Transaction transaction = transactionServiceImpl - .searchTransactionWithTopiaId(transactionTopiaId); - // Si la transaction est trouvée - if (transaction != null) { - // Recherche toutes les entrées comptables de la transaction - List<Entry> listEntry = entryDAO - .findAllByTransaction(transaction); - // Pour chaque entry, on fait appel au convertisseur pour avoir en DTO - convertEntry.setTransaction(topiaContext); - for (Entry entry : listEntry) { - EntryDTO entryDTO = convertEntry.entryEntityToDto(entry); - // On ajoute l'entrée DTO - listEntryDTO.add(entryDTO); - } - } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return listEntryDTO; - }*/ - - /* - * Recherche les entrées comptables pour une transaction donnée au format DTO. - * @param transactionDTO - * @return - * - public List<EntryDTO> searchEntryDTOWithTransaction( - TransactionDTO transactionDTO) { - List<EntryDTO> listEntryOfTransaction = searchEntryDTOWithTransaction(transactionDTO - .getId()); - return listEntryOfTransaction; - }*/ - - /* - * Permet d'effacer une entrée comptable à partir de son identifiant topia. - * @param topiaId - * @return - * - public String removeEntry(String topiaId) { - String result = ServiceHelper.RESPOND_ERROR; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - // Recherche de l'entry - Entry entryDelete = entryDAO.findByTopiaId(topiaId); - // Si l'entry existe alors on supprime - if (entryDelete != null) { - // Supprime - entryDAO.delete(entryDelete); - // Création BDD - topiaContext.commitTransaction(); - result = ServiceHelper.RESPOND_SUCCESS; - } else { - result = ServiceHelper.ENTRY_NOT_EXIST; - } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return result; - }*/ - - /* - * Permet d'effacer une entrée comptable au format DTO. - * @param entryDTO - * @return - * - public String removeEntry(EntryDTO entryDTO) { - String result = removeEntry(entryDTO.getId()); - return result; - }*/ - - /* - * Modification d'une entrée comptable. - * @param topiaId - * @param description - * @param amount - * @param debit - * @param lettering - * @param detail - * @param transaction - * @param account - * @return - * - public String modifyEntry(String topiaId, String description, - String amount, boolean debit, String lettering, String detail, - Account account) { - String result = ServiceHelper.RESPOND_ERROR; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - // Recherche Entry - Entry entry = entryDAO.findByTopiaId(topiaId); - entry.setDescription(description); - // On formate le nombre - entry.setAmount(numberUtil.format(amount)); - entry.setDebit(debit); - entry.setLettering(lettering); - entry.setDetail(detail); - entry.setAccount(account); - entry.update(); - // Création BDD - topiaContext.commitTransaction(); - // Chargement DAO transaction - Transaction transaction = entry.getTransaction(); - if (log.isInfoEnabled()) { - log.info("Edit avec succes de l'entrée comptable."); - } - // Création du log - Date logDate = new Date(); - logServiceImpl.addLog(logDate, transaction.getTransDate(), - ServiceHelper.LOG_MODIFY, transaction.getVoucherRef(), - transaction.getDescription(), detail, amount, debit, - lettering); - result = ServiceHelper.RESPOND_SUCCESS; - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return result; - }*/ - - /* - * Permet de modifier une entrée comptable. - * @param entryDTO - * @return - * - public String modifyEntry(EntryDTO entryDTO) { - // Recherche AccountDTO - AccountDTO accountDTO = entryDTO.getAccountDTO(); - Account account = accountServiceImpl.searchAccount(accountDTO - .getAccountNumber()); - // Modification entry - String result = modifyEntry(entryDTO.getId(), - entryDTO.getDescription(), entryDTO.getAmount(), entryDTO - .isDebit(), entryDTO.getLettering(), entryDTO - .getDetail(), account); - return result; - }*/ -} Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -49,8 +49,6 @@ private AccountServiceImpl accountServiceImpl = new AccountServiceImpl(); - private EntryServiceImpl entryServiceImpl = new EntryServiceImpl(); - private EntryBookServiceImpl journalServiceImpl = new EntryBookServiceImpl(); private FiscalPeriodServiceImpl periodServiceImpl = new FiscalPeriodServiceImpl(); 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-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -30,8 +30,13 @@ import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.FinancialTransactionService; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.EntryBookDAO; +import org.chorem.lima.entity.EntryDAO; import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FinancialTransactionDAO; @@ -40,6 +45,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.framework.TopiaQuery.Op; /** * Cette classe permet la création d'une transaction comptable dans l'application. @@ -53,16 +59,11 @@ @Stateless public class FinancialTransactionServiceImpl extends AbstractLimaService implements FinancialTransactionService { - private static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class); + private static final Log log = + LogFactory.getLog(FinancialTransactionServiceImpl.class); private TopiaContext rootContext; - //private RecordServiceImpl logServiceImpl = new RecordServiceImpl(); - - //private EntryServiceImpl entryServiceImpl = new EntryServiceImpl(); - - //private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl(); - public FinancialTransactionServiceImpl() { LimaConfig config = LimaConfig.getInstance(); try { @@ -75,19 +76,11 @@ } /** - * Permet de créer une transaction comptable. Pour ajouter une transaction, - * le timeSpan doit être non bloqué. - * @param entryDate - * @param voucherRef - * @param description - * @param timespan - * @param journal - * @return + * Permet de créer une transaction comptable contenant des entrées * @throws LimaException */ @Override - public void createFinancialTransaction(FinancialTransaction financialtransaction/*Date entryDate, String voucherRef, - String description, TimeSpan timeSpan, Journal journal*/) throws LimaException { + public void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException { TopiaContext topiaContext = null; @@ -110,154 +103,8 @@ finally { doFinally(topiaContext, log); } - - /*String result = ServiceHelper.RESPOND_ERROR; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - TransactionDAO transactionDAO = LimaCallaoDAOHelper - .getTransactionDAO(topiaContext); - String isCorrectTransaction = isCorrectTransaction(timeSpan, - journal); - if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) { - // Creation de la transaction - Transaction newtransaction = transactionDAO.create(); - newtransaction.setTransDate(entryDate); - newtransaction.setVoucherRef(voucherRef); - newtransaction.setDescription(description); - newtransaction.setTimeSpan(timeSpan); - newtransaction.setJournal(journal); - // Création BDD - topiaContext.commitTransaction(); - if (log.isInfoEnabled()) { - log.info("Ajout avec succes de la transaction"); - } - - // Il renvoie soit l'identifiant topiaId ou SUCCESS. - result = newtransaction.getTopiaId(); - //result = ServiceHelper.RESPOND_SUCCESS; - } else { - result = isCorrectTransaction; - } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return result;*/ } - /* - * Permet de créer une transaction à partir d'une transaction DTO. - * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se - * faire. Si on souhaite, on peut créer le journal automatiquement lors de - * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est - * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période - * comptable existante, et par conséquent il ne faut pas le créer. - * @param transactionDTO - * @return - * - public String createTransaction(TransactionDTO transactionDTO) { - String result = ServiceHelper.RESPOND_ERROR; - // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO - if (transactionDTO.getJournalDTO() == null - || transactionDTO.getTimeSpanDTO() == null) { - if (log.isErrorEnabled()) { - log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal."); - } - result = ServiceHelper.TRANSACTION_NOT_JOURNAL; - } else { - // Recherche du journal - JournalServiceImpl journalServiceImpl = new JournalServiceImpl(); - Journal journal = journalServiceImpl - .searchJournalWithLabel(transactionDTO.getJournalDTO() - .getLabel()); - // Recherche du timeSpan - TimeSpan timeSpan = timeSpanServiceImpl - .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO() - .getBeginTimeSpan()); - - // Vérification si timeSpan et Journal existe bien - if (journal == null) { - if (log.isErrorEnabled()) { - log.error("Création transaction : Le journal " - + transactionDTO.getJournalDTO().getLabel() - + " n'existe pas."); - } - result = ServiceHelper.TRANSACTION_NOT_JOURNAL; - } else { - if (timeSpan == null) { - if (log.isErrorEnabled()) { - log.error("Création transaction : Le timeSpan " - + transactionDTO.getTimeSpanDTO().toString() - + " n'existe pas."); - } - result = ServiceHelper.TRANSACTION_NOT_TIMESPAN; - } else { - result = createTransaction(transactionDTO.getEntryDate(), - transactionDTO.getVoucherRef(), transactionDTO - .getDescription(), timeSpan, journal); - } - } - } - return result; - }*/ - - /* - * Permet de modifier une transaction. Cette dernière est identifiée par la - * clé topiaId. - * @param topiaId - * @param entryDate - * @param voucherRef - * @param description - * @param timespan - * @param journal - * @return - * - public String modifyTransaction(String topiaId, Date entryDate, - String voucherRef, String description, TimeSpan timeSpan, - Journal journal) { - String result = ServiceHelper.RESPOND_ERROR; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - TransactionDAO transactionDAO = LimaCallaoDAOHelper - .getTransactionDAO(topiaContext); - // Vérification que la transaction existe bien - Transaction transaction = transactionDAO.findByTopiaId(topiaId); - if (transaction == null) { - if (log.isInfoEnabled()) { - log.info("La transaction " + voucherRef - + " n'existe pas. (identifiant " + topiaId + ")"); - } - result = ServiceHelper.TRANSACTION_NOT_EXIST; - } else { - // Vérification si la transaction possède de bons paramètres - String correct = isCorrectTransaction(timeSpan, journal); - // Si la transaction est correcte - if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) { - // Modification - transaction.setTransDate(entryDate); - transaction.setVoucherRef(voucherRef); - transaction.setDescription(description); - transaction.setTimeSpan(timeSpan); - transaction.setJournal(journal); - transaction.update(); - // Création BDD - topiaContext.commitTransaction(); - result = ServiceHelper.RESPOND_SUCCESS; - } - } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return result; - }*/ - /** * Permet de retrouver la premiere transaction associée au journal. * @@ -281,7 +128,33 @@ return result; } + + /** + * Permet de retrouver la premiere transaction associée au compte. + * + * Utilisé par account service pour savoir si un compte a des transactions + * associées et empecher la suppression. + * + * @param topiaTransaction context à utiliser + * @param account compte + * @throws TopiaException + */ + protected Entry findByAccount(TopiaContext topiaTransaction, Account account) throws TopiaException { + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaTransaction); + //TODO marche pas + TopiaQuery query = entryDAO.createQuery(); + query.add("account", account); + + Entry result = entryDAO.findByQuery(query); + + return result; + } + + + /** + * Return the list of all financial transaction + */ @Override public List<FinancialTransaction> getAllFinancialTransactions() throws LimaException { @@ -289,7 +162,9 @@ return getAllFinancialTransactionsForEntryBook(null); } - + /** + * Return the list of all financial transaction of an entrybook + */ @Override public List<FinancialTransaction> getAllFinancialTransactionsForEntryBook( EntryBook entryBook) throws LimaException { @@ -299,6 +174,9 @@ return getAllFinancialTransactionsForEntryBookAndFinancialPeriod(entryBook, null); } + /** + * Return the list of all financial transaction of a financial period + */ @Override public List<FinancialTransaction> getAllFinancialTransactionsForFinancialPeriod( FinancialPeriod period) throws LimaException { @@ -306,6 +184,9 @@ return getAllFinancialTransactionsForEntryBookAndFinancialPeriod(null, period); } + /** + * Return the list of all financial transaction of a financial period and an entrybook + */ @Override public List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException { @@ -327,6 +208,16 @@ } transactions = transactionDAO.findAllByQuery(query); + + //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION + for (FinancialTransaction financialTransaction : transactions) { + + for (Entry entry : financialTransaction.getEntry()) { + entry.getEntryBook(); + entry.getAccount(); + entry.getFinancialTransaction(); + } + } } catch (TopiaException ex) { doCatch(topiaTransaction, ex, log); @@ -337,98 +228,8 @@ return transactions; } + - /* - * Recherche toutes les transactions appartenant à un même journal donné - * en paramètre. - * @param journal - * @return - * - public List<Transaction> searchListTransactionWithJournal(Journal journal) { - List<Transaction> listTransaction = null; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - TransactionDAO transactionDAO = LimaCallaoDAOHelper - .getTransactionDAO(topiaContext); - // Recherche - listTransaction = transactionDAO.findAllByJournal(journal); - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return listTransaction; - }*/ - - /* - * Permet de rechercher toutes les transactions dans la base de données, - * avec en retour une liste de transactions au format DTO. - * @return - * - public List<TransactionDTO> getAllTransactionDTO() { - List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>(); - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - TransactionDAO transactionDAO = LimaCallaoDAOHelper - .getTransactionDAO(topiaContext); - // Recherche - List<Transaction> listTransaction = transactionDAO.findAll(); - // Converti la transaction en DTO - convertTransaction.setTransaction(rootContext); - for (Transaction transaction : listTransaction) { - TransactionDTO transactionDTO = convertTransaction - .transactionEntityToDto(transaction); - listTransactionDTO.add(transactionDTO); - } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); - } - return listTransactionDTO; - }*/ - - /* - * Cette méthode permet de vérifier si une transaction possède des paramètres - * corrects. - * Un journal doit exister. - * Un timeSpan doit exister et être non bloqué. - * @param timeSpan - * @param journal - * @return - * - public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) { - String result = ServiceHelper.RESPOND_SUCCESS; - // Vérification si timeSpan et Journal existe bien - if (journal == null) { - if (log.isErrorEnabled()) { - log.error("Création transaction : Le journal n'existe pas."); - } - result = ServiceHelper.TRANSACTION_NOT_JOURNAL; - } - if (timeSpan == null) { - if (log.isErrorEnabled()) { - log.error("Création transaction : Le timeSpan n'existe pas."); - } - result = ServiceHelper.TRANSACTION_NOT_TIMESPAN; - } else { - // Vérifie si le timeSpan est bloqué - if (timeSpan.getLocked()) { - if (log.isErrorEnabled()) { - log.error("Le timeSpan est bloqué ! Il est donc impossible" - + " d'ajouter une transaction sur cette période. (" - + "Période du " + timeSpan + ")"); - } - result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED; - } - } - return result; - }*/ - @Override public void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException { @@ -473,213 +274,119 @@ } - - /* - * Permet d'ajouter une entrée comptable pour une transaction donnée. - * ATTENTION : la transaction doit être NON bloquée. - * - * @param description - * @param amount - * @param debit - * @param lettering - * @param detail - * @param transaction - * @return - * - public String addEntry(String description, String amount, boolean debit, - String lettering, String detail, Transaction transaction, - Account account) { - String result = ServiceHelper.RESPOND_ERROR; - // Si la transaction est non bloquée - if (!isTransactionBlocked(transaction)) { - // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante) - result = entryServiceImpl.createEntry(description, amount, debit, - lettering, detail, transaction, account); - } else { - result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED; + + + @Override + public void removeEntry(Entry entry) throws LimaException { + TopiaContext topiaContext = null; + try { + // basic check done, make check in database + // TODO move it into JTA + topiaContext = rootContext.beginTransaction(); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + //delete + entryDAO.delete(entry); + // commit + topiaContext.commitTransaction(); } - return result; - }*/ - - /* - * Permet d'ajouter une entrée comptable pour une transaction donnée. - * L'entrée est sous format DTO. - * - * @param entryDTO - * @return - * - public String addEntry(EntryDTO entryDTO) { - String result = ServiceHelper.RESPOND_ERROR; - // Recherche TransactionDTO - TransactionDTO transactonDTO = entryDTO.getTransactionDTO(); - Transaction transaction = searchTransactionWithTopiaId(transactonDTO); - // Si la transaction est non bloquée - if (!isTransactionBlocked(transaction)) { - - // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante) - result = entryServiceImpl.createEntry(entryDTO); - } else { - result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED; + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); } - return result; - }*/ - - /* - * Permet de modifier une entrée comptable. - * ATTENTION : la transaction doit être NON bloquée. - * - * @param topiaId - * @param description - * @param amount - * @param debit - * @param lettering - * @param detail - * @param transaction - * @param account - * @return - * - public String modifyEntry(String topiaId, String description, - String amount, boolean debit, String lettering, String detail, - Transaction transaction, Account account) { - String result = ServiceHelper.RESPOND_ERROR; - if (!isTransactionBlocked(transaction)) { - result = entryServiceImpl.modifyEntry(topiaId, description, amount, - debit, lettering, detail, account); - } else { - result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED; + finally { + doFinally(topiaContext, log); } - return result; - }*/ + } - /* - * Permet de modifier une entrée. - * @param entryDTO - * @return - * - public String modifyEntry(EntryDTO entryDTO) { - String result = ServiceHelper.RESPOND_ERROR; - // Recherche TransactionDTO - TransactionDTO transactonDTO = entryDTO.getTransactionDTO(); - Transaction transaction = searchTransactionWithTopiaId(transactonDTO); - if (!isTransactionBlocked(transaction)) { - result = entryServiceImpl.modifyEntry(entryDTO); - } else { - result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED; + @Override + public void updateEntry(Entry entry) throws LimaException { + TopiaContext topiaContext = null; + try { + // TODO move it into JTA + topiaContext = rootContext.beginTransaction(); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + //delete + entryDAO.update(entry); + // commit + topiaContext.commitTransaction(); } - return result; - }*/ + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + } - /* - * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant - * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée. - * @param topiaId - * @return + /** + * Création d'une entrée comptable. + * La période ne doit PAS être bloquée. * - public String removeEntry(String topiaId) { - String result = ServiceHelper.RESPOND_ERROR; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - // Recherche de l'entry - Entry entryDelete = entryDAO.findByTopiaId(topiaId); - // Entry doit exister - if (entryDelete != null) { - // Prend la transaction dont appartient entry - Transaction transaction = entryDelete.getTransaction(); - // Vérifie si la transaction est non bloquée. - if (!isTransactionBlocked(transaction)) { - // Création d'un log DTO - LogDTO logDTO = new LogDTO("", new Date(), - ServiceHelper.LOG_REMOVE, transaction - .getTransDate(), transaction - .getVoucherRef(), transaction - .getDescription(), entryDelete - .getDescription(), entryDelete.getAmount(), - entryDelete.getDebit(), entryDelete.getLettering()); - // Appel pour supprimer l'entrée - result = entryServiceImpl.removeEntry(topiaId); - // Si la suppression s'est bien déroulée, création log - if (result.equals(ServiceHelper.RESPOND_SUCCESS)) { - // Ajout du log - logServiceImpl.addLog(logDTO); - } - } else { - result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED; + * @return + */ + + @Override + public void createEntry(Entry entry /*String description, String amount, boolean debit, + String lettering, String detail, Transaction transaction, + Account account*/) throws LimaException { + /*String result = isCorrectEntry(transaction, account); + if (result.equals(ServiceHelper.RESPOND_SUCCESS)) { + result = ServiceHelper.RESPOND_ERROR; + try { + // Acces BDD + TopiaContext topiaContext = rootContext.beginTransaction(); + // Chargement du DAO + EntryDAO entryDAO = LimaCallaoDAOHelper + .getEntryDAO(topiaContext); + // Creation de l'entrée comptable + Entry newEntry = entryDAO.create(); + newEntry.setDescription(description); + // On formate le nombre + newEntry.setAmount(numberUtil.format(amount)); + newEntry.setDebit(debit); + newEntry.setLettering(lettering); + newEntry.setDetail(detail); + newEntry.setTransaction(transaction); + newEntry.setAccount(account); + // Création BDD + topiaContext.commitTransaction(); + // Fermeture BDD + topiaContext.closeContext(); + if (log.isInfoEnabled()) { + log.info("Ajout avec succes de l'entrée comptable."); } - } else { - result = ServiceHelper.ENTRY_NOT_EXIST; + // Création du log + Date logDate = new Date(); + logServiceImpl.addLog(logDate, transaction.getTransDate(), + ServiceHelper.LOG_ADD, transaction.getVoucherRef(), + transaction.getDescription(), detail, amount, debit, + lettering); + + // Il renvoie soit l'identifiant topiaId ou SUCCESS. + result = newEntry.getTopiaId(); + //result = ServiceHelper.RESPOND_SUCCESS; + } catch (TopiaException e) { + log.error(e); } - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); } - return result; - }*/ + return result;*/ + + TopiaContext topiaContext = null; + try { + // basic check done, make check in database + // TODO move it into JTA + topiaContext = rootContext.beginTransaction(); - /* - * Permet de supprimer une entrée à partir d'un DTO. - * @param entryDTO - * @return - * - public String removeEntry(EntryDTO entryDTO) { - String result = removeEntry(entryDTO.getId()); - return result; - }*/ + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + entryDAO.create(entry); - /* - * Permet de vérifier si une transaction est dans une période bloquée ou non - * @param transaction - * @return - * - public boolean isTransactionBlocked(Transaction transaction) { - boolean isTransactionBlocked = true; - try { - // Acces BDD - TopiaContext topiaContext = rootContext.beginTransaction(); - // Chargement du DAO - TransactionDAO transactionDAO = LimaCallaoDAOHelper - .getTransactionDAO(topiaContext); - // Recherche - Transaction transactionSearch = transactionDAO - .findByTopiaId(transaction.getTopiaId()); - isTransactionBlocked = timeSpanServiceImpl - .isTimeSpanBlocked(transactionSearch.getTimeSpan()); - // Fermeture BDD - topiaContext.closeContext(); - } catch (TopiaException e) { - log.error(e); + // commit + topiaContext.commitTransaction(); } - return isTransactionBlocked; - }*/ - - /* - * Permet de vérifier si une transaction est équilibrée. - * @param transaction - * @return - * - public boolean isTransactionBalanced(Transaction transaction) { - List<EntryDTO> ListEntryDTO = entryServiceImpl - .searchEntryDTOWithTransaction(transaction); - float debit = 0; - float credit = 0; - // Pour toutes les entrées comptables trouvées - for (EntryDTO entryDTO : ListEntryDTO) { - // Si entrée au debit - if (entryDTO.isDebit()) { - debit = debit - + Float.parseFloat(entryDTO.getAmount().replaceFirst( - ",", ".")); - } else { - credit = credit - + Float.parseFloat(entryDTO.getAmount().replaceFirst( - ",", ".")); - } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); } - // Vérifie si le debit == credit - boolean isTransactionBalanced = debit == credit; - return isTransactionBalanced; - }*/ + finally { + doFinally(topiaContext, log); + } + } } \ No newline at end of file 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-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -270,7 +270,7 @@ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); result = fiscalPeriodDAO.findAll(); - + // commit transaction.commitTransaction(); } @@ -298,6 +298,13 @@ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); result = fiscalPeriodDAO.findAllByLocked(false); + //IMPORTANT : LOADING FINANCIAL PERIOD FOR NO LAZY EXCEPTION + for (FiscalPeriod fiscalPeriod : result) { + //FIXME besoin d'appeler une lecture bidon de toutes les financialperiod sinon il pete tout de même une lazy exception + for (FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) { + } + } + // commit transaction.commitTransaction(); } @@ -371,7 +378,12 @@ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); + FinancialPeriodDAO financialPeriodDAO = + LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction); for (FiscalPeriod fiscalPeriod : fiscalPeriodDAO.findAll()) { + for (FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()){ + financialPeriodDAO.delete(financialPeriod); + } fiscalPeriodDAO.delete(fiscalPeriod); } Deleted: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -1,61 +0,0 @@ -package org.chorem.lima.business; - -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.ejb.EntryServiceImpl; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Tests pour la gestion des entrées comptables - * - * La classe entry est une composte de la classe Transaction. En effet, cette - * dernière réunnit beaucoup de classes. Afin de faciliter la gestion des tests, - * la classe Test Transaction permet de tester également les entrys. - * - * @author Rémi Chapelet - */ -public class EntryServiceImplTest { - - /** log. */ - private static final org.apache.commons.logging.Log log = LogFactory - .getLog(EntryServiceImplTest.class); - - private static EntryServiceImpl instance; - - @BeforeClass - public static void setUpClass() throws Exception { - LimaConfig.getInstance(); - } - - /** - * On nettoie la base de données - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownClass() throws Exception { - - } - - @Before - public void setUp() { - instance = new EntryServiceImpl(); - } - - public EntryServiceImplTest() { - } - - /** - * Cette classe permet de contrôler les différentes saisies possibles dans - * Callao. Ces saisies sont transmises à la base de données par la classe - * Entry. - */ - @Test - public void createEntryTest() { - /*String result = instance.createEntry("description", "200", true, - "lettering", "detail", null, null); - Assert.assertEquals(ServiceHelper.TRANSACTION_NOT_EXIST, result);*/ - } - -} \ No newline at end of file Modified: trunk/lima-callao/src/main/xmi/accounting.properties =================================================================== --- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-30 11:21:57 UTC (rev 2881) @@ -1,11 +1,8 @@ # Precise l'entete de l'ensemble des fichiers generes model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */ -org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false -org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false -org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false -org.chorem.lima.entity.FinancialTransaction.attribute.entryBook.tagvalue.lazy=false -#org.chorem.lima.entity.Entry.attribute.record.tagvalue.lazy=false +#org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false +#org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false + org.chorem.lima.entity.Account.attribute.identity.tagvalue.lazy=false -org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false #model.tagvalue.dbSchema=Callao model.tagvalue.String=text \ No newline at end of file Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -33,7 +33,6 @@ import org.chorem.lima.LimaMain; import org.chorem.lima.business.AccountService; import org.chorem.lima.business.EntryBookService; -import org.chorem.lima.business.EntryService; import org.chorem.lima.business.FinancialPeriodService; import org.chorem.lima.business.FiscalPeriodService; import org.chorem.lima.business.RecordService; @@ -234,29 +233,6 @@ } /** - * Get entry service. - * - * @return entry service proxy - */ - public EntryService getEntryService() { - - // TODO EC-20100410 put lookup name in configuration - // name should be fully configurable due to custom implementation used - String lookupName = "EntryServiceImplLocal"; - EntryService ejbHome = null; - try { - ejbHome = (EntryService)ctx.lookup(lookupName); - } catch (NamingException eee) { - if (log.isErrorEnabled()) { - log.error("Can't lookup for service : " + lookupName, eee); - } - } - return ejbHome; - } - - - - /** * Get record service. * * @return record service proxy Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx (from rev 2876, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx 2010-04-30 11:21:57 UTC (rev 2881) @@ -0,0 +1,91 @@ +<!-- ##% 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. + ##% --> + +<Table> + <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + <org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> + <script> + <![CDATA[ + + import org.chorem.lima.entity.FiscalPeriod; + import org.chorem.lima.entity.FinancialPeriod; + + ]]> + </script> + + <!-- <JPopupMenu id="MenuRightPanel"> + <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/> + <JMenuItem text="lima.print"/> + </JPopupMenu> + <JPopupMenu id="MenuRightTransaction"> + <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/> + <JMenuItem text="lima.print"/> + </JPopupMenu> --> + + <row fill="horizontal" weightx="1" weighty="0" anchor="center"> + <cell> + <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/> + </cell> + <cell> + <JComboBox id="fiscalPeriodComboBox" + model="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxModel()}" + renderer="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxRenderer()}" + onItemStateChanged="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) event.getItem())" + editable="false"/> + </cell> + <cell> + <JLabel id="financialPeriodLabel" text="lima.transaction.period" + /> + </cell> + <cell> + <JComboBox id="financialPeriodComboBox" + model="{getModelFinancialPeriod()}" + renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxRenderer()}" + onItemStateChanged="getFinancialTransactionTableModel().setFinancialPeriod((FinancialPeriod) event.getItem())" + editable="false" + /> + </cell> + <cell> + <JButton text="lima.add.transaction" + onActionPerformed="getHandler().addFinancialTransaction()"/> + </cell> + <cell> + <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/> + </cell> + <cell> + <JButton text="lima.common.remove" + onActionPerformed="getHandler().deleteSelectedRow()" + enabled="{isSelectedRow()}"/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" rows="3" columns="7"> + <JScrollPane> + <org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel + id="financialTransactionTableModel" /> + <org.chorem.lima.ui.transaction.table.FinancialTransactionTable + id="financialTransactionTable" sortable="false" rowHeight="22" + constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" + highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" /> + <javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()" + onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> +</Table> \ No newline at end of file Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-30 11:21:57 UTC (rev 2881) @@ -1,113 +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. - ##% --> - -<Table> - <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" /> - <Boolean id="selectedRow" javaBean="false" /> - <org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> - <script> - <![CDATA[ - - import org.chorem.lima.entity.EntryBook; - import org.chorem.lima.entity.FiscalPeriod; - import org.chorem.lima.entity.FinancialPeriod; - - - ]]> - </script> - - <!-- <JPopupMenu id="MenuRightPanel"> - <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/> - <JMenuItem text="lima.print"/> - </JPopupMenu> - <JPopupMenu id="MenuRightTransaction"> - <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/> - <JMenuItem text="lima.print"/> - </JPopupMenu> --> - - <row fill="horizontal" weightx="1" weighty="0" anchor="center"> - <cell> - <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/> - </cell> - <cell> - <JComboBox id="fiscalPeriodComboBox" - model="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxModel()}" - renderer="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxRenderer()}" - onItemStateChanged="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) event.getItem())" - editable="false"/> - </cell> - <cell> - <JLabel id="financialPeriodLabel" text="lima.transaction.period" - /> - </cell> - <cell> - <JComboBox id="financialPeriodComboBox" - model="{getModelFinancialPeriod()}" - renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxRenderer()}" - onItemStateChanged="getFinancialTransactionTableModel().setFinancialPeriod((FinancialPeriod) event.getItem())" - editable="false" - /> - </cell> - <cell> - <JLabel id="entryBookLabel" text="lima.transaction.entrybook"/> - </cell> - <cell> - <JComboBox id="entryBookComboBox" - model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}" - renderer="{new org.chorem.lima.ui.transaction.model.EntryBookRenderer()}" - onItemStateChanged="getFinancialTransactionTableModel().setEntryBook((EntryBook) event.getItem())" - editable="false"/> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" rows="3" columns="6"> - <JScrollPane> - <org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel - id="financialTransactionTableModel" /> - <org.chorem.lima.ui.transaction.table.FinancialTransactionTable - id="financialTransactionTable" sortable="false" rowHeight="22" - constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" - highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" /> - <javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()" - onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/> - </JScrollPane> - </cell> - <cell fill="horizontal" weightx="1" weighty="1" anchor="north"> - <Table> - <row> - <cell> - <JButton text="lima.add.transaction" - onActionPerformed="getHandler().addFinancialTransaction()"/> - </cell> - </row> - <row> - <cell> - <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/> - </cell> - </row> - <row> - <cell> - <JButton text="lima.common.remove" - onActionPerformed="getHandler().deleteSelectedRow()" - enabled="{isSelectedRow()}"/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -31,6 +31,8 @@ public class AccountComboBoxModel implements ComboBoxModel { + protected Object selectedAccount; + protected AccountService accountService; public AccountComboBoxModel() { @@ -39,14 +41,12 @@ @Override public Object getSelectedItem() { - // TODO Auto-generated method stub - return null; + return selectedAccount; } @Override public void setSelectedItem(Object anItem) { - // TODO Auto-generated method stub - + selectedAccount = anItem; } @Override Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -23,7 +23,7 @@ JLabel label = new JLabel(); EntryBook entrybook = (EntryBook) value; if (entrybook != null){ - label.setText(entrybook.getLabel()); + label.setText(entrybook.getCode()+" - "+entrybook.getLabel()); } return label; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -24,7 +24,6 @@ import java.util.EventObject; import javax.swing.AbstractCellEditor; -import javax.swing.JComboBox; import javax.swing.JTable; import javax.swing.table.TableCellEditor; @@ -33,12 +32,12 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.ui.transaction.model.AccountComboBoxModel; import org.chorem.lima.ui.transaction.model.AccountRenderer; +import org.chorem.lima.widgets.JWideComboBox; public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor { - protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); - private final JComboBox comboBox; + private final JWideComboBox comboBox; private static final long serialVersionUID = 2580476608066111095L; private static AccountTableCellEditor editor; @@ -46,7 +45,7 @@ * constructor */ public AccountTableCellEditor() { - comboBox = new JComboBox(); + comboBox = new JWideComboBox(); AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); comboBox.setModel(accountComboBoxModel); AccountRenderer accountRenderer = new AccountRenderer(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -19,6 +19,14 @@ package org.chorem.lima.ui.transaction.table; +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.EntryBook; @@ -26,19 +34,10 @@ import org.chorem.lima.ui.transaction.model.EntryBookRenderer; import org.chorem.lima.widgets.JWideComboBox; -import javax.swing.*; -import javax.swing.table.TableCellEditor; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.util.EventObject; - -/** - * @author ore - */ public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor { protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); - private final JComboBox comboBox; + private final JWideComboBox comboBox; private static final long serialVersionUID = 2580476608066111095L; private static EntryBookTableCellEditor editor; @@ -46,7 +45,6 @@ * constructor */ public EntryBookTableCellEditor() { - log.debug("test"); comboBox = new JWideComboBox(); EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); comboBox.setModel(entryBookComboBoxModel); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -30,7 +30,7 @@ import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.EntryService; +import org.chorem.lima.business.EntryBookService; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.FinancialTransactionService; @@ -76,13 +76,9 @@ /** Transaction service. */ protected final FinancialTransactionService transactionService; - /** Entry service. */ - protected final EntryService entryService; - /** Record service. */ - //protected final RecordService recordService; - - protected EntryBook selectedEntryBook; - + /** EntryBook service. */ + protected final EntryBookService entryBookService; + protected FinancialPeriod selectedFinancialPeriod; /** @@ -94,8 +90,9 @@ /* Services */ // recordService = LimaServiceFactory.getInstance().getRecordService(); transactionService = LimaServiceFactory.getInstance() - .getTransactionService(); - entryService = LimaServiceFactory.getInstance().getEntryService(); + .getTransactionService(); + entryBookService = LimaServiceFactory.getInstance(). + getEntryBookService(); } /** @@ -111,13 +108,11 @@ try { List<FinancialTransaction> financialtransactions = - transactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod( - selectedEntryBook, selectedFinancialPeriod); + transactionService.getAllFinancialTransactionsForFinancialPeriod( + selectedFinancialPeriod); for (FinancialTransaction financialtransaction : financialtransactions) { results.add(financialtransaction); - // TODO EC20100408 warn about lazy exception here - // TODO EC20100408 warn about non ordonned transaction.getEntry() results.addAll(financialtransaction.getEntry()); } } @@ -147,10 +142,10 @@ result = Date.class; break; case 1: - result = String.class; + result = EntryBook.class; break; case 2: - result = EntryBook.class; + result = String.class; break; case 3: result = Account.class; @@ -184,10 +179,10 @@ result = _("lima.transaction.column.date"); break; case 1: - result = _("lima.transaction.column.voucher"); + result = _("lima.transaction.column.entrybook"); break; case 2: - result = _("lima.transaction.column.entrybook"); + result = _("lima.transaction.column.voucher"); break; case 3: result = _("lima.transaction.column.account"); @@ -244,25 +239,22 @@ FinancialTransaction currentRow = (FinancialTransaction)result; switch (column) { case 0: - Calendar cal = Calendar.getInstance(); - cal.setTime(currentRow.getTransactionDate()); - result = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); + result = currentRow.getTransactionDate(); break; case 1: result = null; // voucher break; case 2: - //TODO Lazy exception make a methode to get entrybook from the currentFinancialTransaction - result = currentRow.getEntryBook().getLabel(); + result = null; //entrybook break; case 3: - result = null; // account; + result = null; // account break; case 4: - result = null; // description; + result = null; // description break; case 5 : - result = null; //position; + result = null; // position break; case 6: result = FinancialTransactionHelper.getDebit(currentRow); @@ -282,14 +274,24 @@ case 0: result = null; // date break; - case 1 : - result = currentEntry.getVoucher(); + case 1 : // entry book + if (currentEntry.getEntryBook() != null){ + result = currentEntry.getEntryBook().getCode(); + } + else { + result = null; + } break; case 2: - result = null; // entry book + result = currentEntry.getVoucher(); break; - case 3: - result = currentEntry.getAccount().getLabel();// account + case 3: // account + if (currentEntry.getAccount() != null){ + result = currentEntry.getAccount().getAccountNumber(); + } + else { + result = null; + } break; case 4: result = currentEntry.getDescription(); @@ -307,6 +309,7 @@ result = null; // balance break; } + } } else { @@ -324,14 +327,7 @@ selectedFinancialPeriod = financialPeriod; fireTableDataChanged(); } - - public void setEntryBook(EntryBook entryBook){ - - selectedEntryBook = entryBook; - fireTableDataChanged(); - } - /** * To set cells editable or not * different condition for entry or financial transaction @@ -342,11 +338,11 @@ List<Object> datas = getDataList(); Object currentRow = datas.get(rowIndex); // cells editable for the entry row, all cells exclude the date - if ((currentRow instanceof Entry) && !(columnIndex==0 || columnIndex==2 || columnIndex==8)) { + if ((currentRow instanceof Entry) && !(columnIndex==0)) { editableCell=true; } // cells editable for the financialtransaction row, no cells exclude the date - if ((currentRow instanceof FinancialTransaction) && (columnIndex==0 || columnIndex==2)){ + if ((currentRow instanceof FinancialTransaction) && (columnIndex==0)){ editableCell=true; } return editableCell; @@ -360,9 +356,8 @@ //TODO transaction = currentdate, current periode, current journal FinancialTransaction financialTransaction = new FinancialTransactionImpl(); //if a period and an entrybook is selected - if (selectedFinancialPeriod != null && selectedEntryBook!=null){ + if (selectedFinancialPeriod != null){ financialTransaction.setFinancialPeriod(selectedFinancialPeriod); - financialTransaction.setEntryBook(selectedEntryBook); // get today Calendar actualCalendar = Calendar.getInstance(); // get the financial period date @@ -378,7 +373,7 @@ fireTableRowsInserted(row, row); } else { - throw new LimaBusinessException("No financial period and bookentry selected"); + throw new LimaBusinessException("No financial period selected"); } } @@ -403,7 +398,7 @@ } //create it entry.setFinancialTransaction(currentTransaction); - entryService.createEntry(entry); + transactionService.createEntry(entry); fireTableRowsUpdated(row, row); } @@ -426,13 +421,11 @@ case 0: currentFinancialTransaction.setTransactionDate((Date)value); break; - case 2: - currentFinancialTransaction.setEntryBook((EntryBook)value); - break; } // notify service for modification try { - transactionService.updateFinancialTransaction(currentFinancialTransaction); + transactionService. + updateFinancialTransaction(currentFinancialTransaction); } catch (LimaException e) { if (log.isDebugEnabled()){ log.debug("Can't update financial transaction", e); @@ -445,6 +438,9 @@ Entry currentEntry = (Entry)currentRow; switch (column) { case 1 : + currentEntry.setEntryBook((EntryBook)value); + break; + case 2 : currentEntry.setVoucher((String)value); break; case 3: @@ -466,17 +462,16 @@ break; } try { - entryService.updateEntry(currentEntry); + transactionService.updateEntry(currentEntry); } catch (LimaException e) { if (log.isDebugEnabled()){ log.debug("Can't update entry", e); } } //update the financial transaction in entire - int financialTransactionRow = getDataList().indexOf(((Entry) currentRow).getFinancialTransaction()); + int financialTransactionRow = + getDataList().indexOf(((Entry) currentRow).getFinancialTransaction()); fireTableRowsUpdated(financialTransactionRow, financialTransactionRow); - //update the entry - //fireTableRowsUpdated(row, row); } } else { @@ -505,12 +500,13 @@ List<Object> datas = getDataList(); Object currentRow = datas.get(row); if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = (FinancialTransaction)currentRow; + FinancialTransaction currentTransaction = + (FinancialTransaction)currentRow; transactionService.removeFinancialTransaction(currentTransaction); } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry)currentRow; - entryService.removeEntry(currentEntry); + transactionService.removeEntry(currentEntry); } fireTableRowsDeleted(row, row); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java 2010-04-30 11:21:57 UTC (rev 2881) @@ -23,7 +23,6 @@ import javax.swing.plaf.basic.ComboPopup; import javax.swing.plaf.metal.MetalComboBoxUI; import java.awt.*; -import java.util.Vector; // put it at begin, otherwise jaxx complains again !!! class ScrollMetalComboUI extends MetalComboBoxUI { Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-30 11:21:57 UTC (rev 2881) @@ -320,7 +320,9 @@ lima.transaction.column.document=Voucher lima.transaction.column.entrybook=Entrybook lima.transaction.column.period=Period +lima.transaction.column.position= lima.transaction.column.status=Status +lima.transaction.column.voucher= lima.transaction.confirmdelete= lima.transaction.entrybook= lima.transaction.period=Period 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-04-29 12:07:34 UTC (rev 2880) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-30 11:21:57 UTC (rev 2881) @@ -24,9 +24,9 @@ lima.action.fullscreen.tip=Passer en mode plein \u00E9cran lima.action.normalscreen=Ecran normal lima.action.normalscreen.tip=Revenir en \u00E9cran normal -lima.add.entry=Ajouter une entr\u00E9e +lima.add.entry=Ajouter entr\u00E9e lima.add.lettering= -lima.add.transaction=Ajouter une transaction +lima.add.transaction=Ajouter transaction lima.all=Tous lima.all.criteria=Tous les crit\u00E8res correspondent lima.amount=Montant @@ -296,7 +296,7 @@ lima.transaction.column.account=Compte lima.transaction.column.balance=Balance lima.transaction.column.credit=Cr\u00E9dit -lima.transaction.column.date=Jour +lima.transaction.column.date=Date lima.transaction.column.debit=D\u00E9bit lima.transaction.column.description=Description lima.transaction.column.entrybook=Journal
participants (1)
-
jpepin@users.chorem.org