Lima-commits
Threads by month
- ----- 2026 -----
- August
- July
- 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
June 2012
- 3 participants
- 48 discussions
r3457 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod
by mallon@users.chorem.org June 19, 2012
by mallon@users.chorem.org June 19, 2012
June 19, 2012
Author: mallon
Date: 2012-06-19 16:15:41 +0200 (Tue, 19 Jun 2012)
New Revision: 3457
Url: http://chorem.org/repositories/revision/lima/3457
Log:
Gestion des boutons de suppression et de cloture d'exercice : les boutons n'appara?\195?\174ssent plus pour les exercices clots.
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/FiscalPeriodViewHandler.java
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 2012-06-19 12:14:39 UTC (rev 3456)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2012-06-19 14:15:41 UTC (rev 3457)
@@ -28,13 +28,36 @@
<import>
javax.swing.ListSelectionModel
org.chorem.lima.entity.FiscalPeriod
- org.chorem.lima.entity.FinancialPeriod
+ org.chorem.lima.entity.FinancialPeriod
</import>
<FiscalPeriodViewHandler id="handler" constructorParams="this"/>
<Boolean id="selectedPeriod" javaBean="false"/>
<script><![CDATA[
+ import static org.nuiton.i18n.I18n._;
+
+ /**
+ * Manage the differents buttons for fiscal period
+ * */
+ public void reloadEnablingButton()
+ {
+ int selectedRow = fiscalPeriodTable.getSelectedRow();
+
+ Object valueColumnClos = fiscalPeriodTableModel.getValueAt(selectedRow, 1 );
+
+ if ( String.valueOf(valueColumnClos).equals( _("lima.ui.fiscalperiod.closed") ) )//Cloture
+ {
+ blockButton.setEnabled(false);
+ deleteButton.setEnabled(false);
+ }
+ else
+ {
+ blockButton.setEnabled(true);
+ deleteButton.setEnabled(true);
+ }
+ }
+
void $afterCompleteSetup() {
getHandler().init();
}
@@ -49,6 +72,7 @@
constructorParams="getFiscalPeriodTableModel()"
selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
columnControlVisible="true"
+ onMouseClicked="reloadEnablingButton()"
/>
<ListSelectionModel
javaBean="getFiscalPeriodTable().getSelectionModel()"
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 2012-06-19 12:14:39 UTC (rev 3456)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-06-19 14:15:41 UTC (rev 3457)
@@ -280,32 +280,6 @@
}
}
- /**
- * Manage the differents buttons for fiscal period
- * */
- public void reloadEnablingButton()
- {
- System.out.println("reloadEnablingButton");
-
- //get the fiscal period selected
- JXTable fiscalPeriodeTable = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = view.getFiscalPeriodTableModel();
- FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(fiscalPeriodeTable.getSelectedRow());
-
- if (selectedFiscalPeriod.getLocked())
- {
- System.out.println("Fiscal period closed");
- view.getBlockButton().setEnabled(false);
- view.getDeleteButton().setEnabled(false);
- }
- else
- {
- System.out.println("Fiscal period opened");
- view.getBlockButton().setEnabled(true);
- view.getDeleteButton().setEnabled(true);
- }
- }
-
private int checkTimeFiscalPeriod(FiscalPeriod fiscalPeriod){
//check if fiscalperiod have 12 months, ask a confirmation
int nbMonth = DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(),
1
0
r3456 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod
by mallon@users.chorem.org June 19, 2012
by mallon@users.chorem.org June 19, 2012
June 19, 2012
Author: mallon
Date: 2012-06-19 14:14:39 +0200 (Tue, 19 Jun 2012)
New Revision: 3456
Url: http://chorem.org/repositories/revision/lima/3456
Log:
Correction de la gestion des boutons des exercices (Modification, suppression)
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.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
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-06-19 08:57:25 UTC (rev 3455)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-06-19 12:14:39 UTC (rev 3456)
@@ -131,6 +131,7 @@
addDays(dateLastFiscalPeriod, 1);
dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
+
if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
throw new LimaBusinessException(_("lima-business.franceaccountingrules.newfiscalperiodadjoiningerror"));
}
@@ -216,6 +217,7 @@
}
+
/**
* Check if old financialperiod for a an entrybook are closed before bock the asked closedperiodicentrybook
* <p/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-06-19 08:57:25 UTC (rev 3455)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-06-19 12:14:39 UTC (rev 3456)
@@ -134,7 +134,7 @@
fiscalPeriods.remove(fiscalPeriod);
fireTableRowsDeleted(row, row);
}
-
+
public void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
/*List<FinancialTransaction> financialTransactionsUnbal =
financialTransactionService.getAllInexactFinancialTransactions(fiscalPeriod);
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 2012-06-19 08:57:25 UTC (rev 3455)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2012-06-19 12:14:39 UTC (rev 3456)
@@ -47,9 +47,8 @@
<FiscalPeriodTable
id="fiscalPeriodTable" sortable="false" rowHeight="24"
constructorParams="getFiscalPeriodTableModel()"
- selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
+ selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
columnControlVisible="true"
- onActionPerformed="getHandler().reloadEnablingButton()"
/>
<ListSelectionModel
javaBean="getFiscalPeriodTable().getSelectionModel()"
@@ -77,11 +76,4 @@
onActionPerformed="getHandler().deleteFiscalPeriod()"/>
</cell>
</row>
- <row>
- <cell fill="horizontal">
- <JButton id="modifyButton" text="lima.charts.fiscalperiod.delete"
- enabled="{isSelectedPeriod()}"
- onActionPerformed="getHandler().deleteFiscalPeriod()"/>
- </cell>
- </row>
</Table>
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 2012-06-19 08:57:25 UTC (rev 3455)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-06-19 12:14:39 UTC (rev 3456)
@@ -109,19 +109,9 @@
addPeriodDialog.setVisible(true);
FiscalPeriod fiscalPeriod = addPeriodDialog.getPeriod();
- // null = cancel
- if (fiscalPeriod != null) {
- //check if fiscalperiod have 12 months, ask a confirmation
- int nbMonth = DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(),
- fiscalPeriod.getEndDate());
- int response = JOptionPane.YES_OPTION;
- if (nbMonth != 12) {
- response = JOptionPane.showConfirmDialog(view,
- _("lima.ui.fiscalperiod.addfiscalperiod.morethan12"),
- _("lima.ui.fiscalperiod.addfiscalperiodtitle"),
- JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
- }
- if (response == JOptionPane.YES_OPTION) {
+ if (fiscalPeriod != null) {
+ int response = JOptionPane.YES_OPTION;
+ if (response == checkTimeFiscalPeriod(fiscalPeriod)) {
fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
model.addFiscalPeriod(fiscalPeriod);
}
@@ -151,7 +141,7 @@
model.deleteFiscalPeriod(selectedFiscalPeriod);
}
}
-
+
/**
* Init add period view.
*
@@ -291,9 +281,44 @@
}
/**
- * manage
+ * Manage the differents buttons for fiscal period
* */
- public void reloadEnablingButton(){
-
+ public void reloadEnablingButton()
+ {
+ System.out.println("reloadEnablingButton");
+
+ //get the fiscal period selected
+ JXTable fiscalPeriodeTable = view.getFiscalPeriodTable();
+ FiscalPeriodTableModel model = view.getFiscalPeriodTableModel();
+ FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(fiscalPeriodeTable.getSelectedRow());
+
+ if (selectedFiscalPeriod.getLocked())
+ {
+ System.out.println("Fiscal period closed");
+ view.getBlockButton().setEnabled(false);
+ view.getDeleteButton().setEnabled(false);
+ }
+ else
+ {
+ System.out.println("Fiscal period opened");
+ view.getBlockButton().setEnabled(true);
+ view.getDeleteButton().setEnabled(true);
+ }
}
+
+ private int checkTimeFiscalPeriod(FiscalPeriod fiscalPeriod){
+ //check if fiscalperiod have 12 months, ask a confirmation
+ int nbMonth = DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(),
+ fiscalPeriod.getEndDate());
+ int response = JOptionPane.YES_OPTION;
+ if (nbMonth != 12) {
+ response = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.addfiscalperiod.morethan12"),
+ _("lima.ui.fiscalperiod.addfiscalperiodtitle"),
+ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+ }
+
+ return response;
+ }
+
}
1
0
r3455 - trunk/lima-callao/src/main/java/org/chorem/lima/entity
by mallon@users.chorem.org June 19, 2012
by mallon@users.chorem.org June 19, 2012
June 19, 2012
Author: mallon
Date: 2012-06-19 10:57:25 +0200 (Tue, 19 Jun 2012)
New Revision: 3455
Url: http://chorem.org/repositories/revision/lima/3455
Log:
L'ajout de plus de deux exercices avec des dates correctes est d?\195?\169sormais possible.
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-06-18 16:31:34 UTC (rev 3454)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-06-19 08:57:25 UTC (rev 3455)
@@ -83,7 +83,7 @@
*/
public FiscalPeriod getLastFiscalPeriod() throws TopiaException {
String query = "FROM " + FiscalPeriod.class.getName() +
- " ORDER BY endDate";
+ " ORDER BY endDate desc";
List<FiscalPeriod> fiscalPeriods = context.find(query);
FiscalPeriod result = null;
1
0
June 18, 2012
Author: mallon
Date: 2012-06-18 18:31:34 +0200 (Mon, 18 Jun 2012)
New Revision: 3454
Url: http://chorem.org/repositories/revision/lima/3454
Log:
La suppression des exercices(Ceux ouverts et vides) est d?\195?\169sormais possible, via un bouton de suppression, ajout?\195?\169 au panneau des gestion des exercices.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.out.xml
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.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/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/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -73,6 +73,8 @@
List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
/**
* Entry rules
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -116,6 +116,12 @@
}
+ /** Rules to check before delete fiscals periods */
+ @Override
+ public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod)
+ throws LimaException {
+ }
+
/**
* Rules to check if an account and all his subaccount is not used
* Recursive function
@@ -401,4 +407,5 @@
throw new LimaException("Can't check financial transaction", ex);
}
}
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -37,6 +37,7 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.nuiton.topia.TopiaException;
@@ -194,6 +195,28 @@
}
/**
+ * Règles de vérification de supression d'un exercice, appliquées à la comptabilité française.
+ *
+ * On ne peut supprimer qu'une periode comptable ouverte vide.
+ */
+ @Override
+ public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaBusinessException {
+
+ try {
+
+ FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
+
+ //Check if the fiscal period to delete is empty
+ if (financialTransactionDAO.findAllByDates(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()).size() != 0) {
+ throw new LimaBusinessException(_("lima-business.franceaccountingrules.fiscalperiodnotempty"));
+ }
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't check rule", ex);
+ }
+
+ }
+
+ /**
* Check if old financialperiod for a an entrybook are closed before bock the asked closedperiodicentrybook
* <p/>
* get all closedperiodicentrybook between the first financial period of fiscalperiod
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -58,6 +58,8 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
+import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryImpl;
@@ -447,4 +449,49 @@
}
}
+ @Override
+ /**
+ * to delete a fiscal period
+ * <p/>
+ * check localized rules before delete it
+ */
+ public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod)
+ throws LimaException {
+
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+
+ try {
+ try {
+ //get entities with DAO
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
+
+ // re-attach entities to current session
+ FiscalPeriod localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId());
+
+ //check rules
+ accountingRules.deleteFiscalPeriodRules(localFiscalPeriod);
+
+ //all "ClosedPeriodicEntryBooks" for the fiscal period
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookDAOList = closedPeriodicEntryBookDAO.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod);
+
+ //delete closedPeriodicEntryBook before fiscal period
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookDAOList) {
+ // fix : ObjectDeletedException: deleted object would be re-saved by cascade (Need to delete association between entryBook and financial period via closedPeriodEntityBook)
+ closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ closedPeriodicEntryBookDAO.delete(closedPeriodicEntryBook);
+ }
+
+ fiscalPeriodDAO.delete(localFiscalPeriod);
+
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't find fiscal period", ex);
+ }
+
+ } catch (Exception ex) {
+ throw new LimaException("Can't delete period", ex);
+ }
+
+ }
+
}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-18 16:31:34 UTC (rev 3454)
@@ -68,6 +68,7 @@
lima-business.franceaccountingrules.accountstartnumbererror=Master account is not a digit between 1 to 8 \: %d
lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=The previous financial periods for this entrybook must be blocked before this
lima-business.franceaccountingrules.antefiscalperiodnotblocked=The ante fiscal period is not locked
+lima-business.franceaccountingrules.fiscalperiodnotempty=The fiscal period is not empty \!
lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=The new fiscal period must adjoining the last
lima-business.import.accountadded=SUCCES \: Account %s - %s added\n
lima-business.import.accountalreadyexist=FAILED \: Account %s already exist \n
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-18 16:31:34 UTC (rev 3454)
@@ -67,8 +67,9 @@
lima-business.franceaccountingrules.accountnumbernotnumeric=Le numéro de copte n'est pas numéric \: %s
lima-business.franceaccountingrules.accountstartnumbererror=Le numéro du copte général n'est pas compris entre 1 et 8 \: %d
lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=Les périodes financières précédentes pour ce journal doivent être bloquées avant
-lima-business.franceaccountingrules.antefiscalperiodnotblocked=La période fiscale précédante n'est pas bloquée
-lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=La nouvelle période fiscale doit suivre la précédante
+lima-business.franceaccountingrules.antefiscalperiodnotblocked=La période fiscale précédente n'est pas bloquée
+lima-business.franceaccountingrules.fiscalperiodnotempty=La période fiscale à supprimer n'est pas vide \!
+lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=La nouvelle période fiscale doit suivre la précédente
lima-business.import.accountadded=Succès \: Compte %s - %s ajouté\n
lima-business.import.accountalreadyexist=Échec \: Le compte %s existe déjà \n
lima-business.import.closedperiodicentrybookupdated=Succès \: La période financière %s - %s - %s est ajoutée \! \n
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -53,6 +53,8 @@
FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
void addRetainedEarnings(FiscalPeriod fiscalPeriod,
boolean newyear,
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -175,5 +175,23 @@
List<ClosedPeriodicEntryBook> result = context.find(query);
return result;
}
+
+ /**
+ * Retourne les ClosedPeriodicEntryBook d'un exercice ouvert.
+ *
+ * @return les ClosedPeriodicEntryBook
+ * @throws TopiaException
+ */
+ public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromFiscalPeriod(FiscalPeriod fiscalPeriod) throws TopiaException {
+ String query = "SELECT C FROM " + ClosedPeriodicEntryBook.class.getName() + " C" +
+ ", " + FiscalPeriod.class.getName() + " F" +
+ " WHERE C.financialPeriod IN ELEMENTS (F.financialPeriod)" +
+ " AND F = :fiscalPeriod" +
+ " ORDER BY C.financialPeriod.beginDate";
+
+ List<ClosedPeriodicEntryBook> result = context.find(query, "fiscalPeriod", fiscalPeriod);
+ return result;
+ }
+
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -112,5 +112,5 @@
}
return result;
- }
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -129,6 +129,12 @@
fireTableRowsInserted(row, row);
}
+ public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) {
+ int row = fiscalPeriods.indexOf(fiscalPeriod);
+ fiscalPeriods.remove(fiscalPeriod);
+ fireTableRowsDeleted(row, row);
+ }
+
public void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
/*List<FinancialTransaction> financialTransactionsUnbal =
financialTransactionService.getAllInexactFinancialTransactions(fiscalPeriod);
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 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2012-06-18 16:31:34 UTC (rev 3454)
@@ -48,7 +48,9 @@
id="fiscalPeriodTable" sortable="false" rowHeight="24"
constructorParams="getFiscalPeriodTableModel()"
selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
- columnControlVisible="true"/>
+ columnControlVisible="true"
+ onActionPerformed="getHandler().reloadEnablingButton()"
+ />
<ListSelectionModel
javaBean="getFiscalPeriodTable().getSelectionModel()"
onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/>
@@ -68,4 +70,18 @@
onActionPerformed="getHandler().blockFiscalPeriod()"/>
</cell>
</row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="deleteButton" text="lima.charts.fiscalperiod.delete"
+ enabled="{isSelectedPeriod()}"
+ onActionPerformed="getHandler().deleteFiscalPeriod()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="modifyButton" text="lima.charts.fiscalperiod.delete"
+ enabled="{isSelectedPeriod()}"
+ onActionPerformed="getHandler().deleteFiscalPeriod()"/>
+ </cell>
+ </row>
</Table>
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.out.xml
===================================================================
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 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-06-18 16:31:34 UTC (rev 3454)
@@ -129,6 +129,30 @@
}
/**
+ * Undisplay period and perform delete.
+ */
+ public void deleteFiscalPeriod() {
+
+ JXTable fiscalPeriodeTable = view.getFiscalPeriodTable();
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) view.getFiscalPeriodTable().getModel();
+
+ //check if the user want to delete the fiscal year
+ int response = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.delete.confirmation"),
+ _("lima.ui.fiscalperiod.delete.title"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+
+ int selectedRow = fiscalPeriodeTable.getSelectedRow();
+ FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
+
+ if (response == JOptionPane.YES_OPTION) {
+ fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
+
+ model.deleteFiscalPeriod(selectedFiscalPeriod);
+ }
+ }
+
+ /**
* Init add period view.
*
* @param addPeriod view to init
@@ -265,4 +289,11 @@
loadAllFiscalPeriod();
}
}
+
+ /**
+ * manage
+ * */
+ public void reloadEnablingButton(){
+
+ }
}
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 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-06-18 16:31:34 UTC (rev 3454)
@@ -25,6 +25,7 @@
lima.charts.fiscalperiod.add=Add fiscalperiod
lima.charts.fiscalperiod.block=Block fiscalperiod
lima.charts.fiscalperiod.create=Create fiscalperiod
+lima.charts.fiscalperiod.delete=Delete fiscalperiod
lima.charts.fiscalyear=Fiscal Years
lima.charts.vatpdf=PDF structure
lima.charts.vatstatement=VAT statement chart
@@ -263,6 +264,8 @@
lima.ui.fiscalperiod.block.title=
lima.ui.fiscalperiod.closed=
lima.ui.fiscalperiod.closure=
+lima.ui.fiscalperiod.delete.confirmation=
+lima.ui.fiscalperiod.delete.title=
lima.ui.fiscalperiod.fiscalperiod=
lima.ui.fiscalperiod.open=
lima.ui.home.account=
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-07 14:14:32 UTC (rev 3453)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-18 16:31:34 UTC (rev 3454)
@@ -25,6 +25,7 @@
lima.charts.fiscalperiod.add=Nouvel exercice
lima.charts.fiscalperiod.block=Cloturer un exercice
lima.charts.fiscalperiod.create=Choisissez la date de début et de fin du nouvel exercice
+lima.charts.fiscalperiod.delete=Supprimer un exercice
lima.charts.fiscalyear=Exercices
lima.charts.vatpdf=Structure du pdf
lima.charts.vatstatement=Plan TVA
@@ -263,6 +264,8 @@
lima.ui.fiscalperiod.block.title=Cloture de l'exercice
lima.ui.fiscalperiod.closed=Cloturé
lima.ui.fiscalperiod.closure=Cloture
+lima.ui.fiscalperiod.delete.confirmation=Ètes vous sûre de vouloir supprimer cette période ? Cette action est irréversible \!
+lima.ui.fiscalperiod.delete.title=Suppression de l'exercice
lima.ui.fiscalperiod.fiscalperiod=Exercice
lima.ui.fiscalperiod.open=Ouvert
lima.ui.home.account=Plan comptable
1
0
r3453 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports
by echatellier@users.chorem.org June 7, 2012
by echatellier@users.chorem.org June 7, 2012
June 7, 2012
Author: echatellier
Date: 2012-06-07 16:14:32 +0200 (Thu, 07 Jun 2012)
New Revision: 3453
Url: http://chorem.org/repositories/revision/lima/3453
Log:
Uncomment code (just for testing)
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-07 08:04:04 UTC (rev 3452)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-07 14:14:32 UTC (rev 3453)
@@ -187,16 +187,13 @@
}
//shows error message to user if the fiscalPeriod is unblocked
- //FIXME echatellier 20120605 why ?
- // ui is only filled with non blocked periods, else case
- // can NEVER happen
- /*if (error) {
+ if (error) {
JOptionPane.showMessageDialog(
view,
_("lima.entrybooksreports.documentcreationfiscalerror"),
_("lima.entrybooksreports.documentcreationfiscaltitle"),
JOptionPane.ERROR_MESSAGE);
- } else {*/
+ } else {
int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
@@ -222,7 +219,7 @@
} catch (URISyntaxException e) {
log.error("Can't create news URI", e);
}
- //}
+ }
}
}
1
0
r3452 - in trunk/lima-business/src/main: java/org/chorem/lima/business/ejb resources/i18n
by echatellier@users.chorem.org June 7, 2012
by echatellier@users.chorem.org June 7, 2012
June 7, 2012
Author: echatellier
Date: 2012-06-07 10:04:04 +0200 (Thu, 07 Jun 2012)
New Revision: 3452
Url: http://chorem.org/repositories/revision/lima/3452
Log:
Amelioration du rapport journal general
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 15:32:14 UTC (rev 3451)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-07 08:04:04 UTC (rev 3452)
@@ -715,9 +715,6 @@
return t;
}
- //############## EntryBooks ##############
-
-
@Override
public void createEntryBooksDocuments(Date beginDate,
Date endDate,
@@ -779,39 +776,24 @@
String title = _("lima-business.document.entrybooktitle",
closedPeriodicEntryBook.getEntryBook().getLabel(),
closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
- //list = list.subList(1, list.size());
- int i = 0;
- int n = entries.size();
- int max = n;
- // alloc nb rows max for pdf documents on one page
- if (format == FormatsEnum.PDF) {
- max = 35;
- }
- while (i < n) {
- int j = i + max;
- if (j > n) {
- j = n;
- }
- List<Entry> subEntries =
- entries.subList(i, j);
- //create page
- Table table = createEntryBooksTable(subEntries, debit, credit);
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(title, identity,
- beginDate, endDate));
- //n° page
- chapter.add(createNumberPage(nbpages, newDate));
- //table
- Paragraph paragraphTable = new Paragraph();
- paragraphTable.add(table);
- chapter.add(paragraphTable);
- //add page
- document.add(chapter);
- i = i + max;
- nbpages++;
- }
+
+ //create page
+ Table table = createEntryBooksTable(entries, debit, credit);
+ //new page
+ Chapter chapter = new Chapter(0);
+ //headerPage
+ chapter.add(createHeaderPage(title, identity,
+ beginDate, endDate));
+ //n° page
+ chapter.add(createNumberPage(nbpages, newDate));
+ //table
+ Paragraph paragraphTable = new Paragraph();
+ paragraphTable.add(table);
+ chapter.add(paragraphTable);
+ //add page
+ document.add(chapter);
+
+ nbpages++;
}
document.close();
@@ -1203,45 +1185,28 @@
//create pages
- int i = 0;
- int n = list.size();
- int max = n;
- // alloc nb rows max for pdf documents on one page
- if (format == FormatsEnum.PDF) {
- max = 35;
- }
- while (i < n) {
- int j = i + max;
- if (j > n) {
- j = n;
- }
- List<GeneralEntryBooksDatas> subList =
- list.subList(i, j);
- //create page : header + table + footer
- Table headerTable = createGeneralEntryBooksHeaderTable();
- Table table = createGeneralEntryBooksTable(subList);
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(
- DocumentsEnum.GENERAL_ENTRYBOOK.getDescription(),
- identity, beginDate,
- endDate));
- //n° page
- chapter.add(createNumberPage(nbpages, newDate));
- //headerTable
- Paragraph paragraphHeaderTable = new Paragraph();
- paragraphHeaderTable.add(headerTable);
- chapter.add(paragraphHeaderTable);
- //table
- Paragraph paragraphTable = new Paragraph();
- paragraphTable.add(table);
- chapter.add(paragraphTable);
- //add page
- document.add(chapter);
- i = i + max;
- nbpages++;
- }
+ Table headerTable = createGeneralEntryBooksHeaderTable();
+ Table table = createGeneralEntryBooksTable(list);
+ //new page
+ Chapter chapter = new Chapter(0);
+ //headerPage
+ chapter.add(createHeaderPage(
+ DocumentsEnum.GENERAL_ENTRYBOOK.getDescription(),
+ identity, beginDate,
+ endDate));
+ //n° page
+ chapter.add(createNumberPage(nbpages, newDate));
+ //headerTable
+ Paragraph paragraphHeaderTable = new Paragraph();
+ paragraphHeaderTable.add(headerTable);
+ chapter.add(paragraphHeaderTable);
+ //table
+ Paragraph paragraphTable = new Paragraph();
+ paragraphTable.add(table);
+ chapter.add(paragraphTable);
+ //add page
+ document.add(chapter);
+ nbpages++;
document.close();
@@ -1250,7 +1215,7 @@
}
}
- public Table createGeneralEntryBooksHeaderTable() {
+ protected Table createGeneralEntryBooksHeaderTable() {
Table t = null;
try {
t = new Table(5, 1);
@@ -1314,8 +1279,7 @@
phrase = new Phrase(_("lima-business.document.amounts"),
boldFont);
} else {
- phrase = new Phrase(_("lima-business.document.amounts")
- + " " + generalEntryBooksDatas.getPeriod(),
+ phrase = new Phrase(_("lima-business.document.amountsperiod", generalEntryBooksDatas.getPeriod()),
boldFont);
}
Cell cell2 = new Cell(phrase);
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-06 15:32:14 UTC (rev 3451)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-07 08:04:04 UTC (rev 3452)
@@ -19,6 +19,7 @@
lima-business.defaultaccountingrules.missingentrybook=Can't block financialperiod / missing EntryBook in transactions
lima-business.document.accountnumber=Account N°
lima-business.document.amounts=Amounts
+lima-business.document.amountsperiod=Amounts %1$tB %1$tY
lima-business.document.balance=Balance
lima-business.document.businessnumber=Business N°
lima-business.document.carryback=Carry Back
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-06 15:32:14 UTC (rev 3451)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-07 08:04:04 UTC (rev 3452)
@@ -19,6 +19,7 @@
lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
lima-business.document.accountnumber=N° Compte
lima-business.document.amounts=Totaux
+lima-business.document.amountsperiod=Totaux %1$tB %1$tY
lima-business.document.balance=Balance
lima-business.document.businessnumber=N° Siret
lima-business.document.carryback=Report
1
0
r3451 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by echatellier@users.chorem.org June 6, 2012
by echatellier@users.chorem.org June 6, 2012
June 6, 2012
Author: echatellier
Date: 2012-06-06 17:32:14 +0200 (Wed, 06 Jun 2012)
New Revision: 3451
Url: http://chorem.org/repositories/revision/lima/3451
Log:
Correction des 3 trois tableaux diff?\195?\169rents qui causait un probl?\195?\168me d'alignement des colonnes.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 14:08:42 UTC (rev 3450)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 15:32:14 UTC (rev 3451)
@@ -75,6 +75,7 @@
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
+import com.lowagie.text.DocWriter;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
@@ -728,12 +729,13 @@
String filePath = path + File.separator + DocumentsEnum.ENTRYBOOKS.getFileName();
FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
+ DocWriter writer = null;
switch (format) {
case HTML:
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
+ writer = HtmlWriter.getInstance(document, fileOut);
break;
case PDF:
- PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
+ writer = PdfWriter.getInstance(document, fileOut);
break;
}
document.open();
@@ -758,8 +760,8 @@
List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- BigDecimal debit = null;
- BigDecimal credit = null;
+ BigDecimal debit = BigDecimal.ZERO;
+ BigDecimal credit = BigDecimal.ZERO;
int nbAmount = results.size();
if (nbAmount == 2) {
debit = (BigDecimal) results.get(0)[1];
@@ -792,9 +794,8 @@
}
List<Entry> subEntries =
entries.subList(i, j);
- //create page : header + table + footer
- Table headerTable = createEntryBooksHeaderTable();
- Table table = createEntryBooksTable(subEntries);
+ //create page
+ Table table = createEntryBooksTable(subEntries, debit, credit);
//new page
Chapter chapter = new Chapter(0);
//headerPage
@@ -802,21 +803,10 @@
beginDate, endDate));
//n° page
chapter.add(createNumberPage(nbpages, newDate));
- //headerTable
- Paragraph paragraphHeaderTable = new Paragraph();
- paragraphHeaderTable.add(headerTable);
- chapter.add(paragraphHeaderTable);
//table
Paragraph paragraphTable = new Paragraph();
paragraphTable.add(table);
chapter.add(paragraphTable);
- //final amounts
- if (i >= n - max) {
- Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createEntryBooksAmountTable(
- _("lima-business.document.amounts"), debit, credit));
- chapter.add(finalAmountParagraph);
- }
//add page
document.add(chapter);
i = i + max;
@@ -825,52 +815,45 @@
}
document.close();
-
+ writer.close();
} catch (Exception ex) {
throw new LimaException("Can't create document", ex);
}
}
-
- protected Table createEntryBooksHeaderTable() {
- Table t = null;
- try {
- t = new Table(6, 1);
- float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setWidth(100f);
- t.setPadding(3f);
- //defaut cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.LEFT);
- cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- t.setDefaultCell(cell);
- t.setOffset(8);
- t.addCell(new Phrase(_("lima-business.document.date"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.accountnumber"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.voucher"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.description"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.debit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.credit"), boldFont));
-
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
-
- }
-
- protected Table createEntryBooksTable(List<Entry> entries) {
+
+ protected Table createEntryBooksTable(List<Entry> entries, BigDecimal debit, BigDecimal credit) {
int nbrow = entries.size();
Table t = null;
try {
//define table
- t = new Table(6, nbrow);
+ t = new Table(6, nbrow + 1);
t.setWidth(100f);
float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f};
t.setWidths(widths);
t.setPadding(1.5f);
t.setBorderWidth(1);
t.setOffset(0);
+
+ Cell cell1 = new Cell(_("lima-business.document.date"));
+ cell1.setHeader(true);
+ t.addCell(cell1);
+ Cell cell2 = new Cell(_("lima-business.document.accountnumber"));
+ cell2.setHeader(true);
+ t.addCell(cell2);
+ Cell cell3 = new Cell(_("lima-business.document.voucher"));
+ cell3.setHeader(true);
+ t.addCell(cell3);
+ Cell cell4 = new Cell(_("lima-business.document.description"));
+ cell4.setHeader(true);
+ t.addCell(cell4);
+ Cell cell5 = new Cell(_("lima-business.document.debit"));
+ cell5.setHeader(true);
+ t.addCell(cell5);
+ Cell cell6 = new Cell(_("lima-business.document.credit"));
+ cell6.setHeader(true);
+ t.addCell(cell6);
+ t.endHeaders();
+
//define default cell
Cell cell = new Cell();
cell.setBorder(Rectangle.LEFT);
@@ -892,33 +875,15 @@
t.addCell(new Phrase(String.valueOf(
!entry.getDebit() ? entry.getAmount() : 0), normalFont));
}
-
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
- }
-
- protected Table createEntryBooksAmountTable(String title,
- BigDecimal credit,
- BigDecimal debit) {
- Table t = null;
- try {
- t = new Table(3, 1);
- float[] widths = {0.7f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setWidth(100f);
- t.setPadding(3f);
- t.setOffset(0);
- //defaut cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.RIGHT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
-
- t.addCell(new Phrase(title, boldFont));
+
+ // total
+ Cell cellTotal = new Cell(new Phrase(_("lima-business.document.amounts"), boldFont));
+ cellTotal.setColspan(4);
+ cellTotal.setHorizontalAlignment(Element.ALIGN_RIGHT);
+ t.addCell(cellTotal);
t.addCell(new Phrase(debit.toString(), boldFont));
t.addCell(new Phrase(credit.toString(), boldFont));
+
} catch (BadElementException eeBEE) {
log.error("Can't create table", eeBEE);
}
@@ -1187,8 +1152,8 @@
BigDecimal subAmountCredit = new BigDecimal(0);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- BigDecimal debit = null;
- BigDecimal credit = null;
+ BigDecimal debit = BigDecimal.ZERO;
+ BigDecimal credit = BigDecimal.ZERO;
List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
1
0
r3450 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by echatellier@users.chorem.org June 6, 2012
by echatellier@users.chorem.org June 6, 2012
June 6, 2012
Author: echatellier
Date: 2012-06-06 16:08:42 +0200 (Wed, 06 Jun 2012)
New Revision: 3450
Url: http://chorem.org/repositories/revision/lima/3450
Log:
Fix debit/credit affich?\195?\169 a chaque fois
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 14:06:43 UTC (rev 3449)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 14:08:42 UTC (rev 3450)
@@ -890,7 +890,7 @@
t.addCell(new Phrase(String.valueOf(
entry.getDebit() ? entry.getAmount() : 0), normalFont));
t.addCell(new Phrase(String.valueOf(
- entry.getDebit() ? entry.getAmount() : 0), normalFont));
+ !entry.getDebit() ? entry.getAmount() : 0), normalFont));
}
} catch (BadElementException eeBEE) {
1
0
r3449 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by echatellier@users.chorem.org June 6, 2012
by echatellier@users.chorem.org June 6, 2012
June 6, 2012
Author: echatellier
Date: 2012-06-06 16:06:43 +0200 (Wed, 06 Jun 2012)
New Revision: 3449
Url: http://chorem.org/repositories/revision/lima/3449
Log:
Add doc
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 13:36:35 UTC (rev 3448)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 14:06:43 UTC (rev 3449)
@@ -34,7 +34,6 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -321,7 +320,7 @@
}
}
- public Table createFinancialStatementsHeaderTable() {
+ protected Table createFinancialStatementsHeaderTable() {
Table t = null;
try {
t = new Table(4, 1);
@@ -351,7 +350,7 @@
}
- public Table createFinancialStatementsTable(List<FinancialStatementAmounts> financialStatementAmounts) {
+ protected Table createFinancialStatementsTable(List<FinancialStatementAmounts> financialStatementAmounts) {
int nbrow = financialStatementAmounts.size();
Table t = null;
try {
@@ -576,7 +575,7 @@
}
}
- public Table createLedgerHeaderTable() {
+ protected Table createLedgerHeaderTable() {
Table t = null;
try {
t = new Table(7, 1);
@@ -605,7 +604,7 @@
}
- public Table createLedgerTable(List<Object> subList) {
+ protected Table createLedgerTable(List<Object> subList) {
int nbrow = subList.size();
Table t = null;
try {
@@ -683,7 +682,7 @@
return t;
}
- public Table createLedgerAmountTable(String account,
+ protected Table createLedgerAmountTable(String account,
String title,
BigDecimal debit,
BigDecimal credit) {
@@ -832,7 +831,7 @@
}
}
- public Table createEntryBooksHeaderTable() {
+ protected Table createEntryBooksHeaderTable() {
Table t = null;
try {
t = new Table(6, 1);
@@ -900,7 +899,7 @@
return t;
}
- public Table createEntryBooksAmountTable(String title,
+ protected Table createEntryBooksAmountTable(String title,
BigDecimal credit,
BigDecimal debit) {
Table t = null;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-06-06 13:36:35 UTC (rev 3448)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-06-06 14:06:43 UTC (rev 3449)
@@ -107,14 +107,14 @@
}
}
-
@Override
public int getHttpPort() {
return port;
}
-
- /** this servlet send a static html page */
+ /**
+ * This servlet send a static html page.
+ */
public class MainServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -145,8 +145,7 @@
//if doc pdf or html
else if (model != null && format != null && beginDate != null && endDate != null) {
FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format);
- URL doc = new URL("file:" + path + File.separator
- + model + formatsEnum.getExtension());
+
//create docs
try {
Date beginDateFormat = DATEFORMAT.parse(beginDate);
@@ -184,6 +183,12 @@
} catch (ParseException eeePE) {
log.error("Can't parse date", eeePE);
}
+
+ // FIXME echatellier 20120606 on connait le fichier
+ // ou sera généré le rapport, et on peut donc le relire
+ // après génération
+ // fonctionne pour le moment, mais a modifier
+ URL doc = new URL("file:" + path + File.separator + model + formatsEnum.getExtension());
resp.setContentType(formatsEnum.getMimeType());
InputStream in = doc.openStream();
OutputStream out = resp.getOutputStream();
@@ -276,8 +281,6 @@
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req, resp);
-
}
}
-
}
1
0
r3448 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/resources/i18n lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports
by echatellier@users.chorem.org June 6, 2012
by echatellier@users.chorem.org June 6, 2012
June 6, 2012
Author: echatellier
Date: 2012-06-06 15:36:35 +0200 (Wed, 06 Jun 2012)
New Revision: 3448
Url: http://chorem.org/repositories/revision/lima/3448
Log:
D?\195?\169placement des dateformat en dur dans les fichiers i18n
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 13:36:02 UTC (rev 3447)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-06-06 13:36:35 UTC (rev 3448)
@@ -93,7 +93,6 @@
@TransactionAttribute
public class DocumentServiceImpl extends AbstractLimaService implements DocumentService {
- //Services
@EJB
private IdentityService identityService;
@@ -108,17 +107,6 @@
protected String path;
- //SDFs
- private static final SimpleDateFormat dateFormat =
- new SimpleDateFormat("dd/MM/yyyy");
-
- private static final SimpleDateFormat hourFormat =
- new SimpleDateFormat("HH:mm");
-
- private static final SimpleDateFormat monthYearFormat =
- new SimpleDateFormat("MMM yyyy");
-
- //FONTs
private static final Font titleFont =
new Font(Font.HELVETICA, 14, Font.BOLD, Color.BLACK);
@@ -134,16 +122,23 @@
private static final Font bolditalicFont =
new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK);
-
public DocumentServiceImpl() {
path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
}
-
- public Paragraph createHeaderPage(String title,
+ /**
+ * Crée l'entete du document avec le titre, l'ientité, et les dates.
+ *
+ * @param title
+ * @param identity
+ * @param beginDate
+ * @param endDate
+ * @return
+ */
+ protected Paragraph createHeaderPage(String title,
Identity identity,
- String beginDate,
- String endDate) {
+ Date beginDate,
+ Date endDate) {
Paragraph paragraphHeaderPage = new Paragraph();
Table t = null;
try {
@@ -186,14 +181,14 @@
t.addCell("");
t.addCell(new Phrase(_("lima-business.document.period1"),
bolditalicFont));
- t.addCell(new Phrase(beginDate, italicFont));
+ t.addCell(new Phrase(_("lima-business.document.period1format", beginDate), italicFont));
//line 5
t.addCell(new Phrase(identity.getZipCode() + " " + identity.getCity(),
italicFont));
t.addCell("");
t.addCell(new Phrase(_("lima-business.document.period2"),
bolditalicFont));
- t.addCell(new Phrase(endDate, italicFont));
+ t.addCell(new Phrase(_("lima-business.document.period2format", endDate), italicFont));
} catch (BadElementException eeBEE) {
log.error("Can't create table", eeBEE);
}
@@ -202,10 +197,15 @@
return paragraphHeaderPage;
}
-
- public Paragraph createNumberPage(int nbPages,
- String dateS,
- String hourS) throws BadElementException {
+ /**
+ * Sous tableau.
+ *
+ * @param nbPages
+ * @param date
+ * @return
+ * @throws BadElementException
+ */
+ protected Paragraph createNumberPage(int nbPages, Date date) throws BadElementException {
//n° page
Paragraph paragraphPage = new Paragraph();
Table infos = new Table(2);
@@ -216,18 +216,12 @@
c.setBorder(Rectangle.NO_BORDER);
c.setHorizontalAlignment(Element.ALIGN_CENTER);
infos.setDefaultCell(c);
- infos.addCell(new Phrase(_("lima-business.document.createdate1")
- + dateS + _("lima-business.document.createdate2")
- + hourS, normalFont));
- infos.addCell(new Phrase(_("lima-business.document.pagenumber")
- + nbPages, normalFont));
+ infos.addCell(new Phrase(_("lima-business.document.createdate", date), normalFont));
+ infos.addCell(new Phrase(_("lima-business.document.pagenumber", nbPages), normalFont));
paragraphPage.add(infos);
return paragraphPage;
}
- //############## FinancialStatements ##############
-
-
@Override
public void createFinancialStatementsDocuments(Date beginDate,
Date endDate,
@@ -238,9 +232,6 @@
financialStatementService.financialStatementReport(beginDate, endDate);
Date newDate = new Date();
- String dateS = dateFormat.format(newDate);
- String hourS = hourFormat.format(newDate);
-
String filePath = path + File.separator + DocumentsEnum.FINANCIALSTATEMENT.getFileName();
try {
@@ -303,10 +294,9 @@
//new page
Chapter chapter = new Chapter(0);
//headerPage
- chapter.add(createHeaderPage(title, identity,
- dateFormat.format(beginDate), dateFormat.format(endDate)));
+ chapter.add(createHeaderPage(title, identity, beginDate, endDate));
//n° page
- chapter.add(createNumberPage(nbpages, dateS, hourS));
+ chapter.add(createNumberPage(nbpages, newDate));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -480,8 +470,6 @@
}
Date newDate = new Date();
- String dateS = dateFormat.format(newDate);
- String hourS = hourFormat.format(newDate);
BigDecimal currentAmountDebit = new BigDecimal(0);
BigDecimal currentAmountCredit = new BigDecimal(0);
@@ -521,9 +509,9 @@
Chapter chapter = new Chapter(0);
//headerPage
chapter.add(createHeaderPage(DocumentsEnum.LEDGER.getDescription(), identity,
- dateFormat.format(beginDate), dateFormat.format(endDate)));
+ beginDate, endDate));
//n° page
- chapter.add(createNumberPage(nbpages, dateS, hourS));
+ chapter.add(createNumberPage(nbpages, newDate));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -673,9 +661,8 @@
amountCredit = entry.getAmount();
}
- t.addCell(new Phrase(dateFormat.format(
- entry.getFinancialTransaction().getTransactionDate()),
- normalFont));
+ t.addCell(new Phrase(_("lima-business.document.dateformat",
+ entry.getFinancialTransaction().getTransactionDate()), normalFont));
t.addCell(new Phrase(entryBookCode, normalFont));
t.addCell(new Phrase(entry.getVoucher(), normalFont));
t.addCell(new Phrase(entry.getDescription(), normalFont));
@@ -739,8 +726,6 @@
try {
Date newDate = new Date();
- String dateS = dateFormat.format(newDate);
- String hourS = hourFormat.format(newDate);
String filePath = path + File.separator + DocumentsEnum.ENTRYBOOKS.getFileName();
FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
@@ -790,8 +775,8 @@
}
//create pages
- String title = closedPeriodicEntryBook.getEntryBook().getLabel()
- + "\n" + monthYearFormat.format(
+ String title = _("lima-business.document.entrybooktitle",
+ closedPeriodicEntryBook.getEntryBook().getLabel(),
closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
//list = list.subList(1, list.size());
int i = 0;
@@ -815,9 +800,9 @@
Chapter chapter = new Chapter(0);
//headerPage
chapter.add(createHeaderPage(title, identity,
- dateFormat.format(beginDate), dateFormat.format(endDate)));
+ beginDate, endDate));
//n° page
- chapter.add(createNumberPage(nbpages, dateS, hourS));
+ chapter.add(createNumberPage(nbpages, newDate));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -875,7 +860,7 @@
}
- public Table createEntryBooksTable(List<Entry> entries) {
+ protected Table createEntryBooksTable(List<Entry> entries) {
int nbrow = entries.size();
Table t = null;
try {
@@ -894,9 +879,8 @@
t.setDefaultCell(cell);
for (Entry entry : entries) {
- t.addCell(new Phrase(dateFormat.format(
- entry.getFinancialTransaction().getTransactionDate()),
- normalFont));
+ t.addCell(new Phrase(_("lima-business.document.dateformat",
+ entry.getFinancialTransaction().getTransactionDate()), normalFont));
String account = "";
if (entry.getAccount() != null) {
account = entry.getAccount().getAccountNumber();
@@ -957,9 +941,6 @@
try {
Date newDate = new Date();
- String dateS = dateFormat.format(newDate);
- String hourS = hourFormat.format(newDate);
-// String fileDateS = filedateFormat.format(newDate);
BigDecimal currentAmountDebit = new BigDecimal(0);
BigDecimal currentAmountCredit = new BigDecimal(0);
@@ -999,9 +980,10 @@
//new page
Chapter chapter = new Chapter(0);
//headerPage
- chapter.add(createHeaderPage(DocumentsEnum.BALANCE.getDescription(), identity, dateFormat.format(beginDate), dateFormat.format(endDate)));
+ chapter.add(createHeaderPage(DocumentsEnum.BALANCE.getDescription(),
+ identity, beginDate, endDate));
//n° page
- chapter.add(createNumberPage(nbpages, dateS, hourS));
+ chapter.add(createNumberPage(nbpages, newDate));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -1169,8 +1151,6 @@
try {
Date newDate = new Date();
- String dateS = dateFormat.format(newDate);
- String hourS = hourFormat.format(newDate);
String filePath = path + File.separator + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
@@ -1233,8 +1213,7 @@
closedPeriodicEntryBook.getEntryBook().getCode());
generalEntryBooksDatas.setDescription(
closedPeriodicEntryBook.getEntryBook().getLabel());
- generalEntryBooksDatas.setPeriod(
- monthYearFormat.format(financialPeriod.getBeginDate()));
+ generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
generalEntryBooksDatas.setCredit(credit);
generalEntryBooksDatas.setDebit(debit);
list.add(generalEntryBooksDatas);
@@ -1246,8 +1225,7 @@
generalEntryBooksDatas.setSubAmount(true);
generalEntryBooksDatas.setCredit(subAmountCredit);
generalEntryBooksDatas.setDebit(subAmountDebit);
- generalEntryBooksDatas.setPeriod(
- monthYearFormat.format(financialPeriod.getBeginDate()));
+ generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
list.add(generalEntryBooksDatas);
amountCredit = amountCredit.add(subAmountCredit);
amountDebit = amountDebit.add(subAmountDebit);
@@ -1283,10 +1261,10 @@
//headerPage
chapter.add(createHeaderPage(
DocumentsEnum.GENERAL_ENTRYBOOK.getDescription(),
- identity, dateFormat.format(beginDate),
- dateFormat.format(endDate)));
+ identity, beginDate,
+ endDate));
//n° page
- chapter.add(createNumberPage(nbpages, dateS, hourS));
+ chapter.add(createNumberPage(nbpages, newDate));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -1359,9 +1337,8 @@
generalEntryBooksDatas.getCode(), normalFont));
t.addCell(new Phrase(
generalEntryBooksDatas.getDescription(), normalFont));
+ t.addCell(new Phrase(_("lima-business.document.monthformat", generalEntryBooksDatas.getPeriod()), normalFont));
t.addCell(new Phrase(
- generalEntryBooksDatas.getPeriod(), normalFont));
- t.addCell(new Phrase(
String.valueOf(generalEntryBooksDatas.getDebit()),
normalFont));
t.addCell(new Phrase(
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-06 13:36:02 UTC (rev 3447)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-06 13:36:35 UTC (rev 3448)
@@ -24,26 +24,30 @@
lima-business.document.carryback=Carry Back
lima-business.document.carryforward=reporterÀ
lima-business.document.classificationcode=Classification Code
-lima-business.document.createdate1=Editing Date
-lima-business.document.createdate2=to
+lima-business.document.createdate=Editing Date %1$tm/%1$te/%1$tY at %1$tH\:%1$tM
lima-business.document.credit=Credit
lima-business.document.date=Date
lima-business.document.date.begin=Begin date
lima-business.document.date.end=End date
+lima-business.document.dateformat=%1$tm/%1$te/%1$tY
lima-business.document.debit=Debit
lima-business.document.description=Description
lima-business.document.entrybook=EntryBook
+lima-business.document.entrybooktitle=%s\n%2$tB %2$tY
lima-business.document.financialstatement=FinancialStatement
lima-business.document.generalentrybook=General EntryBook
lima-business.document.grossamount=Gross Amount
lima-business.document.label=Label
lima-business.document.ledger=Ledger
+lima-business.document.monthformat=%1$tB %1$tY
lima-business.document.movementcredit=Credit movement
lima-business.document.movementdebit=Debit movement
lima-business.document.netamount=Net Amount
-lima-business.document.pagenumber=Page N°
+lima-business.document.pagenumber=Page N° %d
lima-business.document.period1=Periode from
+lima-business.document.period1format=%1$tm/%1$te/%1$tY
lima-business.document.period2=to
+lima-business.document.period2format=%1$tm/%1$te/%1$tY
lima-business.document.provisiondeprecationamount=Provision Deprecation Amount
lima-business.document.solde=Solde
lima-business.document.soldecredit=Credit solde
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-06 13:36:02 UTC (rev 3447)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-06 13:36:35 UTC (rev 3448)
@@ -24,26 +24,30 @@
lima-business.document.carryback=Report
lima-business.document.carryforward=À reporter
lima-business.document.classificationcode=NAF
-lima-business.document.createdate1=Date de tirage
-lima-business.document.createdate2=à
+lima-business.document.createdate=Date de tirage %1$te/%1$tm/%1$tY à %1$tH\:%1$tM
lima-business.document.credit=Crédit
lima-business.document.date=Date
lima-business.document.date.begin=Date de début \:
lima-business.document.date.end=Date de fin \:
+lima-business.document.dateformat=%1$te/%1$tm/%1$tY
lima-business.document.debit=Débit
lima-business.document.description=Description
lima-business.document.entrybook=Journal
+lima-business.document.entrybooktitle=%s\n%2$tB %2$tY
lima-business.document.financialstatement=Bilan et compte de résultat
lima-business.document.generalentrybook=Journal Général
lima-business.document.grossamount=Brut
lima-business.document.label=Libellé
lima-business.document.ledger=Grand Livre
+lima-business.document.monthformat=%1$tB %1$tY
lima-business.document.movementcredit=Mouvement Créditeur
lima-business.document.movementdebit=Mouvement Débiteur
lima-business.document.netamount=Net
-lima-business.document.pagenumber=N° page
+lima-business.document.pagenumber=N° page %d
lima-business.document.period1=Période du
+lima-business.document.period1format=%1$te/%1$tm/%1$tY
lima-business.document.period2=au
+lima-business.document.period2format=%1$te/%1$tm/%1$tY
lima-business.document.provisiondeprecationamount=Amortissements et provisions
lima-business.document.solde=Solde
lima-business.document.soldecredit=Solde Créditeur
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-06 13:36:02 UTC (rev 3447)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-06 13:36:35 UTC (rev 3448)
@@ -187,13 +187,16 @@
}
//shows error message to user if the fiscalPeriod is unblocked
- if (error) {
+ //FIXME echatellier 20120605 why ?
+ // ui is only filled with non blocked periods, else case
+ // can NEVER happen
+ /*if (error) {
JOptionPane.showMessageDialog(
view,
_("lima.entrybooksreports.documentcreationfiscalerror"),
_("lima.entrybooksreports.documentcreationfiscaltitle"),
JOptionPane.ERROR_MESSAGE);
- } else {
+ } else {*/
int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
@@ -219,7 +222,7 @@
} catch (URISyntaxException e) {
log.error("Can't create news URI", e);
}
- }
+ //}
}
}
1
0
r3447 - trunk/lima-callao/src/main/java/org/chorem/lima/entity
by echatellier@users.chorem.org June 6, 2012
by echatellier@users.chorem.org June 6, 2012
June 6, 2012
Author: echatellier
Date: 2012-06-06 15:36:02 +0200 (Wed, 06 Jun 2012)
New Revision: 3447
Url: http://chorem.org/repositories/revision/lima/3447
Log:
Fix queries
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-05 16:05:09 UTC (rev 3446)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-06 13:36:02 UTC (rev 3447)
@@ -112,7 +112,7 @@
Date endDate) throws TopiaException {
String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
- " WHERE :begindate <= financialPeriod.beginDate " +
+ " WHERE :beginDate <= financialPeriod.beginDate " +
" AND financialPeriod.beginDate <= :endDate" +
" ORDER BY entryBook.code";
return context.find(query, "beginDate", beginDate, "endDate", endDate);
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-06-05 16:05:09 UTC (rev 3446)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-06-06 13:36:02 UTC (rev 3447)
@@ -108,8 +108,8 @@
public List<Entry> findAllEntryOfBalancedTransaction(EntryBook entryBook, Date beginDate,
Date endDate) throws TopiaException {
String query = getEquilibredTransactionQuery(beginDate, endDate) +
- // concerne le compte
- " AND E = :entryBook" +
+ // concerne le journal
+ " AND E.financialTransaction.entryBook = :entryBook" +
// fix order
" ORDER BY E.financialTransaction.transactionDate, E.financialTransaction.topiaId";
@@ -132,8 +132,8 @@
Date beginDate, Date endDate) throws TopiaException {
String query = "SELECT E.debit, sum(E.amount) " +
getEquilibredTransactionQuery(beginDate, endDate) +
- // concerne le compte
- " AND E = :entryBook" +
+ // concerne le journal
+ " AND E.financialTransaction.entryBook = :entryBook" +
" GROUP BY E.debit";
List<Object[]> result = context.find(query, "beginDate", beginDate,
@@ -156,8 +156,8 @@
// entre les 2 dates
" WHERE :beginDate <= E.financialTransaction.transactionDate" +
" AND E.financialTransaction.transactionDate <= :endDate" +
- // concerne le compte
- " AND E.entryBook = :entryBook";
+ // concerne le journal
+ " AND E.financialTransaction.entryBook = :entryBook";
List<Entry> entries = context.find(query, "beginDate", beginDate,
"endDate", endDate, "entryBook", entryBook);
@@ -181,8 +181,8 @@
// entre les 2 dates
" WHERE :beginDate <= E.financialTransaction.transactionDate" +
" AND E.financialTransaction.transactionDate <= :endDate" +
- // concerne le compte
- " AND E.entryBook = :entryBook" +
+ // concerne le journal
+ " AND E.financialTransaction.entryBook = :entryBook" +
" GROUP BY E.debit";
List<Object[]> result = context.find(query, "beginDate", beginDate,
1
0
Author: echatellier
Date: 2012-06-05 18:05:09 +0200 (Tue, 05 Jun 2012)
New Revision: 3446
Url: http://chorem.org/repositories/revision/lima/3446
Log:
Update some libs
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-06-05 16:02:31 UTC (rev 3445)
+++ trunk/pom.xml 2012-06-05 16:05:09 UTC (rev 3446)
@@ -208,13 +208,13 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
- <version>8.1.3.v20120416</version>
+ <version>8.1.4.v20120524</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
- <version>8.1.3.v20120416</version>
+ <version>8.1.4.v20120524</version>
</dependency>
<!-- pdfbox to create pdf document -->
@@ -330,7 +330,7 @@
<jaxxVersion>2.5-SNAPSHOT</jaxxVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<openEjbVersion>4.0.0</openEjbVersion>
- <slf4jVersion>1.6.4</slf4jVersion>
+ <slf4jVersion>1.6.5</slf4jVersion>
<!-- license to use -->
<license.licenseName>gpl_v3</license.licenseName>
1
0
Author: echatellier
Date: 2012-06-05 18:02:31 +0200 (Tue, 05 Jun 2012)
New Revision: 3445
Url: http://chorem.org/repositories/revision/lima/3445
Log:
Update to h2 1.3.167
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-06-05 15:54:08 UTC (rev 3444)
+++ trunk/pom.xml 2012-06-05 16:02:31 UTC (rev 3445)
@@ -103,7 +103,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.3.166</version>
+ <version>1.3.167</version>
<scope>runtime</scope>
</dependency>
1
0
r3444 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
by echatellier@users.chorem.org June 5, 2012
by echatellier@users.chorem.org June 5, 2012
June 5, 2012
Author: echatellier
Date: 2012-06-05 17:54:08 +0200 (Tue, 05 Jun 2012)
New Revision: 3444
Url: http://chorem.org/repositories/revision/lima/3444
Log:
Fix NPE
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-06-05 15:08:46 UTC (rev 3443)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-06-05 15:54:08 UTC (rev 3444)
@@ -25,6 +25,7 @@
package org.chorem.lima.ui.financialtransaction;
+import org.apache.commons.collections.CollectionUtils;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
@@ -53,8 +54,14 @@
/**
* Table des transaction qui ajoute des comportement (keys).
+ *
+ * <ul>
+ * <li>Auto creation des entrees si la transaction est vide (tab)
+ * <li>positionnement automatique sur les cellules editables
+ * </ul>
*
* @author jpepin
+ * @author echatellier
*/
public class FinancialTransactionTable extends JXTable {
@@ -189,14 +196,13 @@
}
}
- /**
+ /*
* Touche tab
* Incrémente le curseur de case tant que la case n'est pas editable
* Ajoute une entrée comptable si tab est sur
- * la dernière cellule et si la transaction est non équilibré
+ * la dernière cellule et si la transaction est non équilibrée
* sinon rajoute une transaction
*/
-
if (e.getKeyChar() == KeyEvent.VK_TAB) {
int max_x = getColumnCount();
int max_y = getRowCount();
@@ -222,7 +228,7 @@
//if transaction, add entry
if (object instanceof FinancialTransaction) {
FinancialTransaction financialTransaction = (FinancialTransaction) object;
- if (financialTransaction.getEntry().size() == 0) {
+ if (CollectionUtils.isEmpty(financialTransaction.getEntry())) {
handler.addEntry();
setColumnSelectionInterval(1, 1);
}
1
0
r3443 - in trunk/lima-business/src/main/java/org/chorem/lima/business: accountingrules ejb
by echatellier@users.chorem.org June 5, 2012
by echatellier@users.chorem.org June 5, 2012
June 5, 2012
Author: echatellier
Date: 2012-06-05 17:08:46 +0200 (Tue, 05 Jun 2012)
New Revision: 3443
Url: http://chorem.org/repositories/revision/lima/3443
Log:
Corrige l'operation de cloture d'un exercice
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-05 14:51:55 UTC (rev 3442)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-05 15:08:46 UTC (rev 3443)
@@ -208,7 +208,7 @@
closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findByTopiaId(closedPeriodicEntryBook.getTopiaId());
// Check if all financial transactions of closedperiodicentrybook are equilibrate
- // FIMXE echatellier 20120504 unutile de recuperer une liste
+ // FIXME echatellier 20120504 unutile de recuperer une liste
// entiere juste pour tester l'existence
FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod();
List<FinancialTransaction> result = financialTransactionDAO.getAllUnbalancedTransaction(period.getBeginDate(),
@@ -220,18 +220,16 @@
// Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
result = financialTransactionDAO.getAllUnfilledTransaction(period.getBeginDate(),
period.getEndDate(), closedPeriodicEntryBook.getEntryBook());
- // FIMXE echatellier 20120504 unutile de recuperer une liste
+ // FIXME echatellier 20120504 unutile de recuperer une liste
// entiere juste pour tester l'existence
if (result.size() > 0) {
throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingelements"));
}
// Check if all financial transactions have EntryBooks
- // FIXME echatellier 20120605 only check in interval defined
- // by period to block (not all database)
result = financialTransactionDAO.getAllTransactionWithoutEntryBook(period.getBeginDate(),
period.getEndDate());
- // FIMXE echatellier 20120504 unutile de recuperer une liste
+ // FIXME echatellier 20120504 unutile de recuperer une liste
// entiere juste pour tester l'existence
if (result.size() > 0) {
FinancialTransaction transaction = result.get(0);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-05 15:08:46 UTC (rev 3443)
@@ -263,7 +263,7 @@
} catch (TopiaException ex) {
throw new LimaException("Can't find fiscal period", ex);
}
-
+
//sets dates
// - endRetainedEarnings: last day of the closing year
// - beginRetainedEarnings: first open day of the following year
@@ -280,6 +280,7 @@
found = true;
}
}
+
//if entrybook isn't found
//then create it
if (!found) {
@@ -305,8 +306,7 @@
accountMaster = new AccountImpl();
accountMaster.setAccountNumber("89");
accountMaster.setLabel("BILAN");
- accountService.createAccount(accountMaster);
- accountMaster = accountService.getAccountByNumber("89");
+ accountMaster = accountService.createAccount(accountMaster);
}
//890 Bilan d'ouverture
@@ -315,8 +315,7 @@
beginRetainedAccount = new AccountImpl();
beginRetainedAccount.setAccountNumber("890");
beginRetainedAccount.setLabel("Bilan d'ouverture");
- accountService.createAccount(beginRetainedAccount);
- beginRetainedAccount = accountService.getAccountByNumber("890");
+ beginRetainedAccount = accountService.createAccount(beginRetainedAccount);
}
//891 Bilan de cloture
@@ -325,19 +324,18 @@
endRetainedAccount = new AccountImpl();
endRetainedAccount.setAccountNumber("891");
endRetainedAccount.setLabel("Bilan de clôture");
- accountService.createAccount(endRetainedAccount);
- endRetainedAccount = accountService.getAccountByNumber("891");
+ endRetainedAccount = accountService.createAccount(endRetainedAccount);
}
//look for the last financial period from the previous fiscal year
+ //check if the last financial period isn't blocked
Collection<FinancialPeriod> fperiod = localFiscalPeriod.getFinancialPeriod();
-
Iterator<FinancialPeriod> itr = fperiod.iterator();
FinancialPeriod lastFPeriod = null;
while (itr.hasNext()) {
lastFPeriod = itr.next();
}
- //check if the last financial period isn't blocked
+
if (lastFPeriod.getLocked()) {
throw new LimaBusinessException(_("lima-business.fiscalperiod.previousfiscalperiodalreadyblocked"));
}
@@ -378,7 +376,7 @@
//Sets the endfinancialTransaction
endfinancialTransaction.setEntryBook(entryBook);
endfinancialTransaction.setTransactionDate(localFiscalPeriod.getEndDate());
- financialTransactionService.createFinancialTransaction(endfinancialTransaction);
+ endfinancialTransaction = financialTransactionService.createFinancialTransaction(endfinancialTransaction);
}
//holds entries of all opening transactions
@@ -388,7 +386,7 @@
//Sets the endfinancialTransaction
beginfinancialTransaction.setEntryBook(entryBook);
beginfinancialTransaction.setTransactionDate(beginfinancialPeriod.getBeginDate());
- financialTransactionService.createFinancialTransaction(beginfinancialTransaction);
+ beginfinancialTransaction = financialTransactionService.createFinancialTransaction(beginfinancialTransaction);
}
}
@@ -397,9 +395,6 @@
calendar.setTime(fiscalPeriod.getEndDate());
//Sets entries
- Entry beginEntry;
-
-
BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(),
localFiscalPeriod.getEndDate(), null, false, false);
@@ -410,7 +405,7 @@
if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6
&& !report.getAmountSolde().equals(BigDecimal.ZERO)) {
//close accounts by removing amounts from all class 1 to 5 accounts
- beginEntry = new EntryImpl();
+ Entry beginEntry = new EntryImpl();
beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
beginEntry.setFinancialTransaction(endfinancialTransaction);
1
0
June 5, 2012
Author: echatellier
Date: 2012-06-05 16:51:55 +0200 (Tue, 05 Jun 2012)
New Revision: 3442
Url: http://chorem.org/repositories/revision/lima/3442
Log:
Correction diverses pour la saisie de la comptabilit?\195?\169
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -227,11 +227,15 @@
}
// Check if all financial transactions have EntryBooks
- result = financialTransactionDAO.getAllTransactionWithoutEntryBook();
+ // FIXME echatellier 20120605 only check in interval defined
+ // by period to block (not all database)
+ result = financialTransactionDAO.getAllTransactionWithoutEntryBook(period.getBeginDate(),
+ period.getEndDate());
// FIMXE echatellier 20120504 unutile de recuperer une liste
// entiere juste pour tester l'existence
if (result.size() > 0) {
- throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingentrybook"));
+ FinancialTransaction transaction = result.get(0);
+ throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingentrybook", transaction.getTransactionDate()));
}
} catch (TopiaException ex) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -240,19 +240,13 @@
@Override
public void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
+ // check if the financial period is blocked
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
try {
-
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- financialtransaction);
-
FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO();
- FinancialTransaction financialTransaction2 =
- //patch : conflict object already instanciate
- transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
-
+ transactionDAO.delete(financialtransaction);
} catch (Exception ex) {
throw new LimaException("Can't remove financial transaction", ex);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -70,7 +70,7 @@
/**
* Gestion des exercices.
- * Un exercice ne peut être supprimée et débloquée après cloture.
+ * Un exercice ne peut être supprimé et débloqué après cloture.
*
* @author Rémi Chapelet
*/
@@ -255,19 +255,27 @@
public void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear,
EntryBook entryBook) throws LimaException {
+ // re-attach entities to current session
+ FiscalPeriod localFiscalPeriod = null;
+ try {
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
+ localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId());
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't find fiscal period", ex);
+ }
+
//sets dates
// - endRetainedEarnings: last day of the closing year
// - beginRetainedEarnings: first open day of the following year
-// Date endRetainedEarnings = fiscalPeriod.getBeginDate();
-// Date beginRetainedEarnings = null;
+ // Date endRetainedEarnings = fiscalPeriod.getBeginDate();
+ // Date beginRetainedEarnings = null;
//Sets entryBook
//search for the entryBook to use using param
boolean found = false;
List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode())
- && entry.getLabel().equals(entryBook.getLabel())) {
+ if (!found && entry.getCode().equals(entryBook.getCode())) {
entryBook = entry;
found = true;
}
@@ -278,8 +286,7 @@
entryBookService.createEntryBook(entryBook);
entryBooksList = entryBookService.getAllEntryBooks();
for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode())
- && entry.getLabel().equals(entryBook.getLabel())) {
+ if (!found && entry.getCode().equals(entryBook.getCode())) {
entryBook = entry;
found = true;
}
@@ -323,7 +330,7 @@
}
//look for the last financial period from the previous fiscal year
- Collection<FinancialPeriod> fperiod = fiscalPeriod.getFinancialPeriod();
+ Collection<FinancialPeriod> fperiod = localFiscalPeriod.getFinancialPeriod();
Iterator<FinancialPeriod> itr = fperiod.iterator();
FinancialPeriod lastFPeriod = null;
@@ -352,7 +359,7 @@
// - unlocked entrybook
// - right code and label
if (!found && !cPeriodicEntryBook.getFinancialPeriod().getLocked()
- && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(fiscalPeriod.getEndDate())
+ && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(localFiscalPeriod.getEndDate())
&& !cPeriodicEntryBook.getLocked()
&& cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode())
&& cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) {
@@ -370,7 +377,7 @@
if (lastFPeriod != null) {
//Sets the endfinancialTransaction
endfinancialTransaction.setEntryBook(entryBook);
- endfinancialTransaction.setTransactionDate(fiscalPeriod.getEndDate());
+ endfinancialTransaction.setTransactionDate(localFiscalPeriod.getEndDate());
financialTransactionService.createFinancialTransaction(endfinancialTransaction);
}
@@ -393,18 +400,15 @@
Entry beginEntry;
- BalanceTrial results = reportService.generateBalanceTrial(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), null, false, false);
+ BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(),
+ localFiscalPeriod.getEndDate(), null, false, false);
List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
- //check if at least one transaction has been reported
- boolean transaction = false;
-
for (ReportsDatas report : reportsDatasList) {
//Account class from 1 to 5 and only non zero amount
if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6
&& !report.getAmountSolde().equals(BigDecimal.ZERO)) {
- transaction = true;
//close accounts by removing amounts from all class 1 to 5 accounts
beginEntry = new EntryImpl();
beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -35,13 +35,12 @@
private static final long serialVersionUID = 1L;
- private static final Log log =
- LogFactory.getLog(FinancialPeriodComparator.class);
+ private static final Log log = LogFactory.getLog(FinancialPeriodComparator.class);
@Override
public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) {
if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == 0) {
- if (o1.getEntryBook().getLabel().compareToIgnoreCase(o2.getEntryBook().getLabel()) == 0) {
+ if (o1.getEntryBook().getCode().compareToIgnoreCase(o2.getEntryBook().getCode()) == 0) {
return o1.getTopiaCreateDate().compareTo(o2.getTopiaCreateDate());
} else {
return o1.getEntryBook().getCode().compareToIgnoreCase(o2.getEntryBook().getCode());
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-05 14:51:55 UTC (rev 3442)
@@ -16,7 +16,7 @@
lima-business.defaultaccountingrules.financialtransactionblocked=La période financière de cette transaction est bloquée
lima-business.defaultaccountingrules.invalidaccountnumber=Numéro de compte invalide \: %d
lima-business.defaultaccountingrules.missingelements=Impossible de bloquer la période financière / il manque des éléments dans des transactions
-lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il mmanque un journal dans une transaction
+lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
lima-business.document.accountnumber=N° Compte
lima-business.document.amounts=Totaux
lima-business.document.balance=Balance
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -132,7 +132,7 @@
Date beginDate, Date endDate) throws TopiaException {
String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
- " WHERE :begindate <= financialPeriod.beginDate " +
+ " WHERE :beginDate <= financialPeriod.beginDate " +
" AND financialPeriod.beginDate <= :endDate" +
" AND entryBook = :entryBook";
return context.find(query, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook);
@@ -152,7 +152,7 @@
Date beginDate, Date endDate) throws TopiaException {
String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
- " WHERE :begindate <= financialPeriod.beginDate " +
+ " WHERE :beginDate <= financialPeriod.beginDate " +
" AND financialPeriod.beginDate <= :endDate" +
" AND entryBook = :entryBook" +
" AND locked = true";
@@ -160,16 +160,17 @@
}
/**
- * Retourne les ClosedPeriodicEntryBook clos de toutes les exercive encore ouvert.
+ * Retourne les ClosedPeriodicEntryBook de toutes les exercices encore ouverts.
*
* @return les ClosedPeriodicEntryBook
* @throws TopiaException
*/
public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws TopiaException {
- String query = "FROM " + ClosedPeriodicEntryBook.class.getName() + " C" +
+ String query = "SELECT C FROM " + ClosedPeriodicEntryBook.class.getName() + " C" +
", " + FiscalPeriod.class.getName() + " F" +
- " WHERE E.financialPeriod IN ELEMENTS (F.financialPeriod)" +
- " ORDER BY E.financialPeriod.beginDate";
+ " WHERE C.financialPeriod IN ELEMENTS (F.financialPeriod)" +
+ " AND F.locked = false" +
+ " ORDER BY C.financialPeriod.beginDate";
List<ClosedPeriodicEntryBook> result = context.find(query);
return result;
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -223,12 +223,13 @@
/**
* Find all transaction without entry book.
*
- * TODO echatellier 20120425 same method as getAllUnfilledTransaction ?
- *
- * @return
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return transaction without entry books
* @throws TopiaException
*/
- public List<FinancialTransaction> getAllTransactionWithoutEntryBook() throws TopiaException {
+ public List<FinancialTransaction> getAllTransactionWithoutEntryBook(Date beginDate,
+ Date endDate) throws TopiaException {
String query = "SELECT T FROM " + FinancialTransaction.class.getName() + " T"+
" LEFT JOIN T.entry AS E" +
@@ -237,9 +238,11 @@
" (SELECT sum(amount) FROM " + Entry.class.getName() +
" WHERE debit = false AND financialTransaction = T) OR E.account = null" +
" OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = '')" +
- " AND entryBook = null";
- // FIXME echatellier 20120504 doesn't concern a period ? all database ?
- List<FinancialTransaction> result = context.find(query);
+ " AND entryBook = null" +
+ " AND :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate";
+ List<FinancialTransaction> result = context.find(query, "beginDate",
+ beginDate, "endDate", endDate);
return result;
}
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2012-06-05 14:51:55 UTC (rev 3442)
@@ -47,6 +47,8 @@
org.chorem.lima.entity.FiscalPeriod.attribute.endDate.tagvalue.notNull=true
# lazy
+org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.entryBook.tagvalue.lazy=false
+org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.financialPeriod.tagvalue.lazy=false
org.chorem.lima.entity.Entry.attribute.account.tagvalue.lazy=false
org.chorem.lima.entity.Entry.attribute.financialTransaction.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -24,27 +24,21 @@
*/
package org.chorem.lima.ui.accountsreports;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-import org.jdesktop.swingx.JXTable;
-
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.jdesktop.swingx.JXTable;
+
public class AccountsReportsTable extends JXTable
implements KeyListener, MouseListener {
/** serialVersionUID. */
private static final long serialVersionUID = 6093850347322834480L;
- /** log. */
- private static final Log log = LogFactory
- .getLog(AccountsReportsTable.class);
-
public AccountsReportsTable() {
addKeyListener(this);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -42,11 +42,8 @@
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.enums.ComboBoxDatesEnum;
@@ -71,9 +68,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 5973427750255668999L;
- /** log. */
- private static final Log log = LogFactory.getLog(IntervalPanel.class);
-
protected List<IntervalListener> listeners;
protected JComboBox typeComboBox;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -34,7 +34,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FiscalPeriodService;
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Structure - Plan BCR.
+ */
+package org.chorem.lima.ui.financialstatementchart;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -35,8 +35,6 @@
import javax.swing.table.AbstractTableModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.utils.EntryComparator;
@@ -65,10 +63,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3914954536809622358L;
- /** log. */
- private static final Log log = LogFactory
- .getLog(FinancialTransactionUnbalancedTableModel.class);
-
/** Transaction service. */
protected final FinancialTransactionService financialTransactionService;
1
0
r3441 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by echatellier@users.chorem.org June 5, 2012
by echatellier@users.chorem.org June 5, 2012
June 5, 2012
Author: echatellier
Date: 2012-06-05 15:47:53 +0200 (Tue, 05 Jun 2012)
New Revision: 3441
Url: http://chorem.org/repositories/revision/lima/3441
Log:
fix : ObjectDeletedException: deleted object would be re-saved by cascade
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.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/EntryBookServiceImpl.java 2012-06-05 09:04:14 UTC (rev 3440)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
@@ -140,27 +140,35 @@
@Override
public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ // check rule
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
-
- // check rule
accountingRules.removeEntryBookRules(entryBook);
try {
-
+ // re-attach to current transaction
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
+ EntryBook localEntryBook = entryBookDAO.findByTopiaId(entryBook.getTopiaId());
// delete all ClosedPeriodicEntryBook from this EntryBook
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
getDaoHelper().getClosedPeriodicEntryBookDAO();
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- closedPeriodicEntryBookDAO.findAllByEntryBook(entryBook);
+ closedPeriodicEntryBookDAO.findAllByEntryBook(localEntryBook);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) {
+ if (log.isDebugEnabled()) {
+ log.debug("Deleting closed " + closedPeriodicEntryBook.getTopiaId());
+ }
+
+ // fix : ObjectDeletedException: deleted object would be re-saved by cascade
+ closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ closedPeriodicEntryBook.getFinancialPeriod().removeEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBook);
+
closedPeriodicEntryBookDAO.delete(closedPeriodicEntryBook);
}
// delete entry book
- EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
- entryBookDAO.delete(entryBook);
+ entryBookDAO.delete(localEntryBook);
} catch (Exception ex) {
throw new LimaException("Can't remove entry book", ex);
1
0
r3440 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/common
by echatellier@users.chorem.org June 5, 2012
by echatellier@users.chorem.org June 5, 2012
June 5, 2012
Author: echatellier
Date: 2012-06-05 11:04:14 +0200 (Tue, 05 Jun 2012)
New Revision: 3440
Url: http://chorem.org/repositories/revision/lima/3440
Log:
Correction probl?\195?\168me de commit
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java 2012-06-04 16:07:10 UTC (rev 3439)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java 2012-06-05 09:04:14 UTC (rev 3440)
@@ -0,0 +1,31 @@
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package org.chorem.lima.ui.common;
+
+import java.util.EventListener;
+import java.util.EventObject;
+
+public interface IntervalListener extends EventListener {
+ public void intervalChanged(EventObject e);
+}
1
0
r3439 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: accountsreports balance common entrybooksreports financialstatementreport ledger
by echatellier@users.chorem.org June 4, 2012
by echatellier@users.chorem.org June 4, 2012
June 4, 2012
Author: echatellier
Date: 2012-06-04 18:07:10 +0200 (Mon, 04 Jun 2012)
New Revision: 3439
Url: http://chorem.org/repositories/revision/lima/3439
Log:
Refactoring report - balance, ledger, financialstatement
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -27,13 +27,10 @@
<import>
javax.swing.ListSelectionModel
- org.jdesktop.swingx.JXDatePicker
org.jdesktop.swingx.decorator.HighlighterFactory
- org.chorem.lima.enums.ComboBoxDatesEnum
org.chorem.lima.ui.accountsreports.AccountComboBox
org.chorem.lima.ui.common.AccountComboBoxModel
- org.chorem.lima.ui.common.FiscalPeriodComboBoxModel
- org.chorem.lima.ui.common.FinancialPeriodComboBoxModel
+ org.chorem.lima.ui.common.IntervalPanel
</import>
<AccountsReportsViewHandler id="handler" constructorParams="this"/>
@@ -47,29 +44,8 @@
</script>
<row weightx="1" weighty="0" anchor="center">
<cell fill='horizontal'>
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="handler.periodTypeChanged()"/>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
- <cell fill='horizontal'>
- <CardLayout id="periodTypeLayout" />
- <JPanel id="periodTypeContainer" layout="{periodTypeLayout}">
- <FiscalPeriodComboBoxModel id="fiscalPeriodModel" />
- <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FISCAL_PERIOD"' />
- <FinancialPeriodComboBoxModel id="financialPeriodModel" />
- <JComboBox id="financialPeriodComboBox" model="{financialPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FINANCIAL_PERIOD"' />
- <JPanel constraints='"PERIOD"'>
- <JLabel text="lima.common.begindate" />
- <JXDatePicker id="periodBeginDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- <JLabel text="lima.common.enddate" />
- <JXDatePicker id="periodEndDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- </JPanel>
- </JPanel>
- </cell>
<cell fill='horizontal' anchor="east">
<JLabel id="accountSelectorLabel" text="lima.common.account"/>
</cell>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -29,15 +29,9 @@
import java.awt.event.ItemEvent;
import java.math.BigDecimal;
-import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import javax.swing.JComboBox;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
@@ -49,7 +43,6 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
import org.chorem.lima.service.LimaServiceFactory;
/**
@@ -60,9 +53,6 @@
protected AccountsReportsView view;
- /** log. */
- private static final Log log = LogFactory.getLog(AccountsReportsViewHandler.class);
-
/** Services. */
protected ReportService reportService;
protected AccountService accountService;
@@ -89,49 +79,17 @@
List<Account> account = accountService.getAllAccounts();
view.getAccountComboboxModel().setObjects(account);
List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- view.getFiscalPeriodModel().setObjects(fiscalPeriod);
List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
- view.getFinancialPeriodModel().setObjects(financialPeriod);
-
- // init date periods
- initDatePeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- /**
- * Init date pickers objects with contextual dates.
- */
- private void initDatePeriods() {
-
- // get begin date
- Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
- view.getPeriodBeginDatePicker().setDate(beginDate);
-
- // get end date
- Date endDate = new Date();
- view.getPeriodEndDatePicker().setDate(endDate);
- }
-
- public void periodTypeChanged() {
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
-
- // show corresponding component in layout
- view.getPeriodTypeLayout().show(view.getPeriodTypeContainer(), type.name());
- }
-
- protected void periodsChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
-
protected void accountChanged(ItemEvent event) {
if (event.getStateChange() == ItemEvent.SELECTED) {
refreshData();
}
}
- protected void periodDatesChanged() {
+ public void intervalChanged() {
refreshData();
}
@@ -140,34 +98,9 @@
*/
protected void refreshData() {
- Date beginDate = null;
- Date endDate = null;
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- switch (type) {
- case PERIOD:
- beginDate = view.getPeriodBeginDatePicker().getDate();
- endDate = view.getPeriodEndDatePicker().getDate();
- break;
- case FINANCIAL_PERIOD: {
- FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- case FISCAL_PERIOD: {
- FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- }
-
Account account = (Account)view.getAccountComboBox().getModel().getSelectedItem();
if (beginDate != null && endDate != null && account != null) {
@@ -176,6 +109,8 @@
AccountsReportsTableModel dataModel = view.getAccountsReportsTableModel();
dataModel.setReportDatas(results);
+
+ updateFooter(results);
}
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,163 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.balance;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class BalancePeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(BalancePeriodSearchPanel.class);
-
- protected BalanceViewHandler handler;
-
- public BalancePeriodSearchPanel(BalanceViewHandler handler) {
- this.handler = handler;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
-
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setBeginDate(beginDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setEndDate(endDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- handler.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
-
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -24,38 +24,27 @@
*/
package org.chorem.lima.ui.balance;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-import org.jdesktop.swingx.JXTable;
-
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.jdesktop.swingx.JXTable;
+
public class BalanceTable extends JXTable implements KeyListener, MouseListener {
/** serialVersionUID. */
private static final long serialVersionUID = 6093850347322834480L;
- /** log. */
- private static final Log log = LogFactory
- .getLog(BalanceTable.class);
+ public BalanceTable() {
- protected BalanceViewHandler handler;
-
- public BalanceTable(BalanceViewHandler handler) {
-
- this.handler = handler;
-
addKeyListener(this);
addMouseListener(this);
//Get new BigDecimal renderer
setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
-
}
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -25,18 +25,16 @@
package org.chorem.lima.ui.balance;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.BalanceTrial;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.entity.Account;
+import static org.nuiton.i18n.I18n._;
-import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
+import javax.swing.table.AbstractTableModel;
+import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.entity.Account;
/**
* Entry book table model.
@@ -47,17 +45,14 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
- private static final Log log = LogFactory.getLog(BalanceTableModel.class);
-
/** data cache */
- protected BalanceTrial cacheDataList;
+ protected BalanceTrial balanceTrial;
@Override
public int getRowCount() {
int result = 0;
- if (cacheDataList != null) {
- result = cacheDataList.getReportsDatas().size();
+ if (balanceTrial != null) {
+ result = balanceTrial.getReportsDatas().size();
}
return result;
}
@@ -125,54 +120,42 @@
@Override
public Object getValueAt(int row, int column) {
Object result = null;
- ReportsDatas currentRow = ((List<ReportsDatas>) cacheDataList.getReportsDatas()).get(row);
+ ReportsDatas currentRow = ((List<ReportsDatas>) balanceTrial.getReportsDatas()).get(row);
//get entries for the period for the current row
- try {
- switch (column) {
- case 0:
- result = currentRow.getAccount().getAccountNumber(); //account number
- break;
- case 1:
- result = currentRow.getAccount().getLabel(); //account label
- break;
- case 2:
- result = currentRow.getAmountDebit(); // total debit
- break;
- case 3:
- result = currentRow.getAmountCredit(); // total crédit
- break;
- case 4: // solde debit
- if (currentRow.getSoldeDebit()) {
- result = currentRow.getAmountSolde();
- } else {
- result = BigDecimal.ZERO;
- }
- break;
- case 5: // solde credit
- if (!currentRow.getSoldeDebit()) {
- result = currentRow.getAmountSolde();
- } else {
- result = BigDecimal.ZERO;
- }
- break;
- }
- } catch (Exception eee) {
- log.debug("Can't get entries", eee);
+ switch (column) {
+ case 0:
+ result = currentRow.getAccount().getAccountNumber(); //account number
+ break;
+ case 1:
+ result = currentRow.getAccount().getLabel(); //account label
+ break;
+ case 2:
+ result = currentRow.getAmountDebit(); // total debit
+ break;
+ case 3:
+ result = currentRow.getAmountCredit(); // total crédit
+ break;
+ case 4: // solde debit
+ if (currentRow.getSoldeDebit()) {
+ result = currentRow.getAmountSolde();
+ } else {
+ result = BigDecimal.ZERO;
+ }
+ break;
+ case 5: // solde credit
+ if (!currentRow.getSoldeDebit()) {
+ result = currentRow.getAmountSolde();
+ } else {
+ result = BigDecimal.ZERO;
+ }
+ break;
}
return result;
}
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // Just read, no write
- return false;
- }
-
-
- public void refresh(BalanceTrial datasList) {
- cacheDataList = datasList;
+ public void setBalanceTrial(BalanceTrial balanceTrial) {
+ this.balanceTrial = balanceTrial;
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -31,37 +31,22 @@
org.jdesktop.swingx.decorator.HighlighterFactory
org.chorem.lima.business.utils.FormatsEnum
org.chorem.lima.enums.ComboBoxDatesEnum
+ org.chorem.lima.ui.common.IntervalPanel
</import>
- <BalanceViewHandler id="handler" javaBean="new BalanceViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <BalanceTableModel id="modelBalanceTable"/>
+ <BalanceViewHandler id="handler" constructorParams="this"/>
+
<script>
<![CDATA[
-
- BalancePeriodSearchPanel periodSearchPanel = new BalancePeriodSearchPanel(handler);
-
void $afterCompleteSetup() {
+ handler.init();
}
-
]]>
</script>
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
- </cell>
- <cell>
- <BalancePeriodSearchPanel javaBean="periodSearchPanel"/>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell anchor="east">
<JLabel text="lima.common.filter"/>
@@ -70,17 +55,16 @@
<JTextField id='balanceFilter' toolTipText="lima.tooltip.filter"
minimumSize='{balanceFilter.getPreferredSize()}'/>
<Document javaBean="balanceFilter.getDocument()"
- onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())'
- onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())'/>
+ onInsertUpdate='handler.accountFilterChanged()'
+ onRemoveUpdate='handler.accountFilterChanged()'/>
</cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter'
selected='false'
- onActionPerformed="getHandler().refresh()"/>
+ onActionPerformed="getHandler().movmentedFilterChanged()"/>
</cell>
<cell>
- <EnumEditor id='DocumentEditor'
- constructorParams='FormatsEnum.class'/>
+ <EnumEditor id='DocumentEditor' constructorParams='FormatsEnum.class'/>
</cell>
<cell>
<JButton text="lima.common.ok"
@@ -90,15 +74,13 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="8">
<JScrollPane>
+ <BalanceTableModel id="balanceTableModel" />
<BalanceTable id="balanceTable"
rowHeight="24"
- constructorParams="getHandler()"
- model="{getModelBalanceTable()}"
+ model="{balanceTableModel}"
highlighters="{HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
columnControlVisible="true"/>
- <ListSelectionModel
- javaBean="getBalanceTable().getSelectionModel()"/>
</JScrollPane>
</cell>
</row>
@@ -119,7 +101,7 @@
<JLabel id="amountCreditLabel"/>
</cell>
<cell>
- <JLabel id="soldeLabel" text="lima.common.solde"/>
+ <JLabel text="lima.common.solde"/>
</cell>
<cell>
<JLabel id="amountSoldeLabel"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -43,6 +43,7 @@
import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
@@ -50,6 +51,7 @@
import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -66,107 +68,101 @@
/** Services. */
protected ReportService reportService;
-
protected HttpServerService httpServerServiceMonitorable;
-
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
- /** DatePicker Begin Date. */
- protected Date selectedBeginDate;
-
- /** DatePicker EndDate. */
- protected Date selectedEndDate;
-
- /** Text field Accounts */
- protected String selectedAccounts;
-
- protected BalanceTable table;
-
- protected BalanceTableModel model;
-
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
- protected int port;
-
protected BalanceViewHandler(BalanceView view) {
this.view = view;
reportService = LimaServiceFactory.getService(ReportService.class);
- port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
- fiscalPeriodService =
- LimaServiceFactory.getService(FiscalPeriodService.class);
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
-
}
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
- refresh();
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- public void setEndDate(Date date) {
- selectedEndDate = date;
- refresh();
+ public void intervalChanged() {
+ refreshData();
}
- public void setAccountFilter(String accounts) {
- selectedAccounts = accounts;
- refresh();
+ public void accountFilterChanged() {
+ refreshData();
}
+
+ public void movmentedFilterChanged() {
+ refreshData();
+ }
/**
- * get all account fot the selected period
- *
- * @return
+ * Refresh table data depending on item selected on combo boxes.
*/
- public BalanceTrial getDataList() {
- BalanceTrial results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, selectedAccounts, false, view.getMovmentedFilter().isSelected());
- return results;
+ protected void refreshData() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ String account = view.getBalanceFilter().getText().trim();
+
+ if (beginDate != null && endDate != null) {
+ BalanceTrial balanceTrial = reportService.generateBalanceTrial(beginDate,
+ endDate, account, false, view.getMovmentedFilter().isSelected());
+
+ BalanceTableModel dataModel = view.getBalanceTableModel();
+ dataModel.setBalanceTrial(balanceTrial);
+
+ updateFooter(balanceTrial);
+ }
}
- public void refresh() {
+ /**
+ * Update footer labels containing reports total sum fields.
+ *
+ * @param results result to render
+ */
+ protected void updateFooter(BalanceTrial balanceTrial) {
+ // set amounts credit and debit and solde
+ view.amountCreditLabel.setText(
+ balanceTrial.getAmountCredit().toString());
+ view.amountDebitLabel.setText(
+ balanceTrial.getAmountDebit().toString());
+ BigDecimal amountSolde = balanceTrial.getAmountSolde();
+ view.amountSoldeLabel.setText(amountSolde.toString());
- if (selectedBeginDate != null && selectedEndDate != null) {
- model = view.getModelBalanceTable();
- BalanceTrial datasList = getDataList();
- model.refresh(datasList);
- /**
- * update the labels credit, debit, solde on the footer
- * get all entries for all accounts on the selected period
- */
-
- if (datasList != null) {
- // set amounts credit, debit and solde
- view.amountCreditLabel.setText(
- String.valueOf(datasList.getAmountCredit()));
- view.amountDebitLabel.setText(
- String.valueOf(datasList.getAmountDebit()));
- BigDecimal amountSolde = datasList.getAmountSolde();
- view.amountSoldeLabel.setText(
- String.valueOf(amountSolde));
-
-
- if (amountSolde.compareTo(BigDecimal.ZERO) == 0) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (datasList.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
- }
- }
+ if (BigDecimal.ZERO.equals(amountSolde)) {
+ view.amountSoldeLabel.setText(_("lima.common.solde"));
+ } else {
+ // set label solde: credit or debit
+ if (balanceTrial.getSoldeDebit()) {
+ view.amountSoldeLabel.setText(_("lima.common.soldedebit"));
+ } else {
+ view.amountSoldeLabel.setText(_("lima.common.soldecredit"));
}
}
}
public void createDocument() {
- if (selectedBeginDate != null & selectedEndDate != null) {
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+ if (beginDate != null & endDate != null) {
+
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -174,8 +170,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -195,9 +191,10 @@
String address = LimaConfig.getInstance().getHostAdress();
try {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate) + "&format="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate) + "&format="
+ selectedEnum.getExtension() + "&model="
+ DocumentsEnum.BALANCE.getFileName();
Desktop.getDesktop().browse(new URI(url));
@@ -211,9 +208,9 @@
}
@Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")) {
- refresh();
+ public void notifyMethod(String serviceName, String methodName) {
+ if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) {
+ refreshData();
}
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Rapport - Balance.
+ */
+package org.chorem.lima.ui.balance;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,260 @@
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package org.chorem.lima.ui.common;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.enums.ComboBoxDatesEnum;
+import org.jdesktop.swingx.JXDatePicker;
+
+/**
+ * Panel permettant de selectionner un interval de date suivant plusieurs type
+ * possible:
+ * <ul>
+ * <li>date d'un exercice
+ * <li>date d'une perdiode comptable
+ * <li>deux dates
+ * </ul>
+ *
+ * Il supporte les listeners, donc on peut être notifié d'un changement
+ * d'interval.
+ *
+ * @author echatellier
+ */
+public class IntervalPanel extends JPanel implements ActionListener, ItemListener {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 5973427750255668999L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(IntervalPanel.class);
+
+ protected List<IntervalListener> listeners;
+
+ protected JComboBox typeComboBox;
+
+ protected CardLayout typeLayout;
+
+ protected JPanel specificTypePanel;
+
+ protected FiscalPeriodComboBoxModel fiscalPeriodComoboBoxModel;
+
+ protected FinancialPeriodComboBoxModel financialPeriodComoboBoxModel;
+
+ protected JXDatePicker beginDatePicker;
+
+ protected JXDatePicker endDatePicker;
+
+ public IntervalPanel() {
+ super(new BorderLayout());
+ listeners = new ArrayList<IntervalListener>();
+ initUI();
+ }
+
+ public void addIntervalListener(IntervalListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeIntervalListener(IntervalListener listener) {
+ listeners.remove(listener);
+ }
+
+ private void initUI() {
+
+ // type combo box
+ typeComboBox = new JComboBox(ComboBoxDatesEnum.descriptions());
+ add(typeComboBox, BorderLayout.WEST);
+ typeComboBox.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) typeComboBox.getSelectedItem());
+ // show corresponding component in layout
+ typeLayout.show(specificTypePanel, type.name());
+ }
+ });
+
+ typeLayout = new CardLayout();
+ specificTypePanel = new JPanel(typeLayout);
+
+ fiscalPeriodComoboBoxModel = new FiscalPeriodComboBoxModel();
+ JComboBox fiscalPeriodComboBox = new JComboBox(fiscalPeriodComoboBoxModel);
+ fiscalPeriodComboBox.setRenderer(new FiscalPeriodListRenderer());
+ fiscalPeriodComboBox.addItemListener(this);
+ specificTypePanel.add(fiscalPeriodComboBox, ComboBoxDatesEnum.FISCAL_PERIOD.name());
+
+ financialPeriodComoboBoxModel = new FinancialPeriodComboBoxModel();
+ JComboBox financialPeriodComboBox = new JComboBox(financialPeriodComoboBoxModel);
+ financialPeriodComboBox.setRenderer(new FinancialPeriodListRenderer());
+ financialPeriodComboBox.addItemListener(this);
+ specificTypePanel.add(financialPeriodComboBox, ComboBoxDatesEnum.FINANCIAL_PERIOD.name());
+
+ JPanel periodPanel = new JPanel(new GridBagLayout());
+ JLabel beginLabel = new JLabel(_("lima.common.begindate"));
+ periodPanel.add(beginLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+
+ beginDatePicker = new JXDatePicker();
+ beginDatePicker.addActionListener(this);
+ periodPanel.add(beginDatePicker, new GridBagConstraints(1, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+
+ JLabel endLabel = new JLabel(_("lima.common.begindate"));
+ periodPanel.add(endLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+
+ endDatePicker = new JXDatePicker();
+ endDatePicker.addActionListener(this);
+ periodPanel.add(endDatePicker, new GridBagConstraints(3, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+ specificTypePanel.add(periodPanel, ComboBoxDatesEnum.PERIOD.name());
+
+ // get begin date
+ Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
+ beginDatePicker.setDate(beginDate);
+ endDatePicker.setDate(new Date());
+
+ add(specificTypePanel, BorderLayout.CENTER);
+ }
+
+ /**
+ * Init component combo models.
+ *
+ * @param fiscalPeriods fiscal periods
+ * @param financialPeriods financial periods
+ */
+ public void init(List<FiscalPeriod> fiscalPeriods, List<FinancialPeriod> financialPeriods) {
+ fiscalPeriodComoboBoxModel.setObjects(fiscalPeriods);
+ financialPeriodComoboBoxModel.setObjects(financialPeriods);
+ }
+
+ /**
+ * Return selected begin date.
+ *
+ * @return begin date, or {@code null} with no valid selection.
+ */
+ public Date getBeginDate() {
+ Date beginDate = null;
+
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) typeComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ beginDate = beginDatePicker.getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)financialPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ }
+ break;
+ }
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)fiscalPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ }
+ break;
+ }
+ }
+
+ return beginDate;
+ }
+
+ /**
+ * Return selected end date.
+ *
+ * @return end date, or {@code null} with no valid selection.
+ */
+ public Date getEndDate() {
+ Date endDate = null;
+
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) typeComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ endDate = endDatePicker.getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)financialPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)fiscalPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ }
+
+ return endDate;
+ }
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ fireEvent();
+ }
+ }
+
+ protected void fireEvent() {
+ for (IntervalListener l : listeners) {
+ l.intervalChanged(null);
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ fireEvent();
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -26,8 +26,7 @@
<Table>
<import>
javax.swing.ListSelectionModel
- org.chorem.lima.enums.ComboBoxDatesEnum
- org.jdesktop.swingx.JXDatePicker
+ org.chorem.lima.ui.common.IntervalPanel
</import>
<EntryBooksReportsViewHandler id="handler" constructorParams="this"/>
@@ -40,34 +39,7 @@
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="handler.periodTypeChanged()"/>
- </cell>
- <cell>
- <CardLayout id="periodTypeLayout" />
- <JPanel id="periodTypeContainer" layout="{periodTypeLayout}">
- <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodModel" />
- <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FISCAL_PERIOD"' />
- <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodModel" />
- <JComboBox id="financialPeriodComboBox" model="{financialPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FINANCIAL_PERIOD"' />
- <JPanel constraints='"PERIOD"'>
- <JLabel text="lima.common.begindate" />
- <JXDatePicker id="periodBeginDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- <JLabel text="lima.common.enddate" />
- <JXDatePicker id="periodEndDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- </JPanel>
- </JPanel>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell anchor="east">
<JLabel id="entryBookSelectorLabel" text="lima.common.entrybook"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -30,17 +30,15 @@
import java.awt.Desktop;
import java.awt.event.ItemEvent;
import java.io.IOException;
+import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import javax.swing.JComboBox;
import javax.swing.JOptionPane;
-import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
@@ -59,7 +57,6 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
import org.chorem.lima.service.LimaServiceFactory;
/**
@@ -106,93 +103,27 @@
List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
view.getEntryBookModel().setObjects(entryBooks);
List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- view.getFiscalPeriodModel().setObjects(fiscalPeriod);
List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
- view.getFinancialPeriodModel().setObjects(financialPeriod);
-
- // init date periods
- initDatePeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- /**
- * Init date pickers objects with contextual dates.
- */
- private void initDatePeriods() {
-
- // get begin date
- Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
- view.getPeriodBeginDatePicker().setDate(beginDate);
-
- // get end date
- Date endDate = new Date();
- view.getPeriodEndDatePicker().setDate(endDate);
+ public void intervalChanged() {
+ refreshData();
}
- public void periodTypeChanged() {
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
-
- // show corresponding component in layout
- view.getPeriodTypeLayout().show(view.getPeriodTypeContainer(), type.name());
- }
-
- protected void periodsChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
-
protected void entryBookChanged(ItemEvent event) {
if (event.getStateChange() == ItemEvent.SELECTED) {
refreshData();
}
}
-
- protected void periodDatesChanged() {
- refreshData();
- }
- /*public ReportsDatas getDataList() {
- ReportsDatas results = null;
- if (selectedEntryBook != null) {
- results = reportService.generateEntryBooksReports(
- selectedEntryBook, selectedBeginDate, selectedEndDate);
- }
- return results;
- }*/
-
/**
* Refresh table data depending on item selected on combo boxes.
*/
protected void refreshData() {
- Date beginDate = null;
- Date endDate = null;
-
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- switch (type) {
- case PERIOD:
- beginDate = view.getPeriodBeginDatePicker().getDate();
- endDate = view.getPeriodEndDatePicker().getDate();
- break;
- case FINANCIAL_PERIOD: {
- FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- case FISCAL_PERIOD: {
- FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- }
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
EntryBook entryBook = (EntryBook)view.getEntryBookCombo().getModel().getSelectedItem();
@@ -202,39 +133,42 @@
EntryBooksReportsTableModel dataModel = view.getEntryBookReportsTableModel();
dataModel.setReportDatas(results);
+
+ updateFooter(results);
}
}
- public void createDocument() {
+ /**
+ * Update footer labels containing reports total sum fields.
+ *
+ * @param results result to render
+ */
+ protected void updateFooter(ReportsDatas reportsDatas) {
+ // set amounts credit and debit and solde
+ view.amountCreditLabel.setText(
+ reportsDatas.getAmountCredit().toString());
+ view.amountDebitLabel.setText(
+ reportsDatas.getAmountDebit().toString());
+ BigDecimal amountSolde = reportsDatas.getAmountSolde();
+ view.amountSoldeLabel.setText(amountSolde.toString());
- // FIXME echatellier 20120601 duplicated code
- Date beginDate = null;
- Date endDate = null;
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- switch (type) {
- case PERIOD:
- beginDate = view.getPeriodBeginDatePicker().getDate();
- endDate = view.getPeriodEndDatePicker().getDate();
- break;
- case FINANCIAL_PERIOD: {
- FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
+ if (BigDecimal.ZERO.equals(amountSolde)) {
+ view.soldeLabel.setText(_("lima.common.solde"));
+ } else {
+ // set label solde: credit or debit
+ if (reportsDatas.getSoldeDebit()) {
+ view.soldeLabel.setText(_("lima.common.soldedebit"));
+ } else {
+ view.soldeLabel.setText(_("lima.common.soldecredit"));
}
- case FISCAL_PERIOD: {
- FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
}
+ }
+
+ public void createDocument() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
if (beginDate != null && endDate != null) {
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,37 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.financialstatementreport;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class FinancialStatementDocument {
-
- private static final Log log =
- LogFactory.getLog(FinancialStatementReportTable.class);
-
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,161 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.financialstatementreport;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class FinancialStatementReportPeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(FinancialStatementReportPeriodSearchPanel.class);
-
- protected FinancialStatementReportTableModel model;
-
- public FinancialStatementReportPeriodSearchPanel(FinancialStatementReportTableModel model) {
- this.model = model;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- model.setBeginDate(beginDatePicker.getDate());
- model.refresh();
- }
- };
- model.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- model.setEndDate(endDatePicker.getDate());
- model.refresh();
- }
- };
- model.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- model.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- model.setBeginDate(fPeriod.getBeginDate());
- model.setEndDate(fPeriod.getEndDate());
- model.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- model.setBeginDate(fPeriod.getBeginDate());
- model.setEndDate(fPeriod.getEndDate());
- model.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -39,14 +39,11 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-
public class FinancialStatementReportTable extends JXTable
implements KeyListener, MouseListener {
private static final long serialVersionUID = 154211277688304679L;
- protected FinancialStatementReportViewHandler handler;
-
protected FinancialStatementReportTableModel model;
private Highlighter colorTransaction;
@@ -54,14 +51,13 @@
/*
* Constructor, call highlighter
*/
- public FinancialStatementReportTable(FinancialStatementReportViewHandler handler) {
- super(handler.getView().modelTable);
- this.handler = handler;
+ public FinancialStatementReportTable(FinancialStatementReportTableModel model) {
+ super(model);
addKeyListener(this);
addMouseListener(this);
- model = this.handler.getView().modelTable;
+ this.model = model;
//highlight financial financial transactions
colorTitle1();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -27,30 +27,12 @@
import static org.nuiton.i18n.I18n._;
-import java.awt.Desktop;
-import java.io.IOException;
import java.math.BigDecimal;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.SimpleDateFormat;
-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.LimaConfig;
import org.chorem.lima.beans.FinancialStatementAmounts;
-import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.business.api.DocumentService;
-import org.chorem.lima.business.api.FinancialStatementService;
-import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.api.HttpServerService;
-import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.utils.DocumentsEnum;
-import org.chorem.lima.business.utils.FormatsEnum;
-import org.chorem.lima.service.LimaServiceFactory;
/**
* Entry book table model.
@@ -62,52 +44,19 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialStatementReportTableModel extends AbstractTableModel implements ServiceListener {
+public class FinancialStatementReportTableModel extends AbstractTableModel {
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
- private static final Log log = LogFactory.getLog(FinancialStatementReportTableModel.class);
-
- /** Services. */
- protected FinancialStatementService financialStatementService;
-
- protected DocumentService documentService;
-
- /** DatePicker Begin Date. */
- protected Date selectedBeginDate;
-
- /** DatePicker EndDate. */
- protected Date selectedEndDate;
-
- protected int port;
-
- private static SimpleDateFormat dateFormat =
- new SimpleDateFormat("yyyy-MM-dd");
-
/** data cache */
- protected List<FinancialStatementAmounts> cacheDataList;
+ protected List<FinancialStatementAmounts> financialStatementAmounts;
- /** Constructor. */
- public FinancialStatementReportTableModel() {
- financialStatementService =
- LimaServiceFactory.getService(
- FinancialStatementService.class);
-
- LimaServiceFactory.addServiceListener(FinancialStatementService.class, this);
- port = LimaServiceFactory.getService(
- HttpServerService.class).getHttpPort();
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
- documentService = LimaServiceFactory.getService(DocumentService.class);
- }
-
@Override
public int getRowCount() {
int result = 0;
- if (cacheDataList != null) {
- result = cacheDataList.size();
+ if (financialStatementAmounts != null) {
+ result = financialStatementAmounts.size();
}
return result;
}
@@ -162,13 +111,13 @@
public Object getElementAt(int row) {
- Object currentRow = cacheDataList.get(row);
+ Object currentRow = financialStatementAmounts.get(row);
return currentRow;
}
@Override
public Object getValueAt(int row, int column) {
- Object result = cacheDataList.get(row);
+ Object result = financialStatementAmounts.get(row);
//get entries for the period for the current row
if (result instanceof FinancialStatementAmounts) {
FinancialStatementAmounts currentRow = (FinancialStatementAmounts) result;
@@ -220,72 +169,8 @@
return result;
}
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // Just read, no write
- return false;
- }
-
- public Date getBeginDate() {
- return selectedBeginDate;
- }
-
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
- }
-
- public Date getEndDate() {
- return selectedEndDate;
- }
-
- public void setEndDate(Date date) {
- selectedEndDate = date;
- }
-
- /**
- * get all account for the selected period
- *
- * @return
- */
- public List<FinancialStatementAmounts> getDataList() {
- List<FinancialStatementAmounts> results = null;
- if (selectedBeginDate != null && selectedEndDate != null) {
- results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate);
- }
- return results;
- }
-
- public void refresh() {
- cacheDataList = getDataList();
+ public void setFinancialStatementAmounts(List<FinancialStatementAmounts> financialStatementAmounts) {
+ this.financialStatementAmounts = financialStatementAmounts;
fireTableDataChanged();
}
-
-
- public void createDocument(FormatsEnum formatsEnum) {
-
- if (selectedBeginDate != null && selectedEndDate != null) {
- String address = LimaConfig.getInstance().getHostAdress();
- try {
- String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
- + "&format=" + formatsEnum.getExtension() + "&model="
- + DocumentsEnum.FINANCIALSTATEMENT.getFileName();
- Desktop.getDesktop().browse(new URI(url));
- } catch (IOException e) {
- log.error("Can't open browser", e);
- } catch (URISyntaxException e) {
- log.error("Can't create news URI", e);
- }
- }
- }
-
- @Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") || methodeName.contains("FinancialStatement") || methodeName.contains("importAll")) {
- refresh();
- }
- }
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,42 +26,22 @@
<Table>
<import>
javax.swing.ListSelectionModel
- org.chorem.lima.enums.ComboBoxDatesEnum
- org.chorem.lima.ui.financialstatementreport.FinancialStatementReportTableModel
+ org.chorem.lima.ui.common.IntervalPanel
</import>
- <FinancialStatementReportViewHandler
- id="handler"
- javaBean="new FinancialStatementReportViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <FinancialStatementReportTableModel id="modelTable"/>
+
+ <FinancialStatementReportViewHandler id="handler" constructorParams="this"/>
+
<script>
<![CDATA[
-
- FinancialStatementReportPeriodSearchPanel periodSearchPanel =
- new FinancialStatementReportPeriodSearchPanel(modelTable);
-
void $afterCompleteSetup() {
+ handler.init();
}
-
-
]]>
</script>
+
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
- </cell>
- <cell>
- <FinancialStatementReportPeriodSearchPanel
- javaBean="periodSearchPanel"/>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell>
<EnumEditor id='DocumentEditor'
@@ -75,9 +55,9 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="7">
<JScrollPane>
+ <FinancialStatementReportTableModel id="financialStatementReportTableModel"/>
<FinancialStatementReportTable id="table" rowHeight="24"
- constructorParams="getHandler()"
- model="{getModelTable()}"
+ constructorParams="financialStatementReportTableModel"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
<ListSelectionModel javaBean="getTable().getSelectionModel()"/>
</JScrollPane>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -27,6 +27,11 @@
import static org.nuiton.i18n.I18n._;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -34,8 +39,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.beans.FinancialStatementAmounts;
+import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.api.FinancialStatementService;
+import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
+import org.chorem.lima.business.api.HttpServerService;
+import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -48,40 +63,70 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialStatementReportViewHandler {
+public class FinancialStatementReportViewHandler implements ServiceListener {
/** log. */
private static final Log log = LogFactory.getLog(FinancialStatementReportViewHandler.class);
protected FinancialStatementReportView view;
- protected FinancialStatementReportTableModel model;
-
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
+ protected FinancialStatementService financialStatementService;
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+
protected FinancialStatementReportViewHandler(FinancialStatementReportView view) {
this.view = view;
- fiscalPeriodService =
- LimaServiceFactory.getService(
- FiscalPeriodService.class);
+
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
+ financialStatementService = LimaServiceFactory.getService(FinancialStatementService.class);
+
+ LimaServiceFactory.addServiceListener(FinancialStatementService.class, this);
+ LimaServiceFactory.addServiceListener(ImportService.class, this);
+ LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
- public void refresh() {
- model = view.getModelTable();
- model.refresh();
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- public FinancialStatementReportView getView() {
- return view;
+ public void intervalChanged() {
+ refreshData();
}
+ /**
+ * Refresh table data depending on item selected on combo boxes.
+ */
+ protected void refreshData() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ if (beginDate != null && endDate != null) {
+ List<FinancialStatementAmounts> results =
+ financialStatementService.financialStatementReport(beginDate, endDate);
+
+ FinancialStatementReportTableModel dataModel = view.getFinancialStatementReportTableModel();
+ dataModel.setFinancialStatementAmounts(results);
+ }
+ }
+
public void createDocument() {
- model = view.getModelTable();
- Date selectedBeginDate = model.getBeginDate();
- Date selectedEndDate = model.getEndDate();
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
- if (selectedBeginDate != null && selectedEndDate != null) {
+ if (beginDate != null && endDate != null) {
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -89,8 +134,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -106,8 +151,30 @@
} else {
FormatsEnum selectedEnum =
(FormatsEnum) view.getDocumentEditor().getSelectedItem();
- model.createDocument(selectedEnum);
+
+ String address = LimaConfig.getInstance().getHostAdress();
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&format=" + selectedEnum.getExtension() + "&model="
+ + DocumentsEnum.FINANCIALSTATEMENT.getFileName();
+ try {
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
+ }
}
}
}
+
+ @Override
+ public void notifyMethod(String serviceName, String methodName) {
+ if (serviceName.contains("FinancialTransaction") ||
+ methodName.contains("FinancialStatement") || methodName.contains("importAll")) {
+ refreshData();
+ }
+ }
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Rapport - Bilan/Compte de resultats.
+ */
+package org.chorem.lima.ui.financialstatementreport;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,161 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.ledger;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class LedgerPeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(LedgerPeriodSearchPanel.class);
-
- protected LedgerViewHandler handler;
-
- public LedgerPeriodSearchPanel(LedgerViewHandler handler) {
- this.handler = handler;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setBeginDate(beginDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setEndDate(endDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- handler.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -40,7 +40,6 @@
import java.awt.event.MouseListener;
import java.math.BigDecimal;
-
/**
* Table des transaction qui ajoute des comportement (keys).
*
@@ -52,16 +51,12 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- protected LedgerViewHandler handler;
-
private Highlighter colorReportsDatas;
/**
*/
- public LedgerTable(LedgerViewHandler handler) {
+ public LedgerTable() {
- this.handler = handler;
-
addKeyListener(this);
addMouseListener(this);
@@ -70,7 +65,6 @@
//highlight financial financial transactions
addColorReportsDatas();
-
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,21 +25,20 @@
package org.chorem.lima.ui.ledger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
+import static org.nuiton.i18n.I18n._;
-import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
+import javax.swing.table.AbstractTableModel;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+
/**
* Entry book table model.
*
@@ -55,19 +54,16 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
- private static final Log log = LogFactory.getLog(LedgerTableModel.class);
-
/** data cache */
- protected List<Object> cacheDataList;
+ protected List<Object> objects;
@Override
public int getRowCount() {
int result = 0;
// just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.size();
+ if (objects != null) {
+ result = objects.size();
}
return result;
@@ -151,8 +147,8 @@
Object result = null;
// just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.get(row);
+ if (objects != null) {
+ result = objects.get(row);
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("dd MMMMM yyyy");
@@ -246,8 +242,8 @@
}
- public void refresh(List<Object> datasList) {
- cacheDataList = datasList;
+ public void setObjects(List<Object> datasList) {
+ objects = datasList;
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -24,35 +24,25 @@
-->
<Table>
- <LedgerViewHandler id="handler" javaBean="new LedgerViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/>
- <org.chorem.lima.ui.ledger.LedgerTableModel id="modelTable"/>
+ <import>
+ javax.swing.ListSelectionModel
+ org.chorem.lima.enums.ComboBoxDatesEnum
+ org.chorem.lima.ui.common.IntervalPanel
+ </import>
+
+ <LedgerViewHandler id="handler" constructorParams="this"/>
+
<script>
<![CDATA[
- import org.chorem.lima.enums.ComboBoxDatesEnum;
- LedgerPeriodSearchPanel periodSearchPanel = new LedgerPeriodSearchPanel(handler);
-
void $afterCompleteSetup() {
+ handler.init();
}
-
]]>
</script>
+
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
- </cell>
- <cell>
- <LedgerPeriodSearchPanel javaBean="periodSearchPanel"/>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell anchor="east">
<JLabel text="lima.common.filter"/>
@@ -61,13 +51,13 @@
<JTextField id='balanceFilter' toolTipText="lima.tooltip.filter"
minimumSize='{balanceFilter.getPreferredSize()}'/>
<javax.swing.text.Document javaBean="balanceFilter.getDocument()"
- onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())'
- onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())'/>
+ onInsertUpdate='handler.accountFilterChanged()'
+ onRemoveUpdate='handler.accountFilterChanged()'/>
</cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter'
selected='false'
- onActionPerformed="getHandler().refresh()"/>
+ onActionPerformed="getHandler().movmentedFilterChanged()"/>
</cell>
<cell>
<EnumEditor id='DocumentEditor'
@@ -81,12 +71,9 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="8">
<JScrollPane>
- <org.chorem.lima.ui.ledger.LedgerTable
- id="table" sortable="false" rowHeight="24"
- constructorParams="getHandler()" model="{getModelTable()}"
+ <org.chorem.lima.ui.ledger.LedgerTableModel id="ledgerTableModel"/>
+ <org.chorem.lima.ui.ledger.LedgerTable sortable="false" rowHeight="24" model="{ledgerTableModel}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <javax.swing.ListSelectionModel
- javaBean="getTable().getSelectionModel()"/>
</JScrollPane>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -46,6 +46,7 @@
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
@@ -55,10 +56,10 @@
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-
/**
* Handler associated with accounts reports view.
* By : $Author$
@@ -70,70 +71,69 @@
protected LedgerTableModel model;
/** log. */
- private static final Log log = LogFactory.getLog(LedgerTableModel.class);
+ private static final Log log = LogFactory.getLog(LedgerViewHandler.class);
/** Services. */
protected ReportService reportService;
-
-// protected DocumentService documentService;
-
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
- /** Begin Date. */
- protected Date selectedBeginDate;
-
- /** EndDate. */
- protected Date selectedEndDate;
-
- /** Text field Accounts */
- protected String selectedAccounts;
-
- protected BalanceTrial balanceTrialCache;
-
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
- protected int port;
-
- protected List<Object> cachedatasList;
-
protected LedgerViewHandler(LedgerView view) {
this.view = view;
reportService =
LimaServiceFactory.getService(ReportService.class);
LimaServiceFactory.addServiceListener(ReportService.class, this);
- port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- public void setEndDate(Date date) {
- selectedEndDate = date;
+ public void intervalChanged() {
+ refreshData();
}
- public void setAccountFilter(String accounts) {
- selectedAccounts = accounts;
- refresh();
+ public void accountFilterChanged() {
+ refreshData();
}
+
+ public void movmentedFilterChanged() {
+ refreshData();
+ }
/**
- * get all account fot the selected period
- *
- * @return
+ * Refresh table data depending on item selected on combo boxes.
*/
- public List<Object> getDataList() {
- List<Object> results = new ArrayList<Object>();
- balanceTrialCache = reportService.generateLedger(selectedBeginDate,
- selectedEndDate, selectedAccounts,
- view.getMovmentedFilter().isSelected());
- if (balanceTrialCache.getReportsDatas() != null) {
- for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) {
+ protected void refreshData() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ String account = view.getBalanceFilter().getText().trim();
+
+ if (beginDate != null && endDate != null) {
+ BalanceTrial balanceTrial = reportService.generateLedger(beginDate,
+ endDate, account, view.getMovmentedFilter().isSelected());
+
+ LedgerTableModel dataModel = view.getLedgerTableModel();
+
+ List<Object> results = new ArrayList<Object>();
+ for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) {
results.add(reportsDatas);
List<Entry> entries = reportsDatas.getListEntry();
if (entries != null) {
@@ -141,48 +141,45 @@
results.addAll(entries);
}
}
+ dataModel.setObjects(results);
+
+ updateFooter(balanceTrial);
}
-
- return results;
}
- public void refresh() {
- if (selectedBeginDate != null && selectedEndDate != null) {
- model = view.getModelTable();
- cachedatasList = getDataList();
- model.refresh(cachedatasList);
+ /**
+ * Update footer labels containing reports total sum fields.
+ *
+ * @param results result to render
+ */
+ protected void updateFooter(BalanceTrial balanceTrial) {
+ // set amounts credit and debit and solde
+ view.amountCreditLabel.setText(
+ balanceTrial.getAmountCredit().toString());
+ view.amountDebitLabel.setText(
+ balanceTrial.getAmountDebit().toString());
+ BigDecimal amountSolde = balanceTrial.getAmountSolde();
+ view.amountSoldeLabel.setText(amountSolde.toString());
- /**
- * set text and amounts of labels credit, debit, solde
- */
- if (balanceTrialCache != null) {
- // set amounts credit, debit and solde
- view.amountCreditLabel.setText(
- String.valueOf(balanceTrialCache.getAmountCredit()));
- view.amountDebitLabel.setText(
- String.valueOf(balanceTrialCache.getAmountDebit()));
- BigDecimal amountSolde = balanceTrialCache.getAmountSolde();
- view.amountSoldeLabel.setText(
- String.valueOf(amountSolde));
-
- if (BigDecimal.ZERO.equals(amountSolde)) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (balanceTrialCache.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
- }
- }
+ if (BigDecimal.ZERO.equals(amountSolde)) {
+ view.amountSoldeLabel.setText(_("lima.common.solde"));
+ } else {
+ // set label solde: credit or debit
+ if (balanceTrial.getSoldeDebit()) {
+ view.amountSoldeLabel.setText(_("lima.common.soldedebit"));
+ } else {
+ view.amountSoldeLabel.setText(_("lima.common.soldecredit"));
}
}
}
-
+
public void createDocument() {
- if (selectedBeginDate != null && selectedEndDate != null) {
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ if (beginDate != null && endDate != null) {
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -191,8 +188,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -211,9 +208,10 @@
String address = LimaConfig.getInstance().getHostAdress();
try {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ "&format=" + selectedEnum.getExtension() + "&model="
+ DocumentsEnum.LEDGER.getFileName();
Desktop.getDesktop().browse(new URI(url));
@@ -227,11 +225,11 @@
}
@Override
- public void notifyMethod(String serviceName, String methodeName) {
+ public void notifyMethod(String serviceName, String methodName) {
if (serviceName.contains("FinancialTransaction") ||
- methodeName.contains("importAccount") ||
- methodeName.contains("importAll")) {
- refresh();
+ methodName.contains("importAccount") ||
+ methodName.contains("importAll")) {
+ refreshData();
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Rapport - Grand livre.
+ */
+package org.chorem.lima.ui.ledger;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r3438 - trunk/lima-business/src/main/java/org/chorem/lima/service
by echatellier@users.chorem.org June 4, 2012
by echatellier@users.chorem.org June 4, 2012
June 4, 2012
Author: echatellier
Date: 2012-06-04 16:34:55 +0200 (Mon, 04 Jun 2012)
New Revision: 3438
Url: http://chorem.org/repositories/revision/lima/3438
Log:
Remove test comment
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-04 14:33:59 UTC (rev 3437)
+++ trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-04 14:34:55 UTC (rev 3438)
@@ -89,7 +89,6 @@
// see http://openejb.apache.org/embedded-configuration.html
// http://openejb.apache.org/properties-listing.html
// for embedded configuration
- //props.setProperty("openejb.jndiname.format", "ejb/{interfaceClass.simpleName}");
container = EJBContainer.createEJBContainer(props);
}
1
0
r3437 - in trunk/lima-business/src: main/java/org/chorem/lima/service main/resources/META-INF test/resources/META-INF
by echatellier@users.chorem.org June 4, 2012
by echatellier@users.chorem.org June 4, 2012
June 4, 2012
Author: echatellier
Date: 2012-06-04 16:33:59 +0200 (Mon, 04 Jun 2012)
New Revision: 3437
Url: http://chorem.org/repositories/revision/lima/3437
Log:
Fix ejb module name to not being generated with application version.
Fix startup from command line.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-01 14:01:39 UTC (rev 3436)
+++ trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-04 14:33:59 UTC (rev 3437)
@@ -58,7 +58,7 @@
protected static EJBContainer container;
/** EJB service namespace. */
- protected static final String NAMESPACE = "java:global/lima-business/";
+ protected static final String NAMESPACE = "java:global/lima/";
/**
* Init openejb container.
@@ -89,6 +89,7 @@
// see http://openejb.apache.org/embedded-configuration.html
// http://openejb.apache.org/properties-listing.html
// for embedded configuration
+ //props.setProperty("openejb.jndiname.format", "ejb/{interfaceClass.simpleName}");
container = EJBContainer.createEJBContainer(props);
}
Modified: trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
===================================================================
--- trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml 2012-06-01 14:01:39 UTC (rev 3436)
+++ trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml 2012-06-04 14:33:59 UTC (rev 3437)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Lima business
@@ -28,7 +29,12 @@
Interceptor based on : http://openejb.apache.org/examples-trunk/alternate-descriptors/
-->
-<ejb-jar>
+<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
+ version="3.1">
+ <!-- Le nom est a fixer sinon, il est généré et contient la version -->
+ <module-name>lima</module-name>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
Modified: trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml
===================================================================
--- trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml 2012-06-01 14:01:39 UTC (rev 3436)
+++ trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml 2012-06-04 14:33:59 UTC (rev 3437)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Lima business
@@ -28,7 +29,12 @@
Interceptor based on : http://openejb.apache.org/examples-trunk/alternate-descriptors/
-->
-<ejb-jar>
+<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
+ version="3.1">
+ <!-- Le nom est a fixer sinon, il est généré et contient la version -->
+ <module-name>lima</module-name>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
1
0
r3436 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/accountsreports java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/common java/org/chorem/lima/ui/entrybooksreports java/org/chorem/lima/ui/financialtransactionsearch resources/i18n
by echatellier@users.chorem.org June 1, 2012
by echatellier@users.chorem.org June 1, 2012
June 1, 2012
Author: echatellier
Date: 2012-06-01 16:01:39 +0200 (Fri, 01 Jun 2012)
New Revision: 3436
Url: http://chorem.org/repositories/revision/lima/3436
Log:
Entry book report refactoring
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.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-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-01 14:01:39 UTC (rev 3436)
@@ -76,7 +76,7 @@
<cell fill='horizontal' anchor="west">
<AccountComboBoxModel id="accountComboboxModel" />
<AccountComboBox id="accountComboBox" model="{accountComboboxModel}"
- renderer="{new org.chorem.lima.ui.common.AccountRenderer()}"
+ renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
onItemStateChanged="handler.accountChanged(event)" />
</cell>
<cell>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -29,7 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.ui.combobox.LeafAccountComboBoxModel;
-import org.chorem.lima.ui.common.AccountRenderer;
+import org.chorem.lima.ui.common.AccountListRenderer;
import org.chorem.lima.util.AccountToString;
import org.chorem.lima.widgets.JWideComboBox;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
@@ -70,7 +70,7 @@
comboBox = new JWideComboBox();
LeafAccountComboBoxModel accountComboBoxModel = new LeafAccountComboBoxModel();
comboBox.setModel(accountComboBoxModel);
- AccountRenderer accountRenderer = new AccountRenderer();
+ AccountListRenderer accountRenderer = new AccountListRenderer();
comboBox.setRenderer(accountRenderer);
AutoCompleteDecorator.decorate(comboBox, AccountToString.getInstance());
comboBox.getEditor().getEditorComponent().addKeyListener(this);
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java (from rev 3429, trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -0,0 +1,64 @@
+/*
+ * #%L
+ * Lima Swing
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.ui.common;
+
+import org.chorem.lima.entity.Account;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import java.awt.Component;
+
+public class AccountListRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+
+ JLabel label = (JLabel) super.getListCellRendererComponent(list,
+ value,
+ index,
+ isSelected,
+ cellHasFocus
+ );
+ if (value != null) {
+ Account account = (Account) value;
+ String accountLabel = account.getLabel();
+ int nbChars = 30;
+ if (accountLabel != null && accountLabel.length() > nbChars) {
+ accountLabel = accountLabel.substring(0, nbChars) + "…";
+ }
+ label.setText(account.getAccountNumber() + " - " + accountLabel);
+ }
+ return this;
+ }
+
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -1,64 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.common;
-
-import org.chorem.lima.entity.Account;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import java.awt.Component;
-
-public class AccountRenderer extends DefaultListCellRenderer {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
-
- JLabel label = (JLabel) super.getListCellRendererComponent(list,
- value,
- index,
- isSelected,
- cellHasFocus
- );
- if (value != null) {
- Account account = (Account) value;
- String accountLabel = account.getLabel();
- int nbChars = 30;
- if (accountLabel != null && accountLabel.length() > nbChars) {
- accountLabel = accountLabel.substring(0, nbChars) + "…";
- }
- label.setText(account.getAccountNumber() + " - " + accountLabel);
- }
- return this;
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,69 +25,41 @@
package org.chorem.lima.ui.entrybooksreports;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.JComboBox;
+
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
import org.chorem.lima.util.EntryBookToString;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-import javax.swing.JComboBox;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-
public class EntryBookComboBox extends JComboBox implements KeyListener {
private static final long serialVersionUID = 1L;
- private static final Log log =
- LogFactory.getLog(EntryBookComboBox.class);
-
- protected EntryBooksReportsViewHandler handler;
-
- public EntryBookComboBox(EntryBooksReportsViewHandler handler) {
- this.handler = handler;
- EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
- setModel(entryBookComboBoxModel);
- setRenderer(LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class));
- setEditable(true);
+ public EntryBookComboBox() {
AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance());
getEditor().getEditorComponent().addKeyListener(this);
- addActionListener(this);
}
public void back() {
int row = getSelectedIndex();
- log.debug(row);
if (row > 0) {
getEditor().setItem(getItemAt(row - 1));
- handler.setEntryBook((EntryBook) getSelectedItem());
}
}
public void next() {
int size = getModel().getSize();
int row = getSelectedIndex();
- log.debug(row);
if (row < size - 1) {
getEditor().setItem(getItemAt(row + 1));
- handler.setEntryBook((EntryBook) getSelectedItem());
}
}
@Override
- public void actionPerformed(ActionEvent e) {
- Object object = getSelectedItem();
- if (object instanceof EntryBook) {
- handler.setEntryBook((EntryBook) getSelectedItem());
- }
- }
-
-
- @Override
public void keyPressed(KeyEvent e) {
}
@@ -96,7 +68,7 @@
public void keyReleased(KeyEvent e) {
Object object = getSelectedItem();
if (object instanceof EntryBook) {
- handler.setEntryBook((EntryBook) getSelectedItem());
+ fireActionEvent();
}
// delegate popup list menu
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
@@ -108,5 +80,4 @@
public void keyTyped(KeyEvent e) {
}
-
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -1,162 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.entrybooksreports;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class EntryBooksReportsPeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(EntryBooksReportsPeriodSearchPanel.class);
-
- protected EntryBooksReportsViewHandler handler;
-
- public EntryBooksReportsPeriodSearchPanel(EntryBooksReportsViewHandler handler) {
- this.handler = handler;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setBeginDate(beginDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setEndDate(endDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- handler.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
-
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -49,8 +49,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- protected EntryBooksReportsViewHandler handler;
-
protected EntryBooksReportsTableModel model;
private Highlighter colorReportsDatas;
@@ -61,9 +59,8 @@
/**
*/
- public EntryBooksReportsTable(EntryBooksReportsViewHandler handler, EntryBooksReportsTableModel model) {
+ public EntryBooksReportsTable(EntryBooksReportsTableModel model) {
- this.handler = handler;
this.model = model;
addKeyListener(this);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -38,7 +38,6 @@
import static org.nuiton.i18n.I18n._;
-
/**
* Entry book table model.
* By : $Author$
@@ -52,15 +51,15 @@
private static final Log log = LogFactory.getLog(EntryBooksReportsTableModel.class);
/** data cache */
- protected ReportsDatas cacheDataList;
+ protected ReportsDatas reportData;
@Override
public int getRowCount() {
int result = 0;
// just prevent too much result
- if (cacheDataList != null && cacheDataList.getListEntry() != null) {
- result = cacheDataList.getListEntry().size();
+ if (reportData != null && reportData.getListEntry() != null) {
+ result = reportData.getListEntry().size();
}
return result;
@@ -135,8 +134,8 @@
@Override
public Object getValueAt(int row, int column) {
Object result = null;
- if (cacheDataList.getListEntry() != null) {
- Entry currentRow = cacheDataList.getListEntry().get(row);
+ if (reportData.getListEntry() != null) {
+ Entry currentRow = reportData.getListEntry().get(row);
SimpleDateFormat simpleDateFormat =
new SimpleDateFormat("dd MMMMM yyyy");
@@ -178,18 +177,11 @@
}
public Entry getElementAt(int row) {
- return cacheDataList.getListEntry().get(row);
+ return reportData.getListEntry().get(row);
}
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // Just read, no write
- return false;
- }
-
- public void refresh(ReportsDatas datasList) {
- cacheDataList = datasList;
+ public void setReportDatas(ReportsDatas datasList) {
+ reportData = datasList;
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-01 14:01:39 UTC (rev 3436)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,27 +27,17 @@
<import>
javax.swing.ListSelectionModel
org.chorem.lima.enums.ComboBoxDatesEnum
- org.chorem.lima.ui.combobox.EntryBookComboBoxModel
- org.chorem.lima.ui.entrybooksreports.EntryBookComboBox
- org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTable
- org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTableModel
+ org.jdesktop.swingx.JXDatePicker
</import>
- <EntryBooksReportsViewHandler id="handler"
- javaBean="new EntryBooksReportsViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/>
- <EntryBooksReportsTableModel id="modelTable"/>
- <script>
- <![CDATA[
- EntryBooksReportsPeriodSearchPanel periodSearchPanel = new EntryBooksReportsPeriodSearchPanel(handler);
- EntryBookComboBox comboBox = new EntryBookComboBox(handler);
-
+ <EntryBooksReportsViewHandler id="handler" constructorParams="this"/>
+
+ <script><![CDATA[
void $afterCompleteSetup() {
+ handler.init();
}
-
- ]]>
- </script>
+ ]]></script>
+
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
<Table>
@@ -55,11 +45,26 @@
<cell anchor="west">
<JComboBox id="periodComboBox"
javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
+ onActionPerformed="handler.periodTypeChanged()"/>
</cell>
<cell>
- <EntryBooksReportsPeriodSearchPanel javaBean="periodSearchPanel"/>
+ <CardLayout id="periodTypeLayout" />
+ <JPanel id="periodTypeContainer" layout="{periodTypeLayout}">
+ <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodModel" />
+ <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodModel}"
+ renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
+ onItemStateChanged="handler.periodsChanged(event)" constraints='"FISCAL_PERIOD"' />
+ <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodModel" />
+ <JComboBox id="financialPeriodComboBox" model="{financialPeriodModel}"
+ renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"
+ onItemStateChanged="handler.periodsChanged(event)" constraints='"FINANCIAL_PERIOD"' />
+ <JPanel constraints='"PERIOD"'>
+ <JLabel text="lima.common.begindate" />
+ <JXDatePicker id="periodBeginDatePicker" onActionPerformed="handler.periodDatesChanged()" />
+ <JLabel text="lima.common.enddate" />
+ <JXDatePicker id="periodEndDatePicker" onActionPerformed="handler.periodDatesChanged()" />
+ </JPanel>
+ </JPanel>
</cell>
</row>
</Table>
@@ -68,15 +73,18 @@
<JLabel id="entryBookSelectorLabel" text="lima.common.entrybook"/>
</cell>
<cell anchor="west">
- <JComboBox javaBean='comboBox'/>
+ <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookModel" />
+ <EntryBookComboBox id="entryBookCombo" model="{entryBookModel}"
+ renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}"
+ onItemStateChanged="handler.entryBookChanged(event)"/>
</cell>
<cell>
<JButton id="back" text="lima.common.buttonback"
- onActionPerformed="comboBox.back()"/>
+ onActionPerformed="entryBookCombo.back()"/>
</cell>
<cell>
<JButton id="next" text="lima.common.buttonnext"
- onActionPerformed="comboBox.next()"/>
+ onActionPerformed="entryBookCombo.next()"/>
</cell>
<cell>
<EnumEditor id='DocumentEditor'
@@ -90,13 +98,11 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="7">
<JScrollPane>
- <EntryBooksReportsTable
- id="table" sortable="false" rowHeight="24"
- constructorParams="getHandler(), getModelTable()"
- model="{getModelTable()}"
+ <EntryBooksReportsTableModel id="entryBookReportsTableModel" />
+ <EntryBooksReportsTable id="reportTable" sortable="false" rowHeight="24"
+ constructorParams="entryBookReportsTableModel"
+ model="{entryBookReportsTableModel}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <ListSelectionModel
- javaBean="getTable().getSelectionModel()"/>
</JScrollPane>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -28,22 +28,27 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Desktop;
+import java.awt.event.ItemEvent;
import java.io.IOException;
-import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
import java.util.List;
+import javax.swing.JComboBox;
import javax.swing.JOptionPane;
+import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.DocumentService;
+import org.chorem.lima.business.api.EntryBookService;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
@@ -52,122 +57,187 @@
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.enums.ComboBoxDatesEnum;
import org.chorem.lima.service.LimaServiceFactory;
/**
* Handler associated with accounts reports view.
+ *
* By : $Author$
*/
public class EntryBooksReportsViewHandler implements ServiceListener {
- protected EntryBooksReportsView view;
-
- protected EntryBooksReportsTable table;
-
- protected EntryBooksReportsTableModel tableModel;
-
/** log. */
private static final Log log = LogFactory.getLog(EntryBooksReportsViewHandler.class);
+ protected EntryBooksReportsView view;
+
/** Services. */
protected ReportService reportService;
-
protected DocumentService documentService;
-
+ protected EntryBookService entryBookService;
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
- /** Account. */
- protected EntryBook selectedEntryBook;
-
- /** Begin Date. */
- protected Date selectedBeginDate;
-
- /** EndDate. */
- protected Date selectedEndDate;
-
- protected int port;
-
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
- protected EntryBooksReportsViewHandler(EntryBooksReportsView view) {
+ public EntryBooksReportsViewHandler(EntryBooksReportsView view) {
this.view = view;
reportService = LimaServiceFactory.getService(ReportService.class);
- port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
documentService = LimaServiceFactory.getService(DocumentService.class);
+ reportService = LimaServiceFactory.getService(ReportService.class);
+ entryBookService = LimaServiceFactory.getService(EntryBookService.class);
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
- refresh();
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
+ view.getEntryBookModel().setObjects(entryBooks);
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ view.getFiscalPeriodModel().setObjects(fiscalPeriod);
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getFinancialPeriodModel().setObjects(financialPeriod);
+
+ // init date periods
+ initDatePeriods();
}
+
+ /**
+ * Init date pickers objects with contextual dates.
+ */
+ private void initDatePeriods() {
- public void setEndDate(Date date) {
- selectedEndDate = date;
- refresh();
+ // get begin date
+ Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
+ view.getPeriodBeginDatePicker().setDate(beginDate);
+
+ // get end date
+ Date endDate = new Date();
+ view.getPeriodEndDatePicker().setDate(endDate);
}
+ public void periodTypeChanged() {
+ JComboBox periodComboBox = view.getPeriodComboBox();
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- public void setEntryBook(EntryBook entryBook) {
- selectedEntryBook = entryBook;
- refresh();
+ // show corresponding component in layout
+ view.getPeriodTypeLayout().show(view.getPeriodTypeContainer(), type.name());
}
- public ReportsDatas getDataList() {
+ protected void periodsChanged(ItemEvent event) {
+ if (event.getStateChange() == ItemEvent.SELECTED) {
+ refreshData();
+ }
+ }
+
+ protected void entryBookChanged(ItemEvent event) {
+ if (event.getStateChange() == ItemEvent.SELECTED) {
+ refreshData();
+ }
+ }
+
+ protected void periodDatesChanged() {
+ refreshData();
+ }
+
+ /*public ReportsDatas getDataList() {
ReportsDatas results = null;
if (selectedEntryBook != null) {
results = reportService.generateEntryBooksReports(
selectedEntryBook, selectedBeginDate, selectedEndDate);
}
return results;
- }
+ }*/
- public void refresh() {
+ /**
+ * Refresh table data depending on item selected on combo boxes.
+ */
+ protected void refreshData() {
+
+ Date beginDate = null;
+ Date endDate = null;
- if (selectedBeginDate != null && selectedEndDate != null && selectedEntryBook != null) {
- tableModel = view.getModelTable();
+ JComboBox periodComboBox = view.getPeriodComboBox();
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ beginDate = view.getPeriodBeginDatePicker().getDate();
+ endDate = view.getPeriodEndDatePicker().getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ }
+
+ EntryBook entryBook = (EntryBook)view.getEntryBookCombo().getModel().getSelectedItem();
+
+ if (beginDate != null && endDate != null && entryBook != null) {
+ ReportsDatas results = reportService.generateEntryBooksReports(entryBook,
+ beginDate, endDate);
+
+ EntryBooksReportsTableModel dataModel = view.getEntryBookReportsTableModel();
+ dataModel.setReportDatas(results);
+ }
+ }
- ReportsDatas datasList = getDataList();
+ public void createDocument() {
- tableModel.refresh(datasList);
+ // FIXME echatellier 20120601 duplicated code
+ Date beginDate = null;
+ Date endDate = null;
- /**
- * set text and amounts of labels credit, debit, solde
- */
-
- if (datasList != null) {
- // set amounts credit, debit and solde
- view.amountCreditLabel.setText(
- String.valueOf(datasList.getAmountCredit()));
- view.amountDebitLabel.setText(
- String.valueOf(datasList.getAmountDebit()));
- BigDecimal amountSolde = datasList.getAmountSolde();
- view.amountSoldeLabel.setText(String.valueOf(amountSolde));
-
- if (BigDecimal.ZERO.equals(amountSolde)) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (datasList.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
- }
+ JComboBox periodComboBox = view.getPeriodComboBox();
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ beginDate = view.getPeriodBeginDatePicker().getDate();
+ endDate = view.getPeriodEndDatePicker().getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
}
+ break;
}
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
+ }
+ break;
+ }
}
- }
+
+ if (beginDate != null && endDate != null) {
-
- public void createDocument() {
-
- if (selectedBeginDate != null && selectedEndDate != null) {
-
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -175,8 +245,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -187,24 +257,25 @@
JOptionPane.showMessageDialog(
view,
_("lima.entrybooksreports.documentcreationfiscalerror"),
- _("lima.common.error"),
+ _("lima.entrybooksreports.documentcreationfiscaltitle"),
JOptionPane.ERROR_MESSAGE);
} else {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
String address = LimaConfig.getInstance().getHostAdress();
try {
String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ "&format=" + selectedEnum.getExtension() + "&model="
+ DocumentsEnum.ENTRYBOOKS.getFileName();
Desktop.getDesktop().browse(new URI(url));
String url2 = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ "&format=" + selectedEnum.getExtension() + "&model="
+ DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
Desktop.getDesktop().browse(new URI(url2));
@@ -219,10 +290,9 @@
}
@Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntryBook") || methodeName.contains("importAll")) {
- refresh();
+ public void notifyMethod(String serviceName, String methodName) {
+ if (serviceName.contains("FinancialTransaction") || methodName.contains("importEntryBook") || methodName.contains("importAll")) {
+ refreshData();
}
}
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -29,7 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.ui.combobox.AccountComboBoxModel;
-import org.chorem.lima.ui.common.AccountRenderer;
+import org.chorem.lima.ui.common.AccountListRenderer;
import org.chorem.lima.util.AccountToString;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
@@ -50,7 +50,7 @@
public AccountSearchComboBox(FinancialTransactionSearchViewHandler handler) {
this.handler = handler;
AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel();
- AccountRenderer accountRenderer = new AccountRenderer();
+ AccountListRenderer accountRenderer = new AccountListRenderer();
setModel(accountComboBoxModel);
setRenderer(accountRenderer);
setEditable(true);
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 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-06-01 14:01:39 UTC (rev 3436)
@@ -95,6 +95,7 @@
lima.entries.writetransaction=Write entries
lima.entrybooksreports.documentcreationerror=Enable to create document
lima.entrybooksreports.documentcreationfiscalerror=Can't create document on an open fiscal year
+lima.entrybooksreports.documentcreationfiscaltitle=
lima.entrybooksreports.listerror=Can't get entries list
lima.enum.comboboxaccount.account=Account
lima.enum.comboboxaccount.accountlist=Account list
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 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-01 14:01:39 UTC (rev 3436)
@@ -95,6 +95,7 @@
lima.entries.writetransaction=Saisir des écritures
lima.entrybooksreports.documentcreationerror=Erreur lors de la création du document
lima.entrybooksreports.documentcreationfiscalerror=Impossible de créer un document quand la période fiscale est ouverte
+lima.entrybooksreports.documentcreationfiscaltitle=
lima.entrybooksreports.listerror=Erreur lors de la récupération des données de la liste
lima.enum.comboboxaccount.account=Compte
lima.enum.comboboxaccount.accountlist=Liste de comptes
1
0
June 1, 2012
Author: echatellier
Date: 2012-06-01 11:27:45 +0200 (Fri, 01 Jun 2012)
New Revision: 3435
Url: http://chorem.org/repositories/revision/lima/3435
Log:
Fix typo
Modified:
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
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 2012-05-30 14:06:48 UTC (rev 3434)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-01 09:27:45 UTC (rev 3435)
@@ -94,7 +94,7 @@
lima.entries.searchunbalancedtransaction=Entrées incorrectes
lima.entries.writetransaction=Saisir des écritures
lima.entrybooksreports.documentcreationerror=Erreur lors de la création du document
-lima.entrybooksreports.documentcreationfiscalerror=Impossible de créedr un document quand la période fiscale est ouverte
+lima.entrybooksreports.documentcreationfiscalerror=Impossible de créer un document quand la période fiscale est ouverte
lima.entrybooksreports.listerror=Erreur lors de la récupération des données de la liste
lima.enum.comboboxaccount.account=Compte
lima.enum.comboboxaccount.accountlist=Liste de comptes
1
0