Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 1853 discussions
r3618 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/importexport resources resources/i18n
by mallon@users.chorem.org 20 Aug '12
by mallon@users.chorem.org 20 Aug '12
20 Aug '12
Author: mallon
Date: 2012-08-20 16:04:19 +0200 (Mon, 20 Aug 2012)
New Revision: 3618
Url: http://chorem.org/repositories/revision/lima/3618
Log:
Correction de l affichage des messages et des clefs d internationalisation, lors des imports pour les plans BCR et TVA.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2012-08-20 13:21:25 UTC (rev 3617)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2012-08-20 14:04:19 UTC (rev 3618)
@@ -202,25 +202,39 @@
@Override
protected void done() {
try {
+
+ if (log.isDebugEnabled()) {
+ log.debug("importMode : " + importMode);
+ }
+
//hidde wait dialog panel
waitView.setVisible(false);
// display result dialog
if (verboseMode) {
String result = get();
- if (!result.equals("")) {
+ if (result.equals("")) {
JOptionPane.showMessageDialog(viewComponent, _("lima.ui.importexport.importerror"),
_("lima.ui.importexport.importtitle"), JOptionPane.ERROR_MESSAGE);
} else {
if (importMode) {
+ if (log.isDebugEnabled()) {
+ log.debug("importMode");
+ }
//special message when importing a VAT PDF
if (importExportMethodeF.equals(ImportExportEnum.PDF_VAT_IMPORT)) {
+ if (log.isDebugEnabled()) {
+ log.debug("PDF_VAT_IMPORT");
+ }
JOptionPane.showMessageDialog(
waitView,
_("lima.ui.importexport.import.vatpdfimport"),
_("lima.ui.importexport.import"),
JOptionPane.INFORMATION_MESSAGE);
} else {
+ if (log.isDebugEnabled()) {
+ log.debug("import.terminated");
+ }
JOptionPane.showMessageDialog(
waitView,
_("lima.ui.importexport.import.terminated"),
@@ -228,6 +242,9 @@
JOptionPane.INFORMATION_MESSAGE);
}
} else {
+ if (log.isDebugEnabled()) {
+ log.debug("export.terminated");
+ }
JOptionPane.showMessageDialog(
waitView,
_("lima.ui.importexport.export.terminated"),
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-08-20 13:21:25 UTC (rev 3617)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-20 14:04:19 UTC (rev 3618)
@@ -326,8 +326,8 @@
lima.ui.importexport.import.vatpdfimport=Le PDF a bien été importé dans le répertoire des ressources de Lima
lima.ui.importexport.importcsv=Import/Export CSV
lima.ui.importexport.importebp=Import/Export EBP
-lima.ui.importexport.importerror=
-lima.ui.importexport.importtitle=
+lima.ui.importexport.importerror=Echec de l'import
+lima.ui.importexport.importtitle=Erreur d'import
lima.ui.importexport.vatstatements=Plan TVA
lima.ui.importexport.wait=Traitement en cours…
lima.ui.importexport.waittitle=Traitement en cours
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-20 13:21:25 UTC (rev 3617)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-20 14:04:19 UTC (rev 3618)
@@ -61,4 +61,5 @@
log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG
log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG
-log4j.logger.org.chorem.lima.business.ejb.FinancialStatementServiceImpl=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.business.ejb.FinancialStatementServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.ui.importexport.ImportExport=DEBUG
\ No newline at end of file
1
0
Author: mallon
Date: 2012-08-20 15:21:25 +0200 (Mon, 20 Aug 2012)
New Revision: 3617
Url: http://chorem.org/repositories/revision/lima/3617
Log:
fixes #775 Correction de la valeur de la clef d'import du pdf de la d?\195?\169claration de tva.
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-08-20 13:15:52 UTC (rev 3616)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-20 13:21:25 UTC (rev 3617)
@@ -30,7 +30,7 @@
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.vatpdf=Import du pdf
lima.charts.vatstatement=Plan TVA
lima.charts.vatstatement.base=Plan TVA de base
lima.charts.vatstatement.deleteparent=Veuillez supprimer les sous-catégories de cette ligne
1
0
r3616 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/importexport resources/i18n
by mallon@users.chorem.org 20 Aug '12
by mallon@users.chorem.org 20 Aug '12
20 Aug '12
Author: mallon
Date: 2012-08-20 15:15:52 +0200 (Mon, 20 Aug 2012)
New Revision: 3616
Url: http://chorem.org/repositories/revision/lima/3616
Log:
fixes #773 Correction sur les clefs d'internationalisation, et les titres du JFileChooser et de son bouton de s?\195?\169lection, aussi bien pour l'import que pour l'export.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2012-08-20 12:52:54 UTC (rev 3615)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2012-08-20 13:15:52 UTC (rev 3616)
@@ -274,10 +274,17 @@
((Container) chooser.getComponent(2)).add(panel, BorderLayout.SOUTH);
}
+ String approveButtonText;
if (importMode) {
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ approveButtonText = _("lima.ui.importexport.import");
+ chooser.setDialogTitle(approveButtonText);
+ chooser.setApproveButtonText(approveButtonText);
} else {
+ approveButtonText = _("lima.ui.importexport.export");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setDialogTitle(approveButtonText);
+ chooser.setApproveButtonText(approveButtonText);
}
if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) {
filePath = chooser.getSelectedFile().getAbsolutePath();
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-08-20 12:52:54 UTC (rev 3615)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-20 13:15:52 UTC (rev 3616)
@@ -150,7 +150,7 @@
lima.identity.phoneNumber=n° Tel
lima.identity.vatNumber=n° TVA
lima.identity.zipCode=Code Postal
-lima.importexport.choiceencoding=
+lima.importexport.choiceencoding=Choix de l'encodage
lima.importexport.export=
lima.importexport.export.terminated=
lima.importexport.usevatpdf=
@@ -317,7 +317,7 @@
lima.ui.importexport.ebp=Import/Export EBP
lima.ui.importexport.entries=Écritures
lima.ui.importexport.entrybooks=Journaux
-lima.ui.importexport.export=Export
+lima.ui.importexport.export=Exporter
lima.ui.importexport.export.terminated=Export terminé
lima.ui.importexport.financialstatements=Plan BCR
lima.ui.importexport.financialtransactions=Écritures
1
0
r3615 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/common lima-swing/src/main/java/org/chorem/lima/ui/vatreports
by mallon@users.chorem.org 20 Aug '12
by mallon@users.chorem.org 20 Aug '12
20 Aug '12
Author: mallon
Date: 2012-08-20 14:52:54 +0200 (Mon, 20 Aug 2012)
New Revision: 3615
Url: http://chorem.org/repositories/revision/lima/3615
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition de la d?\195?\169claration de TVA - Reste ?\195?\160 revoir l'autocompl?\195?\169tion du document,
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java
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-08-20 11:59:56 UTC (rev 3614)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-20 12:52:54 UTC (rev 3615)
@@ -213,7 +213,7 @@
} 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
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-08-20 11:59:56 UTC (rev 3614)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java 2012-08-20 12:52:54 UTC (rev 3615)
@@ -139,7 +139,7 @@
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(1, 1, 1, 1), 0, 0));
- JLabel endLabel = new JLabel(_("lima.common.begindate"));
+ JLabel endLabel = new JLabel(_("lima.common.enddate"));
periodPanel.add(endLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(1, 1, 1, 1), 0, 0));
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java 2012-08-20 11:59:56 UTC (rev 3614)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java 2012-08-20 12:52:54 UTC (rev 3615)
@@ -1,168 +0,0 @@
-/*
- * #%L
- * Lima :: Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2011 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.vatreports;
-
-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 VatReportPeriodSearchPanel extends JPanel {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log =
- LogFactory.getLog(VatReportPeriodSearchPanel.class);
-
- protected VatReportViewHandler handler;
-
- public VatReportPeriodSearchPanel(VatReportViewHandler 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);
- final VatReportTableModel tableModel = handler.getTableModel();
-
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
-
- tableModel.setBeginDate(beginDatePicker.getDate());
- handler.refresh();
- }
- };
- tableModel.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) {
- tableModel.setEndDate(endDatePicker.getDate());
- handler.refresh();
- }
- };
- tableModel.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.getTableModel().setBeginDate(fPeriod.getBeginDate());
- handler.getTableModel().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.getTableModel().setBeginDate(fPeriod.getBeginDate());
- handler.getTableModel().setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx 2012-08-20 11:59:56 UTC (rev 3614)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx 2012-08-20 12:52:54 UTC (rev 3615)
@@ -29,9 +29,7 @@
<import>
javax.swing.ListSelectionModel
org.jdesktop.swingx.JXTable
- org.chorem.lima.entity.FiscalPeriod
- org.chorem.lima.entity.FinancialPeriod
- org.chorem.lima.enums.ComboBoxDatesEnum
+ org.chorem.lima.ui.common.IntervalPanel
</import>
<Boolean id="autoComplete" javaBean="false"/>
@@ -45,18 +43,8 @@
</script>
<row weightx="1" weighty="0" anchor="center">
- <cell anchor="east">
- <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/>
- </cell>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
- </cell>
<cell>
- <VatReportPeriodSearchPanel id="periodSearchPanel"
- constructorParams="handler"/>
+ <IntervalPanel id="intervalPanel"/>
</cell>
<cell>
<JCheckBox id='autocompleteCheckBox' text='lima.common.autocomplete'
@@ -68,17 +56,4 @@
onActionPerformed="getHandler().editVat()"/>
</cell>
</row>
- <row>
- <cell fill="both" weightx="1" weighty="1" rows="3" columns="11">
- <JScrollPane>
- <!--<VatReportTableModel id="vatReportTableModel"/>-->
- <JXTable id="vatReportTable" sortable="false" rowHeight="22"
- model="{new VatReportTableModel()}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <!--<ListSelectionModel-->
- <!--initializer="getVatReportTable().getSelectionModel()"-->
- <!--onValueChanged="setSelectedRow(vatReportTable.getSelectedRow() != -1)"/>-->
- </JScrollPane>
- </cell>
- </row>
</Table>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java 2012-08-20 11:59:56 UTC (rev 3614)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java 2012-08-20 12:52:54 UTC (rev 3615)
@@ -26,20 +26,22 @@
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.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.business.api.DocumentService;
+import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
import org.chorem.lima.business.utils.DocumentsEnum;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
public class VatReportViewHandler {
/** log. */
@@ -47,12 +49,11 @@
LogFactory.getLog(VatReportViewHandler.class);
protected VatReportView view;
-
protected DocumentService documentService;
-
+ protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
-
protected int port;
protected VatReportViewHandler(VatReportView view) {
@@ -61,37 +62,28 @@
port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
documentService = LimaServiceFactory.getService(DocumentService.class);
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
}
+ /**
+ * Init data models and displayed objects.
+ */
public void init() {
- //Get new BigDecimal editor
- view.getVatReportTable().setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor());
-
- //Get new BigDecimal renderer
- view.getVatReportTable().setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
-
- // do refresh (TODO check if required...)
- refresh();
+ List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(blockedFiscalPeriods, financialPeriod);
}
- /** @return VatView */
- public VatReportView getView() {
- return view;
- }
- public VatReportTableModel getTableModel() {
- return (VatReportTableModel) view.getVatReportTable().getModel();
- }
-
/** Edit VAT document */
public void editVat() {
- VatReportTableModel tableModel = getTableModel();
- if (tableModel.getBeginDate() != null || tableModel.getEndDate() != null) {
+ if (view.getIntervalPanel().getBeginDate() != null || view.getIntervalPanel().getEndDate() != null) {
String address = LimaConfig.getInstance().getHostAdress();
try {
String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(tableModel.getBeginDate())
- + "&endDate=" + dateFormat.format(tableModel.getEndDate())
+ + dateFormat.format(view.getIntervalPanel().getBeginDate())
+ + "&endDate=" + dateFormat.format(view.getIntervalPanel().getEndDate())
+ "&format=.pdf&model=" + DocumentsEnum.VAT.getFileName()
+ "&autocomplete=" + view.getAutoComplete();
Desktop.getDesktop().browse(new URI(url));
@@ -103,10 +95,4 @@
}
}
- /** Refresh VatTableModel */
- public void refresh() {
- VatReportTableModel tableModel = getTableModel();
- tableModel.refresh();
- }
-
}
1
0
r3614 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima/business/api lima-swing/src/main/java/org/chorem/lima/ui/financialperiod
by echatellier@users.chorem.org 20 Aug '12
by echatellier@users.chorem.org 20 Aug '12
20 Aug '12
Author: echatellier
Date: 2012-08-20 13:59:56 +0200 (Mon, 20 Aug 2012)
New Revision: 3614
Url: http://chorem.org/repositories/revision/lima/3614
Log:
Corection de la mise ?\195?\160 jour de la liste des periodes comptables apr?\195?\168s fermeture.
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-08-20 11:59:56 UTC (rev 3614)
@@ -153,9 +153,10 @@
}
@Override
- public void blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
+ public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ ClosedPeriodicEntryBook result = null;
try {
// check rules before create the account
accountingRules.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
@@ -164,16 +165,17 @@
getDaoHelper().getClosedPeriodicEntryBookDAO();
// reload object in current transaction
- ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
- closedPeriodicEntryBookDAO.findByTopiaId(
+ result = closedPeriodicEntryBookDAO.findByTopiaId(
closedPeriodicEntryBook.getTopiaId());
- closedPeriodicEntryBook2.setLocked(true);
- closedPeriodicEntryBookDAO.update(closedPeriodicEntryBook2);
+ result.setLocked(true);
+ result = closedPeriodicEntryBookDAO.update(result);
} catch (TopiaException ex) {
throw new LimaException("Can't block period", ex);
}
+
+ return result;
}
@Override
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-08-20 11:59:56 UTC (rev 3614)
@@ -1124,9 +1124,8 @@
.findByEntryBookAndFinancialPeriod(entryBook,
financialPeriod);
try {
- financialPeriodService
- .blockClosedPeriodicEntryBook(
- closedPeriodicEntryBook);
+ closedPeriodicEntryBook = financialPeriodService
+ .blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
result.append(_("lima-business.import.closedperiodicentrybookupdated",
beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook));
} catch (LimaException eee) {
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2012-08-20 11:38:22 UTC (rev 3613)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2012-08-20 11:59:56 UTC (rev 3614)
@@ -68,7 +68,7 @@
// block it
Assert.assertFalse(closedPeriodic.isLocked());
- financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodic);
+ closedPeriodic = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodic);
// check it's blocked
context = getTestContext().beginTransaction();
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2012-08-20 11:38:22 UTC (rev 3613)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2012-08-20 11:59:56 UTC (rev 3614)
@@ -55,7 +55,7 @@
List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException;
- void blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException;
+ ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException;
List<FinancialPeriod> getAllFinancialPeriods() throws LimaException;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2012-08-20 11:38:22 UTC (rev 3613)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2012-08-20 11:59:56 UTC (rev 3614)
@@ -118,11 +118,16 @@
return currentRow;
}
+ public void setElementAt(int row, ClosedPeriodicEntryBook closedPeriodicEntryBook) {
+ closedPeriodicEntryBooks.set(row, closedPeriodicEntryBook);
+ fireTableRowsUpdated(row, row);
+ }
+
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Object result = null;
- ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBooks.get(rowIndex);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = getElementAt(rowIndex);
switch (columnIndex) {
case 0:
@@ -147,11 +152,4 @@
return result;
}
-
- /*public void blockFinancialPeriod(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
- financialPeriodService.
- blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
- refresh();
- }*/
-
}
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-08-20 11:38:22 UTC (rev 3613)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2012-08-20 11:59:56 UTC (rev 3614)
@@ -100,8 +100,8 @@
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
- model.fireTableRowsUpdated(selectedRow, selectedRow);
+ closedPeriodicEntryBook = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ model.setElementAt(selectedRow, closedPeriodicEntryBook);
}
}
1
0
Author: mallon
Date: 2012-08-20 13:38:22 +0200 (Mon, 20 Aug 2012)
New Revision: 3613
Url: http://chorem.org/repositories/revision/lima/3613
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition du bilan et du r?\195?\169sultat (Reste le calcul ?\195?\160 revoir.)
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.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/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.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/AccountDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.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/resources/log4j.properties
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -188,7 +188,7 @@
//Check if the fiscal period to block is the oldest
if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
- throw new LimaBusinessException(_("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
+ throw new LimaBusinessException(_("lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked"));
}
} catch (TopiaException ex) {
throw new LimaException("Can't check rule", ex);
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -27,18 +27,12 @@
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
-import com.lowagie.text.Chapter;
-import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
-import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.Table;
-import com.lowagie.text.html.HtmlWriter;
-import com.lowagie.text.pdf.PdfWriter;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -81,7 +75,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
@@ -234,229 +227,124 @@
}
@Override
- public void createFinancialStatementsDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+ public String createFinancialStatementsDocuments(Date beginDate,
+ Date endDate) throws LimaException {
+ String financialStatementReport = null;
- List<FinancialStatementAmounts> financialStatementAmounts =
- financialStatementService.financialStatementReport(beginDate, endDate);
-
- Date newDate = new Date();
- String filePath = path + File.separator + DocumentsEnum.FINANCIALSTATEMENT.getFileName();
-
try {
- FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
- switch (format) {
- case HTML:
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
- break;
- case PDF:
- PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
- break;
- }
- document.open();
- int nbpages = 1;
+ financialStatementReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
+ financialStatementReport += constructHeadHtml(_("lima.reports.financialstatement"));
+ financialStatementReport += "<body>\n";
- Identity identity = identityService.getIdentity();
+ if (beginDate != null && endDate != null) {
- //Split list by financialstatement type
- List<List<FinancialStatementAmounts>> listList =
- new ArrayList<List<FinancialStatementAmounts>>();
- Boolean first = true;
- int min = 0;
- int size = financialStatementAmounts.size();
- for (int i = 0; i < size; i++) {
- FinancialStatementAmounts fStatementAmounts =
- financialStatementAmounts.get(i);
- if (fStatementAmounts.getLevel() == 1 && !fStatementAmounts.getSubAmount()) {
- if (first) {
- first = false;
- } else {
- listList.add(financialStatementAmounts.subList(min, i - 1));
+ List<FinancialStatementAmounts> financialStatementAmounts =
+ financialStatementService.financialStatementReport(beginDate, endDate);
+ //Split list by financialstatement type
+ List<List<FinancialStatementAmounts>> listList =
+ new ArrayList<List<FinancialStatementAmounts>>();
+ Boolean first = true;
+ int min = 0;
+ int size = financialStatementAmounts.size();
+ for (int i = 0; i < size; i++) {
+ FinancialStatementAmounts fStatementAmounts =
+ financialStatementAmounts.get(i);
+ if (fStatementAmounts.getLevel() == 1 && !fStatementAmounts.getSubAmount()) {
+ if (first) {
+ first = false;
+ } else {
+ listList.add(financialStatementAmounts.subList(min, i - 1));
+ }
+ min = i;
}
- min = i;
}
- }
- listList.add(financialStatementAmounts.subList(min, size));
+ listList.add(financialStatementAmounts.subList(min, size));
- //create pages
- for (List<FinancialStatementAmounts> list : listList) {
- String title = list.get(0).getLabel();
- 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<FinancialStatementAmounts> subFinancialStatementAmounts =
- list.subList(i, j);
- //create page : header + table + footer
- Table headerTable = createFinancialStatementsHeaderTable();
- Table table = createFinancialStatementsTable(
- subFinancialStatementAmounts);
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(title, 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++;
- }
- }
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+ //create pages
+ for (List<FinancialStatementAmounts> list : listList) {
+ String subTitle = list.get(0).getLabel();
+ financialStatementReport += constructSubTitleHtml(boldBegin + subTitle + boldEnd, "");
+ int i = 0;
+ int n = list.size();
+ int max = n;
+ while (i < n) {
+ int j = i + max;
+ if (j > n) {
+ j = n;
+ }
- document.close();
+ financialStatementReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
- } catch (FileNotFoundException eeFNFE) {
- log.error("Can't create pdf file", eeFNFE);
- } catch (DocumentException eeDE) {
- log.error("Can't create document", eeDE);
- }
- }
+ String columnNames [] = {_("lima-business.document.label"), _("lima-business.document.grossamount"),
+ _("lima-business.document.provisiondeprecationamount"), _("lima-business.document.netamount")};
+ financialStatementReport += constructColumnsHtml(columnNames);
- protected Table createFinancialStatementsHeaderTable() {
- Table t = null;
- try {
- t = new Table(4, 1);
- float[] widths = {0.4f, 0.2f, 0.2f, 0.2f};
- 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.label"),
- boldFont));
- t.addCell(new Phrase(_("lima-business.document.grossamount"),
- boldFont));
- t.addCell(new Phrase(_("lima-business.document.provisiondeprecationamount"),
- boldFont));
- t.addCell(new Phrase(_("lima-business.document.netamount"),
- boldFont));
+ String tabLabel = "";
+ String bigAmountString = "0";
+ String provisionDeprecationAmountString = "0";
+ String soldeString = "0";
+ List<FinancialStatementAmounts> subFinancialStatementAmounts = list.subList(i, j);
+ for (FinancialStatementAmounts financialStatementAmount : subFinancialStatementAmounts) {
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
+ String label = financialStatementAmount.getLabel();
+ int level = financialStatementAmount.getLevel();
+ BigDecimal bigAmount =
+ financialStatementAmount.getGrossAmount();
+ if (bigAmount == null) {
+ bigAmount = new BigDecimal(0);
+ }
+ BigDecimal provisionDeprecationAmount =
+ financialStatementAmount.getProvisionDeprecationAmount();
+ if (provisionDeprecationAmount == null) {
+ provisionDeprecationAmount = new BigDecimal(0);
+ }
- }
+ StringBuffer tab = new StringBuffer();
+ for (int k = 0; k < level; k++) {
+ tab.append("\t");
+ }
- protected Table createFinancialStatementsTable(List<FinancialStatementAmounts> financialStatementAmounts) {
- int nbrow = financialStatementAmounts.size();
- Table t = null;
- try {
- //define table
- t = new Table(4, nbrow);
- t.setWidth(100f);
- float[] widths = {0.4f, 0.2f, 0.2f, 0.2f};
- t.setWidths(widths);
- t.setPadding(1.5f);
- t.setBorderWidth(1);
- t.setOffset(0);
- //define default cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.LEFT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
+ if (financialStatementAmount.getHeader()) {
+ tabLabel = boldBegin + tab + label + boldEnd;
+ } else {
+ tabLabel = tab + label;
+ }
+ if (bigAmount != BigDecimal.ZERO) {
+ bigAmountString = bigAmount.toString();
+ }
+ if (provisionDeprecationAmount != BigDecimal.ZERO) {
+ provisionDeprecationAmountString = provisionDeprecationAmount.toString();
+ }
+ BigDecimal solde = bigAmount;
+ solde = solde.subtract(provisionDeprecationAmount);
+ if (solde != BigDecimal.ZERO) {
+ soldeString = solde.toString();
+ }
+ }
- for (FinancialStatementAmounts financialStatementAmount : financialStatementAmounts) {
-
- String label = financialStatementAmount.getLabel();
- int level = financialStatementAmount.getLevel();
- BigDecimal grossAmount =
- financialStatementAmount.getGrossAmount();
- if (grossAmount == null) {
- grossAmount = new BigDecimal(0);
- }
- BigDecimal provisionDeprecationAmount =
- financialStatementAmount.getProvisionDeprecationAmount();
- if (provisionDeprecationAmount == null) {
- provisionDeprecationAmount = new BigDecimal(0);
- }
-
- if (financialStatementAmount.getSubAmount() && level == 1) {
- cell.setGrayFill(0.88f);
- } else if (financialStatementAmount.getSubAmount()) {
- cell.setGrayFill(0.94f);
- } else {
- cell.setGrayFill(1f);
- }
- if (label == null) {
- t.addCell("");
- t.addCell("");
- t.addCell("");
- t.addCell("");
- } else {
- //cell1
- StringBuffer tab = new StringBuffer();
- for (int i = 0; i < level; i++) {
- tab.append("\t");
+ String columnData [] = {(StringUtils.isBlank(tabLabel)?"": tabLabel), bigAmountString,
+ provisionDeprecationAmountString, soldeString};
+ financialStatementReport += constructColumnsHtml(columnData);
+ i = i + max;
+ financialStatementReport += "</table>" +
+ "<p>";
}
- Phrase phrase;
- if (financialStatementAmount.getHeader()) {
- phrase = new Phrase(tab + label, boldFont);
- } else {
- phrase = new Phrase(tab + label, normalFont);
- }
- Cell c = new Cell(phrase);
- c.setHorizontalAlignment(Element.ALIGN_LEFT);
- t.addCell(c);
- //cell2
- if (grossAmount != BigDecimal.ZERO) {
- phrase = new Phrase(String.valueOf(
- grossAmount), normalFont);
- } else {
- phrase = new Phrase("");
- }
- t.addCell(phrase);
- //cell 3
- if (provisionDeprecationAmount != BigDecimal.ZERO) {
- phrase = new Phrase(String.valueOf(
- provisionDeprecationAmount), normalFont);
- } else {
- phrase = new Phrase("");
- }
- t.addCell(phrase);
- //cell 4
- BigDecimal solde = grossAmount;
- solde = solde.subtract(provisionDeprecationAmount);
- if (solde != BigDecimal.ZERO) {
- phrase = new Phrase(solde.toString(), normalFont);
- } else {
- phrase = new Phrase("");
- }
- t.addCell(phrase);
}
}
+ financialStatementReport += "</body>" +
+ "</html>";
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
+ } catch (Exception ex) {
+ log.error("Can't create document", ex);
}
- return t;
+ return financialStatementReport;
}
-
//############## Ledger ##############
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2012-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -39,6 +39,8 @@
import javax.ejb.TransactionAttribute;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.FinancialStatementWayEnum;
import org.chorem.lima.beans.Amounts;
import org.chorem.lima.beans.AmountsImpl;
@@ -64,6 +66,8 @@
@EJB
private ReportService reportService;
+ protected static final Log log = LogFactory.getLog(FinancialStatementServiceImpl.class);
+
@Override
public void createFinancialStatement(FinancialStatement masterFinancialStatement,
FinancialStatement financialStatement) throws LimaException {
@@ -193,6 +197,7 @@
List<FinancialStatementAmounts> result = null;
try {
+
//create list form tree
result = financialStatementReport(null, selectedBeginDate,
selectedEndDate, new FinancialStatementDatasImpl()).getListResult();
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -164,6 +164,7 @@
String generalEntryBooksReport = null;
String balanceReport = null;
String ledgerReport = null;
+ String financialReport = null;
//create docs
try {
@@ -194,8 +195,8 @@
}
break;
case FINANCIALSTATEMENT:
- documentService.createFinancialStatementsDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
+ financialReport = documentService.createFinancialStatementsDocuments(
+ beginDateFormat, endDateFormat);
break;
case LEDGER:
ledgerReport = documentService.createLedgerDocuments(
@@ -225,7 +226,7 @@
resp.setContentType(formatsEnum.getMimeType());
OutputStream out = resp.getOutputStream();
if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null
- || balanceReport != null || ledgerReport != null) {
+ || balanceReport != null || ledgerReport != null || financialReport != null) {
String report = null;
if (accountReport != null) {
report = accountReport;
@@ -235,8 +236,10 @@
report = generalEntryBooksReport;
} else if (balanceReport != null) {
report = balanceReport;
+ } else if (ledgerReport != null) {
+ report = ledgerReport;
} else {
- report = ledgerReport;
+ report = financialReport;
}
IOUtils.write(report, out, Charsets.UTF_8);
} else {
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-20 11:38:22 UTC (rev 3613)
@@ -76,6 +76,7 @@
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.lastFiscalPeriodCantBlocked=
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-20 11:38:22 UTC (rev 3613)
@@ -76,6 +76,7 @@
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édente n'est pas bloquée
lima-business.franceaccountingrules.fiscalperiodnotempty=La période fiscale à supprimer n'est pas vide \!
+lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked=Impossible de clore la dernière période fiscale ouverte
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
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -38,7 +38,7 @@
public interface DocumentService {
- void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ String createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException;
String createLedgerDocuments(Date beginDate, Date endDate) throws LimaException;
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2012-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -161,11 +161,10 @@
}
//search all account start with accountnumber
else {
-
- String query = "FROM " + Account.class.getName() + " a WHERE NOT IN (" +
+ String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" +
"FROM " + Account.class.getName() + " b where b.accountNumber like a.accountNumber+'%')" +
- " AND a.accountNumber LIKE ?";
- List<Account> accountsResult = getContext().findAll(query, s);
+ " AND a.accountNumber LIKE :s";
+ List<Account> accountsResult = getContext().findAll(query, "s",s);
if (accountsResult != null) {
//if first
if (first) {
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -76,10 +76,6 @@
List<Entry> entries = context.findAll(query, "beginDate", beginDate,
"endDate", endDate, "account", account);
- if (log.isDebugEnabled()) {
- log.debug("Size of entries : " + entries.size());
- }
-
return entries;
}
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -78,8 +78,6 @@
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);*/
}
/**
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2012-08-20 11:38:22 UTC (rev 3613)
@@ -41,26 +41,11 @@
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
+ <IntervalPanel id="intervalPanel"/>
</cell>
<cell>
- <EnumEditor id='DocumentEditor'
- constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/>
- </cell>
- <cell>
<JButton text="lima.common.ok"
onActionPerformed="getHandler().createDocument()"/>
</cell>
</row>
- <row>
- <cell fill="both" weightx="1" weighty="1" columns="7">
- <JScrollPane>
- <FinancialStatementReportTableModel id="financialStatementReportTableModel"/>
- <FinancialStatementReportTable id="table" rowHeight="24"
- constructorParams="financialStatementReportTableModel"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <ListSelectionModel javaBean="getTable().getSelectionModel()"/>
- </JScrollPane>
- </cell>
- </row>
</Table>
\ No newline at end of file
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-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-08-20 11:38:22 UTC (rev 3613)
@@ -25,7 +25,6 @@
package org.chorem.lima.ui.financialstatementreport;
-import static org.nuiton.i18n.I18n._;
import java.awt.Desktop;
import java.io.IOException;
@@ -34,22 +33,14 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-
-import javax.swing.JOptionPane;
-
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;
@@ -63,7 +54,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialStatementReportViewHandler implements ServiceListener {
+public class FinancialStatementReportViewHandler {
/** log. */
private static final Log log = LogFactory.getLog(FinancialStatementReportViewHandler.class);
@@ -83,10 +74,6 @@
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);
}
/**
@@ -95,86 +82,31 @@
public void init() {
// init data models
- List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllBlockedFiscalPeriods();
List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- 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() {
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();
-
- //tells if the fiscaPeriod as been found and is blocked
- boolean error = true;
-
- for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
- && blockedFiscalPeriod.getEndDate().equals(endDate)
- && blockedFiscalPeriod.getLocked()) {
- error = false;
- }
+ 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=.html&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);
}
-
- //shows error message to user if the fiscalPeriod is unblocked
- if (error) {
- JOptionPane.showMessageDialog(
- view,
- "Can't create document on an open fiscal year",
- _("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- } else {
- FormatsEnum selectedEnum =
- (FormatsEnum) view.getDocumentEditor().getSelectedItem();
-
- 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();
- }
- }
}
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-17 17:24:10 UTC (rev 3612)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-20 11:38:22 UTC (rev 3613)
@@ -60,4 +60,5 @@
log4j.logger.org.chorem.lima.business.ejb.HttpServerServiceImpl=DEBUG
log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG
log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
-log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.FinancialStatementServiceImpl=DEBUG
\ No newline at end of file
1
0
r3612 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/resources/i18n lima-business-api/src/main/java/org/chorem/lima/business/api lima-swing/src/main/java/org/chorem/lima/ui/ledger
by mallon@users.chorem.org 17 Aug '12
by mallon@users.chorem.org 17 Aug '12
17 Aug '12
Author: mallon
Date: 2012-08-17 19:24:10 +0200 (Fri, 17 Aug 2012)
New Revision: 3612
Url: http://chorem.org/repositories/revision/lima/3612
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition du grand livre.
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
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
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
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-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-08-17 14:41:36 UTC (rev 3611)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-17 17:24:10 UTC (rev 3612)
@@ -461,271 +461,227 @@
@Override
- public void createLedgerDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+ public String createLedgerDocuments(Date beginDate,
+ Date endDate) throws LimaException {
+
List<Object> list = new ArrayList<Object>();
- try {
+ String ledgerReport = "";
+ ledgerReport += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
- BalanceTrial balanceTrial = reportService.generateLedger(beginDate, endDate, null, true);
- if (balanceTrial.getReportsDatas() != null) {
- for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) {
- list.add(reportsDatas);
- List<Entry> entries = (List<Entry>) reportsDatas.getListEntry();
- if (entries != null) {
- Collections.sort(entries, new EntryComparator());
- list.addAll(entries);
+ if (beginDate != null && endDate != null) {
+ try {
+ ledgerReport += "<body>\n";
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+
+ BalanceTrial balanceTrial = reportService.generateLedger(beginDate, endDate, null, true);
+ if (balanceTrial.getReportsDatas() != null) {
+ for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) {
+ list.add(reportsDatas);
+ List<Entry> entries = reportsDatas.getListEntry();
+ if (entries != null) {
+ Collections.sort(entries, new EntryComparator());
+ list.addAll(entries);
+ }
}
}
- }
- Date newDate = new Date();
+ //create pages
+ int i = 0;
+ int n = list.size();
+ int max = n;
- BigDecimal currentAmountDebit = new BigDecimal(0);
- BigDecimal currentAmountCredit = new BigDecimal(0);
- String accountcarry = "";
+ while (i < n) {
+ int j = i + max;
+ if (j > n) {
+ j = n;
+ }
- String filePath = path + File.separator + DocumentsEnum.LEDGER.getFileName();
- FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
- switch (format) {
- case HTML:
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
- break;
- case PDF:
- PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
- break;
- }
- document.open();
- int nbpages = 1;
- Identity identity = identityService.getIdentity();
+ ledgerReport += "<table>" +
+ "<tr> " +
+ "<td>" +
+ "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" +
+ "<tr>\n";
- //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 = 32;
- }
- while (i < n) {
- int j = i + max;
- if (j > n) {
- j = n;
- }
- List<Object> subList = list.subList(i, j);
- //create page : header + table + footer
- Table headerTable = createLedgerHeaderTable();
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(DocumentsEnum.LEDGER.getDescription(), identity,
- beginDate, endDate));
- //n° page
- chapter.add(createNumberPage(nbpages, newDate));
- //headerTable
- Paragraph paragraphHeaderTable = new Paragraph();
- paragraphHeaderTable.add(headerTable);
- chapter.add(paragraphHeaderTable);
- //backward amounts
- if (n > max && nbpages > 1) {
- Paragraph backwardParagraph = new Paragraph();
- backwardParagraph.add(createLedgerAmountTable(
- accountcarry, _("lima-business.document.carryback"),
- currentAmountDebit, currentAmountCredit));
- chapter.add(backwardParagraph);
- }
- //table
- Paragraph paragraphTable = new Paragraph();
- Table table = createLedgerTable(subList);
- paragraphTable.add(table);
- chapter.add(paragraphTable);
- for (Object object : subList) {
- if (object instanceof Entry) {
- Entry entry = (Entry) object;
- if (entry.getDebit()) {
- currentAmountDebit = currentAmountDebit.add(entry.getAmount());
- } else {
- currentAmountCredit = currentAmountCredit.add(entry.getAmount());
- }
- } else {
- ReportsDatas reportsDatas = (ReportsDatas) object;
- Account account = reportsDatas.getAccount();
- if (account != null) {
- accountcarry = account.getAccountNumber()
- + " " + account.getLabel() + " ";
- }
- }
- }
- //forward amounts
- if (n > max && i <= n - max) {
- Paragraph forwardParagraph = new Paragraph();
- forwardParagraph.add(createLedgerAmountTable("",
- _("lima-business.document.carryforward"),
- currentAmountDebit, currentAmountCredit));
- chapter.add(forwardParagraph);
- }
- //final amounts
- if (i >= n - max) {
- Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createLedgerAmountTable("",
- _("lima-business.document.amounts"),
- currentAmountDebit, currentAmountCredit));
- chapter.add(finalAmountParagraph);
- }
- //add page
- document.add(chapter);
- i = i + max;
- nbpages++;
- }
- document.close();
+ String boldItalicBegin = "<b>" + "<i>";
+ String boldItalicEnd = "</i>" + "</b>";
+ BigDecimal currentAmountDebit = new BigDecimal(0);
+ BigDecimal currentAmountCredit = new BigDecimal(0);
+ String accountcarry = "";
+ Identity identity = identityService.getIdentity();
- } catch (FileNotFoundException eeFNFE) {
- log.error("Can't create pdf file", eeFNFE);
- } catch (DocumentException eeDE) {
- log.error("Can't create document", eeDE);
- }
- }
+ String [] columnsNameSociety = {boldItalicBegin + identity.getName()+ boldItalicEnd};
+ ledgerReport += constructColumnsHtml(columnsNameSociety);
- protected Table createLedgerHeaderTable() {
- Table t = null;
- try {
- t = new Table(7, 1);
- float[] widths = {0.1f, 0.05f, 0.1f, 0.3f, 0.15f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setWidth(100f);
- t.setPadding(3.5f);
- //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.entrybook"), 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));
- t.addCell(new Phrase(_("lima-business.document.solde"), boldFont));
+ ledgerReport += "<tr>\n";
+ String [] columnsDescription = {"<i>" + identity.getDescription()+ "</i>"};
+ ledgerReport += constructColumnsHtml(columnsDescription);
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
+ ledgerReport += "<tr>\n";
+ String [] columnsAdressOne = {"<i>" + identity.getAddress() + "</i>"};
+ ledgerReport += constructColumnsHtml(columnsAdressOne);
- }
+ ledgerReport += "<tr>\n";
+ String [] columnsAdressTwo = {"<i>" + identity.getAddress2() + "</i>"};
+ ledgerReport += constructColumnsHtml(columnsAdressTwo);
- protected Table createLedgerTable(List<Object> subList) {
- int nbrow = subList.size();
- Table t = null;
- try {
- //define table
- t = new Table(7, nbrow);
- t.setWidth(100f);
- float[] widths = {0.1f, 0.05f, 0.1f, 0.3f, 0.15f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setPadding(1.5f);
- t.setBorderWidth(1);
- t.setOffset(0);
- //define default cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.LEFT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
+ ledgerReport += "<tr>\n";
+ String [] columnsZipCode = {"<i>" + identity.getZipCode() + "</i>"};
+ ledgerReport += constructColumnsHtml(columnsZipCode);
- for (Object object : subList) {
- if (object instanceof ReportsDatas) {
+ ledgerReport += "<tr>\n";
+ String [] columnsCity = {"<i>" + identity.getCity()+ "</i>"};
+ ledgerReport += constructColumnsHtml(columnsCity);
- ReportsDatas reportsDatas = (ReportsDatas) object;
+ ledgerReport += "</table>\n" +
+ "</td>" +
+ "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" +
+ "<p style=\"font-size:30px;\">" + _("lima-business.document.ledger") + "</p>" +
+ "</td>" +
+ "<td>" +
+ "<table align=\"right\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n";
- String accountS = "";
- Account account = reportsDatas.getAccount();
- if (account != null) {
- accountS = account.getAccountNumber() + "\t" + account.getLabel();
- }
- BigDecimal amountCredit = reportsDatas.getAmountCredit();
- BigDecimal amountDebit = reportsDatas.getAmountDebit();
+ ledgerReport += "<tr>\n";
+ String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") +
+ boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"};
+ ledgerReport += constructColumnsHtml(columnsBusinessNumber);
- Cell c = new Cell(new Phrase(accountS, boldFont));
- c.setColspan(4);
- c.setHorizontalAlignment(Element.ALIGN_LEFT);
- t.addCell(c);
- t.addCell(new Phrase(String.valueOf(amountDebit), boldFont));
- t.addCell(new Phrase(String.valueOf(amountCredit), boldFont));
- BigDecimal solde = amountDebit;
- solde = solde.subtract(amountCredit);
- t.addCell(new Phrase(String.valueOf(solde), boldFont));
- } else {
- Entry entry = (Entry) object;
+ ledgerReport += "<tr>\n";
+ String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") +
+ boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"};
+ ledgerReport += constructColumnsHtml(columnsClassifCode);
- String entryBookCode = "";
- EntryBook entryBook = entry.getFinancialTransaction().getEntryBook();
- if (entryBook != null) {
- entryBookCode = entryBook.getCode();
+ ledgerReport += "<tr>\n";
+ String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd,
+ "<i>" + identity.getVatNumber()+ "</i>", };
+ ledgerReport += constructColumnsHtml(columnsVatNumber);
+
+ ledgerReport += "<tr>\n";
+ String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>"
+ + _("lima-business.document.period1format", beginDate)+ "</i>"};
+ ledgerReport += constructColumnsHtml(columnsPeriodOne);
+
+ ledgerReport += "<tr>\n";
+ String [] columnsPeriodTwo = {boldItalicBegin + _("lima-business.document.period2") + boldItalicEnd, "<i>"
+ + _("lima-business.document.period2format", endDate)+ "</i>"};
+ ledgerReport += constructColumnsHtml(columnsPeriodTwo);
+
+ ledgerReport += "</table>" +
+ "</td>" +
+ "</table>";
+
+ List<Object> subList = list.subList(i, j);
+
+
+ //backward amounts
+ if (n > max ) {
+ String [] columnsCarryBack = {boldBegin + accountcarry + boldEnd, boldBegin + _("lima-business.document.carryback") + boldEnd,
+ boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd,
+ boldBegin + currentAmountDebit.subtract(currentAmountCredit).toString() + boldEnd};
+ ledgerReport += constructColumnsHtml(columnsCarryBack);
}
- BigDecimal amountDebit = new BigDecimal(0),
- amountCredit = new BigDecimal(0);
- if (entry.getDebit()) {
- amountDebit = entry.getAmount();
- } else {
- amountCredit = entry.getAmount();
- }
- 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));
- t.addCell(new Phrase(amountDebit.toString(),
- normalFont));
- t.addCell(new Phrase(amountCredit.toString(),
- normalFont));
- BigDecimal solde = amountDebit.subtract(amountCredit);
- t.addCell(new Phrase(solde.toString(),
- normalFont));
+ ledgerReport += "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" +
+ "<tr>\n";
+ String [] columnsNames = {boldBegin + _("lima-business.document.account")+ boldEnd, boldBegin + _("lima-business.document.debit") + boldEnd,
+ boldBegin + _("lima-business.document.credit") + boldEnd, boldBegin + _("lima-business.document.solde") + boldEnd};
+ ledgerReport += constructColumnsHtml(columnsNames);
+
+ for (Object object : subList) {
+ if (object instanceof ReportsDatas) {
+
+ ReportsDatas reportsDatas = (ReportsDatas) object;
+
+ String accountS = "";
+ Account account = reportsDatas.getAccount();
+ if (account != null) {
+ accountS = account.getAccountNumber() + "\t" + account.getLabel();
+ }
+ BigDecimal amountCredit = reportsDatas.getAmountCredit();
+ BigDecimal amountDebit = reportsDatas.getAmountDebit();
+
+ String [] columnsTable = {boldBegin + accountS + boldEnd,
+ boldBegin + amountDebit.toString() + boldEnd, boldBegin + amountCredit.toString() + boldEnd,
+ boldBegin + amountDebit.subtract(amountCredit).toString() + boldEnd};
+ ledgerReport += constructColumnsHtml(columnsTable);
+
+ } else {
+ Entry entry = (Entry) object;
+
+ String entryBookCode = "";
+ EntryBook entryBook = entry.getFinancialTransaction().getEntryBook();
+ if (entryBook != null) {
+ entryBookCode = entryBook.getCode();
+ }
+ BigDecimal amountDebit = new BigDecimal(0),
+ amountCredit = new BigDecimal(0);
+ if (entry.getDebit()) {
+ amountDebit = entry.getAmount();
+ } else {
+ amountCredit = entry.getAmount();
+ }
+
+ ledgerReport +="<tr><td>";
+ ledgerReport += "<table align=\"right\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" +
+ "<tr>\n";
+ String [] columnsEntry = {boldBegin + _("lima-business.document.date")+ boldEnd,
+ boldBegin + _("lima-business.document.entrybook") + boldEnd, boldBegin + _("lima-business.document.voucher") + boldEnd,
+ boldBegin + _("lima-business.document.description") + boldEnd, boldBegin + _("lima-business.document.debit") + boldEnd,
+ boldBegin + _("lima-business.document.credit") + boldEnd, boldBegin + _("lima-business.document.solde") + boldEnd};
+ ledgerReport += constructColumnsHtml(columnsEntry);
+
+ String [] columnsTable = {_("lima-business.document.dateformat",entry.getFinancialTransaction().getTransactionDate()),
+ entryBookCode, entry.getVoucher(), entry.getDescription(),
+ amountDebit.toString(), amountCredit.toString(), amountDebit.subtract(amountCredit).toString()};
+ ledgerReport += constructColumnsHtml(columnsTable);
+ ledgerReport += "</table>" +
+ "</td></tr>";
+ }
+ }
+
+ for (Object objectList : subList) {
+ if (objectList instanceof Entry) {
+ Entry entry = (Entry) objectList;
+ if (entry.getDebit()) {
+ currentAmountDebit = currentAmountDebit.add(entry.getAmount());
+ } else {
+ currentAmountCredit = currentAmountCredit.add(entry.getAmount());
+ }
+ } else {
+ ReportsDatas reportsDatas = (ReportsDatas) objectList;
+ Account account = reportsDatas.getAccount();
+ if (account != null) {
+ accountcarry = account.getAccountNumber()
+ + " " + account.getLabel() + " ";
+ }
+ }
+ }
+ //forward amounts
+ if (n > max && i <= n - max) {
+ String [] columnsTable = {"", boldBegin + _("lima-business.document.carryforward") + boldEnd,
+ boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd,
+ boldBegin + currentAmountDebit.subtract(currentAmountCredit).toString() + boldEnd};
+ ledgerReport += constructColumnsHtml(columnsTable);
+ }
+ //final amounts
+ if (i >= n - max) {
+ String [] columnsTable = { boldBegin + _("lima-business.document.amounts") + boldEnd,
+ boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd,
+ boldBegin + currentAmountDebit.subtract(currentAmountCredit).toString() + boldEnd};
+ ledgerReport += constructColumnsHtml(columnsTable);
+ }
+ i = i + max;
}
+ ledgerReport += "</table></body>\n</html>";
+ }catch (Exception ex) {
+ log.error("Can't create document", ex);
}
- } catch (DocumentException eeDE) {
- log.error("Can't create table", eeDE);
-
}
- return t;
+ return ledgerReport;
}
- protected Table createLedgerAmountTable(String account,
- String title,
- BigDecimal debit,
- BigDecimal credit) {
- Table t = null;
- try {
- t = new Table(5, 1);
- float[] widths = {0.4f, 0.15f, 0.15f, 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);
- Cell accountCell = new Cell(new Phrase(account, boldFont));
- accountCell.setHorizontalAlignment(Element.ALIGN_LEFT);
- accountCell.setBorder(Rectangle.NO_BORDER);
- t.addCell(accountCell);
- t.addCell(new Phrase(title, boldFont));
- t.addCell(new Phrase(debit.toString(), boldFont));
- t.addCell(new Phrase(credit.toString(), boldFont));
- BigDecimal solde = debit.subtract(credit);
- t.addCell(new Phrase(solde.toString(), boldFont));
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
- }
-
@Override
public String createEntryBooksDocuments(Date beginDate,
Date endDate) throws LimaException {
@@ -871,49 +827,51 @@
String boldItalicBegin = "<b>" + "<i>";
String boldItalicEnd = "</i>" + "</b>";
- String [] columnsNameSociety = {boldItalicBegin + _("lima-business.document.society") +
- boldItalicEnd, "<i>" + identity.getName()+ "</i>"};
+ String [] columnsNameSociety = {boldItalicBegin + identity.getName()+ boldItalicEnd};
balanceReport += constructColumnsHtml(columnsNameSociety);
balanceReport += "<tr>\n";
- String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") +
- boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"};
- balanceReport += constructColumnsHtml(columnsBusinessNumber);
+ String [] columnsDescription = {"<i>" + identity.getDescription()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsDescription);
balanceReport += "<tr>\n";
- String [] columnsDescription = {boldItalicBegin + _("lima-business.document.description") + boldItalicEnd,
- "<i>" + identity.getDescription()+ "</i>"};
- balanceReport += constructColumnsHtml(columnsDescription);
+ String [] columnsAdressOne = {"<i>" + identity.getAddress() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsAdressOne);
balanceReport += "<tr>\n";
- String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") +
- boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"};
- balanceReport += constructColumnsHtml(columnsClassifCode);
+ String [] columnsAdressTwo = {"<i>" + identity.getAddress2() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsAdressTwo);
balanceReport += "<tr>\n";
- String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd,
- "<i>" + identity.getVatNumber()+ "</i>", };
- balanceReport += constructColumnsHtml(columnsVatNumber);
+ String [] columnsZipCode = {"<i>" + identity.getZipCode() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsZipCode);
balanceReport += "<tr>\n";
- String [] columnsAdressOne = {boldItalicBegin + _("lima-business.document.adress") + boldItalicEnd,
- "<i>" + identity.getAddress() + "</i>"};
- balanceReport += constructColumnsHtml(columnsAdressOne);
+ String [] columnsCity = {"<i>" + identity.getCity()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsCity);
+ balanceReport += "</table>\n" +
+ "</td>" +
+ "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" +
+ "<p style=\"font-size:30px;\">" + _("lima-business.document.balance") + "</p>" +
+ "</td>" +
+ "<td>" +
+ "<table align=\"right\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n";
+
balanceReport += "<tr>\n";
- String [] columnsAdressTwo = {boldItalicBegin + _("lima-business.document.adresssuite") + boldItalicEnd,
- "<i>" + identity.getAddress2() + "</i>"};
- balanceReport += constructColumnsHtml(columnsAdressTwo);
+ String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") +
+ boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsBusinessNumber);
balanceReport += "<tr>\n";
- String [] columnsZipCode = {boldItalicBegin + _("lima-business.document.zipcode") + boldItalicEnd,
- "<i>" + identity.getZipCode() + "</i>"};
- balanceReport += constructColumnsHtml(columnsZipCode);
+ String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") +
+ boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsClassifCode);
balanceReport += "<tr>\n";
- String [] columnsCity = {boldItalicBegin + _("lima-business.document.city") + boldItalicEnd,
- "<i>" + identity.getCity()+ "</i>"};
- balanceReport += constructColumnsHtml(columnsCity);
+ String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd,
+ "<i>" + identity.getVatNumber()+ "</i>", };
+ balanceReport += constructColumnsHtml(columnsVatNumber);
balanceReport += "<tr>\n";
String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>"
@@ -925,12 +883,8 @@
+ _("lima-business.document.period2format", endDate)+ "</i>"};
balanceReport += constructColumnsHtml(columnsPeriodTwo);
- balanceReport += "</table>\n" +
+ balanceReport += "</table>" +
"</td>" +
- "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" +
- "<p style=\"font-size:30px;\">" + _("lima-business.document.balance") + "</p>" +
- "</td>" +
- "<tr>" +
"</table>" +
"<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
"<tr align=\"center\">\n";
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-08-17 14:41:36 UTC (rev 3611)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-17 17:24:10 UTC (rev 3612)
@@ -163,6 +163,7 @@
String entryBooksReport = null;
String generalEntryBooksReport = null;
String balanceReport = null;
+ String ledgerReport = null;
//create docs
try {
@@ -197,8 +198,8 @@
beginDateFormat, endDateFormat, formatsEnum);
break;
case LEDGER:
- documentService.createLedgerDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
+ ledgerReport = documentService.createLedgerDocuments(
+ beginDateFormat, endDateFormat);
break;
case VAT:
documentService.createVatDocuments(
@@ -224,7 +225,7 @@
resp.setContentType(formatsEnum.getMimeType());
OutputStream out = resp.getOutputStream();
if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null
- || balanceReport != null) {
+ || balanceReport != null || ledgerReport != null) {
String report = null;
if (accountReport != null) {
report = accountReport;
@@ -232,8 +233,10 @@
report = entryBooksReport;
} else if (generalEntryBooksReport != null) {
report = generalEntryBooksReport;
+ } else if (balanceReport != null) {
+ report = balanceReport;
} else {
- report = balanceReport;
+ report = ledgerReport;
}
IOUtils.write(report, out, Charsets.UTF_8);
} else {
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-08-17 14:41:36 UTC (rev 3611)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 17:24:10 UTC (rev 3612)
@@ -17,7 +17,7 @@
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 manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
-lima-business.document.account=
+lima-business.document.account=Compte
lima-business.document.accountnumber=N° Compte
lima-business.document.adress=Adresse
lima-business.document.adresssuite=Adresse - suite
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 14:41:36 UTC (rev 3611)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 17:24:10 UTC (rev 3612)
@@ -40,7 +40,7 @@
void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
- void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ String createLedgerDocuments(Date beginDate, Date endDate) throws LimaException;
String createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
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-08-17 14:41:36 UTC (rev 3611)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2012-08-17 17:24:10 UTC (rev 3612)
@@ -40,67 +40,13 @@
]]>
</script>
- <row weightx="1" weighty="0" anchor="center">
+ <row>
<cell fill='both'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
+ <IntervalPanel id="intervalPanel"/>
</cell>
- <cell anchor="east">
- <JLabel text="lima.common.filter"/>
- </cell>
- <cell anchor="west">
- <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter"
- minimumSize='{balanceFilter.getPreferredSize()}'/>
- <javax.swing.text.Document javaBean="balanceFilter.getDocument()"
- onInsertUpdate='handler.accountFilterChanged()'
- onRemoveUpdate='handler.accountFilterChanged()'/>
- </cell>
- <cell anchor="center">
- <JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter'
- selected='false'
- onActionPerformed="getHandler().movmentedFilterChanged()"/>
- </cell>
<cell>
- <EnumEditor id='DocumentEditor'
- constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/>
- </cell>
- <cell>
<JButton text="lima.common.ok"
onActionPerformed="getHandler().createDocument()"/>
</cell>
</row>
- <row>
- <cell fill="both" weightx="1" weighty="1" columns="8">
- <JScrollPane>
- <org.chorem.lima.ui.ledger.LedgerTableModel id="ledgerTableModel"/>
- <org.chorem.lima.ui.ledger.LedgerTable sortable="false" rowHeight="24" model="{ledgerTableModel}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell fill="horizontal" weightx="1" columns="7">
- <Table>
- <row fill="horizontal" weightx="1">
- <cell>
- <JLabel text="lima.common.amountdebit"/>
- </cell>
- <cell>
- <JLabel id="amountDebitLabel"/>
- </cell>
- <cell>
- <JLabel text="lima.common.amountcredit"/>
- </cell>
- <cell>
- <JLabel id="amountCreditLabel"/>
- </cell>
- <cell>
- <JLabel id="soldeLabel" text="lima.common.solde"/>
- </cell>
- <cell>
- <JLabel id="amountSoldeLabel"/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
</Table>
\ No newline at end of file
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-08-17 14:41:36 UTC (rev 3611)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-08-17 17:24:10 UTC (rev 3612)
@@ -64,7 +64,7 @@
* Handler associated with accounts reports view.
* By : $Author$
*/
-public class LedgerViewHandler implements ServiceListener {
+public class LedgerViewHandler /*implements ServiceListener*/ {
protected LedgerView view;
@@ -84,13 +84,8 @@
protected LedgerViewHandler(LedgerView view) {
this.view = view;
- reportService =
- LimaServiceFactory.getService(ReportService.class);
- LimaServiceFactory.addServiceListener(ReportService.class, this);
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
/**
@@ -104,133 +99,37 @@
view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- public void intervalChanged() {
- refreshData();
- }
-
- public void accountFilterChanged() {
- refreshData();
- }
-
- public void movmentedFilterChanged() {
- refreshData();
- }
-
- /**
- * Refresh table data depending on item selected on combo boxes.
- */
- 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) {
- Collections.sort(entries, new EntryComparator());
- results.addAll(entries);
- }
- }
- dataModel.setObjects(results);
-
- updateFooter(balanceTrial);
- }
- }
-
- /**
- * Update footer labels containing reports total sum fields.
- *
- * @param balanceTrial 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 (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() {
Date beginDate = view.getIntervalPanel().getBeginDate();
Date endDate = view.getIntervalPanel().getEndDate();
if (beginDate != null && endDate != null) {
+ String address = LimaConfig.getInstance().getHostAdress();
- //looks for all blocked fiscal periods
- List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
-
- //tells if the fiscaPeriod as been found and is blocked
- boolean error = true;
-
- for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
- && blockedFiscalPeriod.getEndDate().equals(endDate)
- && blockedFiscalPeriod.getLocked()) {
- error = false;
- }
+ try {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&format=.html&model="
+ + DocumentsEnum.LEDGER.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);
}
-
- //shows error message to user if the fiscalPeriod is unblocked
- if (error) {
- JOptionPane.showMessageDialog(
- view,
- "Can't create document on an open fiscal year",
- _("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- } else {
-
- FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
- String address = LimaConfig.getInstance().getHostAdress();
-
- try {
- 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.LEDGER.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
+ /* @Override
public void notifyMethod(String serviceName, String methodName) {
if (serviceName.contains("FinancialTransaction") ||
methodName.contains("importAccount") ||
methodName.contains("importAll")) {
refreshData();
}
- }
+ }*/
}
1
0
r3611 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/resources/i18n lima-business-api/src/main/java/org/chorem/lima/business/api lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/balance
by mallon@users.chorem.org 17 Aug '12
by mallon@users.chorem.org 17 Aug '12
17 Aug '12
Author: mallon
Date: 2012-08-17 16:41:36 +0200 (Fri, 17 Aug 2012)
New Revision: 3611
Url: http://chorem.org/repositories/revision/lima/3611
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition de la balance.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java
Removed:
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
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
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
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-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.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-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -816,7 +816,7 @@
entryBookReport += "</table></p>\n";
}
}
- entryBookReport += "</body>\n";
+ entryBookReport += "</body>\n</html>";
}
} catch (Exception ex) {
throw new LimaException("Can't create document", ex);
@@ -828,213 +828,177 @@
//############## Balance ##############
@Override
- public void createBalanceDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+ public String createBalanceDocuments(Date beginDate,
+ Date endDate) throws LimaException {
BalanceTrial balanceTrial =
reportService.generateBalanceTrial(beginDate, endDate, null, false, true);
List<ReportsDatas> list = (List<ReportsDatas>) balanceTrial.getReportsDatas();
- try {
- Date newDate = new Date();
+ String balanceReport = "";
+ balanceReport += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
- BigDecimal currentAmountDebit = new BigDecimal(0);
- BigDecimal currentAmountCredit = new BigDecimal(0);
- BigDecimal currentSoldeDebit = new BigDecimal(0);
- BigDecimal currentSoldeCredit = new BigDecimal(0);
+ if (beginDate != null && endDate != null) {
+ try{
+ BigDecimal currentAmountDebit = new BigDecimal(0);
+ BigDecimal currentAmountCredit = new BigDecimal(0);
+ BigDecimal currentSoldeDebit = new BigDecimal(0);
+ BigDecimal currentSoldeCredit = new BigDecimal(0);
- String filePath = path + File.separator + DocumentsEnum.BALANCE.getFileName();
- FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
- switch (format) {
- case HTML:
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
- break;
- case PDF:
- PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
- break;
- }
- document.open();
- int nbpages = 1;
- Identity identity = identityService.getIdentity();
+ Identity identity = identityService.getIdentity();
- //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 = 26;
- }
- while (i < n) {
- int j = i + max;
- if (j > n) {
- j = n;
- }
- List<ReportsDatas> subList = list.subList(i, j);
- //create page : header + table + footer
- Table headerTable = createBalanceHeaderTable();
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(DocumentsEnum.BALANCE.getDescription(),
- identity, beginDate, endDate));
- //n° page
- chapter.add(createNumberPage(nbpages, newDate));
- //headerTable
- Paragraph paragraphHeaderTable = new Paragraph();
- paragraphHeaderTable.add(headerTable);
- chapter.add(paragraphHeaderTable);
- //backward amounts
- if (n > max && nbpages > 1) {
- Paragraph backwardParagraph = new Paragraph();
- backwardParagraph.add(createBalanceAmountTable(
- _("lima-business.document.carryback"),
- currentAmountDebit, currentAmountCredit,
- currentSoldeDebit, currentSoldeCredit));
- chapter.add(backwardParagraph);
- }
- //table
- Paragraph paragraphTable = new Paragraph();
- Table table = createBalanceTable(subList);
- paragraphTable.add(table);
- chapter.add(paragraphTable);
- for (ReportsDatas reportsDatas : subList) {
- currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit());
- currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit());
- if (reportsDatas.getSoldeDebit()) {
- currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde());
- } else {
- currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde());
+ //create pages
+ int i = 0;
+ int n = list.size();
+ int max = n;
+
+ while (i < n) {
+ int j = i + max;
+ if (j > n) {
+ j = n;
}
- }
- //forward amounts
- if (n > max && i <= n - max) {
- Paragraph forwardParagraph = new Paragraph();
- forwardParagraph.add(createBalanceAmountTable(
- _("lima-business.document.carryforward"),
- currentAmountDebit, currentAmountCredit,
- currentSoldeDebit, currentSoldeCredit));
- chapter.add(forwardParagraph);
- }
- //final amounts
- if (i >= n - max) {
- Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createBalanceAmountTable(
- _("lima-business.document.amounts"),
- currentAmountDebit, currentAmountCredit,
- currentSoldeDebit, currentSoldeCredit));
- chapter.add(finalAmountParagraph);
- }
- //add page
- document.add(chapter);
- i = i + max;
- nbpages++;
- }
- document.close();
+ List<ReportsDatas> subList = list.subList(i, j);
- } catch (FileNotFoundException eeFNFE) {
- log.error("Can't create pdf file", eeFNFE);
- } catch (DocumentException eeDE) {
- log.error("Can't create document", eeDE);
- }
- }
+ balanceReport += "<body>\n" +
+ "<table>" +
+ "<tr> " +
+ "<td>" +
+ "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" +
+ "<tr>\n";
- public Table createBalanceHeaderTable() {
- Table t = null;
- try {
- t = new Table(6, 1);
- float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setWidth(100f);
- t.setPadding(3.5f);
- //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.accountnumber"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.description"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.movementdebit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.movementcredit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.soldedebit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.soldecredit"), boldFont));
+ String boldItalicBegin = "<b>" + "<i>";
+ String boldItalicEnd = "</i>" + "</b>";
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
+ String [] columnsNameSociety = {boldItalicBegin + _("lima-business.document.society") +
+ boldItalicEnd, "<i>" + identity.getName()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsNameSociety);
- }
+ balanceReport += "<tr>\n";
+ String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") +
+ boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsBusinessNumber);
- public Table createBalanceTable(List<ReportsDatas> subList) {
- int nbrow = subList.size();
- Table t = null;
- try {
- //define table
- t = new Table(6, nbrow);
- t.setWidth(100f);
- float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setPadding(1.5f);
- t.setBorderWidth(1);
- t.setOffset(0);
- //define default cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.LEFT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
+ balanceReport += "<tr>\n";
+ String [] columnsDescription = {boldItalicBegin + _("lima-business.document.description") + boldItalicEnd,
+ "<i>" + identity.getDescription()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsDescription);
- for (ReportsDatas reportsDatas : subList) {
+ balanceReport += "<tr>\n";
+ String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") +
+ boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsClassifCode);
- String soldeDebit = String.valueOf(reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0);
- String soldeCredit = String.valueOf(reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde());
+ balanceReport += "<tr>\n";
+ String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd,
+ "<i>" + identity.getVatNumber()+ "</i>", };
+ balanceReport += constructColumnsHtml(columnsVatNumber);
- t.addCell(new Phrase(reportsDatas.getAccount().getAccountNumber(), normalFont));
- t.addCell(new Phrase(reportsDatas.getAccount().getLabel(), normalFont));
- t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountDebit()), normalFont));
- t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountCredit()), normalFont));
- t.addCell(new Phrase(soldeDebit, normalFont));
- t.addCell(new Phrase(soldeCredit, normalFont));
- }
- } catch (DocumentException eeDE) {
- log.error("Can't create table", eeDE);
+ balanceReport += "<tr>\n";
+ String [] columnsAdressOne = {boldItalicBegin + _("lima-business.document.adress") + boldItalicEnd,
+ "<i>" + identity.getAddress() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsAdressOne);
- }
- return t;
- }
+ balanceReport += "<tr>\n";
+ String [] columnsAdressTwo = {boldItalicBegin + _("lima-business.document.adresssuite") + boldItalicEnd,
+ "<i>" + identity.getAddress2() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsAdressTwo);
- public Table createBalanceAmountTable(String title,
- BigDecimal amountDebit,
- BigDecimal amountCredit,
- BigDecimal soldeDebit,
- BigDecimal soldeCredit) {
- Table t = null;
- try {
- t = new Table(5, 1);
- float[] widths = {0.4f, 0.15f, 0.15f, 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);
+ balanceReport += "<tr>\n";
+ String [] columnsZipCode = {boldItalicBegin + _("lima-business.document.zipcode") + boldItalicEnd,
+ "<i>" + identity.getZipCode() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsZipCode);
- t.addCell(new Phrase(title, boldFont));
- t.addCell(new Phrase(amountDebit.toString(), boldFont));
- t.addCell(new Phrase(amountCredit.toString(), boldFont));
- t.addCell(new Phrase(soldeDebit.toString(), boldFont));
- t.addCell(new Phrase(soldeCredit.toString(), boldFont));
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
+ balanceReport += "<tr>\n";
+ String [] columnsCity = {boldItalicBegin + _("lima-business.document.city") + boldItalicEnd,
+ "<i>" + identity.getCity()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsCity);
+
+ balanceReport += "<tr>\n";
+ String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>"
+ + _("lima-business.document.period1format", beginDate)+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsPeriodOne);
+
+ balanceReport += "<tr>\n";
+ String [] columnsPeriodTwo = {boldItalicBegin + _("lima-business.document.period2") + boldItalicEnd, "<i>"
+ + _("lima-business.document.period2format", endDate)+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsPeriodTwo);
+
+ balanceReport += "</table>\n" +
+ "</td>" +
+ "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" +
+ "<p style=\"font-size:30px;\">" + _("lima-business.document.balance") + "</p>" +
+ "</td>" +
+ "<tr>" +
+ "</table>" +
+ "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
+
+ String [] columnsNames = {_("lima-business.document.accountnumber"), _("lima-business.document.description"),
+ _("lima-business.document.movementdebit"), _("lima-business.document.movementcredit"),
+ _("lima-business.document.soldedebit"), _("lima-business.document.soldecredit")};
+ balanceReport += constructColumnsHtml(columnsNames);
+
+ if (n > max) {
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+ String [] columnsBalanceAmount = {"", boldBegin + _("lima-business.document.carryback") + boldEnd,
+ boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd,
+ boldBegin + currentSoldeDebit.toString() + boldEnd,boldBegin + currentSoldeCredit.toString() + boldEnd};
+ balanceReport += constructColumnsHtml(columnsBalanceAmount);
+ balanceReport += "</table>\n";
+ }
+
+ for (ReportsDatas reportsDatas : subList) {
+ String soldeDebit = String.valueOf(reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0);
+ String soldeCredit = String.valueOf(reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde());
+
+ String [] columnsBalanceAmount = {reportsDatas.getAccount().getAccountNumber(), reportsDatas.getAccount().getLabel(),
+ reportsDatas.getAmountDebit().toString(), reportsDatas.getAmountCredit().toString(),
+ soldeDebit, soldeCredit};
+ balanceReport += constructColumnsHtml(columnsBalanceAmount);
+ }
+
+ for (ReportsDatas reportsDatas : subList) {
+ currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit());
+ currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit());
+ if (reportsDatas.getSoldeDebit()) {
+ currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde());
+ } else {
+ currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde());
+ }
+ }
+
+ if (n > max && i <= n - max) {
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+ String [] columnsBalanceAmount = {"", boldBegin + _("lima-business.document.carryforward") + boldEnd,
+ boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd,
+ boldBegin + currentSoldeDebit.toString() + boldEnd,boldBegin + currentSoldeCredit.toString() + boldEnd};
+ balanceReport += constructColumnsHtml(columnsBalanceAmount);
+ balanceReport += "</table>\n";
+ }
+
+ //final amounts
+ if (i >= n - max) {
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+ String [] columnsBalanceAmount = {"", boldBegin + _("lima-business.document.amounts") + boldEnd,
+ boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd,
+ boldBegin + currentSoldeDebit.toString() + boldEnd,boldBegin + currentSoldeCredit.toString() + boldEnd};
+ balanceReport += constructColumnsHtml(columnsBalanceAmount);
+ balanceReport += "</table>\n";
+ }
+ i = i + max;
+ }
+ balanceReport += "</body>\n</html>";
+ } catch (Exception ex) {
+ log.error("Can't create document", ex);
+ }
}
- return t;
+
+ return balanceReport;
}
//############## General EntryBook ##############
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-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -162,6 +162,7 @@
String accountReport = null;
String entryBooksReport = null;
String generalEntryBooksReport = null;
+ String balanceReport = null;
//create docs
try {
@@ -170,8 +171,8 @@
switch (DocumentsEnum.valueOfLink(model)) {
case BALANCE:
- documentService.createBalanceDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
+ balanceReport = documentService.createBalanceDocuments(
+ beginDateFormat, endDateFormat);
break;
case ACCOUNT:
accountReport = documentService.createAccountDocument(
@@ -222,14 +223,17 @@
}
resp.setContentType(formatsEnum.getMimeType());
OutputStream out = resp.getOutputStream();
- if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null) {
+ if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null
+ || balanceReport != null) {
String report = null;
if (accountReport != null) {
report = accountReport;
} else if (entryBooksReport != null) {
report = entryBooksReport;
+ } else if (generalEntryBooksReport != null) {
+ report = generalEntryBooksReport;
} else {
- report = generalEntryBooksReport;
+ report = balanceReport;
}
IOUtils.write(report, out, Charsets.UTF_8);
} else {
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-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-17 14:41:36 UTC (rev 3611)
@@ -19,12 +19,15 @@
lima-business.defaultaccountingrules.missingentrybook=Can't block financialperiod / missing EntryBook in transactions
lima-business.document.account=
lima-business.document.accountnumber=Account N°
+lima-business.document.adress=
+lima-business.document.adresssuite=
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
lima-business.document.carryforward=reporterÀ
+lima-business.document.city=
lima-business.document.classificationcode=Classification Code
lima-business.document.createdate=Editing Date %1$tm/%1$te/%1$tY at %1$tH\:%1$tM
lima-business.document.credit=Credit
@@ -52,12 +55,14 @@
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.society=
lima-business.document.solde=Solde
lima-business.document.soldecredit=Credit solde
lima-business.document.soldedebit=Debit solde
lima-business.document.vat=VAT form
lima-business.document.vatnumber=VAT N°
lima-business.document.voucher=Voucher
+lima-business.document.zipcode=
lima-business.entrybook.entrybookalreadyexist=An EntryBook already exists with this label \: %s
lima-business.financialstatement.check.nothing=Not found \: %s - %s \n
lima-business.financialstatement.check.warn=Warning this function is just an help.\n Many accounts must no calculate on Financial statement.\n Some account marked not found is normally.\n\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-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 14:41:36 UTC (rev 3611)
@@ -19,12 +19,15 @@
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.account=
lima-business.document.accountnumber=N° Compte
+lima-business.document.adress=Adresse
+lima-business.document.adresssuite=Adresse - suite
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
lima-business.document.carryforward=À reporter
+lima-business.document.city=Ville
lima-business.document.classificationcode=NAF
lima-business.document.createdate=Date de tirage %1$te/%1$tm/%1$tY à %1$tH\:%1$tM
lima-business.document.credit=Crédit
@@ -52,12 +55,14 @@
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.society=Nom
lima-business.document.solde=Solde
lima-business.document.soldecredit=Solde Créditeur
lima-business.document.soldedebit=Solde Débiteur
lima-business.document.vat=Déclaration de TVA
lima-business.document.vatnumber=N° TVA
lima-business.document.voucher=Pièce comptable
+lima-business.document.zipcode=Code postal
lima-business.entrybook.entrybookalreadyexist=Un journal existe déjà avec ce libellé \: %s
lima-business.financialstatement.check.nothing=Introuvable \: %s - %s \n
lima-business.financialstatement.check.warn=Attention cette fonctionnalité n'est qu'une aide utilisateur.\n Certains comptes ne doivent pas être présent au bilan et compte de résultat.\n Il est donc normal que des comptes sont marqués comme introuvable.\n\n
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -42,7 +42,7 @@
void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
- void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ String createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
String createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -38,7 +38,7 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.accountsreports.AccountsReportsView;
-import org.chorem.lima.ui.balance.BalanceView;
+import org.chorem.lima.ui.balance.BalanceReportsView;
import org.chorem.lima.ui.entrybook.EntryBookView;
import org.chorem.lima.ui.entrybooksreports.EntryBooksReportsView;
import org.chorem.lima.ui.financialperiod.FinancialPeriodView;
@@ -451,7 +451,7 @@
public void showBalanceView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- BalanceView balanceView = new BalanceView(mainView);
+ BalanceReportsView balanceView = new BalanceReportsView(mainView);
showTab(mainView, _("lima.reports.balance"), balanceView);
swingSession.add(balanceView);
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx (from rev 3587, trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx 2012-08-17 14:41:36 UTC (rev 3611)
@@ -0,0 +1,56 @@
+<!--
+ #%L
+ Lima Swing
+
+ $Id$
+ $HeadURL$
+ %%
+ 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
+ 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%
+ -->
+
+<Table>
+
+ <import>
+ javax.swing.ListSelectionModel
+ javax.swing.text.Document
+ org.jdesktop.swingx.decorator.HighlighterFactory
+ org.chorem.lima.business.utils.FormatsEnum
+ org.chorem.lima.enums.ComboBoxDatesEnum
+ org.chorem.lima.ui.common.IntervalPanel
+ </import>
+
+ <BalanceReportsViewHandler id="handler" constructorParams="this"/>
+
+ <script>
+ <![CDATA[
+ void $afterCompleteSetup() {
+ handler.init();
+ }
+
+ ]]>
+ </script>
+ <row>
+ <cell columns="1">
+ <IntervalPanel id="intervalPanel"/>
+ </cell>
+ <cell>
+ <JButton text="lima.common.ok"
+ onActionPerformed="getHandler().createDocument()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java (from rev 3587, trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -0,0 +1,110 @@
+/*
+ * #%L
+ * Lima Swing
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.api.FiscalPeriodService;
+import org.chorem.lima.business.api.HttpServerService;
+import org.chorem.lima.business.api.ReportService;
+import org.chorem.lima.business.utils.DocumentsEnum;
+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$
+ */
+public class BalanceReportsViewHandler {
+
+ protected BalanceReportsView view;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(BalanceReportsViewHandler.class);
+
+ /** Services. */
+ protected ReportService reportService;
+ protected HttpServerService httpServerServiceMonitorable;
+ protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
+
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+
+ protected BalanceReportsViewHandler(BalanceReportsView view) {
+ this.view = view;
+
+ reportService = LimaServiceFactory.getService(ReportService.class);
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
+ }
+
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllBlockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
+ }
+
+ public void createDocument() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ if (beginDate != null & endDate != null) {
+ String address = LimaConfig.getInstance().getHostAdress();
+
+ try {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate) + "&format=.html&model="
+ + DocumentsEnum.BALANCE.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);
+ }
+ }
+ }
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: 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-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2012-08-17 14:41:36 UTC (rev 3611)
@@ -1,113 +0,0 @@
-<!--
- #%L
- Lima Swing
-
- $Id$
- $HeadURL$
- %%
- 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
- 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%
- -->
-
-<Table>
-
- <import>
- javax.swing.ListSelectionModel
- javax.swing.text.Document
- 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" constructorParams="this"/>
-
- <script>
- <![CDATA[
- void $afterCompleteSetup() {
- handler.init();
- }
-
- ]]>
- </script>
- <row weightx="1" weighty="0" anchor="center">
- <cell fill='both'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
- </cell>
- <cell anchor="east">
- <JLabel text="lima.common.filter"/>
- </cell>
- <cell anchor="west">
- <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter"
- minimumSize='{balanceFilter.getPreferredSize()}'/>
- <Document javaBean="balanceFilter.getDocument()"
- onInsertUpdate='handler.accountFilterChanged()'
- onRemoveUpdate='handler.accountFilterChanged()'/>
- </cell>
- <cell anchor="center">
- <JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter'
- selected='false'
- onActionPerformed="getHandler().movmentedFilterChanged()"/>
- </cell>
- <cell>
- <EnumEditor id='DocumentEditor' constructorParams='FormatsEnum.class'/>
- </cell>
- <cell>
- <JButton text="lima.common.ok"
- onActionPerformed="getHandler().createDocument()"/>
- </cell>
- </row>
- <row>
- <cell fill="both" weightx="1" weighty="1" columns="8">
- <JScrollPane>
- <BalanceTableModel id="balanceTableModel" />
- <BalanceTable id="balanceTable"
- rowHeight="24"
- model="{balanceTableModel}"
- highlighters="{HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- columnControlVisible="true"/>
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell fill="horizontal" weightx="1" columns="7">
- <Table>
- <row fill="horizontal" weightx="1">
- <cell>
- <JLabel text="lima.common.amountdebit"/>
- </cell>
- <cell>
- <JLabel id="amountDebitLabel"/>
- </cell>
- <cell>
- <JLabel text="lima.common.amountcredit"/>
- </cell>
- <cell>
- <JLabel id="amountCreditLabel"/>
- </cell>
- <cell>
- <JLabel text="lima.common.solde"/>
- </cell>
- <cell>
- <JLabel id="amountSoldeLabel"/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: 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-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -1,216 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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
- * 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 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.JOptionPane;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-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;
-import org.chorem.lima.business.api.ImportService;
-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;
-
-/**
- * Handler associated with accounts reports view.
- * By : $Author$
- */
-public class BalanceViewHandler implements ServiceListener {
-
- protected BalanceView view;
-
- /** log. */
- private static final Log log = LogFactory.getLog(BalanceViewHandler.class);
-
- /** Services. */
- protected ReportService reportService;
- protected HttpServerService httpServerServiceMonitorable;
- protected FiscalPeriodService fiscalPeriodService;
- protected FinancialPeriodService financialPeriodService;
-
- private static SimpleDateFormat dateFormat =
- new SimpleDateFormat("yyyy-MM-dd");
-
- protected BalanceViewHandler(BalanceView view) {
- this.view = view;
-
- reportService = LimaServiceFactory.getService(ReportService.class);
- fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
- financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
- }
-
- /**
- * 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 intervalChanged() {
- refreshData();
- }
-
- public void accountFilterChanged() {
- refreshData();
- }
-
- public void movmentedFilterChanged() {
- refreshData();
- }
-
- /**
- * Refresh table data depending on item selected on combo boxes.
- */
- 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);
- }
- }
-
- /**
- * Update footer labels containing reports total sum fields.
- *
- * @param balanceTrial 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 (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() {
-
- 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();
-
- //tells if the fiscaPeriod as been found and is blocked
- boolean error = true;
-
- for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
- && blockedFiscalPeriod.getEndDate().equals(endDate)
- && blockedFiscalPeriod.getLocked()) {
- error = false;
- }
- }
-
- //shows error message to user if the fiscalPeriod is unblocked
- if (error) {
- JOptionPane.showMessageDialog(
- view,
- _("lima.balance.documentcreationfiscalerror"),
- _("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- } else {
-
- FormatsEnum selectedEnum =
- (FormatsEnum) view.getDocumentEditor().getSelectedItem();
- String address = LimaConfig.getInstance().getHostAdress();
-
- try {
- 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.BALANCE.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 methodName) {
- if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) {
- refreshData();
- }
- }
-}
1
0
17 Aug '12
Author: mallon
Date: 2012-08-17 13:03:36 +0200 (Fri, 17 Aug 2012)
New Revision: 3610
Url: http://chorem.org/repositories/revision/lima/3610
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition des journaux et du journal general.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
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
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-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.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/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
trunk/lima-swing/src/main/resources/log4j.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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -28,7 +28,6 @@
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;
@@ -129,8 +128,6 @@
private static final Font bolditalicFont =
new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK);
- private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("dd-MM-yyyy");
-
public DocumentServiceImpl() {
path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
@@ -730,160 +727,102 @@
}
@Override
- public void createEntryBooksDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
-
+ public String createEntryBooksDocuments(Date beginDate,
+ Date endDate) throws LimaException {
+ String entryBookReport;
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMMM yyyy");
try {
- Date newDate = new Date();
+ entryBookReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
- String filePath = path + File.separator + DocumentsEnum.ENTRYBOOKS.getFileName();
- FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
- DocWriter writer = null;
- switch (format) {
- case HTML:
- writer = HtmlWriter.getInstance(document, fileOut);
- break;
- case PDF:
- writer = PdfWriter.getInstance(document, fileOut);
- break;
- }
- document.open();
- int nbpages = 1;
+ String titre = _("lima-business.document.entrybooks");
+ entryBookReport += constructHeadHtml(titre);
- Identity identity = identityService.getIdentity();
+ if (beginDate != null && endDate != null) {
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- getDaoHelper().getClosedPeriodicEntryBookDAO();
- EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- //Split list by financialstatement type
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
- closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- // TODO echatellier 20120509, was not about only
- // balanced transaction here, normal ?
- List<Entry> entries = entryDAO.findAllEntryByDateForEntryBook(closedPeriodicEntryBook.getEntryBook(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
- closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
+ //Split list by financialstatement type
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
+ closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
- List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
- closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- BigDecimal debit = BigDecimal.ZERO;
- BigDecimal credit = BigDecimal.ZERO;
- int nbAmount = results.size();
- if (nbAmount == 2) {
- debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
- }
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
- debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
- }
- }
+ entryBookReport += "<body>\n";
+ String journal = "";
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- //create pages
- String title = _("lima-business.document.entrybooktitle",
- closedPeriodicEntryBook.getEntryBook().getLabel(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+ // TODO echatellier 20120509, was not about only
+ // balanced transaction here, normal ?
+ List<Entry> entries = entryDAO.findAllEntryByDateForEntryBook(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- //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);
+ if (entries.size() > 0) {
+ List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
+ BigDecimal debit = BigDecimal.ZERO;
+ BigDecimal credit = BigDecimal.ZERO;
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
+ }
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
+ debit = (BigDecimal) results.get(0)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
+ }
+ }
- nbpages++;
- }
+ String subTitleSecPart = _("lima-business.document.date") + " : " +
+ simpleDateFormat.format(closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+ if (!journal.equals(closedPeriodicEntryBook.getEntryBook().getLabel())) {
+ entryBookReport += constructSubTitleHtml(_("lima-business.document.entrybook")
+ + " : " + closedPeriodicEntryBook.getEntryBook().getLabel(),
+ subTitleSecPart);
+ journal = closedPeriodicEntryBook.getEntryBook().getLabel();
+ } else {
+ entryBookReport += constructSubTitleHtml("", subTitleSecPart);
+ }
- document.close();
- writer.close();
- } catch (Exception ex) {
- throw new LimaException("Can't create document", ex);
- }
- }
-
- 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 + 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();
+ entryBookReport += "<p><table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
- //define default cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.LEFT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
+ String [] columnNames = {_("lima-business.document.date"), _("lima-business.document.accountnumber"),
+ _("lima-business.document.voucher"), _("lima-business.document.description"),
+ _("lima-business.document.debit"),
+ _("lima-business.document.credit")};
- for (Entry entry : entries) {
- t.addCell(new Phrase(_("lima-business.document.dateformat",
- entry.getFinancialTransaction().getTransactionDate()), normalFont));
- String account = "";
- if (entry.getAccount() != null) {
- account = entry.getAccount().getAccountNumber();
+ entryBookReport += constructColumnsHtml(columnNames);
+
+ for (Entry entry : entries) {
+ String numaccount = null;
+ if (entry.getAccount() != null) {
+ numaccount = entry.getAccount().getAccountNumber();
+ }
+ String [] columnData = {_("lima-business.document.dateformat", entry.getFinancialTransaction().getTransactionDate()),
+ (StringUtils.isBlank(numaccount)?"":numaccount), (StringUtils.isBlank(entry.getVoucher())?"":entry.getVoucher()),
+ (StringUtils.isBlank(entry.getDescription())?"":entry.getDescription()),
+ (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO).toString(),
+ (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()).toString()};
+
+ entryBookReport += constructColumnsHtml(columnData);
+ }
+ String [] columnDataTotal = {"", "", "", _("lima-business.document.amounts"), debit.toString(), credit.toString()};
+ entryBookReport += constructColumnsHtml(columnDataTotal);
+ entryBookReport += "</table></p>\n";
+ }
}
- t.addCell(new Phrase(account, normalFont));
- t.addCell(new Phrase(entry.getVoucher(), normalFont));
- t.addCell(new Phrase(entry.getDescription(), normalFont));
- t.addCell(new Phrase(String.valueOf(
- entry.getDebit() ? entry.getAmount() : 0), normalFont));
- t.addCell(new Phrase(String.valueOf(
- !entry.getDebit() ? entry.getAmount() : 0), normalFont));
+ entryBookReport += "</body>\n";
}
-
- // 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);
+ } catch (Exception ex) {
+ throw new LimaException("Can't create document", ex);
}
- return t;
+
+ return entryBookReport;
}
//############## Balance ##############
@@ -1102,221 +1041,143 @@
@Override
- public void createGeneralEntryBooksDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
+ public String createGeneralEntryBooksDocuments(Date beginDate,
+ Date endDate) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
-
+ String entryBookReport;
try {
+ entryBookReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
- Date newDate = new Date();
+ String titre = _("lima-business.document.entrybook");
+ entryBookReport += constructHeadHtml(titre);
- String filePath = path + File.separator + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
- FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
- switch (format) {
- case HTML:
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
- break;
- case PDF:
- PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
- break;
- }
- document.open();
- int nbpages = 1;
+ if (beginDate != null && endDate != null) {
- Identity identity = identityService.getIdentity();
+ FinancialPeriodDAO financialPeriodDAO =
+ getDaoHelper().getFinancialPeriodDAO();
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- FinancialPeriodDAO financialPeriodDAO =
- getDaoHelper().getFinancialPeriodDAO();
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- getDaoHelper().getClosedPeriodicEntryBookDAO();
- EntryDAO entryDAO = getDaoHelper().getEntryDAO();
+ List<FinancialPeriod> financialPeriods =
+ financialPeriodDAO.findByDates(beginDate, endDate);
- List<FinancialPeriod> financialPeriods =
- financialPeriodDAO.findByDates(beginDate, endDate);
+ List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>();
+ BigDecimal amountDebit = new BigDecimal(0);
+ BigDecimal amountCredit = new BigDecimal(0);
+ for (FinancialPeriod financialPeriod : financialPeriods) {
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
+ closedPeriodicEntryBookDAO.findAllByDates(
+ financialPeriod.getBeginDate(), financialPeriod.getEndDate());
- List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>();
- BigDecimal amountDebit = new BigDecimal(0);
- BigDecimal amountCredit = new BigDecimal(0);
- for (FinancialPeriod financialPeriod : financialPeriods) {
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
- closedPeriodicEntryBookDAO.findAllByDates(
- financialPeriod.getBeginDate(), financialPeriod.getEndDate());
+ BigDecimal subAmountDebit = new BigDecimal(0);
+ BigDecimal subAmountCredit = new BigDecimal(0);
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- BigDecimal subAmountDebit = new BigDecimal(0);
- BigDecimal subAmountCredit = new BigDecimal(0);
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
+ BigDecimal debit = BigDecimal.ZERO;
+ BigDecimal credit = BigDecimal.ZERO;
- BigDecimal debit = BigDecimal.ZERO;
- BigDecimal credit = BigDecimal.ZERO;
+ List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
- closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
-
- int nbAmount = results.size();
- if (nbAmount == 2) {
- debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
- }
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
}
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
+ debit = (BigDecimal) results.get(0)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
+ }
+ }
+ GeneralEntryBooksDatas generalEntryBooksDatas =
+ new GeneralEntryBooksDatasImpl();
+ generalEntryBooksDatas.setCode(
+ closedPeriodicEntryBook.getEntryBook().getCode());
+ generalEntryBooksDatas.setDescription(
+ closedPeriodicEntryBook.getEntryBook().getLabel());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entrybook code added : " + closedPeriodicEntryBook.getEntryBook().getCode());
+ log.debug("Entrybook desc. added : " + closedPeriodicEntryBook.getEntryBook().getLabel());
+ }
+
+ generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
+ generalEntryBooksDatas.setCredit(credit);
+ generalEntryBooksDatas.setDebit(debit);
+ list.add(generalEntryBooksDatas);
+ subAmountCredit = subAmountCredit.add(credit);
+ subAmountDebit = subAmountDebit.add(debit);
}
GeneralEntryBooksDatas generalEntryBooksDatas =
new GeneralEntryBooksDatasImpl();
- generalEntryBooksDatas.setCode(
- closedPeriodicEntryBook.getEntryBook().getCode());
- generalEntryBooksDatas.setDescription(
- closedPeriodicEntryBook.getEntryBook().getLabel());
+ generalEntryBooksDatas.setSubAmount(true);
+ generalEntryBooksDatas.setCredit(subAmountCredit);
+ generalEntryBooksDatas.setDebit(subAmountDebit);
generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
- generalEntryBooksDatas.setCredit(credit);
- generalEntryBooksDatas.setDebit(debit);
list.add(generalEntryBooksDatas);
- subAmountCredit = subAmountCredit.add(credit);
- subAmountDebit = subAmountDebit.add(debit);
+ amountCredit = amountCredit.add(subAmountCredit);
+ amountDebit = amountDebit.add(subAmountDebit);
}
GeneralEntryBooksDatas generalEntryBooksDatas =
new GeneralEntryBooksDatasImpl();
- generalEntryBooksDatas.setSubAmount(true);
- generalEntryBooksDatas.setCredit(subAmountCredit);
- generalEntryBooksDatas.setDebit(subAmountDebit);
- generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
+ generalEntryBooksDatas.setAmount(true);
+ generalEntryBooksDatas.setCredit(amountCredit);
+ generalEntryBooksDatas.setDebit(amountDebit);
list.add(generalEntryBooksDatas);
- amountCredit = amountCredit.add(subAmountCredit);
- amountDebit = amountDebit.add(subAmountDebit);
- }
- GeneralEntryBooksDatas generalEntryBooksDatas =
- new GeneralEntryBooksDatasImpl();
- generalEntryBooksDatas.setAmount(true);
- generalEntryBooksDatas.setCredit(amountCredit);
- generalEntryBooksDatas.setDebit(amountDebit);
- list.add(generalEntryBooksDatas);
+ entryBookReport += "<body>\n" +
+ "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
- //create pages
- 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++;
+ String[] columnNames = {_("lima-business.document.entrybook"), _("lima-business.document.label"),
+ _("lima-business.document.date"), _("lima-business.document.debit"),
+ _("lima-business.document.credit")};
- document.close();
+ entryBookReport += constructColumnsHtml(columnNames);
+ String entryBookCode = "";
- } catch (Exception ex) {
- throw new LimaException("Can't generate document", ex);
- }
- }
-
- protected Table createGeneralEntryBooksHeaderTable() {
- Table t = null;
- try {
- t = new Table(5, 1);
- float[] widths = {0.1f, 0.45f, 0.15f, 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.entrybook"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.label"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.date"), 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 createGeneralEntryBooksTable(List<GeneralEntryBooksDatas> list) {
- int nbrow = list.size();
- Table t = null;
- try {
- //define table
- t = new Table(5, nbrow);
- t.setWidth(100f);
- float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setPadding(1.5f);
- t.setBorderWidth(1);
- t.setOffset(0);
- //define default cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.LEFT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
-
- for (GeneralEntryBooksDatas generalEntryBooksDatas : list) {
- if (!generalEntryBooksDatas.getAmount() && !generalEntryBooksDatas.getSubAmount()) {
- t.addCell(new Phrase(
- 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(
- String.valueOf(generalEntryBooksDatas.getDebit()),
- normalFont));
- t.addCell(new Phrase(
- String.valueOf(generalEntryBooksDatas.getCredit()),
- normalFont));
- } else {
- Phrase phrase;
- if (generalEntryBooksDatas.getAmount()) {
- phrase = new Phrase(_("lima-business.document.amounts"),
- boldFont);
- } else {
- phrase = new Phrase(_("lima-business.document.amountsperiod", generalEntryBooksDatas.getPeriod()),
- boldFont);
+ for (GeneralEntryBooksDatas generalEntryBooksDataInList : list) {
+ if (!generalEntryBooksDataInList.getDebit().equals(BigDecimal.ZERO) && !generalEntryBooksDataInList.getCredit().equals(BigDecimal.ZERO)) {
+ if (!generalEntryBooksDataInList.getAmount() && !generalEntryBooksDataInList.getSubAmount()) {
+ String code;
+ String description;
+ if (!entryBookCode.equals(generalEntryBooksDataInList.getCode())) {
+ entryBookCode = generalEntryBooksDataInList.getCode();
+ code = entryBookCode;
+ description = generalEntryBooksDataInList.getDescription();
+ } else {
+ code = "";
+ description = "";
+ }
+ String[] columnData = {code, description,
+ _("lima-business.document.monthformat", generalEntryBooksDataInList.getPeriod()),
+ generalEntryBooksDataInList.getDebit().toString(),
+ generalEntryBooksDataInList.getCredit().toString()};
+ entryBookReport += constructColumnsHtml(columnData);
+ } else {
+ String amount;
+ if (generalEntryBooksDataInList.getAmount()) {
+ amount = _("lima-business.document.amounts");
+ } else {
+ amount = _("lima-business.document.amountsperiod", generalEntryBooksDataInList.getPeriod());
+ }
+ String[] columnDataTotal = {"", "", "<b>"+ (StringUtils.isBlank(amount)?"":amount) + "</b>",
+ generalEntryBooksDataInList.getDebit().toString(),
+ generalEntryBooksDataInList.getCredit().toString()};
+ entryBookReport += constructColumnsHtml(columnDataTotal);
+ }
}
- Cell cell2 = new Cell(phrase);
- cell2.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
- cell2.setColspan(3);
- t.addCell(cell2);
- cell2 = new Cell(new Phrase(
- String.valueOf(generalEntryBooksDatas.getDebit()),
- boldFont));
- cell2.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
- t.addCell(cell2);
- cell2 = new Cell(new Phrase(
- String.valueOf(generalEntryBooksDatas.getCredit()),
- boldFont));
- cell2.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
- t.addCell(cell2);
}
}
-
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
+ } catch (Exception ex) {
+ throw new LimaException("Can't generate document", ex);
}
- return t;
+ return entryBookReport;
}
//############## VAT ##############
@@ -1397,66 +1258,55 @@
Account accountFormat = accountDAO.findByTopiaId(account);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMMM yyyy");
- accountReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
- "<html>\n" +
- "<head>\n" +
- "<title>"+_("lima.reports.accounts")+"</title>\n" +
- "</head>\n" +
- "<p align=\"center\">" +
- "<font size=5>\n" +
- _("lima.reports.accounts") +
- "</font>\n" +
- "</p>\n" +
- "<p>";
+ accountReport += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
+ String title = _("lima.reports.accounts");
+ accountReport = constructHeadHtml(title);
+
ReportsDatas results;
if (beginDate != null && endDate != null && account != null) {
- accountReport += "<font size=3>\n" +
- _("lima.ui.fiscalperiod.fiscalperiod") + " : " + simpleDateFormat.format(beginDate) + " - " + simpleDateFormat.format(endDate) +
- "</p>\n" +
- "<p>" +
- _("lima.ui.financialtransaction.account") + " : " + accountFormat.getAccountNumber() + " - " + accountFormat.getLabel() +
- "</font>"+
- "</p>" +
- "<body>\n";
+ String subTitleFirstpart = _("lima.ui.fiscalperiod.fiscalperiod") + " : " + simpleDateFormat.format(beginDate) + " - " + simpleDateFormat.format(endDate);
+ String subTitleSecPart = _("lima.ui.financialtransaction.account") + " : " + accountFormat.getAccountNumber() + " - " + accountFormat.getLabel();
+ accountReport += constructSubTitleHtml(subTitleFirstpart, subTitleSecPart);
+
results = reportService.generateAccountsReports(accountFormat, true,
beginDate, endDate);
List<Entry> entries = results.getListEntry();
- accountReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n";
- accountReport += "<tr align=\"center\">\n";
- accountReport +="<td>" + _("lima.table.number") + "</td>\n";
- accountReport +="<td>" + _("lima.table.date") + "</td>\n";
- accountReport +="<td>" + _("lima.table.entrybook") + "</td>\n";
- accountReport +="<td>" + _("lima.table.voucher") + "</td>\n";
- accountReport +="<td>" + _("lima.table.description") + "</td>\n";
- accountReport +="<td>" + _("lima.table.letter") + "</td>\n";
- accountReport +="<td>" + _("lima.table.debit") + "</td>\n";
- accountReport +="<td>" + _("lima.table.credit") + "</td>\n";
- accountReport += "<tr>\n";
+ String[] columnNames = {_("lima.table.number"), _("lima.table.date"), _("lima.table.entrybook"),
+ _("lima.table.voucher"), _("lima.table.decription"), _("lima.table.letter"),
+ _("lima.table.debit"), _("lima.table.credit")};
+
+ accountReport += "<body>\n" +
+ "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
+
+ accountReport += constructColumnsHtml(columnNames);
+
for(Entry entry : entries) {
- accountReport += "<tr align=\"center\">\n";
String accountNumber = entry.getAccount().getAccountNumber();
- accountReport += "<td>" + (StringUtils.isBlank(accountNumber)?"":accountNumber) + "</td>\n";
String transactionDate = simpleDateFormat.format(entry.getFinancialTransaction().getTransactionDate());
- accountReport += "<td>" + (StringUtils.isBlank(transactionDate)?"":transactionDate) + "</td>\n";
+ String code = "";
if (entry.getFinancialTransaction().getEntryBook() != null) {
- String code = entry.getFinancialTransaction().getEntryBook().getCode();
- accountReport += "<td>" + (StringUtils.isBlank(code)?"":code) + "</td>\n";
+ code = entry.getFinancialTransaction().getEntryBook().getCode();
}
String voucher = entry.getVoucher();
- accountReport += "<td>" + (StringUtils.isBlank(voucher)?"":voucher) + "</td>\n";
String description = entry.getDescription();
- accountReport += "<td>" + (StringUtils.isBlank(description)?"":description) + "</td>\n";
String lettering = entry.getLettering();
- accountReport += "<td>" + (StringUtils.isBlank(lettering)?"":lettering) + "</td>\n";
- accountReport += "<td>" + (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO) + "</td>\n";
- accountReport += "<td>" + (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()) + "</td>\n";
- accountReport += "</tr>\n";
+
+ String[] columnData = {(StringUtils.isBlank(accountNumber)?"":accountNumber), (StringUtils.isBlank(transactionDate)?"":transactionDate),
+ (StringUtils.isBlank(code)?"":code), (StringUtils.isBlank(voucher)?"":voucher),
+ (StringUtils.isBlank(description)?"":description), (StringUtils.isBlank(lettering)?"":lettering),
+ (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO).toString(),
+ (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()).toString()};
+
+ accountReport += constructColumnsHtml(columnData);
}
+
accountReport += "</table>\n" +
"</body>\n";
@@ -1475,4 +1325,44 @@
return accountReport;
}
+
+ protected String constructHeadHtml(String title) {
+ String head =
+ "<head>\n" +
+ "<title>"+title+"</title>\n" +
+ "</head>\n" +
+ "<p align=\"center\">" +
+ "<font size=5>\n" +
+ title +
+ "</font>\n" +
+ "</p>\n" +
+ "<p>";
+
+ return head;
+ }
+
+ protected String constructSubTitleHtml(String subTitleFirstpart, String subTitleSecPart) {
+ String subTitle = "<font size=3>\n" +
+ subTitleFirstpart +
+ "</p>\n" +
+ "<p>" +
+ subTitleSecPart +
+ "</font>"+
+ "</p>";
+
+ return subTitle;
+ }
+
+ protected String constructColumnsHtml(String[] columnsNames) {
+
+ String columns = "";
+
+ for (String name : columnsNames) {
+ columns += "<td>" + name + "</td>\n";
+ }
+ columns += "<tr>\n";
+
+ return columns;
+ }
+
}
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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -49,6 +49,7 @@
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -142,7 +143,8 @@
String beginDate = req.getParameter("beginDate");
String endDate = req.getParameter("endDate");
String autocomplete = req.getParameter("autocomplete");
- String account = URLDecoder.decode(req.getParameter("account"), "UTF-8");
+ String account = (StringUtils.isBlank(req.getParameter("account"))?null:URLDecoder.decode(req.getParameter("account"), "UTF-8"));
+ String entryBook = (StringUtils.isBlank(req.getParameter("entryBook"))?null:URLDecoder.decode(req.getParameter("entryBook"), "UTF-8"));
//if image
if (imageParam != null) {
@@ -158,6 +160,8 @@
else if (model != null && format != null && beginDate != null && endDate != null) {
FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format);
String accountReport = null;
+ String entryBooksReport = null;
+ String generalEntryBooksReport = null;
//create docs
try {
@@ -170,29 +174,27 @@
beginDateFormat, endDateFormat, formatsEnum);
break;
case ACCOUNT:
- if (log.isDebugEnabled()) {
- log.debug("Account");
- }
- /*AccountDAO accountDAO = new AccountDAO();
- Account accountFormat = accountDAO.findByTopiaId(account);*/
accountReport = documentService.createAccountDocument(
beginDateFormat, endDateFormat, account);
+ break;
+ case ENTRYBOOKS:
+ entryBooksReport = documentService.createEntryBooksDocuments(
+ beginDateFormat, endDateFormat);
if (log.isDebugEnabled()) {
- log.debug("After creating account document");
+ log.debug("EntryBookReport :" + entryBooksReport);
}
break;
- case ENTRYBOOKS:
- documentService.createEntryBooksDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
+ case GENERAL_ENTRYBOOK:
+ generalEntryBooksReport = documentService.createGeneralEntryBooksDocuments(
+ beginDateFormat, endDateFormat);
+ if (log.isDebugEnabled()) {
+ log.debug("GeneralEntryBooksReport :" + generalEntryBooksReport);
+ }
break;
case FINANCIALSTATEMENT:
documentService.createFinancialStatementsDocuments(
beginDateFormat, endDateFormat, formatsEnum);
break;
- case GENERAL_ENTRYBOOK:
- documentService.createGeneralEntryBooksDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
- break;
case LEDGER:
documentService.createLedgerDocuments(
beginDateFormat, endDateFormat, formatsEnum);
@@ -219,16 +221,29 @@
log.debug(accountReport);
}
resp.setContentType(formatsEnum.getMimeType());
-// InputStream in = doc.openStream();
OutputStream out = resp.getOutputStream();
- if (accountReport != null) {
- IOUtils.write(accountReport, out, Charsets.UTF_8);
-// out.write(accountReport.getBytes());
+ if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null) {
+ String report = null;
+ if (accountReport != null) {
+ report = accountReport;
+ } else if (entryBooksReport != null) {
+ report = entryBooksReport;
+ } else {
+ report = generalEntryBooksReport;
+ }
+ IOUtils.write(report, out, Charsets.UTF_8);
+ } else {
+ InputStream in = doc.openStream();
+ IOUtils.copy(in, out);
}
-// IOUtils.copy(in, out);
}
// else return home html
else {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Home html");
+ }
+
resp.setContentType(FormatsEnum.HTML.getMimeType());
StringBuilder pageContent = new StringBuilder();
String serverAdress = "http://";
@@ -251,30 +266,30 @@
DateUtils.truncate(beginDatePicker, Calendar.YEAR);
pageContent.append("<!DOCTYPE html>\n"
- + "<html lang=\"fr\">\n"
- + "<head>\n"
- + "<title>LIMA Documents Report</title>\n"
- + "<style type=\"text/css\">"
- + "body { font: 14px sans-serif; }"
- + "h1 { font: 20px sans-serif; text-align: center; }"
- + "table.padding td {padding-right:20px;}"
- + ".tdright {text-align: right;}"
- + "</style>"
- + "</head>\n"
- + "<body>\n"
- + "<table class=\"padding\">\n"
- + "<tr><td><img src=\"?img=puzzle_icon_mini.png\"/></td>\n"
- + "<td><h1>LIMA Documents Report</h1></td></tr>\n"
- + "<tr><td class=\"tdright\"><img src=\"?img=identity.png\"/></td>\n"
- + "<td rowspan=3><form method=GET action="
- + serverAdress + ">\n"
- + _("lima-business.document.date.begin")
- + "<input value=\"" + DATEFORMAT.format(beginDatePicker)
- + "\" type=\"date\" name=\"beginDate\">\n"
- + _("lima-business.document.date.end")
- + "<input value=\"" + DATEFORMAT.format(endDatePicker)
- + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"
- + "Format : <select name=\"format\">");
+ + "<html lang=\"fr\">\n"
+ + "<head>\n"
+ + "<title>LIMA Documents Report</title>\n"
+ + "<style type=\"text/css\">"
+ + "body { font: 14px sans-serif; }"
+ + "h1 { font: 20px sans-serif; text-align: center; }"
+ + "table.padding td {padding-right:20px;}"
+ + ".tdright {text-align: right;}"
+ + "</style>"
+ + "</head>\n"
+ + "<body>\n"
+ + "<table class=\"padding\">\n"
+ + "<tr><td><img src=\"?img=puzzle_icon_mini.png\"/></td>\n"
+ + "<td><h1>LIMA Documents Report</h1></td></tr>\n"
+ + "<tr><td class=\"tdright\"><img src=\"?img=identity.png\"/></td>\n"
+ + "<td rowspan=3><form method=GET action="
+ + serverAdress + ">\n"
+ + _("lima-business.document.date.begin")
+ + "<input value=\"" + DATEFORMAT.format(beginDatePicker)
+ + "\" type=\"date\" name=\"beginDate\">\n"
+ + _("lima-business.document.date.end")
+ + "<input value=\"" + DATEFORMAT.format(endDatePicker)
+ + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"
+ + "Format : <select name=\"format\">");
for (FormatsEnum formatsEnum : FormatsEnum.values()) {
pageContent.append("<option value=\""
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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -35,6 +35,7 @@
lima-business.document.debit=Debit
lima-business.document.description=Description
lima-business.document.entrybook=EntryBook
+lima-business.document.entrybooks=
lima-business.document.entrybooktitle=%s\n%2$tB %2$tY
lima-business.document.financialstatement=FinancialStatement
lima-business.document.generalentrybook=General EntryBook
@@ -103,4 +104,15 @@
lima.config.serveraddress.description=Server Address
lima.reports.account.noaccount=
lima.reports.account.noaccounttitle=
+lima.reports.accounts=
+lima.table.credit=
+lima.table.date=
+lima.table.debit=
+lima.table.decription=
+lima.table.entrybook=
+lima.table.letter=
+lima.table.number=
+lima.table.voucher=
+lima.ui.financialtransaction.account=
+lima.ui.fiscalperiod.fiscalperiod=
lima.ui.lettering.accountRegularization=
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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -35,6 +35,7 @@
lima-business.document.debit=Débit
lima-business.document.description=Description
lima-business.document.entrybook=Journal
+lima-business.document.entrybooks=Journaux
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
@@ -103,4 +104,15 @@
lima.config.serveraddress.description=Addresse serveur
lima.reports.account.noaccount=
lima.reports.account.noaccounttitle=
+lima.reports.accounts=
+lima.table.credit=
+lima.table.date=
+lima.table.debit=
+lima.table.decription=
+lima.table.entrybook=
+lima.table.letter=
+lima.table.number=
+lima.table.voucher=
+lima.ui.financialtransaction.account=
+lima.ui.fiscalperiod.fiscalperiod=
lima.ui.lettering.accountRegularization=
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -27,7 +27,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.FormatsEnum;
-import org.chorem.lima.entity.Account;
import java.util.Date;
@@ -43,12 +42,12 @@
void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
- void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
-
void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
- void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ String createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+
void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format, String autocomplete) throws LimaException;
String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -492,6 +492,10 @@
String address = LimaConfig.getInstance().getHostAdress();
String url = "http://" + address + ":" + port + "/";
+ if (log.isDebugEnabled()) {
+ log.debug("URL : " + url);
+ }
+
SwingUtil.openLink(url);
}
Deleted: 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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,97 +0,0 @@
-/*
- * #%L
- * Lima :: Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2011 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.accountsreports;
-
-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;
-
- public AccountsReportsTable() {
-
- addKeyListener(this);
- addMouseListener(this);
-
- //Get new BigDecimal renderer
- setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
-
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void keyTyped(KeyEvent e) {
- }
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!isEditing()) {
- clearSelection();
- }
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,196 +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.accountsreports;
-
-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 javax.swing.table.AbstractTableModel;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Entry book table model.
- * By : $Author$
- */
-public class AccountsReportsTableModel extends AbstractTableModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 1L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
-
- /** data cache */
- protected ReportsDatas reportDatas;
-
- @Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (reportDatas != null) {
- if (reportDatas.getListEntry() != null) {
- result = reportDatas.getListEntry().size();
- }
- }
-
- return result;
- }
-
- @Override
- public int getColumnCount() {
- return 8;
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Account.class;
- break;
- case 1:
- result = Date.class;
- break;
- case 2:
- result = Entry.class;
- break;
- case 3:
- result = String.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = String.class;
- break;
- case 6:
- result = BigDecimal.class;
- break;
- case 7:
- result = BigDecimal.class;
- break;
- }
-
- return result;
- }
-
-
- @Override
- public String getColumnName(int column) {
- String res = "n/a";
- switch (column) {
- case 0:
- res = _("lima.table.account"); //Account Number
- break;
- case 1:
- res = _("lima.table.date"); //Date
- break;
- case 2:
- res = _("lima.table.entrybook"); //EntryBook
- break;
- case 3:
- res = _("lima.table.voucher"); // Voucher
- break;
- case 4:
- res = _("lima.table.description"); //Description
- break;
- case 5:
- res = _("lima.table.letter"); //Letter
- break;
- case 6:
- res = _("lima.table.debit"); //Debit
- break;
- case 7:
- res = _("lima.table.credit"); //Credit
- break;
- }
- return res;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
- if (reportDatas != null) {
- Entry currentRow = reportDatas.getListEntry().get(row);
- // FIXME echatellier 20120515, move it to renderer
- SimpleDateFormat simpleDateFormat
- = new SimpleDateFormat("dd MMMMM yyyy");
-
- switch (column) {
- case 0:
- result = currentRow.getAccount().getAccountNumber();
- break;
- case 1:
- result = simpleDateFormat.
- format(currentRow.getFinancialTransaction().getTransactionDate());
- break;
- case 2:
- if (currentRow.getFinancialTransaction().getEntryBook() != null) {
- result = currentRow.getFinancialTransaction().getEntryBook().getCode();
- } else {
- result = null;
- }
- break;
- case 3:
- result = currentRow.getVoucher();
- break;
- case 4:
- result = currentRow.getDescription();
- break;
- case 5:
- result = currentRow.getLettering();
- break;
- case 6:
- result = currentRow.getDebit() ? currentRow.getAmount() : BigDecimal.ZERO;
- break;
- case 7:
- result = currentRow.getDebit() ? BigDecimal.ZERO : currentRow.getAmount();
- break;
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No Account selected skip table model update");
- }
- }
-
- return result;
- }
-
- public void setReportDatas(ReportsDatas reportDatas) {
- this.reportDatas = reportDatas;
- 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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-08-17 11:03:36 UTC (rev 3610)
@@ -23,7 +23,7 @@
#L%
-->
-<Table>
+<Table constraints='BorderLayout.NORTH'>
<import>
javax.swing.ListSelectionModel
org.chorem.lima.ui.common.IntervalPanel
@@ -37,71 +37,30 @@
}
]]></script>
- <row weightx="1" weighty="0" anchor="center">
- <cell fill='both'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
- </cell>
- <cell anchor="east">
- <JLabel id="entryBookSelectorLabel" text="lima.common.entrybook"/>
- </cell>
- <cell anchor="west">
- <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="entryBookCombo.back()"/>
- </cell>
- <cell>
- <JButton id="next" text="lima.common.buttonnext"
- onActionPerformed="entryBookCombo.next()"/>
- </cell>
- <cell>
- <EnumEditor id='DocumentEditor'
- constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/>
- </cell>
- <cell>
- <JButton text="lima.common.ok"
- onActionPerformed="getHandler().createDocument()"/>
- </cell>
- </row>
<row>
- <cell fill="both" weightx="1" weighty="1" columns="7">
- <JScrollPane>
- <EntryBooksReportsTableModel id="entryBookReportsTableModel" />
- <EntryBooksReportsTable id="reportTable" sortable="false" rowHeight="24"
- constructorParams="entryBookReportsTableModel"
- model="{entryBookReportsTableModel}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- </JScrollPane>
- </cell>
+ <cell columns="3">
+ <Table>
+ <row>
+ <cell anchor="center">
+ <JLabel text="lima-business.document.entrybooks"/>
+ </cell>
+ <cell anchor="center">
+ <JLabel text=" - "/>
+ </cell>
+ <cell anchor="center">
+ <JLabel text="lima-business.document.generalentrybook"/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
</row>
<row>
- <cell fill="horizontal" weightx="1" columns="7">
- <Table>
- <row fill="horizontal" weightx="1">
- <cell>
- <JLabel text="lima.common.amountdebit"/>
- </cell>
- <cell>
- <JLabel id="amountDebitLabel"/>
- </cell>
- <cell>
- <JLabel text="lima.common.amountcredit"/>
- </cell>
- <cell>
- <JLabel id="amountCreditLabel"/>
- </cell>
- <cell>
- <JLabel id="soldeLabel" text="lima.common.solde"/>
- </cell>
- <cell>
- <JLabel id="amountSoldeLabel"/>
- </cell>
- </row>
- </Table>
+ <cell columns="2">
+ <IntervalPanel id="intervalPanel"/>
</cell>
+ <cell columns="1">
+ <JButton text="lima.common.ok"
+ onActionPerformed="getHandler().createDocument()"/>
+ </cell>
</row>
-</Table>
\ No newline at end of file
+</Table>
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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -25,36 +25,24 @@
package org.chorem.lima.ui.entrybooksreports;
-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.Date;
import java.util.List;
-import javax.swing.JOptionPane;
-
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;
-import org.chorem.lima.business.api.ImportService;
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.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -64,7 +52,7 @@
*
* By : $Author$
*/
-public class EntryBooksReportsViewHandler implements ServiceListener {
+public class EntryBooksReportsViewHandler{
/** log. */
private static final Log log = LogFactory.getLog(EntryBooksReportsViewHandler.class);
@@ -90,81 +78,19 @@
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);
+ /*LimaServiceFactory.addServiceListener(ImportService.class, this);
+ LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);*/
}
/**
* 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();
+ List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
- view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
+ view.getIntervalPanel().init(blockedFiscalPeriods, financialPeriod);
}
-
- public void intervalChanged() {
- refreshData();
- }
- protected void entryBookChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
-
- /**
- * Refresh table data depending on item selected on combo boxes.
- */
- protected void refreshData() {
-
- Date beginDate = view.getIntervalPanel().getBeginDate();
- Date endDate = view.getIntervalPanel().getEndDate();
-
- 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);
-
- updateFooter(results);
- }
- }
-
- /**
- * Update footer labels containing reports total sum fields.
- *
- * @param reportsDatas 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());
-
-
- 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"));
- }
- }
- }
-
public void createDocument() {
Date beginDate = view.getIntervalPanel().getBeginDate();
@@ -172,61 +98,29 @@
if (beginDate != null && endDate != null) {
- //looks for all blocked fiscal periods
- List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String address = LimaConfig.getInstance().getHostAdress();
- //tells if the fiscaPeriod as been found and is blocked
- boolean error = true;
+ try {
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&format=.html&model="
+ + DocumentsEnum.ENTRYBOOKS.getFileName();
+ Desktop.getDesktop().browse(new URI(url));
- for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
- && blockedFiscalPeriod.getEndDate().equals(endDate)
- && blockedFiscalPeriod.getLocked()) {
- error = false;
- }
- }
+ String url2 = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&format=.html&model="
+ + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
+ Desktop.getDesktop().browse(new URI(url2));
- //shows error message to user if the fiscalPeriod is unblocked
- if (error) {
- JOptionPane.showMessageDialog(
- view,
- _("lima.entrybooksreports.documentcreationfiscalerror"),
- _("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(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(beginDate)
- + "&endDate=" + dateFormat.format(endDate)
- + "&format=" + selectedEnum.getExtension() + "&model="
- + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
- Desktop.getDesktop().browse(new URI(url2));
-
- } catch (IOException e) {
- log.error("Can't open browser", e);
- } catch (URISyntaxException e) {
- log.error("Can't create news URI", e);
- }
+ } 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("importEntryBook") || methodName.contains("importAll")) {
- refreshData();
- }
- }
}
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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,4 +1,7 @@
=
+-=
+lima-business.document.entrybooks=
+lima-business.document.generalentrybook=
lima.accountsreports.listerror=Can't get entries list
lima.action.commandline.help=Show help in console
lima.action.fullscreen=Full screen
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-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,4 +1,7 @@
=
+-=
+lima-business.document.entrybooks=
+lima-business.document.generalentrybook=
lima.accountsreports.listerror=Erreur lors de la récupération des données de la liste
lima.action.commandline.help=Afficher l'aide en console
lima.action.fullscreen=Plein Ecran
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -59,4 +59,5 @@
log4j.logger.org.chorem.lima.business.ejb.DocumentServiceImpl=DEBUG
log4j.logger.org.chorem.lima.business.ejb.HttpServerServiceImpl=DEBUG
log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG
-log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG
\ No newline at end of file
1
0
Author: mallon
Date: 2012-08-16 16:31:59 +0200 (Thu, 16 Aug 2012)
New Revision: 3609
Url: http://chorem.org/repositories/revision/lima/3609
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition des comptes.
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
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
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.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/EntryDAOImpl.java
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/entrybooksreports/EntryBooksReportsViewHandler.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
trunk/lima-swing/src/main/resources/log4j.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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -40,6 +40,9 @@
import com.lowagie.text.Table;
import com.lowagie.text.html.HtmlWriter;
import com.lowagie.text.pdf.PdfWriter;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.examples.fdf.SetField;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.chorem.lima.beans.BalanceTrial;
@@ -58,6 +61,7 @@
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.Entry;
@@ -67,11 +71,13 @@
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.VatStatement;
+import org.nuiton.topia.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import javax.swing.JOptionPane;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
@@ -79,6 +85,7 @@
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;
@@ -91,6 +98,8 @@
@TransactionAttribute
public class DocumentServiceImpl extends AbstractLimaService implements DocumentService {
+ protected static final Log log = LogFactory.getLog(DocumentServiceImpl.class);
+
@EJB
private IdentityService identityService;
@@ -120,8 +129,15 @@
private static final Font bolditalicFont =
new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK);
+ private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("dd-MM-yyyy");
+
public DocumentServiceImpl() {
path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Path : " + path);
+ }
+
}
/**
@@ -1369,4 +1385,94 @@
throw new LimaException("Can't create document", ex);
}
}
+
+ @Override
+ public String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException {
+
+ String accountReport = null;
+
+ try {
+
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
+ Account accountFormat = accountDAO.findByTopiaId(account);
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMMM yyyy");
+
+ accountReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n" +
+ "<head>\n" +
+ "<title>"+_("lima.reports.accounts")+"</title>\n" +
+ "</head>\n" +
+ "<p align=\"center\">" +
+ "<font size=5>\n" +
+ _("lima.reports.accounts") +
+ "</font>\n" +
+ "</p>\n" +
+ "<p>";
+ ReportsDatas results;
+
+ if (beginDate != null && endDate != null && account != null) {
+
+ accountReport += "<font size=3>\n" +
+ _("lima.ui.fiscalperiod.fiscalperiod") + " : " + simpleDateFormat.format(beginDate) + " - " + simpleDateFormat.format(endDate) +
+ "</p>\n" +
+ "<p>" +
+ _("lima.ui.financialtransaction.account") + " : " + accountFormat.getAccountNumber() + " - " + accountFormat.getLabel() +
+ "</font>"+
+ "</p>" +
+ "<body>\n";
+ results = reportService.generateAccountsReports(accountFormat, true,
+ beginDate, endDate);
+ List<Entry> entries = results.getListEntry();
+
+ accountReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n";
+ accountReport += "<tr align=\"center\">\n";
+ accountReport +="<td>" + _("lima.table.number") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.date") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.entrybook") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.voucher") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.description") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.letter") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.debit") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.credit") + "</td>\n";
+ accountReport += "<tr>\n";
+ for(Entry entry : entries) {
+ accountReport += "<tr align=\"center\">\n";
+
+ String accountNumber = entry.getAccount().getAccountNumber();
+ accountReport += "<td>" + (StringUtils.isBlank(accountNumber)?"":accountNumber) + "</td>\n";
+ String transactionDate = simpleDateFormat.format(entry.getFinancialTransaction().getTransactionDate());
+ accountReport += "<td>" + (StringUtils.isBlank(transactionDate)?"":transactionDate) + "</td>\n";
+ if (entry.getFinancialTransaction().getEntryBook() != null) {
+ String code = entry.getFinancialTransaction().getEntryBook().getCode();
+ accountReport += "<td>" + (StringUtils.isBlank(code)?"":code) + "</td>\n";
+ }
+ String voucher = entry.getVoucher();
+ accountReport += "<td>" + (StringUtils.isBlank(voucher)?"":voucher) + "</td>\n";
+ String description = entry.getDescription();
+ accountReport += "<td>" + (StringUtils.isBlank(description)?"":description) + "</td>\n";
+ String lettering = entry.getLettering();
+ accountReport += "<td>" + (StringUtils.isBlank(lettering)?"":lettering) + "</td>\n";
+ accountReport += "<td>" + (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO) + "</td>\n";
+ accountReport += "<td>" + (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()) + "</td>\n";
+
+ accountReport += "</tr>\n";
+ }
+ accountReport += "</table>\n" +
+ "</body>\n";
+
+ } else {
+ JOptionPane.showMessageDialog(null, _("lima.reports.account.noaccount"), _("lima.reports.account.noaccounttitle"), JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ accountReport += "</html>";
+
+ }catch (TopiaException e) {
+ log.error("Can't find object", e);
+ }
+ catch (Exception e) {
+ throw new LimaException("Can't create document", e);
+ }
+
+ return accountReport;
+ }
}
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -32,6 +32,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
+import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -46,8 +47,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.DocumentService;
@@ -66,6 +70,8 @@
@TransactionAttribute
public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService {
+ protected static final Log log = LogFactory.getLog(HttpServerServiceImpl.class);
+
@EJB
private DocumentService documentService;
@@ -124,6 +130,11 @@
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
+
+ if (log.isDebugEnabled()) {
+ log.debug("doGet");
+ }
+
//get all params
String imageParam = req.getParameter("img");
String model = req.getParameter("model");
@@ -131,6 +142,7 @@
String beginDate = req.getParameter("beginDate");
String endDate = req.getParameter("endDate");
String autocomplete = req.getParameter("autocomplete");
+ String account = URLDecoder.decode(req.getParameter("account"), "UTF-8");
//if image
if (imageParam != null) {
@@ -145,6 +157,7 @@
//if doc pdf or html
else if (model != null && format != null && beginDate != null && endDate != null) {
FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format);
+ String accountReport = null;
//create docs
try {
@@ -156,6 +169,18 @@
documentService.createBalanceDocuments(
beginDateFormat, endDateFormat, formatsEnum);
break;
+ case ACCOUNT:
+ if (log.isDebugEnabled()) {
+ log.debug("Account");
+ }
+ /*AccountDAO accountDAO = new AccountDAO();
+ Account accountFormat = accountDAO.findByTopiaId(account);*/
+ accountReport = documentService.createAccountDocument(
+ beginDateFormat, endDateFormat, account);
+ if (log.isDebugEnabled()) {
+ log.debug("After creating account document");
+ }
+ break;
case ENTRYBOOKS:
documentService.createEntryBooksDocuments(
beginDateFormat, endDateFormat, formatsEnum);
@@ -189,10 +214,18 @@
// après génération
// fonctionne pour le moment, mais a modifier
URL doc = new URL("file:" + path + File.separator + model + formatsEnum.getExtension());
+ if (log.isDebugEnabled()) {
+ log.debug("file:" + path + File.separator + model + formatsEnum.getExtension());
+ log.debug(accountReport);
+ }
resp.setContentType(formatsEnum.getMimeType());
- InputStream in = doc.openStream();
+// InputStream in = doc.openStream();
OutputStream out = resp.getOutputStream();
- IOUtils.copy(in, out);
+ if (accountReport != null) {
+ IOUtils.write(accountReport, out, Charsets.UTF_8);
+// out.write(accountReport.getBytes());
+ }
+// IOUtils.copy(in, out);
}
// else return home html
else {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -36,6 +36,8 @@
import javax.ejb.TransactionAttribute;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.BalanceTrialImpl;
import org.chorem.lima.beans.ReportsDatas;
@@ -64,6 +66,8 @@
@EJB
protected AccountService accountService;
+ protected static final Log log = LogFactory.getLog(ReportServiceImpl.class);
+
/**
* Recursiv
* List entries for a period and an account
@@ -86,37 +90,29 @@
//Get allsubaccounts and thirdParts accounts
List<Account> accounts = accountService.getAllSubAccounts(account);
-
- // is already subaccount
- // TODO echatellier 20120502 c'est vraiment voulu ?
- // il ne peut pas y avoir de transaction sur des comptes non feuilles ?
- // a verifier, sinon, supprimer la récursion
- if (accounts.size() == 0) {
- reportsDatas = generateSubAccountReports(account,
+
+ for (Account subAccount : accounts) {
+ reportsDatas = generateSubAccountReports(subAccount,
beginDate, endDate);
+ debit = debit.add(reportsDatas.getAmountDebit());
+ credit = credit.add(reportsDatas.getAmountCredit());
+ entries.addAll(reportsDatas.getListEntry());
}
- // else is folder accounts contains many subs and thirds accounts
- else {
- for (Account subAccount : accounts) {
- ReportsDatas subReportsDatas =
- generateAccountsReports(subAccount, true, beginDate, endDate);
- debit = debit.add(subReportsDatas.getAmountDebit());
- credit = credit.add(subReportsDatas.getAmountCredit());
- entries.addAll(subReportsDatas.getListEntry());
- }
- //solde = debit - credit
- solde = solde.add(debit);
- solde = solde.subtract(credit);
-
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
- }
- solde = solde.abs();
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
- reportsDatas.setListEntry(entries);
+
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
}
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
+ reportsDatas.setListEntry(entries);
+
} catch (TopiaException ex) {
throw new LimaException("Can't generate report", ex);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -35,7 +35,8 @@
BALANCE(_("lima-business.document.balance"), "lima_balance"),
LEDGER(_("lima-business.document.ledger"), "lima_ledger"),
FINANCIALSTATEMENT(_("lima-business.document.financialstatement"), "lima_financialstatements"),
- VAT(_("lima-business.document.vat"), "lima_vat");
+ VAT(_("lima-business.document.vat"), "lima_vat"),
+ ACCOUNT(_("lima-business.document.account"), "lima_account");
private final String fileName;
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -17,6 +17,7 @@
lima-business.defaultaccountingrules.invalidaccountnumber=Invalid Account Number \: %d
lima-business.defaultaccountingrules.missingelements=Can't block financialperiod / missing elements in transactions for this FinancialPeriod/EntryBook
lima-business.defaultaccountingrules.missingentrybook=Can't block financialperiod / missing EntryBook in transactions
+lima-business.document.account=
lima-business.document.accountnumber=Account N°
lima-business.document.amounts=Amounts
lima-business.document.amountsperiod=Amounts %1$tB %1$tY
@@ -100,4 +101,6 @@
lima.config.rulesnationality.description=Rules Nationality
lima.config.scale.description=Scale
lima.config.serveraddress.description=Server Address
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.ui.lettering.accountRegularization=
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -17,6 +17,7 @@
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 manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
+lima-business.document.account=
lima-business.document.accountnumber=N° Compte
lima-business.document.amounts=Totaux
lima-business.document.amountsperiod=Totaux %1$tB %1$tY
@@ -100,4 +101,6 @@
lima.config.rulesnationality.description=Règles nationales
lima.config.scale.description=Précision
lima.config.serveraddress.description=Addresse serveur
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.ui.lettering.accountRegularization=
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -27,6 +27,7 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.FormatsEnum;
+import org.chorem.lima.entity.Account;
import java.util.Date;
@@ -50,4 +51,5 @@
void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format, String autocomplete) throws LimaException;
+ String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException;
}
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -75,6 +75,11 @@
List<Entry> entries = context.findAll(query, "beginDate", beginDate,
"endDate", endDate, "account", account);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Size of entries : " + entries.size());
+ }
+
return entries;
}
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-08-16 14:31:59 UTC (rev 3609)
@@ -23,7 +23,7 @@
#L%
-->
-<Table>
+<Table constraints='BorderLayout.NORTH'>
<import>
javax.swing.ListSelectionModel
@@ -42,67 +42,37 @@
}
]]>
</script>
- <row weightx="1" weighty="0" anchor="center">
- <cell fill='horizontal'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
- </cell>
- <cell fill='horizontal' anchor="east">
- <JLabel id="accountSelectorLabel" text="lima.common.account"/>
- </cell>
- <cell fill='horizontal' anchor="west">
- <AccountComboBoxModel id="accountComboboxModel" />
- <AccountComboBox id="accountComboBox" model="{accountComboboxModel}"
- renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
- onItemStateChanged="handler.accountChanged(event)" />
- </cell>
- <cell>
- <JButton id="back" text="lima.common.buttonback"
- onActionPerformed="accountComboBox.back()"/>
- </cell>
- <cell>
- <JButton id="next" text="lima.common.buttonnext"
- onActionPerformed="accountComboBox.next()"/>
- </cell>
- </row>
<row>
- <cell fill="both" weightx="1" weighty="1" columns="6">
- <JScrollPane>
- <AccountsReportsTableModel id="accountsReportsTableModel"/>
- <AccountsReportsTable
- id="accountsReportsTable" rowHeight="24"
- model="{accountsReportsTableModel}"
- highlighters="{HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- columnControlVisible="true"/>
- <ListSelectionModel
- javaBean="getAccountsReportsTable().getSelectionModel()"/>
- </JScrollPane>
+ <cell columns="1">
+ <IntervalPanel id="intervalPanel"/>
</cell>
</row>
<row>
- <cell fill="horizontal" weightx="1" columns="7">
- <Table>
- <row fill="horizontal" weightx="1">
- <cell>
- <JLabel text="lima.ui.common.amountdebit"/>
- </cell>
- <cell>
- <JLabel id="amountDebitLabel"/>
- </cell>
- <cell>
- <JLabel text="lima.ui.common.amountcredit"/>
- </cell>
- <cell>
- <JLabel id="amountCreditLabel"/>
- </cell>
- <cell>
- <JLabel id="soldeLabel" text="lima.ui.common.solde"/>
- </cell>
- <cell>
- <JLabel id="amountSoldeLabel"/>
- </cell>
- </row>
- </Table>
+ <cell columns="1">
+ <Table>
+ <row>
+ <cell weightx="0.125" anchor="east">
+ <JLabel id="accountSelectorLabel" text="lima.common.account"/>
+ </cell>
+ <cell weightx="0.5" anchor="east">
+ <AccountComboBoxModel id="accountComboboxModel" />
+ <AccountComboBox id="accountComboBox" model="{accountComboboxModel}"
+ renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" />
+ </cell>
+ <cell weightx="0.125" anchor="east">
+ <JButton id="back" text="lima.common.buttonback"
+ onActionPerformed="accountComboBox.back()"/>
+ </cell>
+ <cell weightx="0.125" anchor="east">
+ <JButton id="next" text="lima.common.buttonnext"
+ onActionPerformed="accountComboBox.next()"/>
+ </cell>
+ <cell weightx="0.125" anchor="east">
+ <JButton id="html" text="lima.common.generateHtml"
+ onActionPerformed="handler.createDocument()"/>
+ </cell>
+ </row>
+ </Table>
</cell>
</row>
</Table>
\ No newline at end of file
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -25,31 +25,34 @@
package org.chorem.lima.ui.accountsreports;
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.event.ItemEvent;
-import java.math.BigDecimal;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.business.ServiceListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.business.api.AccountService;
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.ImportService;
+import org.chorem.lima.business.api.HttpServerService;
import org.chorem.lima.business.api.ReportService;
+import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.entity.Account;
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$
*/
-public class AccountsReportsViewHandler implements ServiceListener {
+public class AccountsReportsViewHandler {
protected AccountsReportsView view;
@@ -58,6 +61,8 @@
protected AccountService accountService;
protected FiscalPeriodService fiscalPeriodService;
protected FinancialPeriodService financialPeriodService;
+ private static final Log log = LogFactory.getLog(AccountsReportsViewHandler.class);
+ private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
protected AccountsReportsViewHandler(AccountsReportsView view) {
this.view = view;
@@ -66,8 +71,6 @@
accountService = LimaServiceFactory.getService(AccountService.class);
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
/**
@@ -83,69 +86,38 @@
view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- protected void accountChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
+ public void createDocument() {
- 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();
-
Account account = (Account)view.getAccountComboBox().getModel().getSelectedItem();
-
+
if (beginDate != null && endDate != null && account != null) {
- ReportsDatas results = reportService.generateAccountsReports(account, true,
- beginDate, endDate);
-
- AccountsReportsTableModel dataModel = view.getAccountsReportsTableModel();
- dataModel.setReportDatas(results);
-
- updateFooter(results);
- }
-
- }
- /**
- * Update footer labels containing reports total sum fields.
- *
- * @param reportsDatas 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());
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String address = LimaConfig.getInstance().getHostAdress();
+ try {
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&account=" + URLEncoder.encode(account.getTopiaId(), "UTF-8")
+ + "&format=.html&model="
+ + DocumentsEnum.ACCOUNT.getFileName();
- 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"));
+ if (log.isDebugEnabled()) {
+ log.debug("URL : " + url);
+ }
+
+ URI uri = URI.create(url);
+ if (log.isDebugEnabled()) {
+ log.debug("URI : " + uri);
+ }
+ Desktop.getDesktop().browse(uri);
+
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
}
}
}
-
- @Override
- public void notifyMethod(String serviceName, String methodName) {
- if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) {
- refreshData();
- }
- }
}
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -141,7 +141,7 @@
/**
* Update footer labels containing reports total sum fields.
*
- * @param results result to render
+ * @param reportsDatas result to render
*/
protected void updateFooter(ReportsDatas reportsDatas) {
// set amounts credit and debit and solde
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -53,6 +53,7 @@
lima.common.entrybooks=EntryBooks
lima.common.error=Error
lima.common.filter=Filter
+lima.common.generateHtml=
lima.common.info=Information
lima.common.label=Label
lima.common.movmentedfilter=Accounts filtered
@@ -169,6 +170,8 @@
lima.opening.accounts=
lima.preferences=Preferences
lima.reports=Reports
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.reports.accounts=Edit account
lima.reports.balance=Balance
lima.reports.entrybooks=Edit entrybook
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-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -53,6 +53,7 @@
lima.common.entrybooks=Journaux
lima.common.error=Erreur
lima.common.filter=Filtrer
+lima.common.generateHtml=HTML
lima.common.info=Information
lima.common.label=Libellé
lima.common.movmentedfilter=Comptes mouvementés
@@ -168,6 +169,8 @@
lima.opening.accounts=
lima.preferences=Préférences
lima.reports=Rapports
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.reports.accounts=Edition compte
lima.reports.balance=Balance
lima.reports.entrybooks=Edition journal
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -55,4 +55,8 @@
log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionPeriodSearchPanel=DEBUG
log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchViewHandler=DEBUG
log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodViewHandler=DEBUG
-log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.DocumentServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.HttpServerServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
\ No newline at end of file
1
0