Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
April 2010
- 5 participants
- 60 discussions
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
Author: tchemit
Date: 2010-04-20 16:05:38 +0200 (Tue, 20 Apr 2010)
New Revision: 2868
Log:
Utilisation de mavenpom4redmine 2.1.2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-19 16:51:59 UTC (rev 2867)
+++ trunk/pom.xml 2010-04-20 14:05:38 UTC (rev 2868)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.0.7</version>
+ <version>2.1.2</version>
</parent>
<groupId>org.chorem</groupId>
1
0
r2867 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 19 Apr '10
by jpepin@users.chorem.org 19 Apr '10
19 Apr '10
Author: jpepin
Date: 2010-04-19 18:51:59 +0200 (Mon, 19 Apr 2010)
New Revision: 2867
Log:
Ajout formulaire cr?\195?\169ation compte de tiers
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
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/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 16:51:59 UTC (rev 2867)
@@ -25,8 +25,6 @@
import java.util.List;
import java.util.ListIterator;
-import javassist.bytecode.Descriptor.Iterator;
-
import javax.ejb.Stateless;
import org.apache.commons.collections.CollectionUtils;
@@ -126,20 +124,9 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- // test si le numero de compte existe deja
-
-
-
-
+ // test si le numero de compte existe deja
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
-
-
-
- /* Suggestion Florian qui marche pas
- * List<Account> existingAccounts =
- accountDAO.findAllByAccountNumber(account.getAccountNumber());
- if (CollectionUtils.isNotEmpty(existingAccounts))*/
Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
if (existAccount != null) {
@@ -186,9 +173,8 @@
// test si le numero de compte existe deja
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> existingAccounts =
- accountDAO.findAllByAccountNumber(account.getAccountNumber());
- if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
+ if (existAccount != null) {
throw new LimaBusinessException(_(
"An account already exists with this number : %s",
account.getAccountNumber()));
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
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-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-19 16:51:59 UTC (rev 2867)
@@ -17,13 +17,16 @@
<JDialog defaultCloseOperation="dispose_on_close" modal="true">
+ <org.chorem.lima.entity.Identity id="identity" javaBean='null'/>
<org.chorem.lima.entity.Account id="account" javaBean='null'/>
+
<Boolean id="addState" javaBean='true'/>
<script>
<![CDATA[
protected void performCancel() {
setAccount(null);
+ setIdentity(null);
dispose();
}
]]>
@@ -61,8 +64,129 @@
selectedItem="{getAccount().getType()}"
onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
</cell>
+ </row>
+ <!-- NAME CONTACT-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.name"/>
+ </cell>
+ <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())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.contact"/>
+ </cell>
+ <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())' />
+ </cell>
</row>
+ <!-- SIRET-->
<row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.siret"/>
+ </cell>
+ <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())' />
+ </cell>
+ </row>
+ <!-- ADDRESS -->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.address"/>
+ </cell>
+ <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())' />
+ </cell>
+ </row>
+ <!-- ZIPCODE CITY-->
+ <row>
+ <cell fill="horizontal">
+ <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())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.city"/>
+ </cell>
+ <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())' />
+ </cell>
+ </row>
+ <!-- COUNTRY-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.country"/>
+ </cell>
+ <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())' />
+ </cell>
+ </row>
+ <!-- PHONE FAX-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.phone"/>
+ </cell>
+ <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())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.fax"/>
+ </cell>
+ <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())' />
+ </cell>
+ </row>
+ <!-- fin fiche identite EMAIL WEBSITE-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.email"/>
+ </cell>
+ <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())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.website"/>
+ </cell>
+ <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())' />
+ </cell>
+ </row>
+ <!-- fin fiche identite -->
+ <row>
<cell fill="none">
<JButton text="lima.common.ok" onActionPerformed="dispose()"/>
</cell>
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-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-19 16:51:59 UTC (rev 2867)
@@ -143,6 +143,18 @@
lima.fiscalyear.listclosed=
lima.grand.livre=General Ledger
lima.home=Home - TODO
+lima.identity.address=
+lima.identity.adress=
+lima.identity.city=
+lima.identity.contact=
+lima.identity.country=
+lima.identity.email=
+lima.identity.fax=
+lima.identity.name=
+lima.identity.phone=
+lima.identity.siret=
+lima.identity.website=
+lima.identity.zipcode=
lima.import=Import
lima.import.account=Import PCG
lima.import.all=Import all datas
@@ -233,9 +245,9 @@
lima.progressBar.load.etape4=Loading periods
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.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.confirmremove.account=This account have subaccounts, do you want remove this account ?
lima.question.remove.entry=Do you want to remove this entry ?
lima.question.remove.journal=Do you want to remove this journal ?
lima.question.remove.transaction=Do you want to remove this transaction ?
@@ -262,6 +274,8 @@
lima.status.tr.wip=Work in progress
lima.subledger.accountnumber=
lima.subledger.code=Code
+lima.subledger.label=
+lima.subledger.type=
lima.success=Success
lima.tab.account=Account
lima.tab.balance=Balance
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-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-19 16:51:59 UTC (rev 2867)
@@ -142,6 +142,17 @@
lima.fiscalyear.listclosed=Voir toutes les cl\u00F4tures
lima.grand.livre=Grand-Livre
lima.home=Page d'accueil - TODO
+lima.identity.address=Adresse
+lima.identity.city=Ville
+lima.identity.contact=Contact
+lima.identity.country=Pays
+lima.identity.email=eMail
+lima.identity.fax=Fax
+lima.identity.name=Nom
+lima.identity.phone=Tel
+lima.identity.siret=Siret
+lima.identity.website=Site Web
+lima.identity.zipcode=Code Postal
lima.import=Import
lima.import.account=Importer le PCG
lima.import.all=Importer une nouvelle base (XML)
@@ -226,9 +237,9 @@
lima.progressBar.load.etape4=Chargement des p\u00E9riodes
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.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.confirmremove.account=Ce compte poss\u00E8de des sous comptes, voulez-vous supprimer ce compte ?
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
@@ -252,7 +263,10 @@
lima.status.tr.balanced=Equilibr\u00E9e
lima.status.tr.finalized=Valid\u00E9e
lima.status.tr.wip=En cours
+lima.subledger.accountnumber=
lima.subledger.code=Code
+lima.subledger.label=
+lima.subledger.type=
lima.success=Succ\u00E8s
lima.tab.account=Plan Comptable
lima.tab.balance=Balance
1
0
r2866 - 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/account lima-swing/src/main/java/org/chorem/lima/ui/account/model lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 19 Apr '10
by jpepin@users.chorem.org 19 Apr '10
19 Apr '10
Author: jpepin
Date: 2010-04-19 17:15:40 +0200 (Mon, 19 Apr 2010)
New Revision: 2866
Log:
Ajout m?\195?\169thode de suppression r?\195?\169cursive des sous-comptes contenus dans un compte
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-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/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-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -50,8 +50,10 @@
void updateAccount(Account account) throws LimaException;
- void removeAccount(Account account) throws LimaException;
+ int 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-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -23,7 +23,10 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.ListIterator;
+import javassist.bytecode.Descriptor.Iterator;
+
import javax.ejb.Stateless;
import org.apache.commons.collections.CollectionUtils;
@@ -124,12 +127,25 @@
transaction = rootContext.beginTransaction();
// test si le numero de compte existe deja
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> existingAccounts =
+
+
+
+
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+
+
+
+ /* Suggestion Florian qui marche pas
+ * List<Account> existingAccounts =
accountDAO.findAllByAccountNumber(account.getAccountNumber());
- if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ if (CollectionUtils.isNotEmpty(existingAccounts))*/
+
+ Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
+ if (existAccount != null) {
throw new LimaBusinessException(_(
- "An account already exists with this number : %s", account.getAccountNumber()));
+ "An account already exists with this number : %s",
+ account.getAccountNumber()));
}
accountDAO.create(account);
@@ -179,8 +195,9 @@
}
//test si le parent ne contient pas de subaccount
- List<Account> existingSubAccounts = masterAccount.getSubAccounts();
- if (CollectionUtils.isNotEmpty(existingSubAccounts)){
+ if (masterAccount.getSubAccounts().size() > 0)
+ /*List<Account> existingSubAccounts = masterAccount.getSubAccounts();
+ if (CollectionUtils.isNotEmpty(existingSubAccounts))*/{
throw new LimaBusinessException(
"Subledger must create on a account whithout subaccount : ");
@@ -479,7 +496,8 @@
try {
transaction = rootContext.beginTransaction();
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
List<Account> accounts = accountDAO.findAll();
accountsList.addAll(accounts);
}
@@ -535,7 +553,8 @@
try {
transaction = rootContext.beginTransaction();
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
TopiaQuery query = accountDAO.createQuery();
@@ -544,7 +563,8 @@
query.add("generalLedger", TopiaQuery.Op.EQ, null);
}
else {
- query.add("masterAccount = :value or generalLedger = :value").addParam("value", masterAccount);
+ query.add("masterAccount = :value or generalLedger = :value")
+ .addParam("value", masterAccount);
}
// TODO Erreur Lazy TopiaQuery
/*if (log.isDebugEnabled()) {
@@ -587,11 +607,12 @@
* ATTENTION : si il existe une entrée comptable associée au numéro de
* compte, il est alors impossible de supprimer le compte.
*
+ * Si un compte contient des sous comptes la fonction retourne -1
* @param account
* @throws LimaException
*/
@Override
- public void removeAccount(Account account) throws LimaException {
+ public int removeAccount(Account account) throws LimaException {
/*String result = ServiceHelper.RESPOND_ERROR;
Account deleteAccount = searchAccount(accountNumber);
// Si le compte n'existe pas
@@ -667,12 +688,12 @@
}
}
return result;*/
-
+ int result = 0;
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- // Vérifie si une entrée ne possède pas ce numéro de compte.
+ //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);
@@ -681,12 +702,19 @@
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;
+ }
+ else {
// remove account
- // FIXME !IMPORTANT! check that subaccounts are also deleted
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
accountDAO.delete(account);
// commit
transaction.commitTransaction();
+ }
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -694,7 +722,38 @@
finally {
doFinally(transaction, log);
}
+ return result;
}
+
+ /**
+ * Delete an account and all his subaccounts
+ * @param account
+ * @throws LimaException
+ */
+ public void removeAccountwithSubAccounts(Account account) throws LimaException{
+ TopiaContext transaction = null;
+ try{
+ transaction = rootContext.beginTransaction();
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> existingSubAccounts = getChildrenAccounts(account);
+ ListIterator itr = existingSubAccounts.listIterator();
+ while(itr.hasNext()){
+ Account subaccount = (Account) itr.next();
+ removeAccountwithSubAccounts(subaccount);
+ }
+ // remove account
+ accountDAO.delete(account);
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+ }
/*
* Permet d'effacer un compte à partir d'un compte DTO. Il appelle la
@@ -767,38 +826,18 @@
transaction = rootContext.beginTransaction();
// update account
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
accountDAO.update(account);
// commit
transaction.commitTransaction();
}
catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
if (log.isErrorEnabled()) {
log.error("Error during create account", ex);
}
throw new LimaException("Can't update account", ex);
}
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't update account", ex);
- }
- }
- }
}
@Override
@@ -809,36 +848,16 @@
transaction = rootContext.beginTransaction();
// get account from his number
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
account = accountDAO.findByAccountNumber(numAccount);
}
catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
if (log.isErrorEnabled()) {
log.error("Error during get account from his number", ex);
}
throw new LimaException("Can't get account from his number", ex);
}
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't get account from his number", ex);
- }
- }
- }
return account;
}
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-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -201,7 +201,25 @@
TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
Account account = (Account) treePath.getLastPathComponent();
try {
- accountsTreeTableModel.removeAccount(treePath, account);
+ 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);
+ }
+ }
+ }
} 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/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -253,11 +253,21 @@
* @param account
* @throws LimaException
*/
- public void removeAccount(TreePath path, Account account) throws LimaException {
+ public int removeAccount(TreePath path, Account account) throws LimaException {
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), account);
- accountService.removeAccount(account);
+ int result = accountService.removeAccount(account);
+ if (result==0){
+ modelSupport.fireChildRemoved(path.getParentPath(), index, account);
+ }
+ return result;
+ }
+
+ public void removeAccountwithSubAccounts(TreePath path, Account account) throws LimaException {
+ int index = getIndexOfChild(
+ path.getParentPath().getLastPathComponent(), account);
+ accountService.removeAccountwithSubAccounts(account);
modelSupport.fireChildRemoved(path.getParentPath(), index, account);
}
}
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-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-19 15:15:40 UTC (rev 2866)
@@ -235,6 +235,7 @@
lima.question=Question
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.confirmremove.account=This account have subaccounts, do you want remove this account ?
lima.question.remove.entry=Do you want to remove this entry ?
lima.question.remove.journal=Do you want to remove this journal ?
lima.question.remove.transaction=Do you want to remove this transaction ?
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-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-19 15:15:40 UTC (rev 2866)
@@ -228,6 +228,7 @@
lima.question=Question
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.confirmremove.account=Ce compte poss\u00E8de des sous comptes, voulez-vous supprimer ce compte ?
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
1
0
Author: jpepin
Date: 2010-04-19 15:19:30 +0200 (Mon, 19 Apr 2010)
New Revision: 2865
Log:
Ajout creation/affichage de comptes tiers
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.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-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
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/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -46,9 +46,13 @@
*/
void createAccount(Account masterAccount, Account account) throws LimaException;
+ void createSubLedger(Account masterAccount, Account account) throws LimaException;
+
void updateAccount(Account account) throws LimaException;
void removeAccount(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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -125,7 +125,8 @@
// test si le numero de compte existe deja
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> existingAccounts = accountDAO.findAllByAccountNumber(account.getAccountNumber());
+ List<Account> existingAccounts =
+ accountDAO.findAllByAccountNumber(account.getAccountNumber());
if (CollectionUtils.isNotEmpty(existingAccounts)) {
throw new LimaBusinessException(_(
"An account already exists with this number : %s", account.getAccountNumber()));
@@ -150,6 +151,61 @@
}
}
+
+ @Override
+ public void createSubLedger(Account masterAccount, Account account)
+ throws LimaException {
+ // TODO Auto-generated method stub
+ // test la validite du numero de compte
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ throw new LimaBusinessException("Invalid AccountNumber : "
+ + account.getAccountNumber());
+ }
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si le numero de compte existe deja
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> existingAccounts =
+ accountDAO.findAllByAccountNumber(account.getAccountNumber());
+ if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ throw new LimaBusinessException(_(
+ "An account already exists with this number : %s",
+ account.getAccountNumber()));
+ }
+
+ //test si le parent ne contient pas de subaccount
+ List<Account> existingSubAccounts = masterAccount.getSubAccounts();
+ if (CollectionUtils.isNotEmpty(existingSubAccounts)){
+ throw new LimaBusinessException(
+ "Subledger must create on a account whithout subaccount : ");
+
+ }
+
+ accountDAO.create(account);
+
+ // test si le compte parent existe;
+ if (masterAccount != null) {
+ masterAccount.addSubLedgers(account);
+ accountDAO.update(masterAccount);
+ }
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ }
+
/*public String createAccount (String accountNumber, String label,Account masterAccount,String type)
{
String result = ServiceHelper.RESPOND_ERROR;
@@ -482,14 +538,19 @@
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
TopiaQuery query = accountDAO.createQuery();
- // masterAccount is not visible, but column "masterAccount"
- // exist in Account table
- query.add("masterAccount", masterAccount);
- if (log.isDebugEnabled()) {
+ if (masterAccount == null){
+ query.add("masterAccount", masterAccount);
+ query.add("generalLedger", TopiaQuery.Op.EQ, null);
+ }
+ else {
+ query.add("masterAccount = :value or generalLedger = :value").addParam("value", masterAccount);
+ }
+ // TODO Erreur Lazy TopiaQuery
+ /*if (log.isDebugEnabled()) {
log.debug("getChildrenAccounts query : " + query);
- }
-
+ }*/
+
accountsList.addAll(accountDAO.findAllByQuery(query));
}
catch (TopiaException ex) {
@@ -740,6 +801,47 @@
}
}
+ @Override
+ public Account getAccountNumber(String numAccount) throws LimaException {
+ Account account = null;
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // get account from his number
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ account = accountDAO.findByAccountNumber(numAccount);
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during get account from his number", ex);
+ }
+ throw new LimaException("Can't get account from his number", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't get account from his number", ex);
+ }
+ }
+ }
+ return account;
+ }
+
/*
* 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-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-19 13:19:30 UTC (rev 2865)
@@ -1,6 +1,7 @@
# Precise l'entete de l'ensemble des fichiers generes
model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */
-#org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
+org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
+org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.entry.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/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -336,6 +336,7 @@
AccountView accountView = new AccountView(mainView);
mainView.showTab(_("lima.tab.account"), accountView);
}
+
public void showTransactionView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-19 13:19:30 UTC (rev 2865)
@@ -27,7 +27,7 @@
</script>
<row>
- <cell fill="both" weightx="1" weighty="1" rows='3'>
+ <cell fill="both" weightx="1" weighty="1" rows='4'>
<JScrollPane>
<org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}"
@@ -40,6 +40,12 @@
<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()"
+ enabled="{isSelectedRow()}"/>
+ </cell>
+ </row>
<row>
<cell fill="horizontal">
<JButton id="updateButton" text="lima.common.update" onActionPerformed="getHandler().updateAccount()"
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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -32,6 +32,7 @@
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;
@@ -100,7 +101,44 @@
}
}
};
+
+ public void addSubLedger(){
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+ Account newAccount = new AccountImpl();
+ SubLedgerForm subledgerForm = new SubLedgerForm(view);
+ subledgerForm.setAccount(newAccount);
+ // jaxx constructor don't call super() ?
+ subledgerForm.setLocationRelativeTo(view);
+ subledgerForm.setVisible(true);
+ newAccount=subledgerForm.getAccount();
+
+ // null == cancel action
+ if (newAccount != null) {
+ // get current selection path
+ TreePath treePath = null;
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ // add it
+ try {
+ accountsTreeTableModel.addSubLedger(treePath, newAccount);
+ } catch (LimaBusinessException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add subledger", ex);
+ }
+ ErrorHelper.showErrorDialog(ex.getMessage(), ex);
+ }
+
+ catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add subledger", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add subledger", ex);
+ }
+ }
+ }
+
/**
* Open account form with selected account.
*/
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-19 13:19:30 UTC (rev 2865)
@@ -0,0 +1,74 @@
+<!-- ##% 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 defaultCloseOperation="dispose_on_close" modal="true">
+
+ <org.chorem.lima.entity.Account id="account" javaBean='null'/>
+ <Boolean id="addState" javaBean='true'/>
+
+ <script>
+ <![CDATA[
+ protected void performCancel() {
+ setAccount(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.subledger.code"/>
+ </cell>
+ <cell fill="horizontal">
+ <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())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.label"/>
+ </cell>
+ <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())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <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())"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="none">
+ <JButton text="lima.common.ok" onActionPerformed="dispose()"/>
+ </cell>
+ <cell fill="none">
+ <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -97,7 +97,8 @@
else {
Account parentAccount = (Account) node;
try {
- List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
result = subaccounts.size();
} catch (LimaException e) {
//FIXME
@@ -113,7 +114,8 @@
Object result = null;
if (parent == getRoot()) {
try {
- List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ List<Account> allAccounts =
+ accountService.getChildrenAccounts(null);
result = allAccounts.get(index);
} catch (LimaException e) {
//FIXME
@@ -125,7 +127,8 @@
// FIXME sub account is a collection ?
try {
- List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
result = subaccounts.get(index);
} catch (LimaException e) {
//FIXME
@@ -143,7 +146,8 @@
if (parent == getRoot()) {
try {
- List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ List<Account> allAccounts =
+ accountService.getChildrenAccounts(null);
result = allAccounts.indexOf(child);
} catch (LimaException e) {
//FIXME
@@ -153,7 +157,8 @@
else {
// FIXME sub account is a collection ?
try {
- List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
result = subaccounts.indexOf(childAccount);
} catch (LimaException e) {
//FIXME
@@ -210,6 +215,24 @@
}
/**
+ * Add account (path can be null).
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void addSubLedger(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ Account parentAccount = (Account)path.getLastPathComponent();
+ if (parentAccount == getRoot()) {
+ parentAccount = null;
+ }
+ accountService.createSubLedger(parentAccount, account);
+ int index = getIndexOfChild(path.getLastPathComponent(), account);
+ modelSupport.fireChildAdded(path, index, account);
+ }
+
+ /**
* Update account.
*
* @param path
@@ -232,7 +255,8 @@
*/
public void removeAccount(TreePath path, Account account) throws LimaException {
// Calling account service
- int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
+ int index = getIndexOfChild(
+ path.getParentPath().getLastPathComponent(), account);
accountService.removeAccount(account);
modelSupport.fireChildRemoved(path.getParentPath(), index, account);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -89,13 +89,13 @@
String res = "n/a";
switch (column) {
case 0:
- res = _("lima.entrybook.label");
+ res = _("lima.entrybook.code");
break;
case 1:
- res = _("lima.entrybook.description");
+ res = _("lima.entrybook.label");
break;
case 2:
- res = _("lima.entrybook.prefix");
+ res = _("lima.entrybook.type");
break;
}
return res;
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -0,0 +1,196 @@
+package org.chorem.lima.ui.subledger.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Entry book table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision: 2864 $
+ *
+ * Last update : $Date: 2010-04-16 12:26:55 +0200 (ven. 16 avril 2010) $
+ * By : $Author: jpepin $
+ */
+public class SubLedgerTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7578692417919755647L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(SubLedgerTableModel.class);
+
+ /** Services. */
+ protected AccountService subledgerService;
+
+ /**
+ * Constructor.
+ */
+ public SubLedgerTableModel() {
+ subledgerService = LimaServiceFactory.getInstance().getAccountService();
+ }
+
+ /*
+ * @return
+ *
+ public List<JournalDTO> getData() {
+ return data;
+ }*/
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ try {
+ result = subledgerService.getAllAccounts().size();
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 3;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = "n/a";
+ switch (column) {
+ case 0:
+ res = _("lima.subledger.accountnumber");
+ break;
+ case 1:
+ res = _("lima.subledger.label");
+ break;
+ case 2:
+ res = _("lima.subledger.type");
+ break;
+ }
+ return res;
+ }
+
+ public Account getSubLedgerAtRow(int row) throws LimaException {
+ Account subledger = null;
+ subledger = subledgerService.getAllAccounts().get(row);
+ return subledger;
+ }
+
+ /*
+ * @param row
+ * @return
+ *
+ @Override
+ public Object getRow(int row) {
+ return data.get(row);
+ }*/
+
+ @Override
+ public Object getValueAt(int row, int column) {
+
+ Object result = null;
+ try {
+ Account subledger = getSubLedgerAtRow(row);
+
+ switch (column) {
+ case 0:
+ result = subledger.getAccountNumber();
+ break;
+ case 1:
+ result = subledger.getLabel();
+ break;
+ case 2:
+ result = subledger.getType();
+ break;
+ }
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ try {
+ Account subledger = getSubLedgerAtRow(row);
+
+ switch (column) {
+ case 0:
+ subledger.setAccountNumber((String)value);
+ break;
+ case 1:
+ subledger.setLabel((String)value);
+ break;
+ case 2:
+ subledger.setType((String)value);
+ break;
+ }
+
+ // update on remote service
+ subledgerService.updateAccount(subledger);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // TODO why false ?
+ return false;
+ }
+
+ /**
+ * @param subledger
+ * @throws LimaException
+ */
+ public void addSubLedger(Account subledger, String numMasterAccount) throws LimaException {
+ /* Calling journal service */
+ Account masterAccount = subledgerService.getAccountNumber(numMasterAccount);
+ subledgerService.createAccount(masterAccount, subledger);
+ int row = subledgerService.getAllAccounts().indexOf(subledger);
+ fireTableRowsInserted(row, row);
+ }
+
+ /**
+ *
+ * @param subledger
+ * @throws LimaException
+ */
+ public void updateSubLedger(Account subledger) throws LimaException {
+ /* Calling journal service */
+ subledgerService.updateAccount(subledger);
+ int row = subledgerService.getAllAccounts().indexOf(subledger);
+ fireTableRowsUpdated(row, row);
+ }
+
+ /**
+ *
+ * @param subledger
+ * @throws LimaException
+ */
+ public void removeSubLedger(Account subledger) throws LimaException {
+ /* Calling journal service */
+ int row = subledgerService.getAllAccounts().indexOf(subledger);
+ subledgerService.removeAccount(subledger);
+ fireTableRowsDeleted(row, row);
+ }
+}
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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-19 13:19:30 UTC (rev 2865)
@@ -16,7 +16,7 @@
##% -->
<Table>
- <TransactionViewHandler id="handler" javaBean="new TransactionViewHandler(this)" />
+ <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" />
<Boolean id="selectedRow" javaBean="false" />
<script>
@@ -62,15 +62,15 @@
<row>
<cell fill="both" weightx="1" weighty="1" rows="3" columns="4">
<JScrollPane>
- <org.chorem.lima.ui.transaction.table.TransactionTableModel
- id="transactionTableModel" />
- <org.chorem.lima.ui.transaction.table.TransactionTable
- id="transactionTable" sortable="false" rowHeight="22"
- constructorParams="getHandler()" model="{getTransactionTableModel()}"
+ <org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel
+ id="financialTransactionTableModel" />
+ <org.chorem.lima.ui.transaction.table.FinancialTransactionTable
+ id="financialTransactionTable" sortable="false" rowHeight="22"
+ constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" />
- <javax.swing.ListSelectionModel javaBean="getTransactionTable().getSelectionModel()"
- onValueChanged="setSelectedRow(transactionTable.getSelectedRow() != -1)"/>
+ <javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
<cell>
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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-19 13:19:30 UTC (rev 2865)
@@ -7,8 +7,8 @@
Loading\ accounting...=
lima.about.message=
lima.account=Account
-lima.account.label=
-lima.account.number=
+lima.account.label=Label
+lima.account.number=Number
lima.account.type=Account type
lima.accountplan=Plan de comptes
lima.actif=Asset
@@ -47,9 +47,11 @@
lima.chartofaccounts=
lima.chartofaccounts.journal=
lima.chartofaccounts.management=
+lima.chartofaccounts.subledgers=
lima.closure.period.begin=Period from
lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period.
lima.common.add=
+lima.common.addSubLedger=
lima.common.all=
lima.common.cancel=
lima.common.ok=
@@ -257,6 +259,8 @@
lima.status.tr.balanced=Balanced
lima.status.tr.finalized=Finalized
lima.status.tr.wip=Work in progress
+lima.subledger.accountnumber=
+lima.subledger.code=Code
lima.success=Success
lima.tab.account=Account
lima.tab.balance=Balance
@@ -269,6 +273,7 @@
lima.tab.reports=Reports
lima.tab.result=Result
lima.tab.search.result=Search result
+lima.tab.subledgers=
lima.tab.transaction=Transaction
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=About Lima...
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-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-19 13:19:30 UTC (rev 2865)
@@ -10,6 +10,7 @@
lima.account.label=Libell\u00E9
lima.account.menu=Plan de comptes
lima.account.number=Num\u00E9ro du compte
+lima.account.parentnumber=
lima.account.type=Type de compte
lima.actif=Actif
lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
@@ -42,12 +43,14 @@
lima.bilan.total=Total
lima.block=Bloquer
lima.charge=Charge
-lima.chartofaccounts=Plan des comptes
-lima.chartofaccounts.journal=Journal
-lima.chartofaccounts.management=Gestion du plan
+lima.chartofaccounts=Structure
+lima.chartofaccounts.journal=Journaux
+lima.chartofaccounts.management=Plan comptable
+lima.chartofaccounts.subledgers=Plan tiers
lima.closure.period.begin=P\u00E9riode de
lima.closure.timespan.warning=Attention \: lorsque la p\u00E9riode est bloqu\u00E9e, il n'est plus possible d'ajouter, modifier et supprimer les entr\u00E9es comptables sur cette p\u00E9riode.
-lima.common.add=Ajout
+lima.common.add=Ajout Compte G\u00E9n\u00E9ral
+lima.common.addSubLedger=Ajouter Compte Tiers
lima.common.cancel=Annuler
lima.common.ok=OK
lima.common.print=
@@ -248,8 +251,9 @@
lima.status.tr.balanced=Equilibr\u00E9e
lima.status.tr.finalized=Valid\u00E9e
lima.status.tr.wip=En cours
+lima.subledger.code=Code
lima.success=Succ\u00E8s
-lima.tab.account=Compte
+lima.tab.account=Plan Comptable
lima.tab.balance=Balance
lima.tab.bilan=Bilan
lima.tab.home=Accueil
@@ -259,6 +263,7 @@
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...
1
0
Author: jpepin
Date: 2010-04-16 12:26:55 +0200 (Fri, 16 Apr 2010)
New Revision: 2864
Log:
Modification du mod?\195?\168le et ajout de classe. Classe Transaction chang?\195?\169 en FinancialTransaction
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.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/table/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
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/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.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/model/TransactionDataTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.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
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java (from rev 2863, trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,71 @@
+/* *##% 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 java.util.List;
+
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialTransaction;
+
+/**
+ * Transaction service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface FinancialTransactionService {
+
+ /**
+ * Find all transaction (use carefully, can return a lot of results).
+ *
+ * @return all transaction
+ * @throws LimaException
+ */
+ List<FinancialTransaction> getAllFinancialTransactions() throws LimaException;
+
+ /**
+ * Find all transaction for an entry book.
+ *
+ * @param entryBook entry book
+ * @return all transaction for entry book
+ * @throws LimaException
+ */
+ List<FinancialTransaction> getAllFinancialTransactionsForEntryBook(EntryBook entryBook) throws LimaException;
+
+ /**
+ * Find all transaction for an entry book and a financial period.
+ *
+ * @param entryBook entry book
+ * @param period financial period
+ * @return all transaction for entry book and period
+ * @throws LimaException
+ */
+ List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
+
+ void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+
+ void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+
+ void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,71 +0,0 @@
-/* *##% Lima Business
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business;
-
-import java.util.List;
-
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.Transaction;
-
-/**
- * Transaction service.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public interface TransactionService {
-
- /**
- * Find all transaction (use carefully, can return a lot of results).
- *
- * @return all transaction
- * @throws LimaException
- */
- List<Transaction> getAllTransactions() throws LimaException;
-
- /**
- * Find all transaction for an entry book.
- *
- * @param entryBook entry book
- * @return all transaction for entry book
- * @throws LimaException
- */
- List<Transaction> getAllTransactionsForEntryBook(EntryBook entryBook) throws LimaException;
-
- /**
- * Find all transaction for an entry book and a financial period.
- *
- * @param entryBook entry book
- * @param period financial period
- * @return all transaction for entry book and period
- * @throws LimaException
- */
- List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
-
- Transaction createTransaction() throws LimaException;
-
- void updateTransaction(Transaction transaction) throws LimaException;
-
- void removeTransaction(Transaction transaction) throws LimaException;
-}
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-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -35,7 +35,7 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.entity.FinancialTransaction;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -54,7 +54,7 @@
private TopiaContext rootContext;
- protected TransactionServiceImpl transactionService = new TransactionServiceImpl();
+ protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl();
//private ConvertEntryBook convertEntryBook = new ConvertEntryBook();
@@ -361,8 +361,8 @@
topiaTransaction = rootContext.beginTransaction();
// Vérifie si une transaction n'appartient pas à ce EntryBook.
- Transaction transaction = transactionService.findByEntryBook(topiaTransaction, entryBook);
- if (transaction != null) {
+ FinancialTransaction financialtransaction = financialTransactionService.findByEntryBook(topiaTransaction, entryBook);
+ if (financialtransaction != null) {
throw new LimaBusinessException("Can't delete EntryBook with transactions");
}
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-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -46,7 +46,7 @@
private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
// TODO A revoir car transaction a besoin de entry et vice versa
- private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+ private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -57,7 +57,7 @@
private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
- private TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+ private FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
/**
* Cete méthode permet d'exporter des données de Callao vers un fichier au
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-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -50,7 +50,7 @@
private TopiaContext rootContext;
- private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+ private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
public FinancialPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java (from rev 2863, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,676 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+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;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionDAO;
+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;
+
+/**
+ * Cette classe permet la création d'une transaction comptable dans l'application.
+ * Toute action sur une transaction entraîne automatiquement une création de log.
+ * Une transaction est composée d'entrées comptables.
+ * Les actions sur les transactions sont soumises au statut de celle-ci, si elle
+ * est dans une période bloquée ou non.
+ *
+ * @author Rémi Chapelet
+ */
+@Stateless
+public class FinancialTransactionServiceImpl extends AbstractLimaService implements FinancialTransactionService {
+
+ private static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ //private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
+
+ //private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
+
+ //private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
+
+ public FinancialTransactionServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer une transaction comptable. Pour ajouter une transaction,
+ * le timeSpan doit être non bloqué.
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ * @throws LimaException
+ */
+ @Override
+ public void createFinancialTransaction(FinancialTransaction financialtransaction/*Date entryDate, String voucherRef,
+ String description, TimeSpan timeSpan, Journal journal*/) throws LimaException {
+
+
+ TopiaContext topiaContext = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ topiaContext = rootContext.beginTransaction();
+
+ FinancialTransactionDAO financialtransactionDAO = LimaCallaoDAOHelper
+ .getFinancialTransactionDAO(topiaContext);
+
+ financialtransactionDAO.create(financialtransaction);
+
+ // commit
+ topiaContext.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ String isCorrectTransaction = isCorrectTransaction(timeSpan,
+ journal);
+ if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Creation de la transaction
+ Transaction newtransaction = transactionDAO.create();
+ newtransaction.setTransDate(entryDate);
+ newtransaction.setVoucherRef(voucherRef);
+ newtransaction.setDescription(description);
+ newtransaction.setTimeSpan(timeSpan);
+ newtransaction.setJournal(journal);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes de la transaction");
+ }
+
+ // Il renvoie soit l'identifiant topiaId ou SUCCESS.
+ result = newtransaction.getTopiaId();
+ //result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = isCorrectTransaction;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+ }
+
+ /*
+ * Permet de créer une transaction à partir d'une transaction DTO.
+ * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se
+ * faire. Si on souhaite, on peut créer le journal automatiquement lors de
+ * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est
+ * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période
+ * comptable existante, et par conséquent il ne faut pas le créer.
+ * @param transactionDTO
+ * @return
+ *
+ public String createTransaction(TransactionDTO transactionDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO
+ if (transactionDTO.getJournalDTO() == null
+ || transactionDTO.getTimeSpanDTO() == null) {
+ if (log.isErrorEnabled()) {
+ log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ // Recherche du journal
+ JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+ Journal journal = journalServiceImpl
+ .searchJournalWithLabel(transactionDTO.getJournalDTO()
+ .getLabel());
+ // Recherche du timeSpan
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
+ .getBeginTimeSpan());
+
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal "
+ + transactionDTO.getJournalDTO().getLabel()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan "
+ + transactionDTO.getTimeSpanDTO().toString()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ result = createTransaction(transactionDTO.getEntryDate(),
+ transactionDTO.getVoucherRef(), transactionDTO
+ .getDescription(), timeSpan, journal);
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une transaction. Cette dernière est identifiée par la
+ * clé topiaId.
+ * @param topiaId
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ *
+ public String modifyTransaction(String topiaId, Date entryDate,
+ String voucherRef, String description, TimeSpan timeSpan,
+ Journal journal) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Vérification que la transaction existe bien
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ if (transaction == null) {
+ if (log.isInfoEnabled()) {
+ log.info("La transaction " + voucherRef
+ + " n'existe pas. (identifiant " + topiaId + ")");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ } else {
+ // Vérification si la transaction possède de bons paramètres
+ String correct = isCorrectTransaction(timeSpan, journal);
+ // Si la transaction est correcte
+ if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Modification
+ transaction.setTransDate(entryDate);
+ transaction.setVoucherRef(voucherRef);
+ transaction.setDescription(description);
+ transaction.setTimeSpan(timeSpan);
+ transaction.setJournal(journal);
+ transaction.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /**
+ * Permet de retrouver la premiere transaction associée au journal.
+ *
+ * Utilisé par entrybook service pour savoir si un journal a des transactions
+ * associées et empecher la suppression.
+ *
+ * @param topiaTransaction context à utiliser
+ * @param entryBook journal
+ * @throws TopiaException
+ */
+ protected FinancialTransaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
+
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+
+ TopiaQuery query = transactionDAO.createQuery();
+ // entryBook is not visible, but column "entryBook"
+ // exist in transaction table
+ query.add("entryBook", entryBook);
+
+ FinancialTransaction result = transactionDAO.findByQuery(query);
+
+ return result;
+ }
+
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactions() throws LimaException {
+
+ // find all with null entry book filter
+
+ return getAllFinancialTransactionsForEntryBook(null);
+ }
+
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactionsForEntryBook(EntryBook entryBook) throws LimaException {
+
+ // find all with null period filter
+
+ return getAllFinancialTransactionsForEntryBookAndFinancialPeriod(entryBook, null);
+ }
+
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException {
+
+ List<FinancialTransaction> transactions = null;
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+
+ // filter with topia query
+ TopiaQuery query = transactionDAO.createQuery();
+
+ if (entryBook != null) {
+ query.add("entryBook", entryBook);
+ }
+
+ if (financialPeriod != null) {
+ query.add("financialPeriod", financialPeriod);
+ }
+
+ transactions = transactionDAO.findAllByQuery(query);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ return transactions;
+ }
+
+ /*
+ * Recherche toutes les transactions appartenant à un même journal donné
+ * en paramètre.
+ * @param journal
+ * @return
+ *
+ public List<Transaction> searchListTransactionWithJournal(Journal journal) {
+ List<Transaction> listTransaction = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ listTransaction = transactionDAO.findAllByJournal(journal);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransaction;
+ }*/
+
+ /*
+ * Permet de rechercher toutes les transactions dans la base de données,
+ * avec en retour une liste de transactions au format DTO.
+ * @return
+ *
+ public List<TransactionDTO> getAllTransactionDTO() {
+ List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ List<Transaction> listTransaction = transactionDAO.findAll();
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ for (Transaction transaction : listTransaction) {
+ TransactionDTO transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ listTransactionDTO.add(transactionDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransactionDTO;
+ }*/
+
+ /*
+ * Cette méthode permet de vérifier si une transaction possède des paramètres
+ * corrects.
+ * Un journal doit exister.
+ * Un timeSpan doit exister et être non bloqué.
+ * @param timeSpan
+ * @param journal
+ * @return
+ *
+ public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) {
+ String result = ServiceHelper.RESPOND_SUCCESS;
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ }
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ // Vérifie si le timeSpan est bloqué
+ if (timeSpan.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("Le timeSpan est bloqué ! Il est donc impossible"
+ + " d'ajouter une transaction sur cette période. ("
+ + "Période du " + timeSpan + ")");
+ }
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ }
+ return result;
+ }*/
+
+ @Override
+ public void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
+
+ // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
+
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ transactionDAO.update(financialtransaction);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ }
+
+ @Override
+ public void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
+
+ // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
+
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ transactionDAO.delete(financialtransaction);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ }
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @return
+ *
+ public String addEntry(String description, String amount, boolean debit,
+ String lettering, String detail, Transaction transaction,
+ Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(description, amount, debit,
+ lettering, detail, transaction, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * L'entrée est sous format DTO.
+ *
+ * @param entryDTO
+ * @return
+ *
+ public String addEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée comptable.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param topiaId
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String modifyEntry(String topiaId, String description,
+ String amount, boolean debit, String lettering, String detail,
+ Transaction transaction, Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(topiaId, description, amount,
+ debit, lettering, detail, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée.
+ * @param entryDTO
+ * @return
+ *
+ public String modifyEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant
+ * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée.
+ * @param topiaId
+ * @return
+ *
+ public String removeEntry(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de l'entry
+ Entry entryDelete = entryDAO.findByTopiaId(topiaId);
+ // Entry doit exister
+ if (entryDelete != null) {
+ // Prend la transaction dont appartient entry
+ Transaction transaction = entryDelete.getTransaction();
+ // Vérifie si la transaction est non bloquée.
+ if (!isTransactionBlocked(transaction)) {
+ // Création d'un log DTO
+ LogDTO logDTO = new LogDTO("", new Date(),
+ ServiceHelper.LOG_REMOVE, transaction
+ .getTransDate(), transaction
+ .getVoucherRef(), transaction
+ .getDescription(), entryDelete
+ .getDescription(), entryDelete.getAmount(),
+ entryDelete.getDebit(), entryDelete.getLettering());
+ // Appel pour supprimer l'entrée
+ result = entryServiceImpl.removeEntry(topiaId);
+ // Si la suppression s'est bien déroulée, création log
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Ajout du log
+ logServiceImpl.addLog(logDTO);
+ }
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ } else {
+ result = ServiceHelper.ENTRY_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de supprimer une entrée à partir d'un DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String removeEntry(EntryDTO entryDTO) {
+ String result = removeEntry(entryDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est dans une période bloquée ou non
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBlocked(Transaction transaction) {
+ boolean isTransactionBlocked = true;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ Transaction transactionSearch = transactionDAO
+ .findByTopiaId(transaction.getTopiaId());
+ isTransactionBlocked = timeSpanServiceImpl
+ .isTimeSpanBlocked(transactionSearch.getTimeSpan());
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return isTransactionBlocked;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est équilibrée.
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBalanced(Transaction transaction) {
+ List<EntryDTO> ListEntryDTO = entryServiceImpl
+ .searchEntryDTOWithTransaction(transaction);
+ float debit = 0;
+ float credit = 0;
+ // Pour toutes les entrées comptables trouvées
+ for (EntryDTO entryDTO : ListEntryDTO) {
+ // Si entrée au debit
+ if (entryDTO.isDebit()) {
+ debit = debit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ } else {
+ credit = credit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ }
+ }
+ // Vérifie si le debit == credit
+ boolean isTransactionBalanced = debit == credit;
+ return isTransactionBalanced;
+ }*/
+}
\ No newline at end of file
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,676 +0,0 @@
-/* *##% Lima Business
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business.ejb;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
-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.TransactionService;
-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;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.entity.TransactionDAO;
-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;
-
-/**
- * Cette classe permet la création d'une transaction comptable dans l'application.
- * Toute action sur une transaction entraîne automatiquement une création de log.
- * Une transaction est composée d'entrées comptables.
- * Les actions sur les transactions sont soumises au statut de celle-ci, si elle
- * est dans une période bloquée ou non.
- *
- * @author Rémi Chapelet
- */
-@Stateless
-public class TransactionServiceImpl extends AbstractLimaService implements TransactionService {
-
- private static final Log log = LogFactory.getLog(TransactionServiceImpl.class);
-
- private TopiaContext rootContext;
-
- //private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
-
- //private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
-
- //private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
-
- public TransactionServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Permet de créer une transaction comptable. Pour ajouter une transaction,
- * le timeSpan doit être non bloqué.
- * @param entryDate
- * @param voucherRef
- * @param description
- * @param timespan
- * @param journal
- * @return
- * @throws LimaException
- */
- @Override
- public void createTransaction(Transaction transaction/*Date entryDate, String voucherRef,
- String description, TimeSpan timeSpan, Journal journal*/) throws LimaException {
-
-
- TopiaContext topiaContext = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- topiaContext = rootContext.beginTransaction();
-
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
-
- transactionDAO.create(transaction);
-
- // commit
- topiaContext.commitTransaction();
- }
- catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
- }
- finally {
- doFinally(topiaContext, log);
- }
-
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- String isCorrectTransaction = isCorrectTransaction(timeSpan,
- journal);
- if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Creation de la transaction
- Transaction newtransaction = transactionDAO.create();
- newtransaction.setTransDate(entryDate);
- newtransaction.setVoucherRef(voucherRef);
- newtransaction.setDescription(description);
- newtransaction.setTimeSpan(timeSpan);
- newtransaction.setJournal(journal);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Ajout avec succes de la transaction");
- }
-
- // Il renvoie soit l'identifiant topiaId ou SUCCESS.
- result = newtransaction.getTopiaId();
- //result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- result = isCorrectTransaction;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
- }
-
- /*
- * Permet de créer une transaction à partir d'une transaction DTO.
- * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se
- * faire. Si on souhaite, on peut créer le journal automatiquement lors de
- * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est
- * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période
- * comptable existante, et par conséquent il ne faut pas le créer.
- * @param transactionDTO
- * @return
- *
- public String createTransaction(TransactionDTO transactionDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO
- if (transactionDTO.getJournalDTO() == null
- || transactionDTO.getTimeSpanDTO() == null) {
- if (log.isErrorEnabled()) {
- log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- } else {
- // Recherche du journal
- JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
- Journal journal = journalServiceImpl
- .searchJournalWithLabel(transactionDTO.getJournalDTO()
- .getLabel());
- // Recherche du timeSpan
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
- .getBeginTimeSpan());
-
- // Vérification si timeSpan et Journal existe bien
- if (journal == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le journal "
- + transactionDTO.getJournalDTO().getLabel()
- + " n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- } else {
- if (timeSpan == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le timeSpan "
- + transactionDTO.getTimeSpanDTO().toString()
- + " n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
- } else {
- result = createTransaction(transactionDTO.getEntryDate(),
- transactionDTO.getVoucherRef(), transactionDTO
- .getDescription(), timeSpan, journal);
- }
- }
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une transaction. Cette dernière est identifiée par la
- * clé topiaId.
- * @param topiaId
- * @param entryDate
- * @param voucherRef
- * @param description
- * @param timespan
- * @param journal
- * @return
- *
- public String modifyTransaction(String topiaId, Date entryDate,
- String voucherRef, String description, TimeSpan timeSpan,
- Journal journal) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Vérification que la transaction existe bien
- Transaction transaction = transactionDAO.findByTopiaId(topiaId);
- if (transaction == null) {
- if (log.isInfoEnabled()) {
- log.info("La transaction " + voucherRef
- + " n'existe pas. (identifiant " + topiaId + ")");
- }
- result = ServiceHelper.TRANSACTION_NOT_EXIST;
- } else {
- // Vérification si la transaction possède de bons paramètres
- String correct = isCorrectTransaction(timeSpan, journal);
- // Si la transaction est correcte
- if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Modification
- transaction.setTransDate(entryDate);
- transaction.setVoucherRef(voucherRef);
- transaction.setDescription(description);
- transaction.setTimeSpan(timeSpan);
- transaction.setJournal(journal);
- transaction.update();
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /**
- * Permet de retrouver la premiere transaction associée au journal.
- *
- * Utilisé par entrybook service pour savoir si un journal a des transactions
- * associées et empecher la suppression.
- *
- * @param topiaTransaction context à utiliser
- * @param entryBook journal
- * @throws TopiaException
- */
- protected Transaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
-
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
-
- TopiaQuery query = transactionDAO.createQuery();
- // entryBook is not visible, but column "entryBook"
- // exist in transaction table
- query.add("entryBook", entryBook);
-
- Transaction result = transactionDAO.findByQuery(query);
-
- return result;
- }
-
- @Override
- public List<Transaction> getAllTransactions() throws LimaException {
-
- // find all with null entry book filter
-
- return getAllTransactionsForEntryBook(null);
- }
-
- @Override
- public List<Transaction> getAllTransactionsForEntryBook(EntryBook entryBook) throws LimaException {
-
- // find all with null period filter
-
- return getAllTransactionsForEntryBookAndFinancialPeriod(entryBook, null);
- }
-
- @Override
- public List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException {
-
- List<Transaction> transactions = null;
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
-
- // filter with topia query
- TopiaQuery query = transactionDAO.createQuery();
-
- if (entryBook != null) {
- query.add("entryBook", entryBook);
- }
-
- if (financialPeriod != null) {
- query.add("financialPeriod", financialPeriod);
- }
-
- transactions = transactionDAO.findAllByQuery(query);
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- return transactions;
- }
-
- /*
- * Recherche toutes les transactions appartenant à un même journal donné
- * en paramètre.
- * @param journal
- * @return
- *
- public List<Transaction> searchListTransactionWithJournal(Journal journal) {
- List<Transaction> listTransaction = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- listTransaction = transactionDAO.findAllByJournal(journal);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTransaction;
- }*/
-
- /*
- * Permet de rechercher toutes les transactions dans la base de données,
- * avec en retour une liste de transactions au format DTO.
- * @return
- *
- public List<TransactionDTO> getAllTransactionDTO() {
- List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- List<Transaction> listTransaction = transactionDAO.findAll();
- // Converti la transaction en DTO
- convertTransaction.setTransaction(rootContext);
- for (Transaction transaction : listTransaction) {
- TransactionDTO transactionDTO = convertTransaction
- .transactionEntityToDto(transaction);
- listTransactionDTO.add(transactionDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTransactionDTO;
- }*/
-
- /*
- * Cette méthode permet de vérifier si une transaction possède des paramètres
- * corrects.
- * Un journal doit exister.
- * Un timeSpan doit exister et être non bloqué.
- * @param timeSpan
- * @param journal
- * @return
- *
- public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) {
- String result = ServiceHelper.RESPOND_SUCCESS;
- // Vérification si timeSpan et Journal existe bien
- if (journal == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le journal n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- }
- if (timeSpan == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le timeSpan n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
- } else {
- // Vérifie si le timeSpan est bloqué
- if (timeSpan.getLocked()) {
- if (log.isErrorEnabled()) {
- log.error("Le timeSpan est bloqué ! Il est donc impossible"
- + " d'ajouter une transaction sur cette période. ("
- + "Période du " + timeSpan + ")");
- }
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- }
- return result;
- }*/
-
- @Override
- public void updateTransaction(Transaction transaction) throws LimaException {
-
- // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
-
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
- transactionDAO.update(transaction);
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- }
-
- @Override
- public void removeTransaction(Transaction transaction) throws LimaException {
-
- // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
-
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
- transactionDAO.delete(transaction);
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- }
-
- /*
- * Permet d'ajouter une entrée comptable pour une transaction donnée.
- * ATTENTION : la transaction doit être NON bloquée.
- *
- * @param description
- * @param amount
- * @param debit
- * @param lettering
- * @param detail
- * @param transaction
- * @return
- *
- public String addEntry(String description, String amount, boolean debit,
- String lettering, String detail, Transaction transaction,
- Account account) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si la transaction est non bloquée
- if (!isTransactionBlocked(transaction)) {
- // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
- result = entryServiceImpl.createEntry(description, amount, debit,
- lettering, detail, transaction, account);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet d'ajouter une entrée comptable pour une transaction donnée.
- * L'entrée est sous format DTO.
- *
- * @param entryDTO
- * @return
- *
- public String addEntry(EntryDTO entryDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche TransactionDTO
- TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
- Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
- // Si la transaction est non bloquée
- if (!isTransactionBlocked(transaction)) {
-
- // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
- result = entryServiceImpl.createEntry(entryDTO);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une entrée comptable.
- * ATTENTION : la transaction doit être NON bloquée.
- *
- * @param topiaId
- * @param description
- * @param amount
- * @param debit
- * @param lettering
- * @param detail
- * @param transaction
- * @param account
- * @return
- *
- public String modifyEntry(String topiaId, String description,
- String amount, boolean debit, String lettering, String detail,
- Transaction transaction, Account account) {
- String result = ServiceHelper.RESPOND_ERROR;
- if (!isTransactionBlocked(transaction)) {
- result = entryServiceImpl.modifyEntry(topiaId, description, amount,
- debit, lettering, detail, account);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une entrée.
- * @param entryDTO
- * @return
- *
- public String modifyEntry(EntryDTO entryDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche TransactionDTO
- TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
- Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
- if (!isTransactionBlocked(transaction)) {
- result = entryServiceImpl.modifyEntry(entryDTO);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant
- * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée.
- * @param topiaId
- * @return
- *
- public String removeEntry(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- // Recherche de l'entry
- Entry entryDelete = entryDAO.findByTopiaId(topiaId);
- // Entry doit exister
- if (entryDelete != null) {
- // Prend la transaction dont appartient entry
- Transaction transaction = entryDelete.getTransaction();
- // Vérifie si la transaction est non bloquée.
- if (!isTransactionBlocked(transaction)) {
- // Création d'un log DTO
- LogDTO logDTO = new LogDTO("", new Date(),
- ServiceHelper.LOG_REMOVE, transaction
- .getTransDate(), transaction
- .getVoucherRef(), transaction
- .getDescription(), entryDelete
- .getDescription(), entryDelete.getAmount(),
- entryDelete.getDebit(), entryDelete.getLettering());
- // Appel pour supprimer l'entrée
- result = entryServiceImpl.removeEntry(topiaId);
- // Si la suppression s'est bien déroulée, création log
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Ajout du log
- logServiceImpl.addLog(logDTO);
- }
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- } else {
- result = ServiceHelper.ENTRY_NOT_EXIST;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de supprimer une entrée à partir d'un DTO.
- * @param entryDTO
- * @return
- *
- public String removeEntry(EntryDTO entryDTO) {
- String result = removeEntry(entryDTO.getId());
- return result;
- }*/
-
- /*
- * Permet de vérifier si une transaction est dans une période bloquée ou non
- * @param transaction
- * @return
- *
- public boolean isTransactionBlocked(Transaction transaction) {
- boolean isTransactionBlocked = true;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- Transaction transactionSearch = transactionDAO
- .findByTopiaId(transaction.getTopiaId());
- isTransactionBlocked = timeSpanServiceImpl
- .isTimeSpanBlocked(transactionSearch.getTimeSpan());
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return isTransactionBlocked;
- }*/
-
- /*
- * Permet de vérifier si une transaction est équilibrée.
- * @param transaction
- * @return
- *
- public boolean isTransactionBalanced(Transaction transaction) {
- List<EntryDTO> ListEntryDTO = entryServiceImpl
- .searchEntryDTOWithTransaction(transaction);
- float debit = 0;
- float credit = 0;
- // Pour toutes les entrées comptables trouvées
- for (EntryDTO entryDTO : ListEntryDTO) {
- // Si entrée au debit
- if (entryDTO.isDebit()) {
- debit = debit
- + Float.parseFloat(entryDTO.getAmount().replaceFirst(
- ",", "."));
- } else {
- credit = credit
- + Float.parseFloat(entryDTO.getAmount().replaceFirst(
- ",", "."));
- }
- }
- // Vérifie si le debit == credit
- boolean isTransactionBalanced = debit == credit;
- return isTransactionBalanced;
- }*/
-}
\ No newline at end of file
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.User;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaNotFoundException;
@@ -61,8 +60,9 @@
* @param name new user name
* @throws LimaException
*/
- public void addUser(User user/*String name*/) throws LimaException {
- /*// Attention doublon utilisateur
+ /*
+ public void addUser(User user/*String name) throws LimaException {
+ // Attention doublon utilisateur
try {
// Acces BDD
TopiaContext topiaContext = rootContext.beginTransaction();
@@ -83,8 +83,8 @@
throw new LimaException("Can't create user", ex);
}
- }*/
- }
+ }
+ }*/
/**
* Find user with name.
@@ -92,7 +92,7 @@
* @param name
* @throws LimaException
*/
- public void findUser(String name) throws LimaException {
+ /*public void findUser(String name) throws LimaException {
/*try {
// Acces BDD
TopiaContext topiaContext = rootContext.beginTransaction();
@@ -110,6 +110,6 @@
log.error("Can't find user", ex);
throw new LimaException("Can't find user", ex);
}
- }*/
- }
+ }
+ }*/
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -5,7 +5,7 @@
import org.chorem.lima.business.ejb.EntryBookServiceImpl;
import org.chorem.lima.business.ejb.FiscalPeriodServiceImpl;
import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
-import org.chorem.lima.business.ejb.TransactionServiceImpl;
+import org.chorem.lima.business.ejb.FinancialTransactionServiceImpl;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -19,7 +19,7 @@
/** log. */
private static final org.apache.commons.logging.Log log = LogFactory.getLog(TransactionServiceImplTest.class);
- private static TransactionServiceImpl instanceTransaction;
+ private static FinancialTransactionServiceImpl instanceTransaction;
private static FiscalPeriodServiceImpl instancePeriod;
private static FinancialPeriodServiceImpl instanceTimespan;
private static EntryBookServiceImpl instanceJournal;
@@ -34,7 +34,7 @@
@Before
public void setUp() {
- instanceTransaction = new TransactionServiceImpl();
+ instanceTransaction = new FinancialTransactionServiceImpl();
instancePeriod = new FiscalPeriodServiceImpl();
instanceTimespan = new FinancialPeriodServiceImpl();
instanceJournal = new EntryBookServiceImpl();
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,6 +1,6 @@
# Precise l'entete de l'ensemble des fichiers generes
model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */
#org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
-org.chorem.lima.entity.Transaction.attribute.entry.tagvalue.lazy=false
+org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
model.tagvalue.String=text
\ No newline at end of file
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -36,7 +36,7 @@
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.RecordService;
-import org.chorem.lima.business.TransactionService;
+import org.chorem.lima.business.FinancialTransactionService;
/**
* Is class is a service factory based on embedded openejb container.
@@ -195,14 +195,14 @@
*
* @return transaction service proxy
*/
- public TransactionService getTransactionService() {
+ public FinancialTransactionService getTransactionService() {
// TODO EC-20100410 put lookup name in configuration
// name should be fully configurable due to custom implementation used
String lookupName = "TransactionServiceImplLocal";
- TransactionService ejbHome = null;
+ FinancialTransactionService ejbHome = null;
try {
- ejbHome = (TransactionService)ctx.lookup(lookupName);
+ ejbHome = (FinancialTransactionService)ctx.lookup(lookupName);
} catch (NamingException eee) {
if (log.isErrorEnabled()) {
log.error("Can't lookup for service : " + lookupName, eee);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -52,7 +52,7 @@
/**
* Services
*/
- private final transient TransactionService transServ;
+ private final transient FinancialTransactionService transServ;
private final List<TransactionDTO> data;
private boolean editable = true;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -57,7 +57,7 @@
/**
* Services
*/
- protected final transient TransactionService transactionServ;
+ protected final transient FinancialTransactionService transactionServ;
private boolean filtered = false;
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -60,7 +60,7 @@
* Services
*/
protected final EntryService entryServ;
- protected final TransactionService transactionServ;
+ protected final FinancialTransactionService transactionServ;
/**
* @return
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -65,7 +65,7 @@
* Services
*/
protected final EntryService entryServ;
- protected final TransactionService transactionServ;
+ protected final FinancialTransactionService transactionServ;
/**
* @param model
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-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-16 10:26:55 UTC (rev 2864)
@@ -32,6 +32,17 @@
<Table>
<row>
<cell>
+ <JLabel text="lima.entrybook.code"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookCodeField().getDocument()"
+ onInsertUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())'
+ onRemoveUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
<JLabel text="lima.entrybook.label"/>
</cell>
<cell>
@@ -43,28 +54,17 @@
</row>
<row>
<cell>
- <JLabel text="lima.entrybook.description"/>
+ <JLabel text="lima.entrybook.type"/>
</cell>
<cell>
- <JTextField id="entryBookDescriptionField" text="{getEntryBook().getDescription()}"/>
- <javax.swing.text.Document javaBean="getEntryBookDescriptionField().getDocument()"
- onInsertUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())'
- onRemoveUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())' />
+ <JTextField id="entryBookTypeField" text="{getEntryBook().getType()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookTypeField().getDocument()"
+ onInsertUpdate='getEntryBook().setType(getEntryBookTypeField().getText())'
+ onRemoveUpdate='getEntryBook().setType(getEntryBookTypeField().getText())' />
</cell>
</row>
<row>
<cell>
- <JLabel text="lima.entrybook.prefix"/>
- </cell>
- <cell>
- <JTextField id="entryBookPrefixField" text="{getEntryBook().getPrefix()}"/>
- <javax.swing.text.Document javaBean="getEntryBookPrefixField().getDocument()"
- onInsertUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())'
- onRemoveUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())' />
- </cell>
- </row>
- <row>
- <cell>
<JButton id="okButton" text="lima.common.ok" onActionPerformed="dispose()"/>
</cell>
<cell>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -126,13 +126,13 @@
switch (column) {
case 0:
- result = entryBook.getLabel();
+ result = entryBook.getCode();
break;
case 1:
- result = entryBook.getDescription();
+ result = entryBook.getLabel();
break;
case 2:
- result = entryBook.getPrefix();
+ result = entryBook.getType();
break;
}
} catch (LimaException e) {
@@ -153,13 +153,13 @@
switch (column) {
case 0:
- entryBook.setLabel((String)value);
+ entryBook.setCode((String)value);
break;
case 1:
- entryBook.setDescription((String)value);
+ entryBook.setLabel((String)value);
break;
case 2:
- entryBook.setPrefix((String)value);
+ entryBook.setType((String)value);
break;
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,79 @@
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 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.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialTransaction;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionHelper {
+
+ /**
+ * Get total credit for a transaction.
+ *
+ * @param transaction transaction to get credit
+ * @return total credit
+ */
+ public static double getCredit(FinancialTransaction financialtransaction) {
+ double credit = 0;
+ for (Entry entry : financialtransaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (!entry.getDebit()) {
+ credit += entry.getAmount();
+ }
+ }
+ return credit;
+ }
+
+ /**
+ * Get total debit for a transaction.
+ *
+ * @param transaction transaction to get debit
+ * @return total debit
+ */
+ public static double getDebit(FinancialTransaction financialtransaction) {
+ double debit = 0;
+ for (Entry entry : financialtransaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (entry.getDebit()) {
+ debit += entry.getAmount();
+ }
+ }
+ return debit;
+ }
+
+ /**
+ * Return true if transaction is balanced (credit == debit).
+ *
+ * @param transaction transaction to test
+ * @return {@code true} if transaction is balanced
+ */
+ public static boolean isBalanced(FinancialTransaction financialtransaction) {
+ boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction);
+ return balanced;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java (from rev 2861, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,156 @@
+/* *##% 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;
+
+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.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionViewHandler {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(FinancialTransactionViewHandler.class);
+
+ protected TransactionView view;
+
+ protected FinancialTransactionViewHandler(TransactionView view) {
+ this.view = view;
+ }
+
+ //add a new transaction
+ protected void addFinancialTransaction() {
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+
+ try {
+ model.addFinancialTransaction();
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add transaction", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add transaction", ex);
+ }
+ }
+
+ //implement new transaction button
+ //add a new entry to the selected transaction
+ public void addEmptyEntry(){
+
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+ model.addEmptyEntry(selectedValue, indexSelectedRow);
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call addentry selected transaction without selection");
+ }
+ }
+ }
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @throws LimaException
+ */
+ public void deleteSelectedRow(){
+
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+ String message = null;
+ if (selectedValue instanceof FinancialTransaction) {
+ message = _("lima.question.remove.transaction");
+ }
+ else {
+ message = _("lima.question.remove.entry");
+ }
+
+ int response = JOptionPane.showConfirmDialog(view, message,
+ _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
+
+ if (response == JOptionPane.YES_OPTION) {
+
+ 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);
+ }
+ }
+ else if (selectedValue instanceof Entry) {
+ // TODO EC-20100409 implements this
+ if (log.isWarnEnabled()) {
+ log.warn("TODO implement Entry deletion");
+ }
+ }*/
+ }
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call delete selected row without selection");
+ }
+ }
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,79 +0,0 @@
-/* *##% Lima Main
- * Copyright (C) 2008 - 2010 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.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.Transaction;
-
-/**
- * TODO add comment here.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class TransactionHelper {
-
- /**
- * Get total credit for a transaction.
- *
- * @param transaction transaction to get credit
- * @return total credit
- */
- public static double getCredit(Transaction transaction) {
- double credit = 0;
- for (Entry entry : transaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (!entry.getDebit()) {
- credit += entry.getAmount();
- }
- }
- return credit;
- }
-
- /**
- * Get total debit for a transaction.
- *
- * @param transaction transaction to get debit
- * @return total debit
- */
- public static double getDebit(Transaction transaction) {
- double debit = 0;
- for (Entry entry : transaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (entry.getDebit()) {
- debit += entry.getAmount();
- }
- }
- return debit;
- }
-
- /**
- * Return true if transaction is balanced (credit == debit).
- *
- * @param transaction transaction to test
- * @return {@code true} if transaction is balanced
- */
- public static boolean isBalanced(Transaction transaction) {
- boolean balanced = getDebit(transaction) == getCredit(transaction);
- return balanced;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,156 +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.transaction;
-
-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.Transaction;
-import org.chorem.lima.entity.TransactionImpl;
-import org.chorem.lima.ui.entrybook.EntryBookForm;
-import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
-import org.chorem.lima.ui.transaction.table.TransactionTable;
-import org.chorem.lima.ui.transaction.table.TransactionTableModel;
-import org.chorem.lima.util.ErrorHelper;
-import org.jdesktop.swingx.JXTable;
-
-
-/**
- * Handler associated with account view.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class TransactionViewHandler {
-
- /** log. */
- private static final Log log = LogFactory.getLog(TransactionViewHandler.class);
-
- protected TransactionView view;
-
- protected TransactionViewHandler(TransactionView view) {
- this.view = view;
- }
-
- //add a new transaction
- protected void addEmptyTransaction() {
- TransactionTable table = (TransactionTable)view.getTransactionTable();
- TransactionTableModel model = (TransactionTableModel)table.getModel();
-
- try {
- model.addEmptyTransaction();
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add transaction", ex);
- }
- ErrorHelper.showErrorDialog("Can't add transaction", ex);
- }
- }
-
- //implement new transaction button
- //add a new entry to the selected transaction
- public void addEmptyEntry(){
-
- TransactionTable table = (TransactionTable)view.getTransactionTable();
- TransactionTableModel model = (TransactionTableModel)table.getModel();
-
- int indexSelectedRow = table.getSelectedRow();
- if (indexSelectedRow != -1) {
- Object selectedValue = model.getElementAt(indexSelectedRow);
- model.addEmptyEntry(selectedValue, indexSelectedRow);
- }
- else {
- if (log.isWarnEnabled()) {
- log.warn("Call addentry selected transaction without selection");
- }
- }
- }
-
- /**
- * Delete selected row in table (could be transaction or entry).
- *
- * Called by model.
- * @throws LimaException
- */
- public void deleteSelectedRow(){
-
- TransactionTable table = (TransactionTable)view.getTransactionTable();
- TransactionTableModel model = (TransactionTableModel)table.getModel();
-
- int indexSelectedRow = table.getSelectedRow();
- if (indexSelectedRow != -1) {
-
- Object selectedValue = model.getElementAt(indexSelectedRow);
- String message = null;
- if (selectedValue instanceof Transaction) {
- message = _("lima.question.remove.transaction");
- }
- else {
- message = _("lima.question.remove.entry");
- }
-
- int response = JOptionPane.showConfirmDialog(view, message,
- _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
-
- if (response == JOptionPane.YES_OPTION) {
-
- 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);
- }
- }
- else if (selectedValue instanceof Entry) {
- // TODO EC-20100409 implements this
- if (log.isWarnEnabled()) {
- log.warn("TODO implement Entry deletion");
- }
- }*/
- }
- }
- else {
- if (log.isWarnEnabled()) {
- log.warn("Call delete selected row without selection");
- }
- }
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java (from rev 2861, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,374 @@
+/* *##% 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.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.ui.transaction.FinancialTransactionViewHandler;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+
+
+/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class FinancialTransactionTable extends JXTable implements KeyListener {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
+
+ protected FinancialTransactionViewHandler handler;
+
+ private ColorHighlighter colorEmptyLine;
+
+ private ColorHighlighter colorTransaction;
+
+ private ColorHighlighter colorBalance;
+
+ private EmptyLineSelectionListener emptyLineSelectionListener;
+
+ /**
+ */
+ public FinancialTransactionTable(FinancialTransactionViewHandler handler/*,
+ TransactionTableModel model,
+ TransactionSortedTableColumnModel columnModel*/) {
+ //super(model, columnModel);
+
+ this.handler = handler;
+
+ /*
+ * New Table Header
+ */
+ // header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
+ //getTableHeader().addMouseListener(new TransactionHeaderListener(this));
+
+ /*
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
+ * automatiquement une nouvelle ligne (une entrée comptable)
+ */
+ //addMouseListener(getEmptyLineSelectionListener());
+
+ /*
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
+ * programme insère une ligne comptable.
+ */
+ addKeyListener(this);
+
+ // cell rendering
+ /*TableColumnModel tcm = getColumnModel();
+ tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellRenderer(PeriodTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.STATUS.ordinal()).setCellRenderer(StatusTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.BALANCE.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+
+ // 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.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/
+
+ setDefaultEditor(Date.class, new DateTableCellEditor());
+
+
+ // Color transactions
+ // addColorTransaction();
+ // addColorNonBalancedTransaction();
+ }
+
+ /**
+ *
+ */
+ public void addColorEmptyLine() {
+
+ // Renvoie une couleur jaune pour chaque nouvelle ligne créée
+ /*removeColorEmptyLine();
+ if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
+ final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ return adapter.row == posNext;
+ }
+ };
+ colorEmptyLine = new ColorHighlighter(predicate, new Color(248,255,136), Color.BLACK,new Color(248,255,136), Color.BLACK);
+ addHighlighter(colorEmptyLine);
+ }*/
+ }
+
+ /**
+ *
+ */
+ public void removeColorEmptyLine() {
+ if (colorEmptyLine != null) {
+ removeHighlighter(colorEmptyLine);
+ }
+ }
+
+ /**
+ * Cette méthode permet de colorer toutes les transactions dans le tableau
+ * afin de bien distinguer les transactions et entrées comptables.
+ */
+ /* protected void addColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ return getModel().getElementAt(adapter.row) instanceof Transaction;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(222, 222,
+ 222), null, null, null);
+ addHighlighter(colorTransaction);
+ }*/
+
+ /**
+ * Permet de surligner une transaction dans le tableau lorsque cette dernière
+ * n'est pas équilibrée.
+ */
+/* protected void addColorNonBalancedTransaction() {
+ if (colorBalance != null) {
+ removeHighlighter(colorBalance);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ boolean isHighlighted = false;
+ Object value = getModel().getElementAt(adapter.row);
+ if (value instanceof Transaction) {
+ Transaction currentTransaction = (Transaction) value;
+ if (!TransactionHelper.isBalanced(currentTransaction)) {
+ isHighlighted = true;
+ }
+ }
+ return isHighlighted;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
+ 209), null, null, null);
+ addHighlighter(colorTransaction);
+ }*/
+
+ /* @Override
+ public TransactionTableModel getModel() {
+ return (TransactionTableModel) this.dataModel;
+ }
+
+ @Override
+ public TransactionSortedTableColumnModel getColumnModel() {
+ return (TransactionSortedTableColumnModel) this.columnModel;
+ }
+
+*/
+ /*
+ public EmptyLineSelectionListener getEmptyLineSelectionListener() {
+ if (emptyLineSelectionListener == null) {
+ return new EmptyLineSelectionListener();
+ }
+ return emptyLineSelectionListener;
+ }
+*/
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ // VK_DELETE suppression de la transaction en cours
+ // ou de l'entree
+ if (e.getKeyCode() == KeyEvent.VK_DELETE) {
+ // handler.deleteSelectedRow();
+ }
+
+ // Touche : insert ou ctrl+I
+ // Ajoute une transaction
+ if ((e.getKeyCode() == KeyEvent.VK_INSERT)
+ || (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+
+ // TODO EC 20100408 String result = table.getModel().addEmptyTransaction();
+ }
+
+ // Touche '+' OU 'ctrl+Entr'
+ // Ajoute une entrée comptable ou transaction
+ if (e.getKeyCode() == KeyEvent.VK_PLUS
+ || (e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+ /*int max_y = table.getRowCount();
+ addLine(table);
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y, max_y);*/
+ }
+
+ /**
+ * Touche tab
+ * Ajoute une entrée comptable ou transaction seulement si tab est sur
+ * la dernière cellule.
+ */
+ if (e.getKeyChar() == KeyEvent.VK_TAB) {
+ // Vérifie si la cellule sélectionnée est la dernière
+ /*int x = table.getSelectedColumn();
+ int y = table.getSelectedRow();
+ int max_x = table.getColumnCount() - 1;
+ int max_y = table.getRowCount() - 1;
+ if (x == max_x && y == max_y) {
+ boolean result = addLine(table);
+ // positionne la sélection sur la nouvelle ligne créée
+ if (result) {
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y + 1, max_y + 1);
+ }
+ }*/
+ }
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyReleased(KeyEvent e) {
+
+ }
+
+ /**
+ * Permet d'ajouter une nouvelle ligne : transaction ou entrée
+ * @param table la table
+ * @return
+ */
+ /*private boolean addLine(TransactionJXTable table) {
+ if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) {
+ // Vérifie si le tableau est vide, alors ajout d'une transaction
+ if (table.getRowCount() == 0) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+ TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table
+ .getModel();
+ int selectedRow = 0;
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ selectedRow = table.getRowCount() - 1;
+ } else {
+ // Line selected
+ selectedRow = table.getSelectedRow();
+ }
+ // Récupère la position de la transaction rattachée
+ 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 false;
+ }
+ } else {
+ //Entry n'est pas éditable
+ if (!ServiceHelper.isEditable((EntryDTO) o)) {
+ return false;
+ }
+ }
+
+ // Vérifie si la transaction est équilibrée ou non (et qu'elle posséde des entrées)
+ TransactionDTO transaction = (TransactionDTO) flattenModel
+ .getElementAt(parentIndex);
+ if (DTOHelper.isBalanced(transaction)
+ && !transaction.getEntries().isEmpty()) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = selectedRow + 1;
+ flattenModel.createEmptyLine();
+ flattenModel.addEmptyLine(posNext);
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+
+ // New Line Color
+ table.addColorEmptyLine();
+ } else {
+ // Line selected
+ // 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();
+ }
+ return true;
+ }
+ return false;
+ }*/
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java (from rev 2863, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,506 @@
+/* *##% 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.table;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
+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.
+ *
+ * Le modele est filtré sur {@link #selectedEntryBook} et
+ * {@link #selectedFinancialPeriod} (montée en charge !).
+ *
+ * TODO EC20100408 revoir le modele, avoir des transactions et des entries
+ * c'est pas gérables.
+ * Le mieux serait d'avoir un "mega component transaction par ligne" et
+ * que ce composant puisse editer les entries.
+ * Ou autre chose.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3914954536809622358L;
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(FinancialTransactionTableModel.class);
+
+ /** Transaction service. */
+ protected final FinancialTransactionService transactionService;
+ /** Record service. */
+ protected final RecordService recordService;
+
+ protected EntryBook selectedEntryBook;
+
+ protected FinancialPeriod selectedFinancialPeriod;
+
+ /**
+ * Model constructor.
+ *
+ * Just init service proxies.
+ */
+ public FinancialTransactionTableModel() {
+ /* Services */
+ recordService = LimaServiceFactory.getInstance().getRecordService();
+ transactionService = LimaServiceFactory.getInstance()
+ .getTransactionService();
+ }
+
+ /**
+ * Le model est une combinaison de Transaction/Entries.
+ *
+ * TODO EC20100408 c'est pas evident a manipuler via une table
+ *
+ * @return
+ */
+ protected List<Object> getDataList() {
+
+ log.debug("getDatalist");
+
+ List<Object> results = new ArrayList<Object>();
+ try {
+
+ List<FinancialTransaction> financialtransactions =
+ transactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
+
+ for (FinancialTransaction financialtransaction : financialtransactions) {
+ results.add(financialtransaction);
+ // TODO EC20100408 warn about lazy exception here
+ // TODO EC20100408 warn about non ordonned transaction.getEntry()
+ results.addAll(financialtransaction.getEntry());
+ }
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
+
+ return results;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 10;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+
+ Class<?> result = null;
+
+ switch (column) {
+ case 0:
+ result = Date.class;
+ break;
+ case 1:
+ result = Account.class;
+ break;
+ case 2:
+ result = EntryBook.class;
+ break;
+ case 3:
+ result = FinancialPeriod.class;
+ break;
+ case 4:
+ result = String.class;
+ break;
+ case 5:
+ result = Double.class;
+ break;
+ case 6:
+ result = Double.class;
+ break;
+ case 7:
+ result = String.class;
+ break;
+ case 8:
+ result = String.class;
+ break;
+ case 9:
+ result = String.class;
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String result = "n/a";
+
+ switch (column) {
+ case 0:
+ result = _("lima.transaction.column.date");
+ break;
+ case 1:
+ result = _("lima.transaction.column.account");
+ break;
+ case 2:
+ result = _("lima.transaction.column.entrybook");
+ break;
+ case 3:
+ result = _("lima.transaction.column.period");
+ break;
+ case 4:
+ result = _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = _("lima.transaction.column.debit");
+ break;
+ case 6:
+ result = _("lima.transaction.column.credit");
+ break;
+ case 7:
+ result = _("lima.transaction.column.balance");
+ break;
+ case 8:
+ result = _("lima.transaction.column.description");
+ break;
+ case 9:
+ result = _("lima.transaction.column.document");
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ List<Object> datas = getDataList();
+ result = datas.size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+
+ // just prevent too much result
+ System.out.println("OK2");
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ result = datas.get(row);
+
+ if (result instanceof FinancialTransaction) {
+ FinancialTransaction currentRow = (FinancialTransaction)result;
+ switch (column) {
+ case 0:
+ result = currentRow.getTransactionDate();
+ break;
+ case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = FinancialTransactionHelper.getDebit(currentRow);
+ break;
+ case 6:
+ result = FinancialTransactionHelper.getCredit(currentRow);
+ break;
+ case 7:
+ 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) {
+ Entry currentEntry = (Entry)result;
+ switch (column) {
+ case 0:
+ result = null; // date
+ break;
+ case 1:
+ result = currentEntry.getAccount(); // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
+ break;
+ case 6:
+ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
+ break;
+ case 7:
+ result = null;
+ break;
+ case 8:
+ result = currentEntry.getDescription();
+ break;
+ case 9:
+ result = null;
+ break;
+ }
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+
+ public void setEntryBook(EntryBook entryBook){
+
+ System.out.println("OK");
+ selectedEntryBook = entryBook;
+ fireTableDataChanged();
+ }
+
+ /**
+ * @throws LimaException
+ */
+ public void addFinancialTransaction() throws LimaException{
+ /* 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);
+ }
+
+
+
+ /**
+ * @throws LimaException
+ */
+ public void addEmptyEntry(Object value, int row) {
+ /* Calling transaction service */
+ //TODO transaction = currentdate, current periode, current journal
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ Entry entry=null;
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentTransaction = (FinancialTransaction)currentRow;
+ currentTransaction.addEntry(entry);
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //TODO recuperer l'entrée parente, ajouter entrée
+ }
+ fireTableRowsUpdated(row, row);
+ }
+
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentFinancialTransaction =
+ (FinancialTransaction)currentRow;
+ switch (column) {
+ case 0:
+ currentFinancialTransaction.setTransactionDate((Date)value);
+ break;
+ /*case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ 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();
+ }
+ //fireTableRowsUpdated(row, row); // to update what ???
+
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ switch (column) {
+ /*case 0:
+ result = null; // date
+ break;*/
+ case 1:
+ currentEntry.setAccount((Account)value); // account ?
+ break;
+ /*case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;*/
+ case 5:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(true);
+ break;
+ case 6:
+ 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 :)
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+ }
+
+ public Object getElementAt(int row){
+
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ return currentRow;
+ }
+
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @param Object, int
+ * @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
+ }
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,383 +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.transaction.table;
-
-import java.awt.Color;
-import java.awt.Component;
-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.entity.Transaction;
-import org.chorem.lima.listener.EmptyLineSelectionListener;
-import org.chorem.lima.table.editor.DateTableCellEditor;
-import org.chorem.lima.table.model.TransactionSortedTableColumnModel;
-import org.chorem.lima.table.model.TransactionTableModel;
-import org.chorem.lima.ui.transaction.TransactionHelper;
-import org.chorem.lima.ui.transaction.TransactionViewHandler;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.ColorHighlighter;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-
-/**
- * Table des transaction qui ajoute des comportement (keys).
- *
- * @author ore
- * @author Rémi Chapelet
- */
-public class TransactionTable extends JXTable implements KeyListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3133690382049594727L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(TransactionTable.class);
-
- protected TransactionViewHandler handler;
-
- private ColorHighlighter colorEmptyLine;
-
- private ColorHighlighter colorTransaction;
-
- private ColorHighlighter colorBalance;
-
- private EmptyLineSelectionListener emptyLineSelectionListener;
-
- /**
- */
- public TransactionTable(TransactionViewHandler handler/*,
- TransactionTableModel model,
- TransactionSortedTableColumnModel columnModel*/) {
- //super(model, columnModel);
-
- this.handler = handler;
-
- /*
- * New Table Header
- */
- // header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
- //getTableHeader().addMouseListener(new TransactionHeaderListener(this));
-
- /*
- * Mod : il est possible d'activer cette option.
- * Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
- * automatiquement une nouvelle ligne (une entrée comptable)
- */
- //addMouseListener(getEmptyLineSelectionListener());
-
- /*
- * Mod : il est possible d'activer cette option.
- * Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
- * programme insère une ligne comptable.
- */
- addKeyListener(this);
-
- // cell rendering
- /*TableColumnModel tcm = getColumnModel();
- tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellRenderer(PeriodTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.STATUS.ordinal()).setCellRenderer(StatusTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.BALANCE.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
-
- // 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.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/
-
- setDefaultEditor(Date.class, new DateTableCellEditor());
-
-
- // Color transactions
- // addColorTransaction();
- // addColorNonBalancedTransaction();
- }
-
- /**
- *
- */
- public void addColorEmptyLine() {
-
- // Renvoie une couleur jaune pour chaque nouvelle ligne créée
- /*removeColorEmptyLine();
- if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
- final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
- HighlightPredicate predicate = new HighlightPredicate() {
-
- @Override
- public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
- return adapter.row == posNext;
- }
- };
- colorEmptyLine = new ColorHighlighter(predicate, new Color(248,255,136), Color.BLACK,new Color(248,255,136), Color.BLACK);
- addHighlighter(colorEmptyLine);
- }*/
- }
-
- /**
- *
- */
- public void removeColorEmptyLine() {
- if (colorEmptyLine != null) {
- removeHighlighter(colorEmptyLine);
- }
- }
-
- /**
- * Cette méthode permet de colorer toutes les transactions dans le tableau
- * afin de bien distinguer les transactions et entrées comptables.
- */
- /* protected void addColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- return getModel().getElementAt(adapter.row) instanceof Transaction;
- }
- };
- colorTransaction = new ColorHighlighter(predicate, new Color(222, 222,
- 222), null, null, null);
- addHighlighter(colorTransaction);
- }*/
-
- /**
- * Permet de surligner une transaction dans le tableau lorsque cette dernière
- * n'est pas équilibrée.
- */
-/* protected void addColorNonBalancedTransaction() {
- if (colorBalance != null) {
- removeHighlighter(colorBalance);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- Object value = getModel().getElementAt(adapter.row);
- if (value instanceof Transaction) {
- Transaction currentTransaction = (Transaction) value;
- if (!TransactionHelper.isBalanced(currentTransaction)) {
- isHighlighted = true;
- }
- }
- return isHighlighted;
- }
- };
- colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
- 209), null, null, null);
- addHighlighter(colorTransaction);
- }*/
-
- /* @Override
- public TransactionTableModel getModel() {
- return (TransactionTableModel) this.dataModel;
- }
-
- @Override
- public TransactionSortedTableColumnModel getColumnModel() {
- return (TransactionSortedTableColumnModel) this.columnModel;
- }
-
-*/
- /*
- public EmptyLineSelectionListener getEmptyLineSelectionListener() {
- if (emptyLineSelectionListener == null) {
- return new EmptyLineSelectionListener();
- }
- return emptyLineSelectionListener;
- }
-*/
- @Override
- public void keyPressed(KeyEvent e) {
-
- // VK_DELETE suppression de la transaction en cours
- // ou de l'entree
- if (e.getKeyCode() == KeyEvent.VK_DELETE) {
- // handler.deleteSelectedRow();
- }
-
- // Touche : insert ou ctrl+I
- // Ajoute une transaction
- if ((e.getKeyCode() == KeyEvent.VK_INSERT)
- || (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK)) {
-
- // TODO EC 20100408 String result = table.getModel().addEmptyTransaction();
- }
-
- // Touche '+' OU 'ctrl+Entr'
- // Ajoute une entrée comptable ou transaction
- if (e.getKeyCode() == KeyEvent.VK_PLUS
- || (e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == KeyEvent.CTRL_MASK)) {
- /*int max_y = table.getRowCount();
- addLine(table);
- table.setColumnSelectionInterval(0, 0);
- table.setRowSelectionInterval(max_y, max_y);*/
- }
-
- /**
- * Touche tab
- * Ajoute une entrée comptable ou transaction seulement si tab est sur
- * la dernière cellule.
- */
- if (e.getKeyChar() == KeyEvent.VK_TAB) {
- // Vérifie si la cellule sélectionnée est la dernière
- /*int x = table.getSelectedColumn();
- int y = table.getSelectedRow();
- int max_x = table.getColumnCount() - 1;
- int max_y = table.getRowCount() - 1;
- if (x == max_x && y == max_y) {
- boolean result = addLine(table);
- // positionne la sélection sur la nouvelle ligne créée
- if (result) {
- table.setColumnSelectionInterval(0, 0);
- table.setRowSelectionInterval(max_y + 1, max_y + 1);
- }
- }*/
- }
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
- */
- @Override
- public void keyTyped(KeyEvent e) {
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
- */
- @Override
- public void keyReleased(KeyEvent e) {
-
- }
-
- /**
- * Permet d'ajouter une nouvelle ligne : transaction ou entrée
- * @param table la table
- * @return
- */
- /*private boolean addLine(TransactionJXTable table) {
- if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) {
- // Vérifie si le tableau est vide, alors ajout d'une transaction
- if (table.getRowCount() == 0) {
- String result = table.getModel().addEmptyTransaction();
- ErrorMessage.showMessage(result);
- return true;
- }
- TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table
- .getModel();
- int selectedRow = 0;
- // Vérifie si une ligne est sélectionnée ou non
- if (table.getSelectionModel().isSelectionEmpty()) {
- // Not line selected
- selectedRow = table.getRowCount() - 1;
- } else {
- // Line selected
- selectedRow = table.getSelectedRow();
- }
- // Récupère la position de la transaction rattachée
- 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 false;
- }
- } else {
- //Entry n'est pas éditable
- if (!ServiceHelper.isEditable((EntryDTO) o)) {
- return false;
- }
- }
-
- // Vérifie si la transaction est équilibrée ou non (et qu'elle posséde des entrées)
- TransactionDTO transaction = (TransactionDTO) flattenModel
- .getElementAt(parentIndex);
- if (DTOHelper.isBalanced(transaction)
- && !transaction.getEntries().isEmpty()) {
- String result = table.getModel().addEmptyTransaction();
- ErrorMessage.showMessage(result);
- return true;
- }
-
- // Vérifie si une ligne est sélectionnée ou non
- if (table.getSelectionModel().isSelectionEmpty()) {
- // Not line selected
- // Click in not current transaction
- if (flattenModel.getCurrentParentIndex() != parentIndex) {
- int posNext = selectedRow + 1;
- flattenModel.createEmptyLine();
- flattenModel.addEmptyLine(posNext);
- // To end
- flattenModel.setCurrentParentIndex(parentIndex);
- }
-
- // New Line Color
- table.addColorEmptyLine();
- } else {
- // Line selected
- // 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();
- }
- return true;
- }
- return false;
- }*/
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,505 +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.transaction.table;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.RecordService;
-import org.chorem.lima.business.TransactionService;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.transaction.TransactionHelper;
-import org.chorem.lima.util.ErrorHelper;
-import org.nuiton.topia.TopiaContextFactory;
-
-/**
- * Basic transaction table model.
- *
- * Le modele est filtré sur {@link #selectedEntryBook} et
- * {@link #selectedFinancialPeriod} (montée en charge !).
- *
- * TODO EC20100408 revoir le modele, avoir des transactions et des entries
- * c'est pas gérables.
- * Le mieux serait d'avoir un "mega component transaction par ligne" et
- * que ce composant puisse editer les entries.
- * Ou autre chose.
- *
- * @author ore
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class TransactionTableModel extends AbstractTableModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3914954536809622358L;
-
- /** log. */
- private static final Log log = LogFactory
- .getLog(TransactionTableModel.class);
-
- /** Transaction service. */
- protected final TransactionService transactionService;
- /** Record service. */
- protected final RecordService recordService;
-
- protected EntryBook selectedEntryBook;
-
- protected FinancialPeriod selectedFinancialPeriod;
-
- /**
- * Model constructor.
- *
- * Just init service proxies.
- */
- public TransactionTableModel() {
- /* Services */
- recordService = LimaServiceFactory.getInstance().getRecordService();
- transactionService = LimaServiceFactory.getInstance()
- .getTransactionService();
- }
-
- /**
- * Le model est une combinaison de Transaction/Entries.
- *
- * TODO EC20100408 c'est pas evident a manipuler via une table
- *
- * @return
- */
- protected List<Object> getDataList() {
-
- log.debug("getDatalist");
-
- List<Object> results = new ArrayList<Object>();
- try {
-
- List<Transaction> transactions =
- transactionService.getAllTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
-
- for (Transaction transaction : transactions) {
- results.add(transaction);
- // TODO EC20100408 warn about lazy exception here
- // TODO EC20100408 warn about non ordonned transaction.getEntry()
- results.addAll(transaction.getEntry());
- }
- }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
-
- ErrorHelper.showErrorDialog("Can't get transaction list", eee);
- }
-
- return results;
- }
-
- @Override
- public int getColumnCount() {
- return 10;
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Date.class;
- break;
- case 1:
- result = Account.class;
- break;
- case 2:
- result = EntryBook.class;
- break;
- case 3:
- result = FinancialPeriod.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = Double.class;
- break;
- case 6:
- result = Double.class;
- break;
- case 7:
- result = String.class;
- break;
- case 8:
- result = String.class;
- break;
- case 9:
- result = String.class;
- break;
- }
-
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.transaction.column.date");
- break;
- case 1:
- result = _("lima.transaction.column.account");
- break;
- case 2:
- result = _("lima.transaction.column.entrybook");
- break;
- case 3:
- result = _("lima.transaction.column.period");
- break;
- case 4:
- result = _("lima.transaction.column.status");
- break;
- case 5:
- result = _("lima.transaction.column.debit");
- break;
- case 6:
- result = _("lima.transaction.column.credit");
- break;
- case 7:
- result = _("lima.transaction.column.balance");
- break;
- case 8:
- result = _("lima.transaction.column.description");
- break;
- case 9:
- result = _("lima.transaction.column.document");
- break;
- }
-
- return result;
- }
-
- @Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (selectedEntryBook != null) {
- List<Object> datas = getDataList();
- result = datas.size();
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
- }
- }
-
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
-
- // just prevent too much result
- System.out.println("OK2");
- if (selectedEntryBook != null) {
- // TODO EC-20100407 remove this ugly code
- List<Object> datas = getDataList();
- result = datas.get(row);
-
- if (result instanceof Transaction) {
- Transaction currentRow = (Transaction)result;
- switch (column) {
- case 0:
- result = currentRow.getTransactionDate();
- break;
- case 1:
- result = null; // account ?
- break;
- case 2:
- result = null; // entry book
- 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:
- result = currentRow.getDescription();
- break;
- case 9:
- result = currentRow.getVoucherRef();
- break;
- }
- }
- else if (result instanceof Entry) {
- Entry currentEntry = (Entry)result;
- switch (column) {
- case 0:
- result = null; // date
- break;
- case 1:
- result = currentEntry.getAccount(); // account ?
- break;
- case 2:
- result = null; // entry book
- break;
- case 3:
- result = null; //currentRow.getFinancialPeriod();
- break;
- case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;
- case 5:
- result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
- break;
- case 6:
- result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
- break;
- case 7:
- result = null;
- break;
- case 8:
- result = currentEntry.getDescription();
- break;
- case 9:
- result = null;
- break;
- }
- }
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
- }
- }
-
- return result;
- }
-
-
- public void setEntryBook(EntryBook entryBook){
-
- System.out.println("OK");
- selectedEntryBook = entryBook;
- fireTableDataChanged();
- }
-
- /**
- * @throws LimaException
- */
- public void addTransaction() throws LimaException{
- /* Calling transaction service */
- //TODO transaction = currentdate, current periode, current journal
- Transaction transaction =null;
- transaction.setFinancialPeriod(selectedFinancialPeriod);
- transaction.setEntryBook(selectedEntryBook);
- transaction.setDescription(description);
- transactionService.createTransaction(transaction);
- int row = getDataList().indexOf(transaction);
- //int row = transactionService.getAllTransactions().indexOf(transaction);
- log.debug(row);
- fireTableRowsInserted(row, row);
- }
-
-
-
- /**
- * @throws LimaException
- */
- public void addEmptyEntry(Object value, int row) {
- /* Calling transaction service */
- //TODO transaction = currentdate, current periode, current journal
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
- Entry entry=null;
- if (currentRow instanceof Transaction) {
- Transaction currentTransaction = (Transaction)currentRow;
- currentTransaction.addEntry(entry);
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- //TODO recuperer l'entrée parente, ajouter entrée
- }
- fireTableRowsUpdated(row, row);
- }
-
-
- @Override
- public void setValueAt(Object value, int row, int column) {
-
- // just prevent too much result
- if (selectedEntryBook != null) {
- // TODO EC-20100407 remove this ugly code
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
-
- if (currentRow instanceof Transaction) {
- Transaction currentTransaction = (Transaction)currentRow;
- switch (column) {
- case 0:
- currentTransaction.setTransactionDate((Date)value);
- break;
- /*case 1:
- result = null; // account ?
- break;
- case 2:
- result = null; // entry book
- 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:
- currentTransaction.setDescription((String)value);
- break;
- case 9:
- currentTransaction.setVoucherRef((String)value);
- break;
- }
-
- // notify service for modification
- try {
- transactionService.updateTransaction(currentTransaction);
- } catch (LimaException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //fireTableRowsUpdated(row, row); // to update what ???
-
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- switch (column) {
- /*case 0:
- result = null; // date
- break;*/
- case 1:
- currentEntry.setAccount((Account)value); // account ?
- break;
- /*case 2:
- result = null; // entry book
- break;
- case 3:
- result = null; //currentRow.getFinancialPeriod();
- break;
- case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;*/
- case 5:
- currentEntry.setAmount((Double)value);
- currentEntry.setDebit(true);
- break;
- case 6:
- 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 :)
- }
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
- }
- }
- }
-
- public Object getElementAt(int row){
-
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
- return currentRow;
- }
-
-
- /**
- * Delete selected row in table (could be transaction or entry).
- *
- * Called by model.
- * @param Object, int
- * @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 Transaction) {
- Transaction currentTransaction = (Transaction)currentRow;
- transactionService.removeTransaction(currentTransaction);
- fireTableRowsDeleted(row, row);
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- //TODO supprimer l'entrée
- }
- }
-}
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-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-16 10:26:55 UTC (rev 2864)
@@ -89,9 +89,9 @@
lima.entries.addtransaction=
lima.entries.lettering=
lima.entries.searchtransaction=
-lima.entrybook.description=
+lima.entrybook.code=
lima.entrybook.label=
-lima.entrybook.prefix=
+lima.entrybook.type=
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
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-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-16 10:26:55 UTC (rev 2864)
@@ -87,9 +87,9 @@
lima.entries.addtransaction=Ajouter une transaction
lima.entries.lettering=Ajouter une lettre
lima.entries.searchtransaction=Recherche les transactions
-lima.entrybook.description=Description
+lima.entrybook.code=Code
lima.entrybook.label=Libelle
-lima.entrybook.prefix=Pr\u00E9fixe
+lima.entrybook.type=Type
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
1
0
r2863 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/transaction lima-swing/src/main/java/org/chorem/lima/ui/transaction/table lima-swing/src/main/resources
by jpepin@users.chorem.org 15 Apr '10
by jpepin@users.chorem.org 15 Apr '10
15 Apr '10
Author: jpepin
Date: 2010-04-15 17:30:01 +0200 (Thu, 15 Apr 2010)
New Revision: 2863
Log:
Modification du mod?\195?\168le, UI d'?\195?\169criture
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
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/TransactionTableModel.java
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-15 15:30:01 UTC (rev 2863)
@@ -63,7 +63,7 @@
*/
List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
- void createTransaction(Transaction transaction) throws LimaException;
+ Transaction createTransaction() throws LimaException;
void updateTransaction(Transaction transaction) throws LimaException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
@@ -19,15 +19,21 @@
package org.chorem.lima.business.ejb;
+import static org.nuiton.i18n.I18n._;
+
import java.util.List;
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.TransactionService;
+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;
@@ -81,10 +87,34 @@
* @param timespan
* @param journal
* @return
+ * @throws LimaException
*/
@Override
- public void createTransaction(Transaction transaction /*Date entryDate, String voucherRef,
- String description, TimeSpan timeSpan, Journal journal*/) {
+ public void createTransaction(Transaction transaction/*Date entryDate, String voucherRef,
+ String description, TimeSpan timeSpan, Journal journal*/) throws LimaException {
+
+
+ TopiaContext topiaContext = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ topiaContext = rootContext.beginTransaction();
+
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+
+ transactionDAO.create(transaction);
+
+ // commit
+ topiaContext.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+
/*String result = ServiceHelper.RESPOND_ERROR;
try {
// Acces BDD
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
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-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-15 15:30:01 UTC (rev 2863)
@@ -22,6 +22,8 @@
<script>
<![CDATA[
+ import org.chorem.lima.entity.EntryBook;
+
]]>
</script>
@@ -42,7 +44,8 @@
<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())"
+ editable="false"/>
</cell>
<cell>
<JLabel id="periodLabel" text="lima.transaction.period"
@@ -51,7 +54,9 @@
<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.FinancialPeriodRenderer()}"
+ editable="false"
+ />
</cell>
</row>
<row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
@@ -35,10 +35,12 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.Transaction;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.transaction.TransactionHelper;
import org.chorem.lima.util.ErrorHelper;
+import org.nuiton.topia.TopiaContextFactory;
/**
* Basic transaction table model.
@@ -97,9 +99,12 @@
* @return
*/
protected List<Object> getDataList() {
-
+
+ log.debug("getDatalist");
+
List<Object> results = new ArrayList<Object>();
try {
+
List<Transaction> transactions =
transactionService.getAllTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
@@ -230,6 +235,7 @@
Object result = null;
// just prevent too much result
+ System.out.println("OK2");
if (selectedEntryBook != null) {
// TODO EC-20100407 remove this ugly code
List<Object> datas = getDataList();
@@ -315,15 +321,28 @@
return result;
}
+
+ public void setEntryBook(EntryBook entryBook){
+
+ System.out.println("OK");
+ selectedEntryBook = entryBook;
+ fireTableDataChanged();
+ }
+
/**
* @throws LimaException
*/
- public void addEmptyTransaction() throws LimaException{
+ public void addTransaction() throws LimaException{
/* Calling transaction service */
//TODO transaction = currentdate, current periode, current journal
- Transaction transaction=null;
+ Transaction transaction =null;
+ transaction.setFinancialPeriod(selectedFinancialPeriod);
+ transaction.setEntryBook(selectedEntryBook);
+ transaction.setDescription(description);
transactionService.createTransaction(transaction);
- int row = transactionService.getAllTransactions().indexOf(transaction);
+ int row = getDataList().indexOf(transaction);
+ //int row = transactionService.getAllTransactions().indexOf(transaction);
+ log.debug(row);
fireTableRowsInserted(row, row);
}
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2010-04-15 15:30:01 UTC (rev 2863)
@@ -13,4 +13,4 @@
log4j.appender.file.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
# package level
-log4j.logger.org.chorem.lima=INFO
\ No newline at end of file
+log4j.logger.org.chorem.lima=DEBUG
\ No newline at end of file
1
0
r2862 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model
by jpepin@users.chorem.org 14 Apr '10
by jpepin@users.chorem.org 14 Apr '10
14 Apr '10
Author: jpepin
Date: 2010-04-14 17:46:15 +0200 (Wed, 14 Apr 2010)
New Revision: 2862
Log:
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java 2010-04-14 15:46:15 UTC (rev 2862)
@@ -0,0 +1,34 @@
+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.EntryBook;
+
+
+
+public class EntryBookRenderer 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();
+ EntryBook entrybook = (EntryBook) value;
+ if (entrybook != null){
+ label.setText(entrybook.getLabel());
+ }
+ return label;
+
+ }
+
+
+
+}
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java 2010-04-14 15:46:15 UTC (rev 2862)
@@ -0,0 +1,36 @@
+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
1
0