Author: jpepin Date: 2010-06-03 16:46:55 +0200 (Thu, 03 Jun 2010) New Revision: 2930 Url: http://chorem.org/repositories/revision/lima/2930 Log: Visualisation du Grand-Livre Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -59,11 +59,18 @@ /** * Generation de la balance. * - * @param financialPeriod la periode * @return la balance * @throws LimaException */ - BalanceTrial generateBalanceTrial(Date beginDate, Date endDate) throws LimaException; + BalanceTrial generateBalanceTrial(Date beginDate, Date endDate, Boolean getEntries) throws LimaException; + + /** + * Generation du grand-livre + * + * @throws LimaException + */ + BalanceTrial generateLedger(Date beginDate, Date endDate) throws LimaException; + /** * Generation du rapports des comptes 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 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -174,7 +174,7 @@ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION entriesQuery.addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION); reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery)); - + TopiaQuery amountsQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias); amountsQuery.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")"); @@ -217,16 +217,26 @@ /** * Calculate all credit, debit and solde amounts for the balance + * + * Get all entries if true */ @SuppressWarnings("unchecked") - protected ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException { + protected ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException { ReportsDatas reportsDatas = new ReportsDatasImpl(); double credit = 0, debit = 0, solde = 0; List<Object[]> results = new ArrayList<Object[]>(); String queryAlias = "E"; if (beginDate != null && endDate != null){ try { - EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext); + EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext); + + if (getEntries){ + TopiaQuery entriesQuery = + createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias); + //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION + entriesQuery.addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION); + reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery)); + } TopiaQuery amountsQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias); @@ -353,9 +363,13 @@ * Get balance trial * * Calculate the amounts and the solde for all subaccounts + * + * Boolean Param GetEntries is for get entries in datasreports or not : + * - GetEntries = false for generate balance + * - GetEntries = true for generate ledger */ @Override - public BalanceTrial generateBalanceTrial(Date beginDate, Date endDate) throws LimaException { + public BalanceTrial generateBalanceTrial(Date beginDate, Date endDate, Boolean getEntries) throws LimaException { BalanceTrial balanceTrial = new BalanceTrialImpl(); balanceTrial.setReportsDatas(new ArrayList<ReportsDatas>()); double credit = 0, debit = 0, solde = 0; @@ -371,7 +385,7 @@ for (Account account : accounts) { ReportsDatas reportsDatas = generateSubAccountBalanceWithTransaction(account, beginDate, - endDate, topiaTransaction); + endDate, getEntries, topiaTransaction); reportsDatas.setAccount(account); // add balance sheet to balance trial balanceTrial.addReportsDatas(reportsDatas); @@ -402,6 +416,19 @@ return balanceTrial; } + + /** + * Get Ledger + * + * Calculate the amounts and the solde for all subaccounts + * Get all entries + */ + @Override + public BalanceTrial generateLedger(Date beginDate, Date endDate) throws LimaException { + return generateBalanceTrial(beginDate, endDate, true); + } + + protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database // TODO move it into JTA Modified: 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 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -136,8 +136,8 @@ switch (column) { case 0: - result = StringUtils.capitalize(simpleDateFormat. - format(currentRow.getFinancialTransaction().getTransactionDate())); + result = simpleDateFormat. + format(currentRow.getFinancialTransaction().getTransactionDate()); break; case 1: if (currentRow.getEntryBook() != null){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -20,21 +20,16 @@ package org.chorem.lima.ui.balance; import static org.nuiton.i18n.I18n._; - import java.util.Date; import java.util.List; - import javax.swing.table.AbstractTableModel; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.beans.ReportsDatas; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ReportService; -import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.ReportsHelper; import org.chorem.lima.util.ErrorHelper; /** @@ -58,12 +53,6 @@ /** Services. */ protected ReportService reportService; - /** Helper */ - protected ReportsHelper helper; - - /** Account. */ - protected Account selectedAccount; - /** Begin Date. */ protected Date selectedBeginDate; @@ -187,7 +176,7 @@ BalanceTrial results = null; try { - results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate); + results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, false); } catch (LimaException eee) { if (log.isErrorEnabled()) { Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -0,0 +1,81 @@ +/** + * *##% Lima Main + * Copyright (C) 2008 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.celleditor; + +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Account; +import org.chorem.lima.ui.combobox.AccountRenderer; +import org.chorem.lima.ui.combobox.SubAccountComboBoxModel; +import org.chorem.lima.widgets.JWideComboBox; + +public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor { + + protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); + private final JWideComboBox comboBox; + private static final long serialVersionUID = 2580476608066111095L; + private static AccountTableCellEditor editor; + + /** + * constructor + */ + public AccountTableCellEditor() { + comboBox = new JWideComboBox(); + SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel(); + comboBox.setModel(accountComboBoxModel); + AccountRenderer accountRenderer = new AccountRenderer(); + comboBox.setRenderer(accountRenderer); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof Account){ + comboBox.setSelectedItem((Account) value); + + } + return comboBox; + } + + @Override + public Object getCellEditorValue() { + return comboBox.getSelectedItem(); + } + + @Override + public boolean isCellEditable(EventObject evt) { + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; + } + + public static AccountTableCellEditor getInstance() { + if (editor == null) { + editor = new AccountTableCellEditor(); + } + return editor; + } + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -0,0 +1,72 @@ +/** + * *##% Lima Main + * Copyright (C) 2008 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.celleditor; + +import org.chorem.lima.LimaContext; +import org.jdesktop.swingx.JXDatePicker; + +import javax.swing.*; +import javax.swing.table.TableCellEditor; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.util.Date; +import java.util.EventObject; + +/** + * @author ore + */ +public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor { + + private final JXDatePicker datePicker; + private static final long serialVersionUID = -8455896587828255307L; + private static DateTableCellEditor editor; + + /** + * constructor + */ + public DateTableCellEditor() { + datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale()); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof Date) { + datePicker.setDate((Date) value); + } + return datePicker; + } + + @Override + public Object getCellEditorValue() { + return datePicker.getDate(); + } + + @Override + public boolean isCellEditable(EventObject evt) { + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; + } + + public static DateTableCellEditor getInstance() { + if (editor == null) { + editor = new DateTableCellEditor(); + } + return editor; + } +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -0,0 +1,86 @@ +/** + * *##% Lima Main + * Copyright (C) 2008 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.celleditor; + +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; +import org.chorem.lima.ui.combobox.EntryBookRenderer; +import org.chorem.lima.widgets.JWideComboBox; + +public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor { + + protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); + private final JWideComboBox comboBox; + private static final long serialVersionUID = 2580476608066111095L; + private static EntryBookTableCellEditor editor; + + /** + * constructor + */ + public EntryBookTableCellEditor() { + comboBox = new JWideComboBox(); + EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); + comboBox.setModel(entryBookComboBoxModel); + EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); + comboBox.setRenderer(entryBookRenderer); + + /*// Property Change Listener + LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel); + comboBox.setModel(comboBoxModel); + // AutoCompletion + AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/ + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof EntryBook){ + comboBox.setSelectedItem((EntryBook) value); + + } + return comboBox; + } + + @Override + public Object getCellEditorValue() { + return comboBox.getSelectedItem(); + } + + @Override + public boolean isCellEditable(EventObject evt) { + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; + } + + public static EntryBookTableCellEditor getInstance() { + if (editor == null) { + editor = new EntryBookTableCellEditor(); + } + return editor; + } +} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -1,81 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.ui.financialtransaction.table; - -import java.awt.Component; -import java.awt.event.MouseEvent; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.Account; -import org.chorem.lima.ui.combobox.AccountRenderer; -import org.chorem.lima.ui.combobox.SubAccountComboBoxModel; -import org.chorem.lima.widgets.JWideComboBox; - -public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor { - - protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); - private final JWideComboBox comboBox; - private static final long serialVersionUID = 2580476608066111095L; - private static AccountTableCellEditor editor; - - /** - * constructor - */ - public AccountTableCellEditor() { - comboBox = new JWideComboBox(); - SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel(); - comboBox.setModel(accountComboBoxModel); - AccountRenderer accountRenderer = new AccountRenderer(); - comboBox.setRenderer(accountRenderer); - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof Account){ - comboBox.setSelectedItem((Account) value); - - } - return comboBox; - } - - @Override - public Object getCellEditorValue() { - return comboBox.getSelectedItem(); - } - - @Override - public boolean isCellEditable(EventObject evt) { - return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; - } - - public static AccountTableCellEditor getInstance() { - if (editor == null) { - editor = new AccountTableCellEditor(); - } - return editor; - } - -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -1,72 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.ui.financialtransaction.table; - -import org.chorem.lima.LimaContext; -import org.jdesktop.swingx.JXDatePicker; - -import javax.swing.*; -import javax.swing.table.TableCellEditor; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.util.Date; -import java.util.EventObject; - -/** - * @author ore - */ -public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor { - - private final JXDatePicker datePicker; - private static final long serialVersionUID = -8455896587828255307L; - private static DateTableCellEditor editor; - - /** - * constructor - */ - public DateTableCellEditor() { - datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale()); - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof Date) { - datePicker.setDate((Date) value); - } - return datePicker; - } - - @Override - public Object getCellEditorValue() { - return datePicker.getDate(); - } - - @Override - public boolean isCellEditable(EventObject evt) { - return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; - } - - public static DateTableCellEditor getInstance() { - if (editor == null) { - editor = new DateTableCellEditor(); - } - return editor; - } -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -1,86 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.ui.financialtransaction.table; - -import java.awt.Component; -import java.awt.event.MouseEvent; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; -import org.chorem.lima.ui.combobox.EntryBookRenderer; -import org.chorem.lima.widgets.JWideComboBox; - -public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor { - - protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); - private final JWideComboBox comboBox; - private static final long serialVersionUID = 2580476608066111095L; - private static EntryBookTableCellEditor editor; - - /** - * constructor - */ - public EntryBookTableCellEditor() { - comboBox = new JWideComboBox(); - EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); - comboBox.setModel(entryBookComboBoxModel); - EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); - comboBox.setRenderer(entryBookRenderer); - - /*// Property Change Listener - LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel); - comboBox.setModel(comboBoxModel); - // AutoCompletion - AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/ - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof EntryBook){ - comboBox.setSelectedItem((EntryBook) value); - - } - return comboBox; - } - - @Override - public Object getCellEditorValue() { - return comboBox.getSelectedItem(); - } - - @Override - public boolean isCellEditable(EventObject evt) { - return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; - } - - public static EntryBookTableCellEditor getInstance() { - if (editor == null) { - editor = new EntryBookTableCellEditor(); - } - return editor; - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -28,6 +28,9 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +import org.chorem.lima.ui.celleditor.DateTableCellEditor; +import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; import org.chorem.lima.ui.financialtransaction.FinancialTransactionViewHandler; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -28,10 +28,10 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +import org.chorem.lima.ui.celleditor.DateTableCellEditor; +import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedViewHandler; -import org.chorem.lima.ui.financialtransaction.table.AccountTableCellEditor; -import org.chorem.lima.ui.financialtransaction.table.DateTableCellEditor; -import org.chorem.lima.ui.financialtransaction.table.EntryBookTableCellEditor; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -0,0 +1,83 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.ledger; + +import java.awt.Color; +import java.awt.Component; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Account; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; + + +/** + * Table des transaction qui ajoute des comportement (keys). + * + * @author ore + * @author Rémi Chapelet + */ +public class LedgerTable extends JXTable { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3133690382049594727L; + + /** log. */ + private static final Log log = LogFactory.getLog(LedgerTable.class); + + protected LedgerViewHandler handler; + + protected LedgerTableModel model; + + private Highlighter colorReportsDatas; + + /** + */ + public LedgerTable(LedgerViewHandler handler) { + + this.handler = handler; + //highlight financial financial transactions + addColorReportsDatas(); + + } + + /** + * Cette méthode permet de colorer toutes les reportsdatas dans le tableau + * afin de bien distinguer les entête de comptes et les entrées comptables. + * On récupère la première cellule, on vérifie que c'est pas null + */ + protected void addColorReportsDatas() { + if (colorReportsDatas != null) { + removeHighlighter(colorReportsDatas); + } + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + return (adapter.getValueAt(adapter.row, 0) != null); + } + }; + colorReportsDatas = + new ColorHighlighter(predicate, new Color(222,222,222), null); + addHighlighter(colorReportsDatas); + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -21,14 +21,18 @@ import static org.nuiton.i18n.I18n._; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; import java.util.Date; +import java.util.List; import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.beans.ReportsDatas; -import org.chorem.lima.beans.ReportsDatasImpl; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ReportService; +import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; @@ -65,7 +69,8 @@ protected Date selectedEndDate; /** data cache */ - protected ReportsDatas cacheDataList; + protected List<Object> cacheDataList; + protected BalanceTrial balanceTrialCache; /** * Constructor. @@ -81,12 +86,12 @@ int result = 0; // just prevent too much result - if (selectedEntryBook != null) { - result = cacheDataList.getListEntry().size(); + if (selectedBeginDate != null && selectedEndDate != null) { + result = cacheDataList.size(); } else { if (log.isDebugEnabled()) { - log.debug("No account selected skip table model update"); + log.debug("No period selected skip table model update"); } } @@ -95,7 +100,7 @@ @Override public int getColumnCount() { - return 6; + return 8; } @Override @@ -103,41 +108,50 @@ String res = "n/a"; switch (column) { case 0: - res = _("lima.transaction.column.date"); //Date + res = _("lima.transaction.column.account"); //Account break; case 1: - res = _("lima.transaction.column.account"); //Account + res = _("lima.transaction.column.date"); //Date break; case 2: + res = _("lima.transaction.column.entrybook"); + break; + case 3: res = _("lima.transaction.column.voucher"); // Voucher break; - case 3: + case 4: res = _("lima.transaction.column.description"); //Description break; - case 4: + case 5: res = _("lima.transaction.column.debit"); //Debit break; - case 5: + case 6: res = _("lima.transaction.column.credit"); //Credit break; + case 7: + res = _("lima.transaction.column.solde"); + break; } return res; } - + @Override public Object getValueAt(int row, int column) { Object result = null; - if(selectedEntryBook != null) { - Entry currentRow = cacheDataList.getListEntry().get(row); - SimpleDateFormat simpleDateFormat = - new SimpleDateFormat("dd MMMMM yyyy"); - - switch (column) { + + // just prevent too much result + if (selectedBeginDate != null && selectedEndDate != null) { + result = cacheDataList.get(row); + SimpleDateFormat simpleDateFormat + = new SimpleDateFormat("dd MMMMM yyyy"); + + if (result instanceof ReportsDatas) { + ReportsDatas currentRow = (ReportsDatas)result; + Double amountDebit = currentRow.getAmountDebit(); + Double amountCredit = currentRow.getAmountCredit(); + + switch (column) { case 0: - result = simpleDateFormat. - format(currentRow.getFinancialTransaction().getTransactionDate()); - break; - case 1: if (currentRow.getAccount() != null){ result = currentRow.getAccount().getAccountNumber(); } @@ -145,30 +159,79 @@ result = null; } break; + case 1: + result = null; // date + break; case 2: - result = currentRow.getVoucher(); + result = null; //entrybook break; case 3: - result = currentRow.getDescription(); + result = null; // voucher break; case 4: - result = currentRow.getDebit() ? currentRow.getAmount() : 0; + result = null; // description break; - case 5: - result = currentRow.getDebit() ? 0 : currentRow.getAmount(); + case 5 : + result = amountDebit; // position break; + case 6: + result = amountCredit; + break; + case 7: + result = amountDebit - amountCredit; + break; + } } - } + else if (result instanceof Entry) { + Entry currentRow = (Entry)result; + Double amountDebit = currentRow.getDebit() ? currentRow.getAmount() : 0; + Double amountCredit = currentRow.getDebit() ? 0 : currentRow.getAmount(); + + switch (column) { + case 0: + result = null; // account + break; + case 1 : // date + result = simpleDateFormat. + format(currentRow.getFinancialTransaction().getTransactionDate()); + break; + case 2: + if (currentRow.getEntryBook() != null){ + result = currentRow.getEntryBook().getCode(); + } + else { //entrybook + result = null; + } + break; + case 3: // description + result = currentRow.getVoucher(); + break; + case 4: + result = currentRow.getDescription(); + break; + case 5 : + result = amountDebit; + break; + case 6: + result = amountCredit; + break; + case 7: + result = amountDebit - amountCredit; + break; + } + + } + } else { if (log.isDebugEnabled()) { - log.debug("No EntryBook selected skip table model update"); + log.debug("No fiscalPeriod selected skip table model update"); } } - + return result; } + - @Override public boolean isCellEditable(int rowIndex, int columnIndex) { // Just read, no write @@ -176,33 +239,26 @@ } public void setBeginDate(Date date){ - log.debug("setBeginDate"); selectedBeginDate = date; - log.debug(selectedBeginDate); - cacheDataList=getDataList(); + cacheDataList = getDataList(); fireTableDataChanged(); } public void setEndDate(Date date){ - log.debug("setEndDate"); selectedEndDate = date; - log.debug(selectedEndDate); - cacheDataList=getDataList(); + cacheDataList = getDataList(); fireTableDataChanged(); } - - public void setEntryBook(EntryBook entryBook) { - selectedEntryBook = entryBook; - cacheDataList=getDataList(); - fireTableDataChanged(); - } - - public ReportsDatas getDataList(){ - ReportsDatas results = new ReportsDatasImpl(); + /** + * get all account fot the selected period + * @return + */ + public List<Object> getDataList(){ + List<Object> results = new ArrayList<Object>(); + try { - results = - reportService.generateEntryBooksReports(selectedEntryBook, selectedBeginDate, selectedEndDate); + balanceTrialCache = reportService.generateLedger(selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { @@ -210,6 +266,15 @@ } ErrorHelper.showErrorDialog("Can't get entries list", eee); } + for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { + results.add(reportsDatas); + List<Entry> entries = (List<Entry>) reportsDatas.getListEntry(); + log.debug(reportsDatas); + if (entries != null){ + Collections.sort(entries, new EntryComparator()); + results.addAll(entries); + } + } return results; } 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 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-06-03 14:46:55 UTC (rev 2930) @@ -64,11 +64,10 @@ <row> <cell fill="both" weightx="1" weighty="1" columns="7"> <JScrollPane> - <org.jdesktop.swingx.JXTable id="table" rowHeight="24" - model="{getModelTable()}" - highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" - columnControlVisible="true"/> + <org.chorem.lima.ui.ledger.LedgerTable + id="table" sortable="false" rowHeight="24" + constructorParams="getHandler()" model="{getModelTable()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> <javax.swing.ListSelectionModel javaBean="getTable().getSelectionModel()"/> </JScrollPane> </cell> 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 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-06-03 14:46:55 UTC (rev 2930) @@ -21,7 +21,7 @@ import static org.nuiton.i18n.I18n._; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.beans.ReportsDatas; +import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.ui.ReportsHelper; @@ -56,9 +56,8 @@ public void updateFooterLabel(){ LedgerTableModel tablemodel = (LedgerTableModel) view.getTable().getModel(); + BalanceTrial cacheDataList = tablemodel.balanceTrialCache; - ReportsDatas cacheDataList = tablemodel.cacheDataList; - if (cacheDataList != null){ // set amounts credit, debit and solde view.amountCreditLabel.setText(String.valueOf(cacheDataList.getAmountCredit())); @@ -79,7 +78,7 @@ view.soldeLabel.setText(_("lima.soldecredit")); } } - } + } } } Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-03 14:46:55 UTC (rev 2930) @@ -347,6 +347,7 @@ lima.transaction.column.entrybook=Entrybook lima.transaction.column.period=Period lima.transaction.column.position= +lima.transaction.column.solde=Solde lima.transaction.column.status=Status lima.transaction.column.voucher= lima.transaction.confirmdelete= Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-06-03 10:51:13 UTC (rev 2929) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-06-03 14:46:55 UTC (rev 2930) @@ -319,6 +319,7 @@ lima.transaction.column.entrybook=Journal lima.transaction.column.period=P\u00E9riode lima.transaction.column.position=Statut +lima.transaction.column.solde=Solde lima.transaction.column.voucher=Pi\u00E8ce comptable lima.transaction.confirmdelete= lima.transaction.entrybook=Journal