Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
April 2010
- 5 participants
- 60 discussions
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
1
0
Author: tchemit
Date: 2010-04-29 14:07:34 +0200 (Thu, 29 Apr 2010)
New Revision: 2880
Url: http://chorem.org/repositories/revision/lima/2880
Log:
use JAXX 2.0.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-29 06:13:04 UTC (rev 2879)
+++ trunk/pom.xml 2010-04-29 12:07:34 UTC (rev 2880)
@@ -243,7 +243,7 @@
<nuiton-utils.version>1.2.2</nuiton-utils.version>
<eugene.version>2.0.1</eugene.version>
<topia.version>2.3.3</topia.version>
- <jaxx.version>2.0</jaxx.version>
+ <jaxx.version>2.0.1</jaxx.version>
<i18n.version>1.2.2</i18n.version>
<!--axis.version>1.4.1</axis.version-->
1
0
Author: tchemit
Date: 2010-04-29 08:13:04 +0200 (Thu, 29 Apr 2010)
New Revision: 2879
Log:
use maven-license-plugin 2.x
Modified:
trunk/lima-swing/pom.xml
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-swing/pom.xml 2010-04-29 06:05:49 UTC (rev 2878)
+++ trunk/lima-swing/pom.xml 2010-04-29 06:13:04 UTC (rev 2879)
@@ -271,13 +271,14 @@
<groupId>org.nuiton</groupId>
<artifactId>maven-license-plugin</artifactId>
<configuration>
- <copyToMETA_INF>true</copyToMETA_INF>
+ <generateBundle>true</generateBundle>
+ <!--copyToMETA_INF>true</copyToMETA_INF-->
</configuration>
<executions>
<execution>
<id>attach-licenses</id>
<goals>
- <goal>add-license</goal>
+ <goal>update-project-license</goal>
<goal>add-third-party</goal>
</goals>
</execution>
1
0
Author: tchemit
Date: 2010-04-29 08:05:49 +0200 (Thu, 29 Apr 2010)
New Revision: 2878
Log:
use i18n 1.2.2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-29 05:45:50 UTC (rev 2877)
+++ trunk/pom.xml 2010-04-29 06:05:49 UTC (rev 2878)
@@ -244,7 +244,7 @@
<eugene.version>2.0.1</eugene.version>
<topia.version>2.3.3</topia.version>
<jaxx.version>2.0</jaxx.version>
- <i18n.version>1.2.1</i18n.version>
+ <i18n.version>1.2.2</i18n.version>
<!--axis.version>1.4.1</axis.version-->
<!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar
1
0
Author: tchemit
Date: 2010-04-29 07:45:50 +0200 (Thu, 29 Apr 2010)
New Revision: 2877
Log:
Utilisation de mavenpom4redmine 2.1.3
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-28 15:59:14 UTC (rev 2876)
+++ trunk/pom.xml 2010-04-29 05:45:50 UTC (rev 2877)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.1.2</version>
+ <version>2.1.3</version>
</parent>
<groupId>org.chorem</groupId>
1
0
Author: jpepin
Date: 2010-04-28 17:59:14 +0200 (Wed, 28 Apr 2010)
New Revision: 2876
Log:
Ajout, suppression, modification transactions et entr?\195?\169es
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.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/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/
trunk/lima-swing/src/main/java/org/chorem/lima/comparator/
trunk/lima-swing/src/main/java/org/chorem/lima/filter/
trunk/lima-swing/src/main/java/org/chorem/lima/item/
trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.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/table/TransactionJXTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.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/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -32,6 +32,7 @@
* Last update : $Date$
* By : $Author$
*/
+
public interface EntryBookService {
List<EntryBook> getAllEntryBooks() throws LimaException;
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -0,0 +1,33 @@
+/* *##% 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/FinancialPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -39,8 +39,6 @@
List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException;
- List<FinancialPeriod> getUnblockedFinancialPeriodWithFiscalPeriod(FiscalPeriod selectedFiscalPeriod) throws LimaException;
-
void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException;
//void updateFiscalPeriod(FinancialPeriod financialPeriod) throws LimaException;
Modified: 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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -19,12 +19,18 @@
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;
/**
@@ -37,19 +43,13 @@
*
* @author Rémi Chapelet
*/
-public class EntryServiceImpl { // implements EntryService {
+@Stateless
+public class EntryServiceImpl extends AbstractLimaService implements EntryService {
private static final Log log = LogFactory.getLog(EntryServiceImpl.class);
private TopiaContext rootContext;
- private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
-
- // TODO A revoir car transaction a besoin de entry et vice versa
- private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
-
- private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
-
public EntryServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
try {
@@ -61,15 +61,59 @@
}
}
+
+ @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*/) {
+ Account account*/) throws LimaException {
/*String result = isCorrectEntry(transaction, account);
if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
result = ServiceHelper.RESPOND_ERROR;
@@ -111,6 +155,25 @@
}
}
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);
+ }
}
/*
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -19,12 +19,8 @@
package org.chorem.lima.business.ejb;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
-
import javax.ejb.Stateless;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FinancialPeriodService;
@@ -32,15 +28,13 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
-import org.chorem.lima.entity.FiscalPeriod;
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;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
+
/**
* Gestion des périodes intermédiaires durant l'exercice.
* Chaque timeSpan sera fixe, et devra correspondre à un mois complet.
@@ -55,8 +49,6 @@
private TopiaContext rootContext;
- private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
-
public FinancialPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
try {
@@ -204,17 +196,6 @@
return result;
}
-
- @Override
- public List<FinancialPeriod> getUnblockedFinancialPeriodWithFiscalPeriod(FiscalPeriod selectedFiscalPeriod) throws LimaException {
-
- Collection<FinancialPeriod> temp = selectedFiscalPeriod.getFinancialPeriod();
-
- List result = new ArrayList<FinancialPeriod>(temp);
- log.debug("result : "+result);
-
- return result;
- }
/*
* Permet de trouver un timespan directement avec une date. La date peut
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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -25,15 +25,11 @@
import javax.ejb.Stateless;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.FinancialTransactionService;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -443,6 +439,8 @@
topiaTransaction = rootContext.beginTransaction();
FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
transactionDAO.update(financialtransaction);
+ // commit
+ topiaTransaction.commitTransaction();
}
catch (TopiaException ex) {
doCatch(topiaTransaction, ex, log);
@@ -463,6 +461,8 @@
topiaTransaction = rootContext.beginTransaction();
FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
transactionDAO.delete(financialtransaction);
+ // commit
+ topiaTransaction.commitTransaction();
}
catch (TopiaException ex) {
doCatch(topiaTransaction, ex, log);
@@ -474,7 +474,6 @@
}
-
/*
* Permet d'ajouter une entrée comptable pour une transaction donnée.
* ATTENTION : la transaction doit être NON bloquée.
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-28 15:59:14 UTC (rev 2876)
@@ -3,6 +3,8 @@
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.identity.tagvalue.lazy=false
org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -1,98 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.listener;
-
-import org.chorem.lima.dto.EntryDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.table.TransactionJXTable;
-import org.chorem.lima.table.model.TransactionFlattenTableModel;
-
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-
-/**
- * Cette classe permet de définir les actions possibles sur la table des
- * transactions. Ainsi lorsque l'utilisateur clique sur une ligne, il est possible
- * d'assigner une action précise.
- *
- * @author ore
- * @author Rémi Chapelet
- */
-public class EmptyLineSelectionListener extends MouseAdapter {
-
- @Override
- public void mouseClicked(MouseEvent e) {
- TransactionJXTable table = (TransactionJXTable) e.getSource();
- if (TransactionFlattenTableModel.isFlattenModel(table.getModel()))
- {
- TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table.getModel();
- if (table.getSelectionModel().isSelectionEmpty())
- {
- // Not line selected
- } else {
- // Line selected
- int selectedRow = table.getSelectedRow();
- int parentIndex = flattenModel.getParentIndex(selectedRow);
- /**
- * Is transaction editable ?
- */
- Object o = flattenModel.getElementAt(parentIndex);
- if (DTOHelper.isTransaction(o)) {
- // Transaction n'est pas éditable
- if (!ServiceHelper.isEditable((TransactionDTO) o)) {
- return;
- }
- } else {
- //Entry n'est pas éditable
- if (!ServiceHelper.isEditable((EntryDTO) o)) {
- return;
- }
- }
-
- // Click in not current transaction
- if (flattenModel.getCurrentParentIndex() != parentIndex) {
- int posNext = flattenModel.emptyLineNextPosition(selectedRow);
- /**
- * Once traitement for transaction
- */
- if (flattenModel.isEmptyLineEmpty()) {
- flattenModel.createEmptyLine();
- } else {
- flattenModel.removeEmptyLine();
- selectedRow = table.getSelectedRow();
- parentIndex = flattenModel.getParentIndex(selectedRow);
- posNext = flattenModel.emptyLineNextPosition(selectedRow);
- flattenModel.createEmptyLine();
- }
- flattenModel.addEmptyLine(posNext);
-
- // To end
- flattenModel.setCurrentParentIndex(parentIndex);
- }
- /**
- * New Line Color
- */
- table.addColorEmptyLine();
- }
- }
- }
-}
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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -33,6 +33,7 @@
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;
@@ -168,7 +169,7 @@
}
return ejbHome;
}
-
+
/**
* Get FinancialPeriod service.
*
@@ -212,9 +213,9 @@
}
/**
- * Get transaction service.
+ * Get entrybook service.
*
- * @return transaction service proxy
+ * @return entrybook service proxy
*/
public EntryBookService getEntryBookService() {
@@ -233,6 +234,29 @@
}
/**
+ * 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
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -120,7 +120,7 @@
// cell editoring
tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellEditor(DateTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellEditor(AccountTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(JournalTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(EntryBookTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -22,12 +22,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.AccountComboBoxModel;
import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.util.AccountToStringConverter;
+import org.chorem.lima.entity.FinancialPeriodDAO;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
import javax.swing.*;
@@ -57,7 +53,7 @@
private final JComboBox comboBox;
private static final long serialVersionUID = 1525438571250871093L;
private static AccountTableCellEditor editor;
- private static boolean keyPressed = false;
+ //private static boolean keyPressed = false;
/**
* Constructor
@@ -65,11 +61,13 @@
public AccountTableCellEditor() {
// Création du comboBox pour les comptes, elle hérite de comboBox
- comboBox = new JWideComboBox();
-
+ comboBox = new JComboBox();
/**
* Charge les comptes dans la comboBox
*/
+ FinancialPeriodDAO financialPeriodDAO =
+
+
// Get data from services
List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
LimaContext.getContext().getDataManager().getAccountModel().getData());
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -1,72 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.table.editor;
-
-import org.chorem.lima.LimaContext;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.*;
-import javax.swing.table.TableCellEditor;
-import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.util.Date;
-import java.util.EventObject;
-
-/**
- * @author ore
- */
-public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- private final JXDatePicker datePicker;
- private static final long serialVersionUID = -8455896587828255307L;
- private static DateTableCellEditor editor;
-
- /**
- *
- */
- public DateTableCellEditor() {
- datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof Date) {
- datePicker.setDate((Date) value);
- }
- return datePicker;
- }
-
- @Override
- public Object getCellEditorValue() {
- return datePicker.getDate();
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static DateTableCellEditor getInstance() {
- if (editor == null) {
- editor = new DateTableCellEditor();
- }
- return editor;
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -0,0 +1,98 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction.table;
+
+import org.chorem.lima.dto.EntryDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.service.util.ServiceHelper;
+import org.chorem.lima.table.TransactionJXTable;
+import org.chorem.lima.table.model.TransactionFlattenTableModel;
+
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/**
+ * Cette classe permet de définir les actions possibles sur la table des
+ * transactions. Ainsi lorsque l'utilisateur clique sur une ligne, il est possible
+ * d'assigner une action précise.
+ *
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class EmptyLineSelectionListener extends MouseAdapter {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ TransactionJXTable table = (TransactionJXTable) e.getSource();
+ if (TransactionFlattenTableModel.isFlattenModel(table.getModel()))
+ {
+ TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table.getModel();
+ if (table.getSelectionModel().isSelectionEmpty())
+ {
+ // Not line selected
+ } else {
+ // Line selected
+ int selectedRow = table.getSelectedRow();
+ int parentIndex = flattenModel.getParentIndex(selectedRow);
+ /**
+ * Is transaction editable ?
+ */
+ Object o = flattenModel.getElementAt(parentIndex);
+ if (DTOHelper.isTransaction(o)) {
+ // Transaction n'est pas éditable
+ if (!ServiceHelper.isEditable((TransactionDTO) o)) {
+ return;
+ }
+ } else {
+ //Entry n'est pas éditable
+ if (!ServiceHelper.isEditable((EntryDTO) o)) {
+ return;
+ }
+ }
+
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = flattenModel.emptyLineNextPosition(selectedRow);
+ /**
+ * Once traitement for transaction
+ */
+ if (flattenModel.isEmptyLineEmpty()) {
+ flattenModel.createEmptyLine();
+ } else {
+ flattenModel.removeEmptyLine();
+ selectedRow = table.getSelectedRow();
+ parentIndex = flattenModel.getParentIndex(selectedRow);
+ posNext = flattenModel.emptyLineNextPosition(selectedRow);
+ flattenModel.createEmptyLine();
+ }
+ flattenModel.addEmptyLine(posNext);
+
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+ /**
+ * New Line Color
+ */
+ table.addColorEmptyLine();
+ }
+ }
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -1,97 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.table.editor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.JournalComboBoxModel;
-import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer;
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.util.JournalToStringConverter;
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-
-import javax.swing.*;
-import javax.swing.table.TableCellEditor;
-import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.util.EventObject;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * @author ore
- */
-public class JournalTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- /**
- * log
- */
- protected static final Log log = LogFactory.getLog(JournalTableCellEditor.class);
- private final JComboBox comboBox;
- private static final long serialVersionUID = 2580476608066111095L;
- private static JournalTableCellEditor editor;
-
- /**
- *
- */
- public JournalTableCellEditor() {
-
- comboBox = new JWideComboBox();
-
- /** Getting data from journal model **/
- List<JournalDTO> journals = LimaContext.getContext().getDataManager().getJournalModel().getData();
-
- /** Creating combobox model */
- Vector<JournalDTO> v = new Vector<JournalDTO>(journals);
- JournalComboBoxModel comboBoxModel = new JournalComboBoxModel(v);
- /** Property Change Listener */
- LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
- comboBox.setModel(comboBoxModel);
- /** Renderer */
- comboBox.setRenderer(JournalComboBoxRenderer.getInstance());
-
- /** AutoCompletion */
- AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());
- }
-
- @Override
- public Object getCellEditorValue() {
- return comboBox.getSelectedItem();
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- return comboBox;
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static JournalTableCellEditor getInstance() {
- if (editor == null) {
- editor = new JournalTableCellEditor();
- }
- return editor;
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -27,7 +27,6 @@
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.AboutPanel;
-import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -1,410 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.fiscalperiod;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.swing.JComboBox;
-import javax.swing.ListSelectionModel;
-import javax.swing.RowFilter;
-
-import jaxx.runtime.JAXXContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.model.PeriodComboBoxModel;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.StatusDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.TriPeriodAsc;
-import org.chorem.lima.dto.util.TriPeriodDesc;
-import org.chorem.lima.table.model.ClosureTableModel;
-import org.chorem.lima.ui.ErrorMessage;
-import org.chorem.lima.ui.period.AddPeriod;
-import org.chorem.lima.ui.period.ClosureTimeSpanForm;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-
-/**
- * Permet l'affichage du tableau avec les périodes mensuelles.
- *
- * @author Rémi Chapelet
- */
-public class ClosureViewImpl extends ClosureView {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8759564865633991757L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(ClosureViewImpl.class);
-
- private final JXTable table;
- private JComboBox comboBoxPeriod = new JComboBox();
- private final ClosureTimeSpanForm form;
- private final AddPeriod addPeriodForm;
- private static boolean blockPeriod;
- private JComboBox comboBoxBeginPeriod = new JComboBox();
- private JComboBox comboBoxEndPeriod = new JComboBox();
- private JComboBox comboBeginYearPeriod = new JComboBox();
- private JComboBox comboBeginMonthPeriod = new JComboBox();
- private JComboBox comboEndYearPeriod = new JComboBox();
- private JComboBox comboEndMonthPeriod = new JComboBox();
-
- /**
- * @param parentContext
- */
- public ClosureViewImpl(JAXXContext parentContext) {
- super(parentContext);
-
- // Initialisation du choix pour les périodes
- initComboBoxPeriod();
-
- /* Set Period model */
- // Création du model pour le tableau
- table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel());
- table.setRowHeight(24);
- // Permet d'alterner les couleurs des lignes pour le tableau
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- // Definition de la selection possible sur les lignes
- table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- table.setColumnControlVisible(true);
-
- /*
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Récupère la période master
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)};
- //FilterPipeline filters = new FilterPipeline(filterArray);
-
- RowFilter<Object, Object> filter = null;
- if (periodMaster != null) {
- // 0 = check only in first column
- // filter :
- // period name containing selected periode
- // Final = ??? TODO
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(periodMaster.getBegin());
- filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0);
- if (log.isDebugEnabled()) {
- log.debug("Apply filter on " + calendar.get(Calendar.YEAR));
- }
- }
- table.setRowFilter(filter);
- }
- });
-
- // Ajout du tableau dans l'UI
- getClosureScrollPane().setViewportView(table);
-
- /*
- * Initialisation du formulaire pour bloquer ou débloquer une période.
- */
- form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm();
- form.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- updatePeriod();
- }
- });
-
- /**
- * Initialisation du formulaire pour ajouter un exercice
- */
- addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod();
-
- Calendar cal = Calendar.getInstance();
-
- //Init YEAR Periode Combobox
- // take care about previous year #120
- int todayYear = cal.get(Calendar.YEAR);
- for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) {
- comboBeginYearPeriod.addItem(currentYear);
- comboEndYearPeriod.addItem(currentYear);
- }
- comboBeginYearPeriod.setSelectedItem(todayYear);
- comboEndYearPeriod.setSelectedItem(todayYear);
-
-
- //Add BeginYear ComboBox to addPeriodForm
- addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod);
- addPeriodForm.getBeginYearPeriodPanel().validate();
-
- //Add EndYear ComboBox to addPeriodForm
- addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod);
- addPeriodForm.getEndYearPeriodPanel().validate();
-
- //Init MONTH Periode Combobox
- cal.set(Calendar.MONTH, Calendar.JANUARY);
- for (int j = 0; j <= 11; j++) {
- comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- cal.add(Calendar.MONTH, 1);
- }
-
- //Add BeginMonth ComboBox to addPeriodForm
- addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod);
- addPeriodForm.getBeginMonthPeriodPanel().validate();
-
- //Add EndMonth ComboBox to addPeriodForm
- addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod);
- addPeriodForm.getEndMonthPeriodPanel().validate();
-
- addPeriodForm.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addPeriod();
- addPeriodForm.dispose();
- }
- });
-
- }
-
-
- /**
- * Cette méthode permet de charger les périodes (annuelles) pour choisir
- * les périodes mensuelles à afficher dans le tableau.
- */
- public void initComboBoxPeriod() {
- /**
- * Charge pour le JComboBox le choix des périodes (exercices) à afficher.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxPeriod.setModel(periodModel);
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
-
- /**
- * Cette méthode permet d'initialiser le formulaire pour bloquer une ou
- * plusieurs périodes.
- */
- @Override
- public void initBlockForm() {
- blockPeriod = true;
- form.setTitle(_("lima.ui.block.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise le formulaire pour débloquer des périodes mensuelles.
- */
- @Override
- public void initUnblockForm() {
- blockPeriod = false;
- form.setTitle(_("lima.ui.unblock.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise les combobox pour le formulaire de période. Il ajoute ainsi
- * les deux combobox nécessaires pour début et fin de période.
- */
- public void initComboBoxForm() {
- /**
- * Charge pour les JComboBox le choix des périodes mensuelles à bloquer.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxBeginPeriod.setModel(periodModel);
- comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Création Combobox fin période
- comboBoxEndPeriod.setModel(periodModel);
- comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- form.beginPeriod.add(comboBoxBeginPeriod);
- form.endPeriod.add(comboBoxEndPeriod);
-
- /**
- * Positionne, si les lignes sont sélectionnées, les comboBox sur
- * les bonnes périodes (période min et période max).
- */
- // Si une ou plusieurs lignes sont sélectionnées
- if (table.getSelectedRow() != -1) {
- // Récupère les périodes sélectionnées
- List<PeriodDTO> listPeriod = getSelectedPeriod();
- // Parcours du vecteur
- comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0));
- comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1)));
- }
- }
-
-
- /**
- * Permet d'ajouter un nouvel exercice.
- */
- protected void addPeriod() {
- if (log.isDebugEnabled()) {
- log.debug("addPeriod : ");
- //Get form data
- }
- PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod();
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
-
- // get begin date
- Calendar beginCalendar = Calendar.getInstance();
- if (periodCurrent != null) {
- beginCalendar.setTime(periodCurrent.getBegin());
- }
- beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem());
- beginCalendar.set(Calendar.DAY_OF_MONTH, 1);
- // month is equals to list index
- beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex());
- Date beginDate = beginCalendar.getTime();
-
- // get end date
- Calendar endCalendar = Calendar.getInstance();
- endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem());
- endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex());
- int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
- endCalendar.set(Calendar.DAY_OF_MONTH, maximum);
- Date endDate = endCalendar.getTime();
-
- if (log.isDebugEnabled()) {
- log.debug("Add new periode from " + beginDate + " to " + endDate);
- }
-
- String periodName = null;
- if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) {
- periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR));
- }
- else {
- periodName = Integer.toString(beginCalendar.get(Calendar.YEAR));
- }
-
- // TODO what is status.get(3) ???
- PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3));
-
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- closureModel.addPeriod(period, status);
- }
-
- /**
- * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer
- * une ou plusieurs périodes, ou bien débloquer.
- * On récupère l'intervalle des périodes donné par le formulaire. On prend
- * les périodes aux extrémités.
- * Si on bloque les périodes, on va trier par ordre croissant sinon par
- * ordre décroissant. En effet, pour débloquer une période, il est important
- * que les périodes qui suivent soient bloquées ; par conséquent on doit
- * commencer par les dernières.
- */
- protected void updatePeriod() {
- // Liste des status
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
- // Liste des transactions
- List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData();
- // Chargement du model
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- /**
- * Récupère l'intervalle des périodes sélectionnées
- */
- PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem();
- PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem();
- // Exercice
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- // Si block période, on trie la liste en croissant ou bien décroissant
- List<PeriodDTO> listPeriod = periodMaster.getChildren();
- if (blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- } else {
- Collections.sort(listPeriod, new TriPeriodDesc());
- }
- // Pour toutes les périodes mensuelles
- for (PeriodDTO period : listPeriod) {
- if (((period.getBegin().after(periodBegin.getBegin()))
- && (period.getBegin().before(periodEnd.getBegin())))
- || (period.equals(periodBegin))
- || (period.equals(periodEnd))) {
- if (log.isDebugEnabled()) {
- log.debug("updatePeriod : " + period.getIdName() + " : "
- + blockPeriod);
- }
- /**
- * Détection des messages d'erreur
- */
- String message = closureModel.updatePeriod(period, blockPeriod, status, transactions);
- ErrorMessage.showMessage(message);
- }
- }
- // On trie par ordre croissant si c'était en décroissant, sinon l'affichage
- // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre
- // décroissant).
- if (!blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- }
- form.setVisible(false);
- form.dispose();
- }
-
- /**
- * Cette méthode permet de retourner une liste des périodes sélectionnées.
- *
- * @return liste des périodes sélectionnées
- */
- protected List<PeriodDTO> getSelectedPeriod() {
- // récupère les lignes sélectionnées
- int viewIndex[] = table.getSelectedRows();
- // chargement du model (tableau des périodes)
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>();
- // Pour chaque ligne sélectionnée
- for (int i : viewIndex) {
- int modelIndex = table.convertRowIndexToModel(i);
- listPeriod.add(closureModel.getRow(modelIndex));
- }
- return listPeriod;
- }
-
-
- public void initAddPeriod() {
- addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod"));
- addPeriodForm.setVisible(true);
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -23,9 +23,6 @@
import org.chorem.lima.LimaContext;
import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
import org.chorem.lima.balance.BalanceHelper;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
import org.chorem.lima.table.model.BalanceTableModel;
import org.chorem.lima.table.renderer.BalanceTableCellRenderer;
import static org.nuiton.i18n.I18n._;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -21,17 +21,13 @@
import org.chorem.lima.LimaContext;
import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.BalanceDTO;
import org.chorem.lima.bilan.Bilan;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
import org.chorem.lima.balance.BalanceHelper;
import org.chorem.lima.balance.Category;
import org.chorem.lima.table.BilanActifJXTable;
import org.chorem.lima.table.BilanPassifJXTable;
import org.chorem.lima.table.model.BilanActifTableModel;
import org.chorem.lima.table.model.BilanPassifTableModel;
-import org.chorem.lima.ui.MainViewImpl;
import org.chorem.lima.ui.ProgressBarImpl;
import java.awt.event.*;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -23,14 +23,10 @@
import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
import org.chorem.lima.balance.BalanceHelper;
import org.chorem.lima.balance.Category;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
import org.chorem.lima.table.ResultChargesJXTable;
import org.chorem.lima.table.ResultProduitsJXTable;
import org.chorem.lima.table.model.ResultChargesTableModel;
import org.chorem.lima.table.model.ResultProduitsTableModel;
-import org.chorem.lima.util.Util;
import static org.nuiton.i18n.I18n._;
import org.apache.commons.logging.Log;
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -1,217 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.item.Item;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.ui.transaction.autocomplete.AccountToStringConverter;
-import org.chorem.lima.ui.transaction.model.AccountComboBoxModel;
-import org.chorem.lima.widgets.JWideComboBox;
-import org.jdesktop.swingx.JXDatePicker;
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Date;
-import java.util.List;
-import java.util.Vector;
-
-import jaxx.runtime.JAXXContext;
-
-/**
- * @author ore
- */
-public class CriteriaWidgetImpl extends CriteriaWidget {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(CriteriaWidgetImpl.class);
- private JTextField inputTextField;
- private JXDatePicker datePicker;
- private JComboBox comboBox;
- private JComboBox accountCombo;
-
- /**
- * @param parentContext
- */
- public CriteriaWidgetImpl(JAXXContext parentContext) {
- super(parentContext);
-
- // date input creation
- createDateInput();
-
- // item changed listener
- criteriaComboBox.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- String itemSelected = e.getItem().toString();
- if (itemSelected.equals("date")) {
- createDateInput();
- }
- if (itemSelected.equals("voucher") ||
- itemSelected.equals("description") ||
- itemSelected.equals("account")) {
- createTextInput();
- }
- if (itemSelected.equals("debit") ||
- itemSelected.equals("credit") ||
- itemSelected.equals("amount")) {
- createNumberInput();
- }
- if (itemSelected.equals("account")) {
- createAccountInput();
- }
- }
- }
- });
- }
-
- /**
- *
- */
- private void createNumberInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.greater.than")));
- getComboBox().addItem(new Item(2, _("lima.filter.less.than")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getInputTextField());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("numberinput : ");
- }
- }
-
- /**
- *
- */
- private void createTextInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.contains")));
- getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getInputTextField());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("textinput : ");
- }
- }
-
- /**
- *
- */
- private void createAccountInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.contains")));
- getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getAccountCombo());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("accountinput : ");
- }
- }
-
- /**
- *
- */
- private void createDateInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.before")));
- getComboBox().addItem(new Item(2, _("lima.filter.after")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getDatePicker());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("dateinput : ");
- }
- }
-
- @Override
- protected void removeCriteriaWidget() {
- LimaContext.getContext().getMainUI().getSearchView().removeCriteriaWidget(this);
- }
-
- /**
- * @return
- */
- public JComboBox getComboBox() {
- if (comboBox == null) {
- comboBox = new JComboBox();
- }
- return comboBox;
- }
-
- /**
- * @return
- */
- public JXDatePicker getDatePicker() {
- if (datePicker == null) {
- datePicker = new JXDatePicker(new Date(), LimaContext.getContext().getConfig().getLocale());
- }
- return datePicker;
- }
-
- /**
- * @return
- */
- public JTextField getInputTextField() {
- if (inputTextField == null) {
- inputTextField = new JTextField();
- inputTextField.setPreferredSize(new Dimension(150, 20));
- }
- return inputTextField;
- }
-
- public JComboBox getAccountCombo() {
- if (accountCombo == null) {
- List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
- LimaContext.getContext().getDataManager().getAccountModel().getData());
- Vector<AccountDTO> v = new Vector<AccountDTO>(accounts);
- AccountComboBoxModel model = new AccountComboBoxModel(v);
- accountCombo = new JWideComboBox(model);
- accountCombo.setRenderer(AccountComboBoxRenderer.getInstance());
- accountCombo.setPreferredSize(new Dimension(200, 25));
- // AutoCompletion
- AutoCompleteDecorator.decorate(accountCombo, AccountToStringConverter.getInstance());
- }
- return accountCombo;
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -79,7 +79,13 @@
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
Object selectedValue = model.getElementAt(indexSelectedRow);
+ try {
model.addEmptyEntry(selectedValue, indexSelectedRow);
+ } catch (LimaException ex){
+ if (log.isWarnEnabled()) {
+ log.warn("Can't add empty entry");
+ }
+ }
}
else {
if (log.isWarnEnabled()) {
@@ -121,26 +127,11 @@
try {
model.removeObject(selectedValue, indexSelectedRow);
} catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove transaction or entry", ex);
- }
- ErrorHelper.showErrorDialog("Can't remove transaction or entry", ex);
- }
-
- /*
- if (selectedValue instanceof Transaction) {
- // TODO EC-20100409 implements this
- if (log.isWarnEnabled()) {
- log.warn("TODO implement Transaction deletion");
- model.removeTransaction(selectedValue);
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove transaction or entry", ex);
}
+ ErrorHelper.showErrorDialog("Can't remove transaction or entry", ex);
}
- else if (selectedValue instanceof Entry) {
- // TODO EC-20100409 implements this
- if (log.isWarnEnabled()) {
- log.warn("TODO implement Entry deletion");
- }
- }*/
}
}
else {
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -0,0 +1,14 @@
+package org.chorem.lima.ui.transaction;
+
+public class SearchFinancialTransactionViewHandler {
+
+
+ protected void addCriteriaWidget() {
+
+ }
+
+ protected void doSearch() {
+
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.dto.util.DTOHelper;
import org.chorem.lima.enumeration.FilterEnum;
import org.chorem.lima.table.TransactionJXTable;
import org.jdesktop.swingx.JXDatePicker;
@@ -47,7 +46,7 @@
* @param parentContext
*/
public SearchTransactionViewImpl(JAXXContext parentContext) {
- super(parentContext);
+ super(parentContext);
// At Least one criteria
CriteriaWidgetImpl widget = new CriteriaWidgetImpl();
Modified: 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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-28 15:59:14 UTC (rev 2876)
@@ -74,7 +74,7 @@
</cell>
</row>
<row>
- <cell fill="both" weightx="1" weighty="1" rows="3" columns="5">
+ <cell fill="both" weightx="1" weighty="1" rows="3" columns="6">
<JScrollPane>
<org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel
id="financialTransactionTableModel" />
@@ -87,26 +87,27 @@
onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
- <cell>
- <JButton text="lima.add.transaction"
- onActionPerformed="getHandler().addFinancialTransaction()"/>
- </cell>
- </row>
- <row>
- <cell>
- <!--
- <JButton text="lima.remove.transaction"
- onActionPerformed="getHandler().removeTransaction()"
- enabled="{isSelectedRow()}"/>
- -->
- <JButton text="lima.remove.transaction"
+ <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>
- <row>
- <cell>
- <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/>
- </cell>
- </row>
</Table>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -34,18 +34,10 @@
import org.chorem.lima.combobox.model.PeriodComboBoxModel;
import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer;
import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.EntryDTO;
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.DTOHelper;
import org.chorem.lima.enumeration.FilterEnum;
import org.chorem.lima.listener.ClicRight;
-import org.chorem.lima.service.util.ServiceHelper;
import org.chorem.lima.table.model.*;
import org.chorem.lima.table.TransactionJXTable;
-import org.chorem.lima.ui.ErrorMessage;
-import org.chorem.lima.util.Util;
import static org.nuiton.i18n.I18n._;
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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -18,35 +18,78 @@
package org.chorem.lima.ui.transaction.model;
-import javax.swing.DefaultComboBoxModel;
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
/**
* Account combo box model.
- *
- * Used in:
- * - lettering view
- *
- * @author ore
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
*/
-public class AccountComboBoxModel extends DefaultComboBoxModel {
- /** serialVersionUID. */
- private static final long serialVersionUID = -6914345613508897515L;
+public class AccountComboBoxModel implements ComboBoxModel {
+
+ protected AccountService accountService;
+
+ public AccountComboBoxModel() {
+ accountService = LimaServiceFactory.getInstance().getAccountService();
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ // TODO Auto-generated method stub
+ return null;
+ }
- /** log. */
- private static final Log log = LogFactory.getLog(AccountComboBoxModel.class);
+ @Override
+ public void setSelectedItem(Object anItem) {
+ // TODO Auto-generated method stub
+
+ }
- /**
- * @param items
- */
- public AccountComboBoxModel() {
- super();
+ @Override
+ public void addListDataListener(ListDataListener arg0) {
+ // TODO Auto-generated method stub
+
}
+
+ @Override
+ public Object getElementAt(int index) {
+ Object result = null;
+ // TODO add cache
+ try {
+ result = accountService.getAllAccounts().get(index);
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ @Override
+ public int getSize() {
+ int result = 0;
+ // TODO add cache
+ try {
+ result = accountService.getAllAccounts().size();
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ @Override
+ public void removeListDataListener(ListDataListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -0,0 +1,30 @@
+package org.chorem.lima.ui.transaction.model;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import org.chorem.lima.entity.Account;
+
+public class AccountRenderer extends DefaultListCellRenderer {
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+ // TODO Auto-generated method stub
+
+ JLabel label = new JLabel();
+ Account account = (Account) value;
+ if (account != null){
+ label.setText(account.getAccountNumber()+" - "+account.getLabel());
+ }
+ return label;
+
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -18,9 +18,12 @@
package org.chorem.lima.ui.transaction.model;
+import java.util.Collection;
+
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
+import org.apache.commons.collections.CollectionUtils;
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FiscalPeriod;
@@ -60,9 +63,8 @@
// TODO add cache
try {
if (selectedFiscalPeriod != null){
- result = financialPeriodService.
- getUnblockedFinancialPeriodWithFiscalPeriod(
- selectedFiscalPeriod).size();
+
+ result = selectedFiscalPeriod.getFinancialPeriod().size();
}
else {
result = financialPeriodService.
@@ -85,9 +87,7 @@
// TODO add cache
try {
if (selectedFiscalPeriod != null){
- result = financialPeriodService.
- getUnblockedFinancialPeriodWithFiscalPeriod(
- selectedFiscalPeriod).get(index);
+ result = CollectionUtils.get(selectedFiscalPeriod.getFinancialPeriod(), index);
}
else {
result = financialPeriodService.getUnblockedFinancialPeriods().
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -21,7 +21,6 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Component;
-import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -0,0 +1,82 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+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.JComboBox;
+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.Account;
+import org.chorem.lima.ui.transaction.model.AccountComboBoxModel;
+import org.chorem.lima.ui.transaction.model.AccountRenderer;
+
+public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+
+ protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
+ private final JComboBox comboBox;
+ private static final long serialVersionUID = 2580476608066111095L;
+ private static AccountTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public AccountTableCellEditor() {
+ comboBox = new JComboBox();
+ AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel();
+ comboBox.setModel(accountComboBoxModel);
+ AccountRenderer accountRenderer = new AccountRenderer();
+ comboBox.setRenderer(accountRenderer);
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof Account){
+ comboBox.setSelectedItem((Account) value);
+
+ }
+ return comboBox;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return comboBox.getSelectedItem();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static AccountTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new AccountTableCellEditor();
+ }
+ return editor;
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -0,0 +1,72 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction.table;
+
+import org.chorem.lima.LimaContext;
+import org.jdesktop.swingx.JXDatePicker;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.util.Date;
+import java.util.EventObject;
+
+/**
+ * @author ore
+ */
+public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ private final JXDatePicker datePicker;
+ private static final long serialVersionUID = -8455896587828255307L;
+ private static DateTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public DateTableCellEditor() {
+ datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof Date) {
+ datePicker.setDate((Date) value);
+ }
+ return datePicker;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return datePicker.getDate();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static DateTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new DateTableCellEditor();
+ }
+ return editor;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -0,0 +1,88 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction.table;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel;
+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 static final long serialVersionUID = 2580476608066111095L;
+ private static EntryBookTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public EntryBookTableCellEditor() {
+ log.debug("test");
+ comboBox = new JWideComboBox();
+ EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
+ comboBox.setModel(entryBookComboBoxModel);
+ EntryBookRenderer entryBookRenderer = new EntryBookRenderer();
+ comboBox.setRenderer(entryBookRenderer);
+
+ /*// Property Change Listener
+ LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
+ comboBox.setModel(comboBoxModel);
+ // AutoCompletion
+ AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof EntryBook){
+ comboBox.setSelectedItem((EntryBook) value);
+
+ }
+ return comboBox;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return comboBox.getSelectedItem();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static EntryBookTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new EntryBookTableCellEditor();
+ }
+ return editor;
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-04-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -17,13 +17,14 @@
* ##%*/
package org.chorem.lima.ui.transaction.table;
+
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.listener.EmptyLineSelectionListener;
-import org.chorem.lima.table.editor.DateTableCellEditor;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.ui.transaction.FinancialTransactionViewHandler;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
@@ -51,8 +52,6 @@
private ColorHighlighter colorBalance;
- private EmptyLineSelectionListener emptyLineSelectionListener;
-
/**
*/
public FinancialTransactionTable(FinancialTransactionViewHandler handler/*,
@@ -105,8 +104,12 @@
tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/
+ //Get new date editor
setDefaultEditor(Date.class, new DateTableCellEditor());
-
+ //Get new entry book editor
+ setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
+ //Get new account editor
+ setDefaultEditor(Account.class, new AccountTableCellEditor());
// Color transactions
// addColorTransaction();
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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-28 15:59:14 UTC (rev 2876)
@@ -25,15 +25,14 @@
import java.util.Date;
import java.util.List;
-import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;
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.LimaBusinessException;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.RecordService;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
@@ -41,13 +40,10 @@
import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransactionImpl;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.transaction.FinancialTransactionHelper;
import org.chorem.lima.util.ErrorHelper;
-import org.nuiton.topia.TopiaContextFactory;
/**
* Basic transaction table model.
@@ -79,8 +75,11 @@
/** Transaction service. */
protected final FinancialTransactionService transactionService;
+
+ /** Entry service. */
+ protected final EntryService entryService;
/** Record service. */
- protected final RecordService recordService;
+ //protected final RecordService recordService;
protected EntryBook selectedEntryBook;
@@ -93,9 +92,10 @@
*/
public FinancialTransactionTableModel() {
/* Services */
- recordService = LimaServiceFactory.getInstance().getRecordService();
+ // recordService = LimaServiceFactory.getInstance().getRecordService();
transactionService = LimaServiceFactory.getInstance()
.getTransactionService();
+ entryService = LimaServiceFactory.getInstance().getEntryService();
}
/**
@@ -111,7 +111,8 @@
try {
List<FinancialTransaction> financialtransactions =
- transactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
+ transactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod(
+ selectedEntryBook, selectedFinancialPeriod);
for (FinancialTransaction financialtransaction : financialtransactions) {
results.add(financialtransaction);
@@ -133,7 +134,7 @@
@Override
public int getColumnCount() {
- return 10;
+ return 9;
}
@Override
@@ -146,32 +147,29 @@
result = Date.class;
break;
case 1:
- result = Account.class;
+ result = String.class;
break;
case 2:
result = EntryBook.class;
break;
case 3:
- result = FinancialPeriod.class;
+ result = Account.class;
break;
case 4:
result = String.class;
break;
case 5:
- result = Double.class;
+ result = String.class;
break;
case 6:
result = Double.class;
break;
case 7:
- result = String.class;
+ result = Double.class;
break;
case 8:
- result = String.class;
+ result = Double.class;
break;
- case 9:
- result = String.class;
- break;
}
return result;
@@ -186,32 +184,29 @@
result = _("lima.transaction.column.date");
break;
case 1:
- result = _("lima.transaction.column.account");
+ result = _("lima.transaction.column.voucher");
break;
case 2:
result = _("lima.transaction.column.entrybook");
break;
case 3:
- result = _("lima.transaction.column.period");
+ result = _("lima.transaction.column.account");
break;
case 4:
- result = _("lima.transaction.column.status");
+ result = _("lima.transaction.column.description");
break;
case 5:
- result = _("lima.transaction.column.debit");
+ result = _("lima.transaction.column.position");
break;
case 6:
- result = _("lima.transaction.column.credit");
+ result = _("lima.transaction.column.debit");
break;
case 7:
- result = _("lima.transaction.column.balance");
+ result = _("lima.transaction.column.credit");
break;
case 8:
- result = _("lima.transaction.column.description");
+ result = _("lima.transaction.column.balance");
break;
- case 9:
- result = _("lima.transaction.column.document");
- break;
}
return result;
@@ -249,36 +244,36 @@
FinancialTransaction currentRow = (FinancialTransaction)result;
switch (column) {
case 0:
- result = currentRow.getTransactionDate();
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(currentRow.getTransactionDate());
+ result = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
break;
case 1:
- result = null; // account ?
+ result = null; // voucher
break;
case 2:
- result = null; // entry book
+ //TODO Lazy exception make a methode to get entrybook from the currentFinancialTransaction
+ result = currentRow.getEntryBook().getLabel();
break;
case 3:
- result = null; //currentRow.getFinancialPeriod();
+ result = null; // account;
break;
case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
+ result = null; // description;
break;
- case 5:
- result = FinancialTransactionHelper.getDebit(currentRow);
+ case 5 :
+ result = null; //position;
break;
case 6:
- result = FinancialTransactionHelper.getCredit(currentRow);
+ result = FinancialTransactionHelper.getDebit(currentRow);
break;
case 7:
+ result = FinancialTransactionHelper.getCredit(currentRow);
+ break;
+ case 8:
result = FinancialTransactionHelper.getDebit(currentRow)
- FinancialTransactionHelper.getCredit(currentRow);
break;
- case 8:
- result = currentRow.getDescription();
- break;
- case 9:
- result = currentRow.getVoucherRef();
- break;
}
}
else if (result instanceof Entry) {
@@ -287,33 +282,30 @@
case 0:
result = null; // date
break;
- case 1:
- result = currentEntry.getAccount(); // account ?
+ case 1 :
+ result = currentEntry.getVoucher();
break;
case 2:
result = null; // entry book
break;
case 3:
- result = null; //currentRow.getFinancialPeriod();
+ result = currentEntry.getAccount().getLabel();// account
break;
case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
+ result = currentEntry.getDescription();
break;
- case 5:
- result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
+ case 5 :
+ result = currentEntry.getPosition();
break;
case 6:
- result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
break;
case 7:
- result = null;
+ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
break;
case 8:
- result = currentEntry.getDescription();
+ result = null; // balance
break;
- case 9:
- result = null;
- break;
}
}
}
@@ -339,7 +331,28 @@
fireTableDataChanged();
}
+
/**
+ * To set cells editable or not
+ * different condition for entry or financial transaction
+ */
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ boolean editableCell=false;
+ 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)) {
+ editableCell=true;
+ }
+ // cells editable for the financialtransaction row, no cells exclude the date
+ if ((currentRow instanceof FinancialTransaction) && (columnIndex==0 || columnIndex==2)){
+ editableCell=true;
+ }
+ return editableCell;
+ }
+
+ /**
* @throws LimaException
*/
public void addFinancialTransaction() throws LimaException{
@@ -354,15 +367,14 @@
Calendar actualCalendar = Calendar.getInstance();
// get the financial period date
Date transactionDate = selectedFinancialPeriod.getBeginDate();
- //change the day
- transactionDate = DateUtils.setDays(transactionDate, actualCalendar.get(Calendar.DAY_OF_MONTH));
- //set date to the financial transaction
+ // change the day
+ transactionDate = DateUtils.setDays(transactionDate,
+ actualCalendar.get(Calendar.DAY_OF_MONTH));
+ // set date to the financial transaction
financialTransaction.setTransactionDate(transactionDate);
- //create it
+ // create it
transactionService.createFinancialTransaction(financialTransaction);
int row = getDataList().indexOf(financialTransaction);
- //int row = transactionService.getAllTransactions().indexOf(transaction);
- log.debug(row);
fireTableRowsInserted(row, row);
}
else {
@@ -375,24 +387,30 @@
/**
* @throws LimaException
*/
- public void addEmptyEntry(Object value, int row) {
- /* Calling transaction service */
- //TODO transaction = currentdate, current periode, current journal
+ public void addEmptyEntry(Object value, int row) throws LimaException {
+ FinancialTransaction currentTransaction = null;
List<Object> datas = getDataList();
Object currentRow = datas.get(row);
Entry entry = new EntryImpl();
+ //check if current row is a transaction or an entry
if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentTransaction = (FinancialTransaction)currentRow;
- currentTransaction.addEntry(entry);
+ currentTransaction = (FinancialTransaction)currentRow;
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
- //TODO recuperer l'entrée parente, ajouter entrée
+ //get back the parent transaction of the entry
+ currentTransaction = currentEntry.getFinancialTransaction();
}
+ //create it
+ entry.setFinancialTransaction(currentTransaction);
+ entryService.createEntry(entry);
fireTableRowsUpdated(row, row);
}
+ /**
+ * to modifiy financialtransaction or entry
+ */
@Override
public void setValueAt(Object value, int row, int column) {
@@ -401,7 +419,6 @@
// TODO EC-20100407 remove this ugly code
List<Object> datas = getDataList();
Object currentRow = datas.get(row);
-
if (currentRow instanceof FinancialTransaction) {
FinancialTransaction currentFinancialTransaction =
(FinancialTransaction)currentRow;
@@ -409,85 +426,57 @@
case 0:
currentFinancialTransaction.setTransactionDate((Date)value);
break;
- /*case 1:
- result = null; // account ?
- break;
case 2:
- result = null; // entry book
+ currentFinancialTransaction.setEntryBook((EntryBook)value);
break;
- case 3:
- result = null; //currentRow.getFinancialPeriod();
- break;
- case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;
- case 5:
- result = TransactionHelper.getDebit(currentRow);
- break;
- case 6:
- result = TransactionHelper.getCredit(currentRow);
- break;
- case 7:
- result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
- break;*/
- case 8:
- currentFinancialTransaction.setDescription((String)value);
- break;
- case 9:
- currentFinancialTransaction.setVoucherRef((String)value);
- break;
}
-
// notify service for modification
try {
transactionService.updateFinancialTransaction(currentFinancialTransaction);
} catch (LimaException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ if (log.isDebugEnabled()){
+ log.debug("Can't update financial transaction", e);
+ }
}
- //fireTableRowsUpdated(row, row); // to update what ???
-
+ //update the financial transaction row
+ fireTableRowsUpdated(row, row);
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
switch (column) {
- /*case 0:
- result = null; // date
- break;*/
- case 1:
- currentEntry.setAccount((Account)value); // account ?
+ case 1 :
+ currentEntry.setVoucher((String)value);
break;
- /*case 2:
- result = null; // entry book
- break;
case 3:
- result = null; //currentRow.getFinancialPeriod();
+ currentEntry.setAccount((Account)value);
break;
case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;*/
- case 5:
+ currentEntry.setDescription((String)value);
+ break;
+ case 5 :
+ currentEntry.setPosition((String)value);
+ break;
+ case 6:
currentEntry.setAmount((Double)value);
currentEntry.setDebit(true);
break;
- case 6:
+ case 7:
currentEntry.setAmount((Double)value);
currentEntry.setDebit(false);
break;
- /*case 7:
- result = null;
- break;*/
- case 8:
- currentEntry.setDescription((String)value);
- break;
- /*case 9:
- result = null;
- break;*/
}
-
- //transactionService.updateEntry(currentEntry);
- // fire modification of all transaction
- // see here, table is not adapted :)
+ try {
+ entryService.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());
+ fireTableRowsUpdated(financialTransactionRow, financialTransactionRow);
+ //update the entry
+ //fireTableRowsUpdated(row, row);
}
}
else {
@@ -513,18 +502,16 @@
* @throws LimaException
*/
public void removeObject(Object object, int row) throws LimaException {
- /* Calling journal service */
-
List<Object> datas = getDataList();
Object currentRow = datas.get(row);
if (currentRow instanceof FinancialTransaction) {
FinancialTransaction currentTransaction = (FinancialTransaction)currentRow;
transactionService.removeFinancialTransaction(currentTransaction);
- fireTableRowsDeleted(row, row);
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
- //TODO supprimer l'entrée
+ entryService.removeEntry(currentEntry);
}
+ fireTableRowsDeleted(row, row);
}
}
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-26 16:22:31 UTC (rev 2875)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-28 15:59:14 UTC (rev 2876)
@@ -299,10 +299,10 @@
lima.transaction.column.date=Jour
lima.transaction.column.debit=D\u00E9bit
lima.transaction.column.description=Description
-lima.transaction.column.document=Document
lima.transaction.column.entrybook=Journal
lima.transaction.column.period=P\u00E9riode
-lima.transaction.column.status=Statut
+lima.transaction.column.position=Statut
+lima.transaction.column.voucher=Pi\u00E8ce comptable
lima.transaction.confirmdelete=
lima.transaction.entrybook=Journal
lima.transaction.period=P\u00E9riode
1
0
Author: jpepin
Date: 2010-04-26 18:22:31 +0200 (Mon, 26 Apr 2010)
New Revision: 2875
Log:
Modification r?\195?\168gles clot?\195?\187re d'exercice, affichage des ?\195?\169critures, ajout d'une transaction
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.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-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.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/ui/fiscalperiod/model/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.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/FinancialPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -22,6 +22,7 @@
import java.util.List;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
/**
* Financial period service.
@@ -35,8 +36,10 @@
public interface FinancialPeriodService {
List<FinancialPeriod> getAllFinancialPeriods() throws LimaException;
+
+ List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException;
- List<FinancialPeriod> getNonLockedFinancialPeriods() throws LimaException;
+ List<FinancialPeriod> getUnblockedFinancialPeriodWithFiscalPeriod(FiscalPeriod selectedFiscalPeriod) throws LimaException;
void createFinancialPeriod(FinancialPeriod financialPeriod) 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-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -61,8 +61,12 @@
* @return all transaction for entry book and period
* @throws LimaException
*/
- List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactionsForFinancialPeriod(
+ FinancialPeriod period) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(
+ EntryBook entryBook, FinancialPeriod period) throws LimaException;
+
void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -35,6 +35,8 @@
public interface FiscalPeriodService {
List<FiscalPeriod> getAllFiscalPeriods() throws LimaException;
+
+ List<FiscalPeriod> getAllUnblockedFiscalPeriods() throws LimaException;
void createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -42,11 +42,10 @@
protected static LimaConfig instance;
- protected LimaConfig() {
-
- }
+ private static final String configFile = "lima.properties";
public static LimaConfig getInstance() {
+ /*
if (instance == null) {
instance = new LimaConfig();
instance.setConfigFileName("lima.properties");
@@ -60,8 +59,25 @@
// FIXME put this in another place
instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
+ }*/
+ if (instance == null) {
+ instance = new LimaConfig();
+ instance.loadConfiguration(configFile);
}
-
return instance;
}
+
+ protected void loadConfiguration(String configFileName){
+
+ instance.setConfigFileName(configFileName);
+ try {
+ instance.parse(new String[0]);
+ } catch (ArgumentsParserException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't read configuration", ex);
+ }
+ }
+ instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
+ }
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -19,6 +19,8 @@
package org.chorem.lima.business.ejb;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;
@@ -30,11 +32,14 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.FiscalPeriod;
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;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
/**
* Gestion des périodes intermédiaires durant l'exercice.
@@ -174,7 +179,7 @@
}
@Override
- public List<FinancialPeriod> getNonLockedFinancialPeriods() throws LimaException {
+ public List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException {
List<FinancialPeriod> result = null;
@@ -199,6 +204,17 @@
return result;
}
+
+ @Override
+ public List<FinancialPeriod> getUnblockedFinancialPeriodWithFiscalPeriod(FiscalPeriod selectedFiscalPeriod) throws LimaException {
+
+ Collection<FinancialPeriod> temp = selectedFiscalPeriod.getFinancialPeriod();
+
+ List result = new ArrayList<FinancialPeriod>(temp);
+ log.debug("result : "+result);
+
+ return result;
+ }
/*
* Permet de trouver un timespan directement avec une date. La date peut
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-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -295,7 +295,8 @@
}
@Override
- public List<FinancialTransaction> getAllFinancialTransactionsForEntryBook(EntryBook entryBook) throws LimaException {
+ public List<FinancialTransaction> getAllFinancialTransactionsForEntryBook(
+ EntryBook entryBook) throws LimaException {
// find all with null period filter
@@ -303,6 +304,13 @@
}
@Override
+ public List<FinancialTransaction> getAllFinancialTransactionsForFinancialPeriod(
+ FinancialPeriod period) throws LimaException {
+ // TODO Auto-generated method stub
+ return getAllFinancialTransactionsForEntryBookAndFinancialPeriod(null, period);
+ }
+
+ @Override
public List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException {
List<FinancialTransaction> transactions = null;
@@ -465,6 +473,8 @@
}
+
+
/*
* Permet d'ajouter une entrée comptable pour une transaction donnée.
* ATTENTION : la transaction doit être NON bloquée.
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-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -51,6 +51,7 @@
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
+import org.nuiton.topia.persistence.TopiaEntity;
import org.apache.commons.lang.time.DateUtils;
/**
@@ -283,6 +284,33 @@
return result;
}
+ public List<FiscalPeriod> getAllUnblockedFiscalPeriods() throws LimaException {
+
+ List<FiscalPeriod> result = null;
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ result = fiscalPeriodDAO.findAllByLocked(false);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return result;
+ }
+
@Override
public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
TopiaContext transaction = null;
@@ -292,8 +320,6 @@
if (fiscalPeriod.getLocked()==true){
throw new LimaBusinessException("Fiscal Period already blocked");
}
- //set to true
- fiscalPeriod.setLocked(true);
//TODO verifier que les exercices anterieur a l'exerice à bloquer sont bloqués
FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
@@ -302,19 +328,30 @@
fiscalPeriodDAO.findAllByQuery(query);
query.add(FiscalPeriod.LOCKED, Op.EQ, false);
query.addOrder(FiscalPeriod.END_DATE);
+ // query.add(TopiaEntity.TOPIA_ID, fiscalPeriod.getTopiaId());
+ //int oldestblocked = query.executeCount();
+
FiscalPeriod oldestUnBlockedFiscalPeriod = fiscalPeriodDAO.findByQuery(query);
- log.debug("oldestUnBlockedFiscalPeriod : "+oldestUnBlockedFiscalPeriod);
+ //log.debug("oldestUnBlockedFiscalPeriod : "+oldestUnBlockedFiscalPeriod);
//Check if the fiscal period to block is the oldest
if (!oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)){
throw new LimaBusinessException("The ante fiscal period must be blocked before this.");
}
- //FIXME PJ 23/04/2010 code à changer pour ne pas dépendre de l'impl
+ oldestUnBlockedFiscalPeriod.setLocked(true);
+
+ // locked all financialperiod of the fiscalperiod
+ for ( FinancialPeriod financialPeriod : oldestUnBlockedFiscalPeriod.getFinancialPeriod()) {
+ financialPeriod.setLocked(true);
+ }
+
+
+ /* //FIXME JP 23/04/2010 code à changer pour ne pas dépendre de l'impl
TopiaContextImpl topiaContextImpl = (TopiaContextImpl) transaction;
- topiaContextImpl.getHibernate().evict(oldestUnBlockedFiscalPeriod);
+ topiaContextImpl.getHibernate().evict(oldestUnBlockedFiscalPeriod);*/
// update account
- fiscalPeriodDAO.update(fiscalPeriod);
+ fiscalPeriodDAO.update(oldestUnBlockedFiscalPeriod);
// commit
transaction.commitTransaction();
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -1,11 +1,27 @@
package org.chorem.lima.business;
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.transaction.Transaction;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
import org.chorem.lima.business.ejb.FiscalPeriodServiceImpl;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodDAO;
+import org.chorem.lima.entity.FiscalPeriodImpl;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
/**
* Tests pour la gestion des périodes
@@ -45,6 +61,76 @@
instance.removePeriod(periodDTO);*/
}
+
+
+ @Test
+ public void blockFiscalPeriodTest() throws Exception {
+
+ TopiaContext rootcontext;
+ TopiaContext transaction=null;
+ rootcontext = TopiaContextFactory.getContext(LimaConfigTest.getInstance().getOptions());
+ FiscalPeriod recentFiscalPeriod = new FiscalPeriodImpl();
+ FiscalPeriod oldestFiscalPeriod = new FiscalPeriodImpl();
+
+ try {
+
+ transaction = rootcontext.beginTransaction();
+
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+
+ FinancialPeriodServiceImpl financialPeriodService =
+ new FinancialPeriodServiceImpl();
+
+ //On crée deux période, une récente
+
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ Calendar beginCalendar = Calendar.getInstance();
+ recentFiscalPeriod.setBeginDate(beginCalendar.getTime());
+ Calendar endCalendar = beginCalendar;
+ endCalendar.add(Calendar.MONTH, 12);
+ recentFiscalPeriod.setEndDate(endCalendar.getTime());
+ fiscalPeriodDAO.create(recentFiscalPeriod);
+ recentFiscalPeriod.addFinancialPeriod(financialPeriod);
+ financialPeriodService.createFinancialPeriod(financialPeriod);
+
+
+ //une plus ancienne
+ beginCalendar.add(Calendar.YEAR, -2);
+ oldestFiscalPeriod.setBeginDate(beginCalendar.getTime());
+ endCalendar.add(Calendar.YEAR, -2);
+ oldestFiscalPeriod.setEndDate(endCalendar.getTime());
+ fiscalPeriodDAO.create(oldestFiscalPeriod);
+ oldestFiscalPeriod.addFinancialPeriod(financialPeriod);
+
+ transaction.commitTransaction();
+
+ } finally {
+ transaction.closeContext();
+ }
+
+
+ Assert.assertNotSame(recentFiscalPeriod.getTopiaId(),
+ oldestFiscalPeriod.getTopiaId());
+
+ FiscalPeriodService fiscalPeriodService = new FiscalPeriodServiceImpl();
+
+
+ try{
+
+
+ fiscalPeriodService.blockFiscalPeriod(oldestFiscalPeriod);
+ } catch (Exception ex){
+ log.debug("Error test block Period", ex);
+ Assert.assertEquals(LimaBusinessException.class, ex.getClass());
+ }
+ try {
+ fiscalPeriodService.blockFiscalPeriod(recentFiscalPeriod);
+ } catch (Exception ex){
+ log.debug("Error test block Period", ex);
+ Assert.assertEquals(LimaBusinessException.class, ex.getClass());
+ }
+ }
/**
* Permet de tester l'ajout d'une période.
*/
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LimaConfigTest.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -20,6 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.junit.Ignore;
import org.nuiton.util.ArgumentsParserException;
@@ -37,9 +38,18 @@
private static final Log log = LogFactory.getLog(LimaConfig.class);
+ private static final String configFile = "lima_test.properties";
+
public static LimaConfig getInstance() {
+
if (instance == null) {
instance = new LimaConfig();
+ instance.loadConfiguration(configFile);
+ }
+ return instance;
+
+ /*if (instance == null) {
+ instance = new LimaConfig();
instance.setConfigFileName("lima_test.properties");
try {
instance.parse(new String[0]);
@@ -48,8 +58,8 @@
log.error("Can't read configuration", ex);
}
}
- }
+ instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
- return instance;
+ }*/
}
}
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-26 16:22:31 UTC (rev 2875)
@@ -4,5 +4,6 @@
org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.entry.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/ui/fiscalperiod/model/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -20,8 +20,11 @@
import static org.nuiton.i18n.I18n._;
+import java.util.Calendar;
+import java.util.Date;
import java.util.List;
+import javax.swing.JLabel;
import javax.swing.table.AbstractTableModel;
import org.apache.commons.logging.Log;
@@ -29,6 +32,7 @@
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -130,16 +134,39 @@
periods = fiscalPeriodService.getAllFiscalPeriods();
FiscalPeriod fiscalPeriod = periods.get(rowIndex);
- switch (columnIndex) {
- case 0:
- result = fiscalPeriod.getBeginDate()
- + " - " + fiscalPeriod.getEndDate();
- break;
- case 1:
- result = fiscalPeriod.getLocked();
- break;
+
+ String[] monthName = {_("lima.date.january"), _("lima.date.february"),
+ _("lima.date.march"), _("lima.date.april"), _("lima.date.may"),
+ _("lima.date.june"), _("lima.date.july"), _("lima.date.august"),
+ _("lima.date.september"), _("lima.date.october"),
+ _("lima.date.november"), _("lima.date.december")};
+
+ if (fiscalPeriod != null){
+ Date date = fiscalPeriod.getBeginDate();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ String formatBeginDate = monthName[calendar.get(Calendar.MONTH)]
+ +" "+String.valueOf(calendar.get(Calendar.YEAR));
+ date = fiscalPeriod.getEndDate();
+ calendar.setTime(date);
+ String formatEndDate = monthName[calendar.get(Calendar.MONTH)]
+ +" "+String.valueOf(calendar.get(Calendar.YEAR));
+ date = fiscalPeriod.getEndDate();
+
+
+ switch (columnIndex) {
+ case 0:
+ result = formatBeginDate
+ + " - " + formatEndDate;
+ break;
+ case 1:
+ result = fiscalPeriod.getLocked();
+ break;
+ }
}
+
+
} catch (LimaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -43,7 +43,8 @@
public class FinancialTransactionViewHandler {
/** log. */
- private static final Log log = LogFactory.getLog(FinancialTransactionViewHandler.class);
+ private static final Log log =
+ LogFactory.getLog(FinancialTransactionViewHandler.class);
protected TransactionView view;
@@ -53,8 +54,10 @@
//add a new transaction
protected void addFinancialTransaction() {
- FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+ FinancialTransactionTable table =
+ (FinancialTransactionTable)view.getFinancialTransactionTable();
+ FinancialTransactionTableModel model =
+ (FinancialTransactionTableModel)table.getModel();
try {
model.addFinancialTransaction();
@@ -68,8 +71,10 @@
//add a new entry to the selected transaction
public void addEmptyEntry(){
- FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+ FinancialTransactionTable table =
+ (FinancialTransactionTable)view.getFinancialTransactionTable();
+ FinancialTransactionTableModel model =
+ (FinancialTransactionTableModel)table.getModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
@@ -91,8 +96,10 @@
*/
public void deleteSelectedRow(){
- FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+ FinancialTransactionTable table =
+ (FinancialTransactionTable)view.getFinancialTransactionTable();
+ FinancialTransactionTableModel model =
+ (FinancialTransactionTableModel)table.getModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
Modified: 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-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-26 16:22:31 UTC (rev 2875)
@@ -18,12 +18,15 @@
<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>
@@ -44,6 +47,7 @@
<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>
@@ -52,8 +56,9 @@
</cell>
<cell>
<JComboBox id="financialPeriodComboBox"
- model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}"
+ model="{getModelFinancialPeriod()}"
renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxRenderer()}"
+ onItemStateChanged="getFinancialTransactionTableModel().setFinancialPeriod((FinancialPeriod) event.getItem())"
editable="false"
/>
</cell>
@@ -80,7 +85,7 @@
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>
+ </JScrollPane>
</cell>
<cell>
<JButton text="lima.add.transaction"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -23,6 +23,7 @@
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
/**
@@ -39,11 +40,17 @@
protected Object selectedFinancialPeriod;
protected FinancialPeriodService financialPeriodService;
+
+ protected FiscalPeriod selectedFiscalPeriod;
public FinancialPeriodComboBoxModel() {
financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
}
+ public void setFiscalPeriod(FiscalPeriod fiscalPeriod){
+ selectedFiscalPeriod=fiscalPeriod;
+ }
+
/*
* @see javax.swing.ListModel#getSize()
*/
@@ -52,7 +59,15 @@
int result = 0;
// TODO add cache
try {
- result = financialPeriodService.getNonLockedFinancialPeriods().size();
+ if (selectedFiscalPeriod != null){
+ result = financialPeriodService.
+ getUnblockedFinancialPeriodWithFiscalPeriod(
+ selectedFiscalPeriod).size();
+ }
+ else {
+ result = financialPeriodService.
+ getUnblockedFinancialPeriods().size();
+ }
}
catch (LimaException ex) {
// TODO Auto-generated catch block
@@ -69,7 +84,15 @@
Object result = null;
// TODO add cache
try {
- result = financialPeriodService.getNonLockedFinancialPeriods().get(index);
+ if (selectedFiscalPeriod != null){
+ result = financialPeriodService.
+ getUnblockedFinancialPeriodWithFiscalPeriod(
+ selectedFiscalPeriod).get(index);
+ }
+ else {
+ result = financialPeriodService.getUnblockedFinancialPeriods().
+ get(index);
+ }
}
catch (LimaException ex) {
// TODO Auto-generated catch block
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -18,8 +18,11 @@
package org.chorem.lima.ui.transaction.model;
+import static org.nuiton.i18n.I18n._;
+
import java.awt.Component;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
import javax.swing.DefaultListCellRenderer;
@@ -39,13 +42,20 @@
boolean cellHasFocus) {
// TODO Auto-generated method stub
+ String[] monthName = {_("lima.date.january"), _("lima.date.february"),
+ _("lima.date.march"), _("lima.date.april"), _("lima.date.may"),
+ _("lima.date.june"), _("lima.date.july"), _("lima.date.august"),
+ _("lima.date.september"), _("lima.date.october"),
+ _("lima.date.november"), _("lima.date.december")};
+
JLabel label = new JLabel();
FinancialPeriod financialperiod = (FinancialPeriod) value;
if (financialperiod != null){
- //Date d = financialperiod.getBeginDate();
- //String date = d.getMonth() + " " + (d.getYear() + 1900);
- //label.setText(date);
- label.setText(financialperiod.getBeginDate().toString());
+ Date d = financialperiod.getBeginDate();
+ Calendar beginDate = Calendar.getInstance();
+ beginDate.setTime(d);
+ int year = beginDate.get(Calendar.YEAR);
+ label.setText(monthName[beginDate.get(Calendar.MONTH)]+" "+String.valueOf(year));
}
return label;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -23,6 +23,8 @@
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FiscalPeriodDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.service.LimaServiceFactory;
public class FiscalPeriodComboBoxModel implements ComboBoxModel{
@@ -30,7 +32,7 @@
protected Object selectedFiscalPeriod;
protected FiscalPeriodService fiscalPeriodService;
-
+
public FiscalPeriodComboBoxModel(){
fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
}
@@ -43,7 +45,7 @@
int result = 0;
// TODO add cache
try {
- result = fiscalPeriodService.getAllFiscalPeriods().size();
+ result = fiscalPeriodService.getAllUnblockedFiscalPeriods().size();
}
catch (LimaException ex) {
// TODO Auto-generated catch block
@@ -59,7 +61,7 @@
public Object getElementAt(int index) {
Object result = null;
try {
- result = fiscalPeriodService.getAllFiscalPeriods().get(index);
+ result = fiscalPeriodService.getAllUnblockedFiscalPeriods().get(index);
}
catch (LimaException ex) {
ex.printStackTrace();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java 2010-04-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -19,6 +19,8 @@
package org.chorem.lima.ui.transaction.model;
import java.awt.Component;
+import java.util.Calendar;
+import java.util.Date;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
@@ -39,11 +41,12 @@
JLabel label = new JLabel();
FiscalPeriod fiscalPeriod = (FiscalPeriod) value;
- if (fiscalPeriod != null){
- //Date d = financialperiod.getBeginDate();
- //String date = d.getMonth() + " " + (d.getYear() + 1900);
- //label.setText(date);
- label.setText(fiscalPeriod.getBeginDate().toString());
+ if (fiscalPeriod != null){
+ Date d = fiscalPeriod.getBeginDate();
+ Calendar beginDate = Calendar.getInstance();
+ beginDate.setTime(d);
+ int date = beginDate.get(Calendar.YEAR);
+ label.setText(String.valueOf(date));
}
return label;
}
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-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-26 16:22:31 UTC (rev 2875)
@@ -21,12 +21,14 @@
import static org.nuiton.i18n.I18n._;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;
+import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaBusinessException;
@@ -36,7 +38,10 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialTransactionImpl;
+import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
@@ -80,7 +85,7 @@
protected EntryBook selectedEntryBook;
protected FinancialPeriod selectedFinancialPeriod;
-
+
/**
* Model constructor.
*
@@ -102,8 +107,6 @@
*/
protected List<Object> getDataList() {
- log.debug("getDatalist");
-
List<Object> results = new ArrayList<Object>();
try {
@@ -217,15 +220,15 @@
@Override
public int getRowCount() {
int result = 0;
-
+
// just prevent too much result
- if (selectedEntryBook != null) {
+ if (selectedFinancialPeriod != null) {
List<Object> datas = getDataList();
result = datas.size();
}
else {
if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
+ log.debug("No fiscalPeriod selected skip table model update");
}
}
@@ -237,8 +240,7 @@
Object result = null;
// just prevent too much result
- System.out.println("OK2");
- if (selectedEntryBook != null) {
+ if (selectedFinancialPeriod != null) {
// TODO EC-20100407 remove this ugly code
List<Object> datas = getDataList();
result = datas.get(row);
@@ -268,7 +270,8 @@
result = FinancialTransactionHelper.getCredit(currentRow);
break;
case 7:
- result = FinancialTransactionHelper.getDebit(currentRow) - FinancialTransactionHelper.getCredit(currentRow);
+ result = FinancialTransactionHelper.getDebit(currentRow)
+ - FinancialTransactionHelper.getCredit(currentRow);
break;
case 8:
result = currentRow.getDescription();
@@ -316,19 +319,24 @@
}
else {
if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
+ log.debug("No fiscalPeriod selected skip table model update");
}
}
return result;
}
+
+
+ public void setFinancialPeriod(FinancialPeriod financialPeriod){
+
+ selectedFinancialPeriod = financialPeriod;
+ fireTableDataChanged();
+ }
-
public void setEntryBook(EntryBook entryBook){
-
- System.out.println("OK");
- selectedEntryBook = entryBook;
- fireTableDataChanged();
+
+ selectedEntryBook = entryBook;
+ fireTableDataChanged();
}
/**
@@ -337,21 +345,28 @@
public void addFinancialTransaction() throws LimaException{
/* Calling transaction service */
//TODO transaction = currentdate, current periode, current journal
- FinancialTransaction financialtransaction =null;
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
//if a period and an entrybook is selected
- if (selectedEntryBook != null && selectedFinancialPeriod != null){
- financialtransaction.setFinancialPeriod(selectedFinancialPeriod);
- financialtransaction.setEntryBook(selectedEntryBook);
- //financialransaction.setDescription(description);
+ if (selectedFinancialPeriod != null && selectedEntryBook!=null){
+ financialTransaction.setFinancialPeriod(selectedFinancialPeriod);
+ financialTransaction.setEntryBook(selectedEntryBook);
+ // get today
+ Calendar actualCalendar = Calendar.getInstance();
+ // get the financial period date
+ Date transactionDate = selectedFinancialPeriod.getBeginDate();
+ //change the day
+ transactionDate = DateUtils.setDays(transactionDate, actualCalendar.get(Calendar.DAY_OF_MONTH));
+ //set date to the financial transaction
+ financialTransaction.setTransactionDate(transactionDate);
//create it
- transactionService.createFinancialTransaction(financialtransaction);
- int row = getDataList().indexOf(financialtransaction);
+ transactionService.createFinancialTransaction(financialTransaction);
+ int row = getDataList().indexOf(financialTransaction);
//int row = transactionService.getAllTransactions().indexOf(transaction);
log.debug(row);
fireTableRowsInserted(row, row);
}
else {
- throw new LimaBusinessException("No financialperiod or no entrybook selected");
+ throw new LimaBusinessException("No financial period and bookentry selected");
}
}
@@ -365,7 +380,7 @@
//TODO transaction = currentdate, current periode, current journal
List<Object> datas = getDataList();
Object currentRow = datas.get(row);
- Entry entry=null;
+ Entry entry = new EntryImpl();
if (currentRow instanceof FinancialTransaction) {
FinancialTransaction currentTransaction = (FinancialTransaction)currentRow;
currentTransaction.addEntry(entry);
@@ -382,7 +397,7 @@
public void setValueAt(Object value, int row, int column) {
// just prevent too much result
- if (selectedEntryBook != null) {
+ if (selectedFinancialPeriod != null) {
// TODO EC-20100407 remove this ugly code
List<Object> datas = getDataList();
Object currentRow = datas.get(row);
@@ -477,7 +492,7 @@
}
else {
if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
+ log.debug("No fiscalPeriod selected skip table model update");
}
}
}
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-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-26 16:22:31 UTC (rev 2875)
@@ -260,6 +260,7 @@
lima.progressBar.load.etape5=Loading transactions
lima.question=Question
lima.question.confirmremove.account=This account have subaccounts, do you want remove this account ?
+lima.question.fiscalperiod.blocked=
lima.question.fiscalperiod.morethan12=
lima.question.load.accounts=There is no existing accounts in Lima. Do you want to load default accounts ?
lima.question.remove.account=Do you want to remove this account ?
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-26 07:51:56 UTC (rev 2874)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-26 16:22:31 UTC (rev 2875)
@@ -245,8 +245,8 @@
lima.progressBar.load.etape5=Chargement des transactions
lima.question=Question
lima.question.confirmremove.account=Ce compte poss\u00E8de des sous comptes, voulez-vous supprimer ce compte ?
+lima.question.fiscalperiod.blocked=\u00C8tes vous s\u00FBre de vouloir cl\u00F4turer cette exercice ? Cette action est irr\u00E9versible \!
lima.question.fiscalperiod.morethan12=La p\u00E9riode s\u00E9lectionner n'est pas de 12 mois, voulez-vous continuer ?
-lima.question.fiscalperiod.blocked=\u00C8tes vous s\u00FBre de vouloir cl\u00F4turer cette exercice ? Cette action est irr\u00E9versible !
lima.question.load.accounts=Il n'y a aucun plan comptable existant dans Lima. Voulez-vous en charger un par d\u00E9faut ?
lima.question.remove.account=Voulez-vous supprimer ce compte?
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
@@ -296,7 +296,7 @@
lima.transaction.column.account=Compte
lima.transaction.column.balance=Balance
lima.transaction.column.credit=Cr\u00E9dit
-lima.transaction.column.date=Date
+lima.transaction.column.date=Jour
lima.transaction.column.debit=D\u00E9bit
lima.transaction.column.description=Description
lima.transaction.column.document=Document
@@ -317,6 +317,6 @@
lima.view=Vue
lima.view.flatten=Vue aplatie
lima.voucher=Document
-lima.warning.financialtransaction.noselect=journal et/ou p\u00E9riode non s\u00E9lectionn\u00E9
+lima.warning.financialtransaction.noselect=Aucune p\u00E9riode et/ou aucun journal s\u00E9lectionn\u00E9
lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9
lima.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9.
1
0
Author: echatellier
Date: 2010-04-26 09:51:56 +0200 (Mon, 26 Apr 2010)
New Revision: 2874
Log:
Update h2, log4j, and move snapshots to stable
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-26 07:45:58 UTC (rev 2873)
+++ trunk/pom.xml 2010-04-26 07:51:56 UTC (rev 2874)
@@ -49,7 +49,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.14</version>
+ <version>1.2.16</version>
<scope>runtime</scope>
</dependency>
@@ -104,7 +104,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.2.133</version>
+ <version>1.2.134</version>
<scope>runtime</scope>
</dependency>
@@ -240,9 +240,9 @@
<projectId>lima</projectId>
<!-- customized libs version -->
- <nuiton-utils.version>1.2.2-SNAPSHOT</nuiton-utils.version>
- <eugene.version>2.0.1-SNAPSHOT</eugene.version>
- <topia.version>2.3.3-SNAPSHOT</topia.version>
+ <nuiton-utils.version>1.2.2</nuiton-utils.version>
+ <eugene.version>2.0.1</eugene.version>
+ <topia.version>2.3.3</topia.version>
<jaxx.version>2.0</jaxx.version>
<i18n.version>1.2.1</i18n.version>
1
0
Author: echatellier
Date: 2010-04-26 09:45:58 +0200 (Mon, 26 Apr 2010)
New Revision: 2873
Log:
Revome login/password from public repo
Modified:
trunk/src/referencement.txt
Modified: trunk/src/referencement.txt
===================================================================
--- trunk/src/referencement.txt 2010-04-23 14:40:13 UTC (rev 2872)
+++ trunk/src/referencement.txt 2010-04-26 07:45:58 UTC (rev 2873)
@@ -2,15 +2,3 @@
- http://forum.framasoft.org/viewtopic.php?f=99&t=30743
- http://freshmeat.net/projects/limacallao/
- http://linuxfr.org/forums/12/26311.html
-
-Un compte a été créé pour chacun de ces posts. Les identifiants sont
-toujours les mêmes :
-login : lutintern
-mdp : lutin486
-
-Les adresses mail employées lors de l'inscription sont soit la mienne,
-soit celle de Gildas chez Code Lutin (resp. ejoubaud(a)codelutin.com et
-glementec(a)codelutin.com)
-
-Le site Maven du projet a été déployé à l'adresse suivante :
-http://chorem.labs.libre-entreprise.org/lima/
\ No newline at end of file
1
0
r2872 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/entrybook lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 23 Apr '10
by jpepin@users.chorem.org 23 Apr '10
23 Apr '10
Author: jpepin
Date: 2010-04-23 16:40:13 +0200 (Fri, 23 Apr 2010)
New Revision: 2872
Log:
Ajout : Cl?\195?\180ture exercice avec r?\195?\168gles de v?\195?\169rification
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.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/FiscalPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-04-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-04-23 14:40:13 UTC (rev 2872)
@@ -37,6 +37,8 @@
List<FiscalPeriod> getAllFiscalPeriods() throws LimaException;
void createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
//void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2010-04-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2010-04-23 14:40:13 UTC (rev 2872)
@@ -53,7 +53,7 @@
}
}
if (log.isErrorEnabled()) {
- log.error("Error during create account", cause);
+ log.error("Exception during query", cause);
}
throw new LimaException("Exception during query", cause);
}
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-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-23 14:40:13 UTC (rev 2872)
@@ -36,6 +36,7 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
@@ -46,7 +47,10 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.framework.TopiaContextImpl;
+import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
import org.apache.commons.lang.time.DateUtils;
/**
@@ -62,7 +66,8 @@
private static TopiaContext rootContext;
- private FinancialPeriodServiceImpl financialPeriodService = new FinancialPeriodServiceImpl();
+ private FinancialPeriodServiceImpl financialPeriodService =
+ new FinancialPeriodServiceImpl();
public FiscalPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -183,7 +188,8 @@
//check if the enddate period is after the begindate period
if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())){
//TODO Exception
- throw new LimaBusinessException("The enddate is before the begindate");
+ throw new LimaBusinessException(
+ "The enddate is before the begindate");
}
//Checks if is not the first fiscalperiod to create
@@ -199,19 +205,23 @@
//check the new fiscal period adjoining the last
Date dateLastFiscalPeriod=lastFiscalPeriod.getEndDate();
- dateLastFiscalPeriod = DateUtils.addMilliseconds(dateLastFiscalPeriod, 1);
+ dateLastFiscalPeriod = DateUtils.
+ addMilliseconds(dateLastFiscalPeriod, 1);
Date dateFiscalPeriod=fiscalPeriod.getBeginDate();
if(dateLastFiscalPeriod.compareTo(dateFiscalPeriod)!=0){
- throw new LimaBusinessException("The new fiscalperiod must adjoining the last");
+ throw new LimaBusinessException(
+ "The new fiscalperiod must adjoining the last");
}
//We can create a new fiscal period meantime the last fiscal period was not locked
//But not the ante periodfiscal
- int unblockedFiscalPeriod = fiscalPeriodDAO.findAllByLocked(false).size();
+ int unblockedFiscalPeriod =
+ fiscalPeriodDAO.findAllByLocked(false).size();
log.debug(unblockedFiscalPeriod);
if (unblockedFiscalPeriod>1){
- throw new LimaBusinessException("The ante fiscal period is not locked");
+ throw new LimaBusinessException(
+ "The ante fiscal period is not locked");
}
}
@@ -272,8 +282,51 @@
return result;
}
+
+ @Override
+ public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ if (fiscalPeriod.getLocked()==true){
+ throw new LimaBusinessException("Fiscal Period already blocked");
+ }
+ //set to true
+ fiscalPeriod.setLocked(true);
+
+ //TODO verifier que les exercices anterieur a l'exerice à bloquer sont bloqués
+ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+
+ TopiaQuery query = fiscalPeriodDAO.createQuery();
+ fiscalPeriodDAO.findAllByQuery(query);
+ query.add(FiscalPeriod.LOCKED, Op.EQ, false);
+ query.addOrder(FiscalPeriod.END_DATE);
+ FiscalPeriod oldestUnBlockedFiscalPeriod = fiscalPeriodDAO.findByQuery(query);
+ log.debug("oldestUnBlockedFiscalPeriod : "+oldestUnBlockedFiscalPeriod);
+
+ //Check if the fiscal period to block is the oldest
+ if (!oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)){
+ throw new LimaBusinessException("The ante fiscal period must be blocked before this.");
+ }
+
+ //FIXME PJ 23/04/2010 code à changer pour ne pas dépendre de l'impl
+ TopiaContextImpl topiaContextImpl = (TopiaContextImpl) transaction;
+ topiaContextImpl.getHibernate().evict(oldestUnBlockedFiscalPeriod);
+ // update account
+ fiscalPeriodDAO.update(fiscalPeriod);
+
+ // commit
+ transaction.commitTransaction();
+
+ } catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+ }
-
public void removeAllFiscalPeriods() throws LimaException{
TopiaContext transaction = null;
try {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-04-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-04-23 14:40:13 UTC (rev 2872)
@@ -53,7 +53,8 @@
public void addEntryBook() {
JXTable entryBookTable = view.getEntryBooksTable();
- EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+ EntryBookTableModel entryBookTableModel =
+ (EntryBookTableModel)entryBookTable.getModel();
EntryBook newEntryBook = new EntryBookImpl();
EntryBookForm entryBookForm = new EntryBookForm(view);
@@ -82,11 +83,13 @@
JXTable entryBookTable = view.getEntryBooksTable();
int selectedRow = entryBookTable.getSelectedRow();
- EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+ EntryBookTableModel entryBookTableModel =
+ (EntryBookTableModel)entryBookTable.getModel();
// add it
try {
- EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ EntryBook selectedEntryBook =
+ entryBookTableModel.getEntryBookAtRow(selectedRow);
EntryBookForm entryBookForm = new EntryBookForm(view);
entryBookForm.setEntryBook(selectedEntryBook);
// jaxx constructor don't call super() ?
@@ -109,14 +112,20 @@
public void deleteEntryBook() {
JXTable entryBookTable = view.getEntryBooksTable();
int selectedRow = entryBookTable.getSelectedRow();
- EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+ EntryBookTableModel entryBookTableModel =
+ (EntryBookTableModel)entryBookTable.getModel();
// add it
try {
- EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ EntryBook selectedEntryBook =
+ entryBookTableModel.getEntryBookAtRow(selectedRow);
- int response = JOptionPane.showConfirmDialog(view, _("Do you really want to delete entry book %s ?", selectedEntryBook.getLabel()),
- _("Confirmation"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+ int response =
+ JOptionPane.showConfirmDialog(view,
+ _("Do you really want to delete entry book %s ?",
+ selectedEntryBook.getLabel()),
+ _("Confirmation"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
entryBookTableModel.removeEntryBook(selectedEntryBook);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-04-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-04-23 14:40:13 UTC (rev 2872)
@@ -26,14 +26,17 @@
import javax.swing.JOptionPane;
import org.apache.commons.lang.NotImplementedException;
+import org.jdesktop.swingx.JXTable;
import org.nuiton.util.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel;
import org.chorem.lima.ui.fiscalperiod.AddPeriod;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
@@ -95,8 +98,27 @@
}
public void blockFiscalPeriod() {
- throw new NotImplementedException("To be continued...");
- }
+ JXTable fiscalPeriodeTable = view.getFiscalPeriodTable();
+ int selectedRow = fiscalPeriodeTable.getSelectedRow();
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel();
+
+ // blocked it
+ try {
+ FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAtRow(selectedRow);
+ int response = JOptionPane.showConfirmDialog(view, _("lima.question.fiscalperiod.blocked"),
+ _("lima.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+
+ if (response == JOptionPane.YES_OPTION) {
+ model.blockFiscalPeriod(selectedFiscalPeriod);
+ }
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't block fiscalperiod", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't block fiscalperiod", ex);
+ }
+ }
+
public void removeAllFiscalPeriods(){
FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-04-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-04-23 14:40:13 UTC (rev 2872)
@@ -28,6 +28,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -131,7 +132,8 @@
switch (columnIndex) {
case 0:
- result = fiscalPeriod.getBeginDate() + " - " + fiscalPeriod.getEndDate();
+ result = fiscalPeriod.getBeginDate()
+ + " - " + fiscalPeriod.getEndDate();
break;
case 1:
result = fiscalPeriod.getLocked();
@@ -154,6 +156,14 @@
}
+
+ public FiscalPeriod getFiscalPeriodAtRow(int row) throws LimaException {
+ FiscalPeriod fiscalPeriod = null;
+ fiscalPeriod = fiscalPeriodService.getAllFiscalPeriods().get(row);
+ return fiscalPeriod;
+ }
+
+
/**
* @param period
*/
@@ -170,4 +180,9 @@
fiscalPeriodService.removeAllFiscalPeriods();
fireTableDataChanged();
}
+
+ public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+ fiscalPeriodService.blockFiscalPeriod(fiscalPeriod);
+ fireTableDataChanged();
+ }
}
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-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-23 14:40:13 UTC (rev 2872)
@@ -1,6 +1,8 @@
Bloqu\u00E9e=
Can't\ add\ fiscal\ period=
+Can't\ delete\ all\ fiscal\ period=
Confirmation=
+DEBUG\ delete\ all=
Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
Exercice=
Global\ lima\ exception=
@@ -258,6 +260,7 @@
lima.progressBar.load.etape5=Loading transactions
lima.question=Question
lima.question.confirmremove.account=This account have subaccounts, do you want remove this account ?
+lima.question.fiscalperiod.morethan12=
lima.question.load.accounts=There is no existing accounts in Lima. Do you want to load default accounts ?
lima.question.remove.account=Do you want to remove this account ?
lima.question.remove.entry=Do you want to remove this entry ?
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-23 09:58:20 UTC (rev 2871)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-23 14:40:13 UTC (rev 2872)
@@ -246,6 +246,7 @@
lima.question=Question
lima.question.confirmremove.account=Ce compte poss\u00E8de des sous comptes, voulez-vous supprimer ce compte ?
lima.question.fiscalperiod.morethan12=La p\u00E9riode s\u00E9lectionner n'est pas de 12 mois, voulez-vous continuer ?
+lima.question.fiscalperiod.blocked=\u00C8tes vous s\u00FBre de vouloir cl\u00F4turer cette exercice ? Cette action est irr\u00E9versible !
lima.question.load.accounts=Il n'y a aucun plan comptable existant dans Lima. Voulez-vous en charger un par d\u00E9faut ?
lima.question.remove.account=Voulez-vous supprimer ce compte?
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
1
0