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
- 1853 discussions
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
r2871 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao lima-callao/src/main/xmi 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 11:58:20 +0200 (Fri, 23 Apr 2010)
New Revision: 2871
Log:
Modification du model : composition entre identity et account
Ajout : cr?\195?\169ation d'un 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/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-callao/pom.xml
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
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-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-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-04-23 09:58:20 UTC (rev 2871)
@@ -40,5 +40,5 @@
//void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
- //void removeFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ void removeAllFiscalPeriods() 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-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-23 09:58:20 UTC (rev 2871)
@@ -681,19 +681,10 @@
throw new LimaBusinessException("Account not empty");
}
else {
- Identity existIdentity = account.getIdentity();
// remove account
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
accountDAO.delete(account);
- //check if account is a subledger with identity
- if (existIdentity != null) {
- System.out.println(existIdentity.getAddress());
- // delete identity
- IdentityDAO identityDAO =
- LimaCallaoDAOHelper.getIdentityDAO(transaction);
- identityDAO.delete(existIdentity);
- }
// commit
transaction.commitTransaction();
}
@@ -791,7 +782,7 @@
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = rootContext.beginTransaction();
//Check if the account is a subledger
Identity existIdentity = account.getIdentity();
if (existIdentity != null) {
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-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-23 09:58:20 UTC (rev 2871)
@@ -21,6 +21,9 @@
import static org.nuiton.i18n.I18n._;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -34,6 +37,8 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -41,6 +46,8 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.apache.commons.lang.time.DateUtils;
/**
* Gestion des exercices.
@@ -53,7 +60,7 @@
private static final Log log = LogFactory.getLog(FiscalPeriodServiceImpl.class);
- private TopiaContext rootContext;
+ private static TopiaContext rootContext;
private FinancialPeriodServiceImpl financialPeriodService = new FinancialPeriodServiceImpl();
@@ -161,62 +168,70 @@
// un exercice doit être collé au precedent
- // un exercice ne peut être crée que si l'anti precedent est fermé
+ // un exercice ne peut être crée que si l'ante precedent est fermé
// on peut creer un exercice si le precedent n'est pas fermé
-
+ boolean valid=false;
TopiaContext transaction = null;
try {
+
// basic check done, make check in database
// TODO move it into JTA
transaction = rootContext.beginTransaction();
FiscalPeriodDAO fiscalPeriodDAO =
LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
-
+
//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");
}
- //check if all fiscal period is locked
- if (fiscalPeriodDAO.findAll().size() ==
- fiscalPeriodDAO.findAllByLocked(true).size()){
- //TODO Exception
- throw new LimaBusinessException("Last fiscal period is not locked");
- }
-
- //check if the last enddate period is before the new begindate period
- FiscalPeriod lastFiscalPeriod = null;
- List<FiscalPeriod> listFiscalPeriods = getAllFiscalPeriods();
- ListIterator<FiscalPeriod> itr = listFiscalPeriods.listIterator();
- while(itr.hasNext()){
- FiscalPeriod thisFiscalPeriod = itr.next();
- if (thisFiscalPeriod.getEndDate().
- after(lastFiscalPeriod.getEndDate())){
- lastFiscalPeriod=thisFiscalPeriod;
+ //Checks if is not the first fiscalperiod to create
+ if (fiscalPeriodDAO.findAll().size()!=0){
+
+ TopiaQuery query = fiscalPeriodDAO.createQuery();
+ fiscalPeriodDAO.findAllByQuery(query);
+ query.addOrderDesc(FiscalPeriod.END_DATE);
+
+ //get the last fiscal period
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.findByQuery(query);
+ log.debug("lastFiscalPeriod : "+lastFiscalPeriod);
+
+ //check the new fiscal period adjoining the last
+ Date dateLastFiscalPeriod=lastFiscalPeriod.getEndDate();
+ dateLastFiscalPeriod = DateUtils.addMilliseconds(dateLastFiscalPeriod, 1);
+ Date dateFiscalPeriod=fiscalPeriod.getBeginDate();
+ if(dateLastFiscalPeriod.compareTo(dateFiscalPeriod)!=0){
+ 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();
+ log.debug(unblockedFiscalPeriod);
+ if (unblockedFiscalPeriod>1){
+ throw new LimaBusinessException("The ante fiscal period is not locked");
+ }
}
- if (lastFiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())){
- //TODO Exception
- throw new LimaBusinessException
- ("The begindate is before the enddate of the last fiscalperiod");
- }
+
+ Date beginDate = fiscalPeriod.getBeginDate();
+ Date endDate = fiscalPeriod.getEndDate();
-
- //count the month number
- int monthNumber = fiscalPeriod.getEndDate().getMonth()
- -fiscalPeriod.getBeginDate().getMonth();
-
- //check if fiscalperiod have 12 months, ask a confirmation
- if(monthNumber!=12){
- //TODO Exception
- throw new LimaBusinessException("The fiscal period has not 12 months");
+ // FinancialPeriod of 1 month are created
+ Date loopDate = beginDate;
+ while (loopDate.compareTo(endDate) <= 0) {
+ Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
+ Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ financialPeriod.setBeginDate(loopDate);
+ financialPeriod.setEndDate(periodEndDate);
+ fiscalPeriod.addFinancialPeriod(financialPeriod);
+ loopDate = loopUpperDate;
+ log.debug("financialPeriod : "+financialPeriod);
+ financialPeriodService.createFinancialPeriod(financialPeriod);
}
-
- //TODO create the financialperiods, much as period as months
- for (int i = 0; i < monthNumber; i++) {
- }
-
+ //create
fiscalPeriodDAO.create(fiscalPeriod);
// commit
@@ -258,6 +273,29 @@
return result;
}
+
+ public void removeAllFiscalPeriods() throws LimaException{
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ for (FiscalPeriod fiscalPeriod : fiscalPeriodDAO.findAll()) {
+ fiscalPeriodDAO.delete(fiscalPeriod);
+ }
+
+ // commit
+ transaction.commitTransaction();
+
+ } catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+ }
+
/*
* Permet de créer une période à partir d'une période DTO.
* @param periodDTO période à créer au format DTO.
Modified: trunk/lima-callao/pom.xml
===================================================================
--- trunk/lima-callao/pom.xml 2010-04-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-callao/pom.xml 2010-04-23 09:58:20 UTC (rev 2871)
@@ -15,6 +15,10 @@
<artifactId>lima-callao</artifactId>
<dependencies>
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2010-04-23 09:58:20 UTC (rev 2871)
@@ -22,6 +22,7 @@
import org.chorem.lima.entity.FiscalPeriodImpl;
import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodMonthComboBoxModel;
import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodSplinnerModel;
+ import org.apache.commons.lang.time.DateUtils;
import java.util.Calendar;
protected void performOk() {
@@ -34,15 +35,26 @@
Calendar calendarBegin = Calendar.getInstance();
calendarBegin.set(Calendar.MONTH, ((MonthEnum)periodBeginMonth.getSelectedItem()).ordinal());
calendarBegin.set(Calendar.YEAR, (Integer)periodBeginYear.getValue());
-
+ // set begindate to 0:00.000
+ Date beginDate = calendarBegin.getTime();
+ beginDate = DateUtils.truncate(beginDate, Calendar.MONTH);
+
// get end date
Calendar calendarEnd = Calendar.getInstance();
calendarEnd.set(Calendar.MONTH, ((MonthEnum)periodEndMonth.getSelectedItem()).ordinal());
calendarEnd.set(Calendar.YEAR, (Integer)periodEndYear.getValue());
+ //set end date to last day of month
+ calendarEnd.set(Calendar.DAY_OF_MONTH, calendarEnd.getActualMaximum(Calendar.DAY_OF_MONTH));
+ //set time to max 23:59.999
+ Date endDate = calendarEnd.getTime();
+ endDate = DateUtils.addDays(endDate, 1);
+ endDate = DateUtils.truncate(endDate, Calendar.MONTH);
+ endDate = DateUtils.addMilliseconds(endDate,-1);
+
+
+ getPeriod().setBeginDate(beginDate);
+ getPeriod().setEndDate(endDate);
- getPeriod().setBeginDate(calendarBegin.getTime());
- getPeriod().setEndDate(calendarEnd.getTime());
-
dispose();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-04-23 09:58:20 UTC (rev 2871)
@@ -61,6 +61,12 @@
onActionPerformed="getHandler().blockFiscalPeriod()" />
</cell>
</row>
+ <row>
+ <cell>
+ <JButton id="deleteButton" text="DEBUG delete all"
+ onActionPerformed="getHandler().removeAllFiscalPeriods()" />
+ </cell>
+ </row>
</Table>
</cell>
</row>
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-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-04-23 09:58:20 UTC (rev 2871)
@@ -23,10 +23,13 @@
import java.util.Calendar;
import java.util.Date;
+import javax.swing.JOptionPane;
+
import org.apache.commons.lang.NotImplementedException;
-import org.apache.commons.lang.time.DateUtils;
+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.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
@@ -64,35 +67,29 @@
addPeriodDialog.setLocationRelativeTo(view);
addPeriodDialog.setVisible(true);
- FiscalPeriod period = addPeriodDialog.getPeriod();
+ FiscalPeriod fiscalPeriod = addPeriodDialog.getPeriod();
// null = cancel
- if (period != null) {
-
- Date beginDate = period.getBeginDate();
- Date endDate = period.getEndDate();
- // set both to 0:00.000
- beginDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
- endDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
-
- // on cree pour l'instant des periodes de 1mois
- Date loopDate = beginDate;
- while (loopDate.compareTo(endDate) < 0) {
- Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
- Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- financialPeriod.setBeginDate(loopDate);
- financialPeriod.setEndDate(periodEndDate);
- period.addFinancialPeriod(financialPeriod);
- loopDate = loopUpperDate;
+ if (fiscalPeriod!= null) {
+ System.out.println("begin : "+fiscalPeriod.getBeginDate()+" end :"+fiscalPeriod.getEndDate());
+ //check if fiscalperiod have 12 months, ask a confirmation
+ int nbMonth = DateUtils.getDifferenceInMonths(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate());
+ int n = 0;
+ if(nbMonth !=12){
+ n = JOptionPane.showConfirmDialog(view,
+ _("lima.question.fiscalperiod.morethan12"),
+ _("lima.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
}
-
- try {
- model.addFiscalPeriod(period);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add fiscal period", ex);
+ if (n == JOptionPane.YES_OPTION || nbMonth ==11){
+ try {
+ model.addFiscalPeriod(fiscalPeriod);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add fiscal period", ex);
+ }
+ ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex);
}
- ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex);
}
}
}
@@ -100,4 +97,16 @@
public void blockFiscalPeriod() {
throw new NotImplementedException("To be continued...");
}
+
+ public void removeAllFiscalPeriods(){
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel();
+ try {
+ model.removeAllFiscalPeriods();
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't delete all fiscal period", ex);
+ }
+ ErrorHelper.showErrorDialog(_("Can't delete all fiscal period"), ex);
+ }
+ }
}
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-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-04-23 09:58:20 UTC (rev 2871)
@@ -165,4 +165,9 @@
fiscalPeriodService.createFiscalPeriod(period);
fireTableRowsInserted(currentRowCount, currentRowCount);
}
+
+ public void removeAllFiscalPeriods() throws LimaException {
+ fiscalPeriodService.removeAllFiscalPeriods();
+ fireTableDataChanged();
+ }
}
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-21 16:09:27 UTC (rev 2870)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-23 09:58:20 UTC (rev 2871)
@@ -1,5 +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\ ?=
Global\ lima\ exception=
Loading\ accounting...=
@@ -219,8 +222,11 @@
lima.number=Num\u00E9ro
lima.openejb.remotemode.description=
lima.passif=Passif
+lima.period=
lima.period.begindate=D\u00E9but
+lima.period.close=
lima.period.enddate=Fin
+lima.period.open=
lima.preferences=Pr\u00E9f\u00E9rences
lima.prefix=Pr\u00E9fixe
lima.produit=Produit
@@ -239,6 +245,7 @@
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.morethan12=La p\u00E9riode s\u00E9lectionner n'est pas de 12 mois, voulez-vous continuer ?
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
Author: jpepin
Date: 2010-04-21 18:09:27 +0200 (Wed, 21 Apr 2010)
New Revision: 2870
Log:
Suppression compte tiers et sa fiche d'identit?\195?\169 ;
Modification de l'UI ;
Cr?\195?\169ation de la m?\195?\169thode m?\195?\169tier de cr?\195?\169ation d'exercice en cours.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
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/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css
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
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.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/FiscalPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodMonthComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodSplinnerModel.java
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/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/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -51,10 +51,8 @@
void updateAccount(Account account) throws LimaException;
- void updateIdentity(Identity identity) throws LimaException;
-
void removeAccount(Account account) throws LimaException;
-
+
void removeAccountwithSubAccounts(Account account) throws LimaException;
List<Account> getChildrenAccounts(Account masterAccount) 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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -174,7 +174,8 @@
transaction = rootContext.beginTransaction();
// check if the accountnumber already exist
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
Account existAccount =
accountDAO.findByAccountNumber(account.getAccountNumber());
if (existAccount != null) {
@@ -192,15 +193,14 @@
accountDAO.create(account);
- IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(transaction);
+ IdentityDAO identityDAO =
+ LimaCallaoDAOHelper.getIdentityDAO(transaction);
identityDAO.create(identity);
account.setIdentity(identity);
// check if the masteraccount exist;
if (masterAccount != null) {
masterAccount.addSubLedgers(account);
- //account.setIdentity(identity);
- System.out.println(identity.getName()+" "+identity.getAddress());
accountDAO.update(masterAccount);
}
@@ -680,13 +680,22 @@
if (account.getSubAccounts().size() > 0){
throw new LimaBusinessException("Account not empty");
}
- else {
- // remove account
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(transaction);
- accountDAO.delete(account);
- // commit
- transaction.commitTransaction();
+ else {
+ Identity existIdentity = account.getIdentity();
+ // remove account
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+ accountDAO.delete(account);
+ //check if account is a subledger with identity
+ if (existIdentity != null) {
+ System.out.println(existIdentity.getAddress());
+ // delete identity
+ IdentityDAO identityDAO =
+ LimaCallaoDAOHelper.getIdentityDAO(transaction);
+ identityDAO.delete(existIdentity);
+ }
+ // commit
+ transaction.commitTransaction();
}
}
catch (TopiaException ex) {
@@ -783,7 +792,14 @@
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
-
+ //Check if the account is a subledger
+ Identity existIdentity = account.getIdentity();
+ if (existIdentity != null) {
+ // update identity
+ IdentityDAO identityDAO =
+ LimaCallaoDAOHelper.getIdentityDAO(transaction);
+ identityDAO.update(existIdentity);
+ }
// update account
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
@@ -793,34 +809,12 @@
}
catch (TopiaException ex) {
if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
+ log.error("Error during update account", ex);
}
throw new LimaException("Can't update account", ex);
}
}
- @Override
- public void updateIdentity(Identity identity) throws LimaException {
- // TODO Auto-generated method stub
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- // update account
- IdentityDAO identityDAO =
- LimaCallaoDAOHelper.getIdentityDAO(transaction);
- identityDAO.update(identity);
- // commit
- transaction.commitTransaction();
- }
- catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during update identity", ex);
- }
- throw new LimaException("Can't update identity", ex);
- }
- }
-
/*
* Permet de modifier un compte sur son label et son compte père.
* Il recherche le compte père avec le numéro de compte fourni. Appel ensuite
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -274,12 +274,7 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- // test si un EntryBook de ce nom existe deja
EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
- EntryBook existingEntryBook = entryBookDAO.findByLabel(entryBook.getLabel());
- if (existingEntryBook != null) {
- throw new LimaBusinessException(_("An EntryBook already exists with this label : %s", entryBook.getLabel()));
- }
// creation du EntryBook
entryBookDAO.update(entryBook);
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -22,6 +22,7 @@
import static org.nuiton.i18n.I18n._;
import java.util.List;
+import java.util.ListIterator;
import javax.ejb.Stateless;
@@ -31,6 +32,7 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
@@ -41,9 +43,8 @@
import org.nuiton.topia.TopiaNotFoundException;
/**
- * Gestion des périodes.
- * Chaque période doit posséder 12 timespans mensuels.
- * Une période ne peut être supprimée et débloquée.
+ * Gestion des exercices.
+ * Un exercice ne peut être supprimée et débloquée après cloture.
*
* @author Rémi Chapelet
*/
@@ -85,7 +86,8 @@
*/
@Override
public void createFiscalPeriod(FiscalPeriod fiscalPeriod /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) throws LimaException {
- /*// Par défaut lock est à false
+
+ /*// Par défaut lock est à false
lock = false;
String result = ServiceHelper.RESPOND_ERROR;
@@ -152,28 +154,69 @@
// un exercice ne peut pas faire plus de 24 mois dans tous les cas
// un exercice doit faire au moins une période
- if ( fiscalPeriod.getFinancialPeriod() == null ||
+ /*if ( fiscalPeriod.getFinancialPeriod() == null ||
fiscalPeriod.getFinancialPeriod().isEmpty()) {
throw new LimaBusinessException(_("A fiscal period must have at least one financial period !"));
- }
+ }*/
// un exercice doit être collé au precedent
// un exercice ne peut être crée que si l'anti precedent est fermé
// on peut creer un exercice si le precedent n'est pas fermé
-
+
TopiaContext transaction = null;
try {
// basic check done, make check in database
// TODO move it into JTA
transaction = rootContext.beginTransaction();
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
- // TODO maybe put this in antoher place
- for (FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) {
- financialPeriodService.createFinancialPeriod(transaction, financialPeriod);
+ //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");
}
+
+ //check if all fiscal period is locked
+ if (fiscalPeriodDAO.findAll().size() ==
+ fiscalPeriodDAO.findAllByLocked(true).size()){
+ //TODO Exception
+ throw new LimaBusinessException("Last fiscal period is not locked");
+ }
+
+ //check if the last enddate period is before the new begindate period
+ FiscalPeriod lastFiscalPeriod = null;
+ List<FiscalPeriod> listFiscalPeriods = getAllFiscalPeriods();
+ ListIterator<FiscalPeriod> itr = listFiscalPeriods.listIterator();
+ while(itr.hasNext()){
+ FiscalPeriod thisFiscalPeriod = itr.next();
+ if (thisFiscalPeriod.getEndDate().
+ after(lastFiscalPeriod.getEndDate())){
+ lastFiscalPeriod=thisFiscalPeriod;
+ }
+ }
+ if (lastFiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())){
+ //TODO Exception
+ throw new LimaBusinessException
+ ("The begindate is before the enddate of the last fiscalperiod");
+ }
+
+
+ //count the month number
+ int monthNumber = fiscalPeriod.getEndDate().getMonth()
+ -fiscalPeriod.getBeginDate().getMonth();
+
+ //check if fiscalperiod have 12 months, ask a confirmation
+ if(monthNumber!=12){
+ //TODO Exception
+ throw new LimaBusinessException("The fiscal period has not 12 months");
+ }
+
+ //TODO create the financialperiods, much as period as months
+ for (int i = 0; i < monthNumber; i++) {
+ }
- FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
fiscalPeriodDAO.create(fiscalPeriod);
// commit
@@ -198,7 +241,8 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
result = fiscalPeriodDAO.findAll();
// commit
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -199,7 +199,7 @@
// TODO EC-20100410 put lookup name in configuration
// name should be fully configurable due to custom implementation used
- String lookupName = "TransactionServiceImplLocal";
+ String lookupName = "FinancialTransactionServiceImplLocal";
FinancialTransactionService ejbHome = null;
try {
ejbHome = (FinancialTransactionService)ctx.lookup(lookupName);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -115,22 +115,14 @@
text="lima.common.quit" onActionPerformed='getHandler().close(this)'/>
</JMenu>
- <JMenu text="lima.chartofaccounts">
+ <JMenu text="lima.structure">
<JMenuItem text="lima.chartofaccounts.management" onActionPerformed='getHandler().showAccountView(this)'
actionIcon='account'/>
<JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='getHandler().showJournalView(this)'
actionIcon='journal'/>
+ <JMenuItem text="lima.fiscalyear.management" onActionPerformed='getHandler().showFiscalPeriodView(this)'/>
</JMenu>
- <JMenu text="lima.fiscalyear">
- <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='getHandler().showAddPeriod(this)'/>
- <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='getHandler().showClosureTimeSpanView(this)'
- actionIcon='closure-timespan'/>
- <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='getHandler().showClosurePeriodView(this)'/>
- <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='getHandler().showFiscalPeriodView(this)'
- actionIcon='closure'/>
- </JMenu>
-
<JMenu text="lima.entries">
<JMenuItem text="lima.entries.addtransaction" onActionPerformed='getHandler().showTransactionView(this)'
actionIcon='transaction'/>
@@ -139,7 +131,6 @@
<JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)'
actionIcon='lettering'/>
</JMenu>
-
<JMenu text="lima.view">
<JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten"
onItemStateChanged='getHandler().onChangeView(this)'
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -38,7 +38,7 @@
import org.chorem.lima.LimaContext;
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.entrybook.EntryBookView;
-import org.chorem.lima.ui.period.FiscalPeriodView;
+import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
import org.chorem.lima.ui.report.BalanceView;
import org.chorem.lima.ui.report.BilanView;
import org.chorem.lima.ui.report.ReportsView;
@@ -292,21 +292,13 @@
public void showFiscalPeriodView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView);
- mainView.showTab(_("lima.tab.period"), fiscalPeriodView);
+ mainView.showTab(_("lima.tab.fiscalperiod"), fiscalPeriodView);
}
- public void showClosurePeriodView(JAXXContext rootContext) {
-
- }
-
public void showClosureTimeSpanView(JAXXContext rootContext) {
//getClosureView().initBlockForm();
}
- public void showAddPeriod(JAXXContext rootContext) {
- //getClosureView().initAddPeriod();
- }
-
public void showImportView(String type) {
/*if (!getImportView(type).isEnabled()) {
getImportView(type).setEnabled(true);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -146,7 +146,8 @@
treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
// add it
try {
- accountsTreeTableModel.addSubLedger(treePath, newAccount, newIdentity);
+ accountsTreeTableModel.
+ addSubLedger(treePath, newAccount, newIdentity);
} catch (LimaBusinessException ex) {
if (log.isErrorEnabled()) {
log.error("Can't add subledger", ex);
@@ -195,48 +196,32 @@
accountForm.setVisible(true);
// null == cancel action
selectedObject = accountForm.getAccount();
- if (selectedObject != null){
- // update it
- try {
-
- accountsTreeTableModel.
- updateAccount(treePath, selectedObject);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add update", ex);
- }
- ErrorHelper.showErrorDialog("Can't add update", ex);
- }
- }
}
// else is a subledger
else{
SubLedgerForm subLedgerForm = new SubLedgerForm(view);
subLedgerForm.setAccount(selectedObject);
- //log.debug("nom :"+selectedObject.getIdentity().getName());
- Identity identity=selectedObject.getIdentity();
- subLedgerForm.setIdentity(identity);
+ subLedgerForm.setIdentity(existIdentity);
// jaxx constructor don't call super() ?
subLedgerForm.setLocationRelativeTo(view);
subLedgerForm.setVisible(true);
// null == cancel action
selectedObject = subLedgerForm.getAccount();
- if (selectedObject != null){
- // update it
- try {
- accountsTreeTableModel.
- updateIdentity(identity);
- accountsTreeTableModel.
- updateAccount(treePath, selectedObject);
-
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add update", ex);
- }
- ErrorHelper.showErrorDialog("Can't add update", ex);
- }
- }
}
+ //if action confirmed
+ if (selectedObject != null){
+ // update it
+ try {
+
+ accountsTreeTableModel.
+ updateAccount(treePath, selectedObject);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add update", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add update", ex);
+ }
+ }
}
}
@@ -250,7 +235,7 @@
JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
AccountTreeTableModel accountsTreeTableModel =
(AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
-
+
// Any row selected
int selectedRow = view.getAccountsTreeTable().getSelectedRow();
if ( selectedRow != -1) {
@@ -264,6 +249,7 @@
TreePath treePath = view.getAccountsTreeTable().
getPathForRow(selectedRow);
Account account = (Account) treePath.getLastPathComponent();
+
try{
try {
accountsTreeTableModel.removeAccount(treePath, account);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -257,18 +257,6 @@
}
/**
- * Update identity.
- *
- * @param path
- * @param account
- * @throws LimaException
- */
- public void updateIdentity(Identity identity) throws LimaException {
- // Calling account service
- accountService.updateIdentity(identity);
- }
-
- /**
* Remove account.
*
* @param path
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -18,6 +18,8 @@
package org.chorem.lima.ui.account.model;
+import static org.nuiton.i18n.I18n._;
+
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
@@ -39,7 +41,7 @@
protected Object selectedObject;
/** Data. TODO put string in another place, don't use hard coded string. */
- protected Object[] data = new Object[]{ "actif", "passif", "produit", "charge" };
+ protected Object[] data = new Object[]{ _("lima.account.type1"), _("lima.account.type2"), _("lima.account.type3"), _("lima.account.type4")};
public AccountTypeListModel() {
super();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -57,10 +57,9 @@
<JLabel text="lima.entrybook.type"/>
</cell>
<cell>
- <JTextField id="entryBookTypeField" text="{getEntryBook().getType()}"/>
- <javax.swing.text.Document javaBean="getEntryBookTypeField().getDocument()"
- onInsertUpdate='getEntryBook().setType(getEntryBookTypeField().getText())'
- onRemoveUpdate='getEntryBook().setType(getEntryBookTypeField().getText())' />
+ <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.entrybook.model.EntryBookTypeListModel()}'
+ selectedItem="{getEntryBook().getType()}"
+ onActionPerformed="getEntryBook().setType((String)getTypeComboBox().getSelectedItem())"/>
</cell>
</row>
<row>
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,73 @@
+package org.chorem.lima.ui.entrybook.model;
+
+
+/* *##% 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.
+ * ##%*/
+
+import static org.nuiton.i18n.I18n._;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+/**
+ * Combo box model with entrybook types.
+ * (achats, ventes, trésorerie, général, situation).
+ *
+ */
+public class EntryBookTypeListModel extends AbstractListModel implements ComboBoxModel {
+
+ protected Object selectedObject;
+
+ /** Data. TODO put string in another place, don't use hard coded string. */
+ protected Object[] data = new Object[]{ _("lima.entrybook.type1"), _("lima.entrybook.type2"), _("lima.entrybook.type3"), _("lima.entrybook.type4"), _("lima.entrybook.type5")};
+
+ public EntryBookTypeListModel() {
+ super();
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedObject = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedObject;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return data.length;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return data[index];
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,96 @@
+<!-- ##% 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.
+ ##% -->
+<JDialog modal="true">
+
+ <script>
+ <![CDATA[
+ import org.nuiton.util.MonthEnum;
+ import org.chorem.lima.entity.FiscalPeriodImpl;
+ import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodMonthComboBoxModel;
+ import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodSplinnerModel;
+ import java.util.Calendar;
+
+ protected void performOk() {
+ if (period == null) {
+ // FIXME never ever use IMPL !!!
+ setPeriod(new FiscalPeriodImpl());
+ }
+
+ // get begin date
+ Calendar calendarBegin = Calendar.getInstance();
+ calendarBegin.set(Calendar.MONTH, ((MonthEnum)periodBeginMonth.getSelectedItem()).ordinal());
+ calendarBegin.set(Calendar.YEAR, (Integer)periodBeginYear.getValue());
+
+ // get end date
+ Calendar calendarEnd = Calendar.getInstance();
+ calendarEnd.set(Calendar.MONTH, ((MonthEnum)periodEndMonth.getSelectedItem()).ordinal());
+ calendarEnd.set(Calendar.YEAR, (Integer)periodEndYear.getValue());
+
+ getPeriod().setBeginDate(calendarBegin.getTime());
+ getPeriod().setEndDate(calendarEnd.getTime());
+
+ dispose();
+ }
+
+ protected void performCancel() {
+ setPeriod(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <org.chorem.lima.entity.FiscalPeriod id="period" javaBean="null" />
+
+ <Table fill="both">
+ <row>
+ <cell>
+ <JLabel text="lima.period.begindate"/>
+ </cell>
+ <cell>
+ <JComboBox id="periodBeginMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.JANUARY)}"/>
+ </cell>
+ <cell>
+ <JSpinner id="periodBeginYear" model="{new FiscalPeriodSplinnerModel()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.period.enddate"/>
+ </cell>
+ <cell>
+ <JComboBox id="periodEndMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.DECEMBER)}"/>
+ </cell>
+ <cell>
+ <JSpinner id="periodEndYear" model="{new FiscalPeriodSplinnerModel()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <Table fill="none" anchor="center" weighty="1">
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" onActionPerformed="performOk()"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,19 @@
+<!-- ##% 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.
+ ##% -->
+<JFrame title="lima.export" width="620" height="300" iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
+
+</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,56 @@
+<!-- ##% 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.
+ ##% -->
+
+<JDialog modal="true">
+ <style source="styles.css" />
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <Table>
+ <row>
+ <cell>
+ <JLabel text="lima.closure.period.begin"/>
+ </cell>
+ <cell>
+ <JPanel id="beginPeriod"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.to"/>
+ </cell>
+ <cell>
+ <JPanel id="endPeriod"/>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2">
+ <JTextArea styleClass="warning" text='{_("lima.closure.timespan.warning")}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" />
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="dispose()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,410 @@
+/* *##% 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);
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,67 @@
+<!-- ##% 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>
+
+ <FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" />
+ <Boolean id="selectedPeriod" javaBean="false" />
+
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <!--
+ <row fill="horizontal" weightx="1" anchor="center" columns="2">
+ <cell>
+ <JPanel border='{BorderFactory.createTitledBorder(_("lima.period.filter"))}'>
+ <JLabel text="lima.fiscalperiod.periodFilterLabel"/>
+ <JComboBox id="periodFilterComboBox" />
+ </JPanel>
+ </cell>
+ </row>
+ -->
+ <row>
+ <cell fill="both" weightx="1" weighty="1">
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="fiscalPeriodTable"
+ model="{new org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
+ rowHeight="24"
+ selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
+ columnControlVisible="true" />
+ <javax.swing.ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()"
+ onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ <cell fill="horizontal" weighty="1" anchor="north">
+ <Table>
+ <row>
+ <cell>
+ <JButton id="addButton" text="lima.fiscalperiod.addFiscalPeriod" onActionPerformed="getHandler().addFiscalPeriod()"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="blockButton" text="lima.fiscalperiod.block" enabled="{isSelectedPeriod()}"
+ onActionPerformed="getHandler().blockFiscalPeriod()" />
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+</Table>
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,103 @@
+/* *##% 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.util.Calendar;
+import java.util.Date;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel;
+import org.chorem.lima.ui.fiscalperiod.AddPeriod;
+import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodViewHandler {
+
+ private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class);
+
+ protected FiscalPeriodView view;
+
+ protected FiscalPeriodViewHandler(FiscalPeriodView view) {
+ this.view = view;
+ }
+
+ public void addFiscalPeriod() {
+
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel();
+
+ AddPeriod addPeriodDialog = new AddPeriod(view);
+ // jaxx don't call super() ?
+ addPeriodDialog.setLocationRelativeTo(view);
+ addPeriodDialog.setVisible(true);
+
+ FiscalPeriod period = addPeriodDialog.getPeriod();
+ // null = cancel
+ if (period != null) {
+
+ Date beginDate = period.getBeginDate();
+ Date endDate = period.getEndDate();
+ // set both to 0:00.000
+ beginDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
+ endDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
+
+ // on cree pour l'instant des periodes de 1mois
+ Date loopDate = beginDate;
+ while (loopDate.compareTo(endDate) < 0) {
+ Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
+ Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ financialPeriod.setBeginDate(loopDate);
+ financialPeriod.setEndDate(periodEndDate);
+ period.addFinancialPeriod(financialPeriod);
+ loopDate = loopUpperDate;
+ }
+
+ try {
+ model.addFiscalPeriod(period);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add fiscal period", ex);
+ }
+ ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex);
+ }
+ }
+ }
+
+ public void blockFiscalPeriod() {
+ throw new NotImplementedException("To be continued...");
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodMonthComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java 2010-04-12 15:46:09 UTC (rev 2859)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodMonthComboBoxModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* ##%*/
-package org.chorem.lima.ui.period.model;
+package org.chorem.lima.ui.fiscalperiod.model;
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodSplinnerModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java 2010-04-12 15:46:09 UTC (rev 2859)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodSplinnerModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* ##%*/
-package org.chorem.lima.ui.period.model;
+package org.chorem.lima.ui.fiscalperiod.model;
import java.util.Calendar;
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/period/model/FiscalPeriodTableModel.java 2010-04-12 15:46:09 UTC (rev 2859)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* ##%*/
-package org.chorem.lima.ui.period.model;
+package org.chorem.lima.ui.fiscalperiod.model;
import static org.nuiton.i18n.I18n._;
@@ -88,7 +88,7 @@
switch(columnIndex) {
case 0 :
- result = _("Exercice");
+ result = _("lima.tab.fiscalperiod");
break;
case 1:
result = _("Bloquée");
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,8 @@
+.warning {
+ foreground: red;
+ // JTextArea sur plusieurs lignes
+ lineWrap: true;
+ // Implique que les mots ne sont pas coupés
+ wrapStyleWord: true;
+ editable: false;
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,96 +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.
- ##% -->
-<JDialog modal="true">
-
- <script>
- <![CDATA[
- import org.nuiton.util.MonthEnum;
- import org.chorem.lima.entity.FiscalPeriodImpl;
- import org.chorem.lima.ui.period.model.FiscalPeriodMonthComboBoxModel;
- import org.chorem.lima.ui.period.model.FiscalPeriodSplinnerModel;
- import java.util.Calendar;
-
- protected void performOk() {
- if (period == null) {
- // FIXME never ever use IMPL !!!
- setPeriod(new FiscalPeriodImpl());
- }
-
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- calendarBegin.set(Calendar.MONTH, ((MonthEnum)periodBeginMonth.getSelectedItem()).ordinal());
- calendarBegin.set(Calendar.YEAR, (Integer)periodBeginYear.getValue());
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- calendarEnd.set(Calendar.MONTH, ((MonthEnum)periodEndMonth.getSelectedItem()).ordinal());
- calendarEnd.set(Calendar.YEAR, (Integer)periodEndYear.getValue());
-
- getPeriod().setBeginDate(calendarBegin.getTime());
- getPeriod().setEndDate(calendarEnd.getTime());
-
- dispose();
- }
-
- protected void performCancel() {
- setPeriod(null);
- dispose();
- }
- ]]>
- </script>
-
- <org.chorem.lima.entity.FiscalPeriod id="period" javaBean="null" />
-
- <Table fill="both">
- <row>
- <cell>
- <JLabel text="lima.period.begindate"/>
- </cell>
- <cell>
- <JComboBox id="periodBeginMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.JANUARY)}"/>
- </cell>
- <cell>
- <JSpinner id="periodBeginYear" model="{new FiscalPeriodSplinnerModel()}"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.period.enddate"/>
- </cell>
- <cell>
- <JComboBox id="periodEndMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.DECEMBER)}"/>
- </cell>
- <cell>
- <JSpinner id="periodEndYear" model="{new FiscalPeriodSplinnerModel()}"/>
- </cell>
- </row>
- <row>
- <cell>
- <Table fill="none" anchor="center" weighty="1">
- <row>
- <cell>
- <JButton id="okButton" text="lima.common.ok" onActionPerformed="performOk()"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- </Table>
-</JDialog>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,19 +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.
- ##% -->
-<JFrame title="lima.export" width="620" height="300" iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
-
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,56 +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.
- ##% -->
-
-<JDialog modal="true">
- <style source="styles.css" />
- <script>
- <![CDATA[
-
- ]]>
- </script>
- <Table>
- <row>
- <cell>
- <JLabel text="lima.closure.period.begin"/>
- </cell>
- <cell>
- <JPanel id="beginPeriod"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="endPeriod"/>
- </cell>
- </row>
- <row>
- <cell columns="2">
- <JTextArea styleClass="warning" text='{_("lima.closure.timespan.warning")}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.common.ok" />
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JDialog>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,408 +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.period;
-
-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.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);
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,65 +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>
-
- <FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" />
- <Boolean id="selectedPeriod" javaBean="false" />
-
- <script>
- <![CDATA[
-
- ]]>
- </script>
- <row fill="horizontal" weightx="1" anchor="center" columns="2">
- <cell>
- <JPanel border='{BorderFactory.createTitledBorder(_("lima.period.filter"))}'>
- <JLabel text="lima.period.periodFilterLabel"/>
- <JComboBox id="periodFilterComboBox" />
- </JPanel>
- </cell>
- </row>
- <row>
- <cell fill="both" weightx="1" weighty="1">
- <JScrollPane>
- <org.jdesktop.swingx.JXTable id="fiscalPeriodTable"
- model="{new org.chorem.lima.ui.period.model.FiscalPeriodTableModel()}"
- highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
- rowHeight="24"
- selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
- columnControlVisible="true" />
- <javax.swing.ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()"
- onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/>
- </JScrollPane>
- </cell>
- <cell fill="horizontal" weighty="1" anchor="north">
- <Table>
- <row>
- <cell>
- <JButton id="addButton" text="lima.period.addFiscalPeriod" onActionPerformed="getHandler().addFiscalPeriod()"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="blockButton" text="lima.period.block" enabled="{isSelectedPeriod()}"
- onActionPerformed="getHandler().blockFiscalPeriod()" />
- </cell>
- </row>
- </Table>
- </cell>
- </row>
-</Table>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,103 +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.period;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.Calendar;
-import java.util.Date;
-
-import org.apache.commons.lang.NotImplementedException;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialPeriodImpl;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.ui.period.model.FiscalPeriodTableModel;
-import org.chorem.lima.util.ErrorHelper;
-
-/**
- * TODO add comment here.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FiscalPeriodViewHandler {
-
- private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class);
-
- protected FiscalPeriodView view;
-
- protected FiscalPeriodViewHandler(FiscalPeriodView view) {
- this.view = view;
- }
-
- public void addFiscalPeriod() {
-
- FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel();
-
- AddPeriod addPeriodDialog = new AddPeriod(view);
- // jaxx don't call super() ?
- addPeriodDialog.setLocationRelativeTo(view);
- addPeriodDialog.setVisible(true);
-
- FiscalPeriod period = addPeriodDialog.getPeriod();
- // null = cancel
- if (period != null) {
-
- Date beginDate = period.getBeginDate();
- Date endDate = period.getEndDate();
- // set both to 0:00.000
- beginDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
- endDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
-
- // on cree pour l'instant des periodes de 1mois
- Date loopDate = beginDate;
- while (loopDate.compareTo(endDate) < 0) {
- Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
-
- Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- financialPeriod.setBeginDate(loopDate);
- financialPeriod.setEndDate(periodEndDate);
- period.addFinancialPeriod(financialPeriod);
-
- loopDate = loopUpperDate;
- }
-
- try {
- model.addFiscalPeriod(period);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add fiscal period", ex);
- }
- ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex);
- }
- }
- }
-
- public void blockFiscalPeriod() {
- throw new NotImplementedException("To be continued...");
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,8 +0,0 @@
-.warning {
- foreground: red;
- // JTextArea sur plusieurs lignes
- lineWrap: true;
- // Implique que les mots ne sont pas coupés
- wrapStyleWord: true;
- editable: false;
-}
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -20,26 +20,17 @@
import static org.nuiton.i18n.I18n._;
-import java.util.List;
import javax.swing.JOptionPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryBookImpl;
import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.entity.FinancialTransactionImpl;
-import org.chorem.lima.ui.entrybook.EntryBookForm;
-import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
import org.chorem.lima.ui.transaction.table.FinancialTransactionTable;
import org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel;
import org.chorem.lima.util.ErrorHelper;
-import org.jdesktop.swingx.JXTable;
-
/**
* Handler associated with account view.
*
@@ -68,11 +59,9 @@
try {
model.addFinancialTransaction();
} catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add transaction", ex);
+ JOptionPane.showMessageDialog(view,
+ _("lima.warning.financialtransaction.noselect"));
}
- ErrorHelper.showErrorDialog("Can't add transaction", ex);
- }
}
//implement new transaction button
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-21 16:09:27 UTC (rev 2870)
@@ -38,29 +38,38 @@
<row fill="horizontal" weightx="1" weighty="0" anchor="center">
<cell>
- <JLabel id="entryBookLabel" text="lima.transaction.entrybook"/>
+ <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/>
</cell>
<cell>
- <JComboBox id="entryBookComboBox"
- model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}"
- renderer="{new org.chorem.lima.ui.transaction.model.EntryBookRenderer()}"
- onItemStateChanged="getTransactionTableModel().setEntryBook((EntryBook) event.getItem())"
+ <JComboBox id="fiscalPeriodComboBox"
+ model="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxModel()}"
+ renderer="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxRenderer()}"
editable="false"/>
</cell>
<cell>
- <JLabel id="periodLabel" text="lima.transaction.period"
+ <JLabel id="financialPeriodLabel" text="lima.transaction.period"
/>
</cell>
<cell>
<JComboBox id="financialPeriodComboBox"
model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}"
- renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodRenderer()}"
+ renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxRenderer()}"
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="4">
+ <cell fill="both" weightx="1" weighty="1" rows="3" columns="5">
<JScrollPane>
<org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel
id="financialTransactionTableModel" />
@@ -75,7 +84,7 @@
</cell>
<cell>
<JButton text="lima.add.transaction"
- onActionPerformed="getHandler().addEmptyTransaction()"/>
+ onActionPerformed="getHandler().addFinancialTransaction()"/>
</cell>
</row>
<row>
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java (from rev 2862, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,54 @@
+/* *##% 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.transaction.model;
+
+import java.awt.Component;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import org.chorem.lima.entity.FinancialPeriod;
+
+
+public class FinancialPeriodComboBoxRenderer 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();
+ 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());
+ }
+ return label;
+ }
+
+
+}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java 2010-04-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,36 +0,0 @@
-package org.chorem.lima.ui.transaction.model;
-
-import java.awt.Component;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-
-import org.chorem.lima.entity.FinancialPeriod;
-
-
-public class FinancialPeriodRenderer 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();
- 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());
- }
- return label;
- }
-
-
-}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,102 @@
+/* *##% 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.transaction.model;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
+
+public class FiscalPeriodComboBoxModel implements ComboBoxModel{
+
+ protected Object selectedFiscalPeriod;
+
+ protected FiscalPeriodService fiscalPeriodService;
+
+ public FiscalPeriodComboBoxModel(){
+ fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ int result = 0;
+ // TODO add cache
+ try {
+ result = fiscalPeriodService.getAllFiscalPeriods().size();
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ Object result = null;
+ try {
+ result = fiscalPeriodService.getAllFiscalPeriods().get(index);
+ }
+ catch (LimaException ex) {
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void addListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedFiscalPeriod = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedFiscalPeriod;
+ }
+
+}
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -0,0 +1,52 @@
+/* *##% 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.transaction.model;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
+
+public class FiscalPeriodComboBoxRenderer 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();
+ 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());
+ }
+ 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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-21 16:09:27 UTC (rev 2870)
@@ -24,10 +24,12 @@
import java.util.Date;
import java.util.List;
+import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;
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.business.RecordService;
import org.chorem.lima.business.FinancialTransactionService;
@@ -336,14 +338,21 @@
/* Calling transaction service */
//TODO transaction = currentdate, current periode, current journal
FinancialTransaction financialtransaction =null;
- financialtransaction.setFinancialPeriod(selectedFinancialPeriod);
- financialtransaction.setEntryBook(selectedEntryBook);
- //financialransaction.setDescription(description);
- transactionService.createFinancialTransaction(financialtransaction);
- int row = getDataList().indexOf(financialtransaction);
- //int row = transactionService.getAllTransactions().indexOf(transaction);
- log.debug(row);
- fireTableRowsInserted(row, row);
+ //if a period and an entrybook is selected
+ if (selectedEntryBook != null && selectedFinancialPeriod != null){
+ financialtransaction.setFinancialPeriod(selectedFinancialPeriod);
+ financialtransaction.setEntryBook(selectedEntryBook);
+ //financialransaction.setDescription(description);
+ //create it
+ 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");
+ }
}
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-21 16:09:27 UTC (rev 2870)
@@ -10,6 +10,10 @@
lima.account.label=Label
lima.account.number=Number
lima.account.type=Account type
+lima.account.type1=
+lima.account.type2=
+lima.account.type3=
+lima.account.type4=
lima.accountplan=Plan de comptes
lima.actif=Asset
lima.action.commandline.disable.main.ui=Do not launch main ui
@@ -44,7 +48,6 @@
lima.block=block
lima.cancel=Cancel
lima.charge=Expense
-lima.chartofaccounts=
lima.chartofaccounts.journal=
lima.chartofaccounts.management=
lima.chartofaccounts.subledgers=
@@ -94,6 +97,11 @@
lima.entrybook.code=
lima.entrybook.label=
lima.entrybook.type=
+lima.entrybook.type1=
+lima.entrybook.type2=
+lima.entrybook.type3=
+lima.entrybook.type4=
+lima.entrybook.type5=
lima.error=Error
lima.error.account.double=It exists an account with a same number
lima.error.account.not.exist=This account doesn't exist
@@ -136,11 +144,15 @@
lima.filter.not.contains=Not contains
lima.filter.starts.with=Starts with
lima.find.transaction=Find transaction
+lima.fiscalperiod.addFiscalPeriod=
+lima.fiscalperiod.block=
+lima.fiscalperiod.periodFilterLabel=
lima.fiscalyear=
lima.fiscalyear.addperiod=
lima.fiscalyear.closefiscalyear=
lima.fiscalyear.closeperiod=
lima.fiscalyear.listclosed=
+lima.fiscalyear.management=
lima.grand.livre=General Ledger
lima.home=Home - TODO
lima.identity.address=
@@ -272,6 +284,7 @@
lima.status.tr.balanced=Balanced
lima.status.tr.finalized=Finalized
lima.status.tr.wip=Work in progress
+lima.structure=Structure
lima.subledger.accountnumber=
lima.subledger.code=Code
lima.subledger.label=
@@ -281,6 +294,7 @@
lima.tab.balance=Balance
lima.tab.bilan=Results
lima.tab.closure=Closure
+lima.tab.fiscalperiod=
lima.tab.home=Home
lima.tab.journal=Journal
lima.tab.lettering=Lettering
@@ -317,5 +331,6 @@
lima.view=View
lima.view.flatten=Flatten view
lima.voucher=Voucher
+lima.warning.financialtransaction.noselect=No Financial Period or EntryBook are selectionned
lima.warning.nimbus.landf=Could not find Numbus Look&Feel
lima.warning.no.ui=No ui display detected
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-20 16:33:17 UTC (rev 2869)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-21 16:09:27 UTC (rev 2870)
@@ -1,8 +1,6 @@
-Bloqu\u00E9e=
Can't\ add\ fiscal\ period=
Confirmation=
Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
-Exercice=
Global\ lima\ exception=
Loading\ accounting...=
lima.about.message=\u00C0 propos de Lima
@@ -12,6 +10,10 @@
lima.account.number=Num\u00E9ro du compte
lima.account.parentnumber=
lima.account.type=Type de compte
+lima.account.type1=Actif
+lima.account.type2=Passif
+lima.account.type3=Produit
+lima.account.type4=Charge
lima.actif=Actif
lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
lima.action.commandline.help=Afficher l'aide en console
@@ -43,7 +45,6 @@
lima.bilan.total=Total
lima.block=Bloquer
lima.charge=Charge
-lima.chartofaccounts=Structure
lima.chartofaccounts.journal=Journaux
lima.chartofaccounts.management=Plan comptable
lima.chartofaccounts.subledgers=Plan tiers
@@ -86,13 +87,18 @@
lima.description=Description
lima.edit=Editer
lima.edit.transaction=Editer une transaction
-lima.entries=Entr\u00E9es comptable
-lima.entries.addtransaction=Ajouter une transaction
+lima.entries=Traitement
+lima.entries.addtransaction=Saisir des \u00E9critures
lima.entries.lettering=Ajouter une lettre
lima.entries.searchtransaction=Recherche les transactions
lima.entrybook.code=Code
lima.entrybook.label=Libelle
lima.entrybook.type=Type
+lima.entrybook.type1=Achats
+lima.entrybook.type2=Ventes
+lima.entrybook.type3=Tr\u00E9sorerie
+lima.entrybook.type4=G\u00E9n\u00E9ral
+lima.entrybook.type5=Situation
lima.error=Erreur
lima.error.account.double=Il existe un compte avec ce m\u00EAme num\u00E9ro de compte
lima.error.account.not.exist=Ce num\u00E9ro de compte n'existe pas
@@ -135,11 +141,14 @@
lima.filter.not.contains=Ne contient pas
lima.filter.starts.with=Commence par
lima.find.transaction=Rechercher transaction
-lima.fiscalyear=Exercice comptable
+lima.fiscalperiod.addFiscalPeriod=Nouvel exercice
+lima.fiscalperiod.block=Cloturer un exercice
+lima.fiscalperiod.periodFilterLabel=
lima.fiscalyear.addperiod=Ajouter une p\u00E9riode
lima.fiscalyear.closefiscalyear=Cl\u00F4turer l'exercice
lima.fiscalyear.closeperiod=Cl\u00F4turer une p\u00E9riode
lima.fiscalyear.listclosed=Voir toutes les cl\u00F4tures
+lima.fiscalyear.management=Exercices
lima.grand.livre=Grand-Livre
lima.home=Page d'accueil - TODO
lima.identity.address=Adresse
@@ -210,16 +219,8 @@
lima.number=Num\u00E9ro
lima.openejb.remotemode.description=
lima.passif=Passif
-lima.period=P\u00E9riode
-lima.period.addFiscalPeriod=Nouvel exercice
-lima.period.begindate=D\u00E9but de l'exercice \:
-lima.period.block=Bloquer l'exercice
-lima.period.close=Ferm\u00E9
-lima.period.enddate=Fin de l'exercice \:
-lima.period.filter=Filtre
-lima.period.menu=
-lima.period.open=Ouvert
-lima.period.periodFilterLabel=
+lima.period.begindate=D\u00E9but
+lima.period.enddate=Fin
lima.preferences=Pr\u00E9f\u00E9rences
lima.prefix=Pr\u00E9fixe
lima.produit=Produit
@@ -263,6 +264,7 @@
lima.status.tr.balanced=Equilibr\u00E9e
lima.status.tr.finalized=Valid\u00E9e
lima.status.tr.wip=En cours
+lima.structure=Structure
lima.subledger.accountnumber=
lima.subledger.code=Code
lima.subledger.label=
@@ -271,14 +273,14 @@
lima.tab.account=Plan Comptable
lima.tab.balance=Balance
lima.tab.bilan=Bilan
+lima.tab.blocked=Block\u00E9
+lima.tab.fiscalperiod=Exercice
lima.tab.home=Accueil
lima.tab.journal=Journal
lima.tab.lettering=Lettrage
-lima.tab.period=
lima.tab.reports=Rapports
lima.tab.result=Compte de r\u00E9sultat
lima.tab.search.result=Recherche
-lima.tab.subledgers=Plan Tiers
lima.tab.transaction=Ecriture
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=A propos de Lima...
@@ -307,5 +309,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.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
20 Apr '10
Author: jpepin
Date: 2010-04-20 18:33:17 +0200 (Tue, 20 Apr 2010)
New Revision: 2869
Log:
Modification compte et compte tiers (fiche d'identit?\195?\169)
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.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/account/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-20 16:33:17 UTC (rev 2869)
@@ -22,6 +22,7 @@
import java.util.List;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Identity;
/**
* Account service.
@@ -46,15 +47,15 @@
*/
void createAccount(Account masterAccount, Account account) throws LimaException;
- void createSubLedger(Account masterAccount, Account account) throws LimaException;
+ void createSubLedger(Account masterAccount, Account account, Identity identity) throws LimaException;
void updateAccount(Account account) throws LimaException;
- int removeAccount(Account account) throws LimaException;
+ void updateIdentity(Identity identity) throws LimaException;
+ void removeAccount(Account account) throws LimaException;
+
void removeAccountwithSubAccounts(Account account) throws LimaException;
-
- Account getAccountNumber(String numAccount) throws LimaException;
-
+
List<Account> getChildrenAccounts(Account masterAccount) 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-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-20 16:33:17 UTC (rev 2869)
@@ -39,6 +39,8 @@
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.Identity;
+import org.chorem.lima.entity.IdentityDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
@@ -89,20 +91,20 @@
@Override
public void createAccount(Account masterAccount, Account account) throws LimaException {
- // test la validite du numero de compte
+ // Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
throw new LimaBusinessException("Invalid AccountNumber : "
+ account.getAccountNumber());
}
- // test que le numero de compte est de type numeric
+ // Check if the number account is type numeric
if (!StringUtils.isNumeric(account.getAccountNumber())){
throw new LimaBusinessException("AccountNumber is not numeric : "
+ account.getAccountNumber());
}
- // test que le numero de compte du fils commence par celui du pere
- // (peut etre trop specific à la compta francaise)
+ // Check if the number account start with the number of the master account
+ // (specific to the french accountancy)
if (masterAccount!=null && !account.getAccountNumber().startsWith(
masterAccount.getAccountNumber())){
@@ -111,7 +113,7 @@
+ account.getAccountNumber());
}
- // Test que le compte master crée a un numéro entre 1 a 8
+ // Check if master account have a number between 1 to 8
if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){
throw new LimaBusinessException(
"Master account is not a digit between 1 to 8 :"
@@ -124,11 +126,12 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- // test si le numero de compte existe deja
+ // check if account number already exist
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
- Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
+ Account existAccount =
+ accountDAO.findByAccountNumber(account.getAccountNumber());
if (existAccount != null) {
throw new LimaBusinessException(_(
"An account already exists with this number : %s",
@@ -137,7 +140,7 @@
accountDAO.create(account);
- // test si le compte parent existe;
+ // check if parent account exist;
if (masterAccount != null) {
masterAccount.addSubAccounts(account);
accountDAO.update(masterAccount);
@@ -156,10 +159,9 @@
@Override
- public void createSubLedger(Account masterAccount, Account account)
+ public void createSubLedger(Account masterAccount, Account account, Identity identity)
throws LimaException {
- // TODO Auto-generated method stub
- // test la validite du numero de compte
+ // check the number account is not empty
if (StringUtils.isBlank(account.getAccountNumber())) {
throw new LimaBusinessException("Invalid AccountNumber : "
+ account.getAccountNumber());
@@ -171,29 +173,34 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- // test si le numero de compte existe deja
+ // check if the accountnumber already exist
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
+ Account existAccount =
+ accountDAO.findByAccountNumber(account.getAccountNumber());
if (existAccount != null) {
throw new LimaBusinessException(_(
"An account already exists with this number : %s",
account.getAccountNumber()));
}
- //test si le parent ne contient pas de subaccount
- if (masterAccount.getSubAccounts().size() > 0)
- /*List<Account> existingSubAccounts = masterAccount.getSubAccounts();
- if (CollectionUtils.isNotEmpty(existingSubAccounts))*/{
+ //check if parentaccount have no subaccount
+ if (masterAccount.getSubAccounts().size() > 0){
throw new LimaBusinessException(
- "Subledger must create on a account whithout subaccount : ");
-
+ "Subledger must create on a account whithout subaccount : ");
}
accountDAO.create(account);
- // test si le compte parent existe;
+
+ IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(transaction);
+ identityDAO.create(identity);
+ account.setIdentity(identity);
+
+ // check if the masteraccount exist;
if (masterAccount != null) {
masterAccount.addSubLedgers(account);
+ //account.setIdentity(identity);
+ System.out.println(identity.getName()+" "+identity.getAddress());
accountDAO.update(masterAccount);
}
@@ -543,7 +550,6 @@
LimaCallaoDAOHelper.getAccountDAO(transaction);
TopiaQuery query = accountDAO.createQuery();
-
if (masterAccount == null){
query.add("masterAccount", masterAccount);
query.add("generalLedger", TopiaQuery.Op.EQ, null);
@@ -569,23 +575,6 @@
return accountsList;
}
- /*
- * Renvoie vrai si le compte avec son numéro existe déjà dans la base de
- * données.
- * @param accountNumber numéro du compte recherché
- * @return
- *
- public boolean existAccount(String accountNumber) {
- // Recherche du compte
- Account accountSearch = searchAccount(accountNumber);
- boolean result = false;
- // Si le compte est trouvé
- if (accountSearch != null) {
- result = true;
- }
- return result;
- }*/
-
/**
* Permet d'effacer un compte dans la base de données.
*
@@ -598,7 +587,7 @@
* @throws LimaException
*/
@Override
- public int removeAccount(Account account) throws LimaException {
+ public void removeAccount(Account account) throws LimaException {
/*String result = ServiceHelper.RESPOND_ERROR;
Account deleteAccount = searchAccount(accountNumber);
// Si le compte n'existe pas
@@ -680,7 +669,6 @@
transaction = rootContext.beginTransaction();
//Check if an account has not his number
- // FIXME !IMPORTANT! check that subaccounts have no entries too
EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
Entry firstEntry = entryDAO.findByAccount(account);
@@ -688,10 +676,9 @@
throw new LimaBusinessException("Can't delete account with entries");
}
- //Check if the account is not empty, return -1
- List<Account> existingSubAccounts = getChildrenAccounts(account);
- if (CollectionUtils.isNotEmpty(existingSubAccounts)){
- result =-1;
+ //Check if the account is not empty
+ if (account.getSubAccounts().size() > 0){
+ throw new LimaBusinessException("Account not empty");
}
else {
// remove account
@@ -708,7 +695,6 @@
finally {
doFinally(transaction, log);
}
- return result;
}
/**
@@ -741,19 +727,6 @@
}
}
- /*
- * Permet d'effacer un compte à partir d'un compte DTO. Il appelle la
- * méthode removeAccount, qui effacera également les enfants (et ainsi de
- * suite dans la hiérarchie du compte).
- * @param accountDTO Compte au format DTO qu'on souhaite supprimer.
- * @return
- *
- public String removeAccount(AccountDTO accountDTO) {
- String result;
- result = removeAccount(accountDTO.getAccountNumber());
- return result;
- }*/
-
/**
* Permet de modifier un compte sur son label et son compte père.
*
@@ -827,24 +800,25 @@
}
@Override
- public Account getAccountNumber(String numAccount) throws LimaException {
- Account account = null;
+ public void updateIdentity(Identity identity) throws LimaException {
+ // TODO Auto-generated method stub
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- // get account from his number
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(transaction);
- account = accountDAO.findByAccountNumber(numAccount);
+ // update account
+ IdentityDAO identityDAO =
+ LimaCallaoDAOHelper.getIdentityDAO(transaction);
+ identityDAO.update(identity);
+ // commit
+ transaction.commitTransaction();
}
catch (TopiaException ex) {
if (log.isErrorEnabled()) {
- log.error("Error during get account from his number", ex);
+ log.error("Error during update identity", ex);
}
- throw new LimaException("Can't get account from his number", ex);
+ throw new LimaException("Can't update identity", ex);
}
- return account;
}
/*
Modified: 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-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-04-20 16:33:17 UTC (rev 2869)
@@ -26,7 +26,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- LimaConfigTest.getInstance();
+ LimaConfig.getInstance();
}
/**
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-04-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-04-20 16:33:17 UTC (rev 2869)
@@ -26,7 +26,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- LimaConfigTest.getInstance();
+ LimaConfig.getInstance();
}
/**
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-20 16:33:17 UTC (rev 2869)
@@ -3,5 +3,6 @@
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.Account.attribute.identity.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/account/AccountView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
@@ -29,32 +29,38 @@
<row>
<cell fill="both" weightx="1" weighty="1" rows='4'>
<JScrollPane>
- <org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ <org.jdesktop.swingx.JXTreeTable id="accountsTreeTable"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}"
highlighters='{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}' />
- <javax.swing.ListSelectionModel javaBean="getAccountsTreeTable().getSelectionModel()"
- onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/>
+ <javax.swing.ListSelectionModel
+ javaBean="getAccountsTreeTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
<cell fill="horizontal">
- <JButton id="addButton" text="lima.common.add" onActionPerformed="getHandler().addAccount()"/>
+ <JButton id="addButton" text="lima.common.add"
+ onActionPerformed="getHandler().addAccount()"/>
</cell>
</row>
<row>
<cell fill="horizontal">
- <JButton id="addSubLedger" text="lima.common.addSubLedger" onActionPerformed="getHandler().addSubLedger()"
+ <JButton id="addSubLedger" text="lima.common.addSubLedger"
+ onActionPerformed="getHandler().addSubLedger()"
enabled="{isSelectedRow()}"/>
</cell>
</row>
<row>
<cell fill="horizontal">
- <JButton id="updateButton" text="lima.common.update" onActionPerformed="getHandler().updateAccount()"
+ <JButton id="updateButton" text="lima.common.update"
+ onActionPerformed="getHandler().updateAccount()"
enabled="{isSelectedRow()}"/>
</cell>
</row>
<row>
<cell fill="horizontal">
- <JButton id="removeButton" text="lima.common.remove" onActionPerformed="getHandler().removeAccount()"
+ <JButton id="removeButton" text="lima.common.remove"
+ onActionPerformed="getHandler().removeAccount()"
enabled="{isSelectedRow()}"/>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869)
@@ -26,15 +26,24 @@
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.entity.Account;
import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.entity.Identity;
+import org.chorem.lima.entity.IdentityDAO;
+import org.chorem.lima.entity.IdentityImpl;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.ui.account.model.AccountTreeTableModel;
import org.chorem.lima.ui.account.AccountForm;
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.account.SubLedgerForm;
import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTreeTable;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
/**
* Handler associated with account view.
@@ -51,9 +60,19 @@
private static final Log log = LogFactory.getLog(AccountViewHandler.class);
protected AccountView view;
+
+ private TopiaContext rootContext;
protected AccountViewHandler(AccountView view) {
this.view = view;
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
}
/**
@@ -62,7 +81,8 @@
public void addAccount() {
JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
- AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+ AccountTreeTableModel accountsTreeTableModel =
+ (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
Account newAccount = new AccountImpl();
AccountForm accountForm = new AccountForm(view);
@@ -104,15 +124,19 @@
public void addSubLedger(){
JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
- AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+ AccountTreeTableModel accountsTreeTableModel =
+ (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
Account newAccount = new AccountImpl();
SubLedgerForm subledgerForm = new SubLedgerForm(view);
subledgerForm.setAccount(newAccount);
+ Identity newIdentity = new IdentityImpl();
+ subledgerForm.setIdentity(newIdentity);
// jaxx constructor don't call super() ?
subledgerForm.setLocationRelativeTo(view);
subledgerForm.setVisible(true);
newAccount=subledgerForm.getAccount();
+ newIdentity=subledgerForm.getIdentity();
// null == cancel action
if (newAccount != null) {
@@ -122,7 +146,7 @@
treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
// add it
try {
- accountsTreeTableModel.addSubLedger(treePath, newAccount);
+ accountsTreeTableModel.addSubLedger(treePath, newAccount, newIdentity);
} catch (LimaBusinessException ex) {
if (log.isErrorEnabled()) {
log.error("Can't add subledger", ex);
@@ -141,44 +165,82 @@
/**
* Open account form with selected account.
+ * Verifiy if it's an account or a subledger
*/
public void updateAccount() {
JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
- AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+ AccountTreeTableModel accountsTreeTableModel =
+ (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
// get selected account
int selectedRow = view.getAccountsTreeTable().getSelectedRow();
TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // not null
- Account selectedAccount = (Account)treePath.getLastPathComponent();
+ Account selectedObject = (Account)treePath.getLastPathComponent();
+ //TODO update Account or update SubLedger
+ if (selectedObject != null) {
+ // get current selection path
+ if ( selectedRow != -1) {
+ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ } else {
+ treePath = new TreePath(accountsTreeTableModel.getRoot());
+ }
+ //test if selectedrow is account or ledger
+ Identity existIdentity = selectedObject.getIdentity();
+ // if is an account or subaccount
+ if (existIdentity == null) {
+ AccountForm accountForm = new AccountForm(view);
+ accountForm.setAccount(selectedObject);
+ // jaxx constructor don't call super() ?
+ accountForm.setLocationRelativeTo(view);
+ accountForm.setVisible(true);
+ // null == cancel action
+ selectedObject = accountForm.getAccount();
+ if (selectedObject != null){
+ // update it
+ try {
+
+ accountsTreeTableModel.
+ updateAccount(treePath, selectedObject);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add update", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add update", ex);
+ }
+ }
+ }
+ // else is a subledger
+ else{
+ SubLedgerForm subLedgerForm = new SubLedgerForm(view);
+ subLedgerForm.setAccount(selectedObject);
+ //log.debug("nom :"+selectedObject.getIdentity().getName());
+ Identity identity=selectedObject.getIdentity();
+ subLedgerForm.setIdentity(identity);
+ // jaxx constructor don't call super() ?
+ subLedgerForm.setLocationRelativeTo(view);
+ subLedgerForm.setVisible(true);
+ // null == cancel action
+ selectedObject = subLedgerForm.getAccount();
+ if (selectedObject != null){
+ // update it
+ try {
+ accountsTreeTableModel.
+ updateIdentity(identity);
+ accountsTreeTableModel.
+ updateAccount(treePath, selectedObject);
+
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add update", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add update", ex);
+ }
+ }
+ }
+ }
+
+ }
- AccountForm accountForm = new AccountForm(view);
- accountForm.setAccount(selectedAccount);
- // jaxx constructor don't call super() ?
- accountForm.setLocationRelativeTo(view);
- accountForm.setVisible(true);
-
- // null == cancel action
- selectedAccount = accountForm.getAccount();
- if (selectedAccount != null) {
- // get current selection path
- if ( selectedRow != -1) {
- treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
- } else {
- treePath = new TreePath(accountsTreeTableModel.getRoot());
- }
-
- // update it
- try {
- accountsTreeTableModel.updateAccount(treePath, selectedAccount);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add account", ex);
- }
- ErrorHelper.showErrorDialog("Can't add account", ex);
- }
- }
- };
-
/**
* Ask for user to remove for selected account, and remove it if confirmed.
*/
@@ -186,7 +248,8 @@
// maybe this code can be factorised
JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
- AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+ AccountTreeTableModel accountsTreeTableModel =
+ (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
// Any row selected
int selectedRow = view.getAccountsTreeTable().getSelectedRow();
@@ -198,28 +261,25 @@
JOptionPane.QUESTION_MESSAGE);
if (n == JOptionPane.YES_OPTION) {
// update view of treetable
- TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ TreePath treePath = view.getAccountsTreeTable().
+ getPathForRow(selectedRow);
Account account = (Account) treePath.getLastPathComponent();
- try {
- int result = accountsTreeTableModel.removeAccount(treePath, account);
- if (result ==-1){
- int n2 = JOptionPane.showConfirmDialog(view,
- _("lima.question.confirmremove.account"),
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- if (n2 == JOptionPane.YES_OPTION) {
- // update view of treetable
- try {
- accountsTreeTableModel.removeAccountwithSubAccounts(treePath, account);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't delete account", ex);
- }
- ErrorHelper.showErrorDialog("Can't delete account", ex);
- }
- }
- }
+ try{
+ try {
+ accountsTreeTableModel.removeAccount(treePath, account);
+ }
+ catch(LimaBusinessException ex){
+ int n2 = JOptionPane.showConfirmDialog(view,
+ _("lima.question.confirmremove.account"),
+ _("lima.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ if (n2 == JOptionPane.YES_OPTION) {
+ // update view of treetable
+ accountsTreeTableModel.
+ removeAccountwithSubAccounts(treePath, account);
+ }
+ }
} catch (LimaException ex) {
if (log.isErrorEnabled()) {
log.error("Can't delete account", ex);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-20 16:33:17 UTC (rev 2869)
@@ -17,8 +17,8 @@
<JDialog defaultCloseOperation="dispose_on_close" modal="true">
+ <org.chorem.lima.entity.Account id="account" javaBean='null'/>
<org.chorem.lima.entity.Identity id="identity" javaBean='null'/>
- <org.chorem.lima.entity.Account id="account" javaBean='null'/>
<Boolean id="addState" javaBean='true'/>
@@ -26,7 +26,6 @@
<![CDATA[
protected void performCancel() {
setAccount(null);
- setIdentity(null);
dispose();
}
]]>
@@ -38,7 +37,8 @@
<JLabel text="lima.subledger.code"/>
</cell>
<cell fill="horizontal">
- <JTextField id="numberTextField" editable='{isAddState()}' text="{getAccount().getAccountNumber()}"/>
+ <JTextField id="numberTextField" editable='{isAddState()}'
+ text="{getAccount().getAccountNumber()}"/>
<javax.swing.text.Document javaBean="getNumberTextField().getDocument()"
onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())'
onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' />
@@ -51,8 +51,8 @@
<cell fill="horizontal">
<JTextField id="descriptionTextField" text="{getAccount().getLabel()}"/>
<javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()"
- onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())'
- onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' />
+ onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())'
+ onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' />
</cell>
</row>
<row>
@@ -60,9 +60,10 @@
<JLabel text="lima.account.type"/>
</cell>
<cell fill="horizontal">
- <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.account.model.AccountTypeListModel()}'
- selectedItem="{getAccount().getType()}"
- onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
+ <JComboBox id="typeComboBox"
+ model='{new org.chorem.lima.ui.account.model.AccountTypeListModel()}'
+ selectedItem="{getAccount().getType()}"
+ onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
</cell>
</row>
<!-- NAME CONTACT-->
@@ -73,8 +74,8 @@
<cell fill="horizontal">
<JTextField id="nameIdentityTextField" text="{getIdentity().getName()}"/>
<javax.swing.text.Document javaBean="getNameIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setName(getNameIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setName(getNameIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setName(getNameIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setName(getNameIdentityTextField().getText())' />
</cell>
<cell fill="horizontal">
<JLabel text="lima.identity.contact"/>
@@ -82,8 +83,8 @@
<cell fill="horizontal">
<JTextField id="contactIdentityTextField" text="{getIdentity().getContact()}"/>
<javax.swing.text.Document javaBean="getContactIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setContact(getContactIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setContact(getContactIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setContact(getContactIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setContact(getContactIdentityTextField().getText())' />
</cell>
</row>
<!-- SIRET-->
@@ -94,8 +95,8 @@
<cell fill="horizontal">
<JTextField id="SiretIdentityTextField" text="{getIdentity().getSiret()}"/>
<javax.swing.text.Document javaBean="getSiretIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setSiret(getZIPCodeIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setSiret(getZIPCodeIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setSiret(getSiretIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setSiret(getSiretIdentityTextField().getText())' />
</cell>
</row>
<!-- ADDRESS -->
@@ -106,8 +107,8 @@
<cell fill="horizontal">
<JTextField id="addressIdentityTextField" text="{getIdentity().getAddress()}"/>
<javax.swing.text.Document javaBean="getAddressIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())' />
</cell>
</row>
<!-- ZIPCODE CITY-->
@@ -116,10 +117,10 @@
<JLabel text="lima.identity.zipcode"/>
</cell>
<cell fill="horizontal">
- <JTextField id="ZIPCodeIdentityTextField" text="{getIdentity().getZIPCode()}"/>
- <javax.swing.text.Document javaBean="getZIPCodeIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setZIPCode(getZIPCodeIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setZIPCode(getZIPCodeIdentityTextField().getText())' />
+ <JTextField id="ZipCodeIdentityTextField" text="{getIdentity().getZipCode()}"/>
+ <javax.swing.text.Document javaBean="getZipCodeIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setZipCode(getZipCodeIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setZipCode(getZipCodeIdentityTextField().getText())' />
</cell>
<cell fill="horizontal">
<JLabel text="lima.identity.city"/>
@@ -127,8 +128,8 @@
<cell fill="horizontal">
<JTextField id="cityIdentityTextField" text="{getIdentity().getCity()}"/>
<javax.swing.text.Document javaBean="getCityIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setCity(getCityIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setCity(getCityIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setCity(getCityIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setCity(getCityIdentityTextField().getText())' />
</cell>
</row>
<!-- COUNTRY-->
@@ -139,8 +140,8 @@
<cell fill="horizontal">
<JTextField id="CountryIdentityTextField" text="{getIdentity().getCountry()}"/>
<javax.swing.text.Document javaBean="getCountryIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setCountry(getZIPCodeIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setCountry(getZIPCodeIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setCountry(getCountryIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setCountry(getCountryIdentityTextField().getText())' />
</cell>
</row>
<!-- PHONE FAX-->
@@ -151,8 +152,8 @@
<cell fill="horizontal">
<JTextField id="phoneIdentityTextField" text="{getIdentity().getPhone()}"/>
<javax.swing.text.Document javaBean="getPhoneIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())' />
</cell>
<cell fill="horizontal">
<JLabel text="lima.identity.fax"/>
@@ -160,8 +161,8 @@
<cell fill="horizontal">
<JTextField id="faxIdentityTextField" text="{getIdentity().getFax()}"/>
<javax.swing.text.Document javaBean="getFaxIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())' />
</cell>
</row>
<!-- fin fiche identite EMAIL WEBSITE-->
@@ -172,8 +173,8 @@
<cell fill="horizontal">
<JTextField id="emailIdentityTextField" text="{getIdentity().getEmail()}"/>
<javax.swing.text.Document javaBean="getEmailIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())' />
</cell>
<cell fill="horizontal">
<JLabel text="lima.identity.website"/>
@@ -181,8 +182,8 @@
<cell fill="horizontal">
<JTextField id="websiteIdentityTextField" text="{getIdentity().getWebsite()}"/>
<javax.swing.text.Document javaBean="getWebsiteIdentityTextField().getDocument()"
- onInsertUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())' />
+ onInsertUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())' />
</cell>
</row>
<!-- fin fiche identite -->
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-20 16:33:17 UTC (rev 2869)
@@ -24,11 +24,16 @@
import javax.swing.tree.TreePath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.entity.Identity;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.account.AccountViewHandler;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
/**
@@ -42,7 +47,10 @@
* By : $Author$
*/
public class AccountTreeTableModel extends AbstractTreeTableModel {
-
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountViewHandler.class);
+
/** Account service. */
protected final AccountService accountService;
@@ -111,6 +119,7 @@
@Override
public Object getChild(Object parent, int index) {
+ log.debug("GETCHILD_BEGIN");
Object result = null;
if (parent == getRoot()) {
try {
@@ -135,6 +144,7 @@
e.printStackTrace();
}
}
+ log.debug("GETCHILD_END");
return result;
}
@@ -221,13 +231,13 @@
* @param account
* @throws LimaException
*/
- public void addSubLedger(TreePath path, Account account) throws LimaException {
+ public void addSubLedger(TreePath path, Account account, Identity identity) throws LimaException {
// Calling account service
Account parentAccount = (Account)path.getLastPathComponent();
if (parentAccount == getRoot()) {
parentAccount = null;
}
- accountService.createSubLedger(parentAccount, account);
+ accountService.createSubLedger(parentAccount, account, identity);
int index = getIndexOfChild(path.getLastPathComponent(), account);
modelSupport.fireChildAdded(path, index, account);
}
@@ -247,21 +257,30 @@
}
/**
+ * Update identity.
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void updateIdentity(Identity identity) throws LimaException {
+ // Calling account service
+ accountService.updateIdentity(identity);
+ }
+
+ /**
* Remove account.
*
* @param path
* @param account
* @throws LimaException
*/
- public int removeAccount(TreePath path, Account account) throws LimaException {
+ public void removeAccount(TreePath path, Account account) throws LimaException {
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), account);
- int result = accountService.removeAccount(account);
- if (result==0){
+ accountService.removeAccount(account);
modelSupport.fireChildRemoved(path.getParentPath(), index, account);
- }
- return result;
}
public void removeAccountwithSubAccounts(TreePath path, Account account) throws LimaException {
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-20 14:05:38 UTC (rev 2868)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869)
@@ -62,7 +62,7 @@
//add a new transaction
protected void addFinancialTransaction() {
- FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable();
FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
try {
@@ -79,7 +79,7 @@
//add a new entry to the selected transaction
public void addEmptyEntry(){
- FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable();
FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
int indexSelectedRow = table.getSelectedRow();
@@ -102,7 +102,7 @@
*/
public void deleteSelectedRow(){
- FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable();
FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
int indexSelectedRow = table.getSelectedRow();
1
0