r2929 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui java/org/chorem/lima/ui/financialtransaction java/org/chorem/lima/ui/financialtransaction/table java/org/chorem/lima/ui/financialtransactionunbalanced java/org/chorem/lima/ui/ledger resources/i18n
Author: jpepin Date: 2010-06-03 12:51:13 +0200 (Thu, 03 Jun 2010) New Revision: 2929 Url: http://chorem.org/repositories/revision/lima/2929 Log: Cr?\195?\169ation UI Grand-Livre. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/ 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 Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-06-03 10:51:13 UTC (rev 2929) @@ -142,7 +142,8 @@ <JMenu text="lima.reports"> <JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)'/> <JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'/> - <JMenuItem text="lima.balance" onActionPerformed='getHandler().showBalanceView(this)'/> + <JMenuItem text="lima.reports.balance" onActionPerformed='getHandler().showBalanceView(this)'/> + <JMenuItem text="lima.reports.ledger" onActionPerformed='getHandler().showLedgerView(this)'/> <JMenuItem text="lima.reports" onActionPerformed='getHandler().showReportsView(this)' actionIcon='rapport'/> <JMenuItem text="lima.bilan" onActionPerformed='getHandler().showBilanView(this)'/> <JMenuItem text="lima.result" onActionPerformed='getHandler().showResultView(this)'/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -44,6 +44,7 @@ import org.chorem.lima.ui.financialtransaction.FinancialTransactionView; import org.chorem.lima.ui.financialtransaction.LetteringView; import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedView; +import org.chorem.lima.ui.ledger.LedgerView; import org.chorem.lima.util.ErrorHelper; /** @@ -285,7 +286,7 @@ public void showAccountView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); AccountView accountView = new AccountView(mainView); - mainView.showTab(_("lima.tab.account"), accountView); + mainView.showTab(_("lima.charts.account"), accountView); } /** * Show account tree table view to create or modify accounts @@ -294,7 +295,7 @@ public void showEntryBookView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); EntryBookView entryBookView= new EntryBookView(mainView); - mainView.showTab(_("lima.entrybooks"), entryBookView); + mainView.showTab(_("lima.charts.entrybook"), entryBookView); } /** @@ -304,7 +305,7 @@ public void showFiscalPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView); - mainView.showTab(_("lima.tab.fiscalperiod"), fiscalPeriodView); + mainView.showTab(_("lima.charts.fiscalyear"), fiscalPeriodView); } /** @@ -345,7 +346,7 @@ public void showTransactionView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialTransactionView transactionView = new FinancialTransactionView(mainView); - mainView.showTab(_("lima.tab.transaction"), transactionView); + mainView.showTab(_("lima.entries.addtransaction"), transactionView); } public void showTransactionUnbalancedView(JAXXContext rootContext) { @@ -357,9 +358,15 @@ public void showBalanceView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); BalanceView balanceView = new BalanceView(mainView); - mainView.showTab(_("lima.tab.balance"), balanceView); + mainView.showTab(_("lima.reports.balance"), balanceView); } + public void showLedgerView(JAXXContext rootContext) { + MainView mainView = getUI(rootContext); + LedgerView ledgerView = new LedgerView(mainView); + mainView.showTab(_("lima.reports.ledger"), ledgerView); + } + public void showBilanView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); // BilanView bilanView = new BilanView(mainView); @@ -385,7 +392,7 @@ public void showLetteringView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); LetteringView letteringView = new LetteringView(mainView); - mainView.showTab(_("lima.tab.lettering"), letteringView); + mainView.showTab(_("lima.entries.lettering"), letteringView); } public void showSearchView(JAXXContext rootContext) { Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -1,84 +0,0 @@ -/* *##% Lima Main - * Copyright (C) 2008 - 2010 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.ui.financialtransaction; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel; - -/** - * TODO add comment here. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class FinancialTransactionHelper { - /** log. */ - private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class); - - /** - * Get total credit for a transaction. - * - * @param transaction transaction to get credit - * @return total credit - */ - public static double getCredit(FinancialTransaction financialtransaction) { - double credit = 0; - for (Entry entry : financialtransaction.getEntry()) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (!entry.getDebit()) { - credit += entry.getAmount(); - } - } - return credit; - } - - /** - * Get total debit for a transaction. - * - * @param transaction transaction to get debit - * @return total debit - */ - public static double getDebit(FinancialTransaction financialtransaction) { - double debit = 0; - for (Entry entry : financialtransaction.getEntry()) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (entry.getDebit()) { - debit += entry.getAmount(); - } - } - return debit; - } - - /** - * Return true if transaction is balanced (credit == debit). - * - * @param transaction transaction to test - * @return {@code true} if transaction is balanced - */ - public static boolean isBalanced(FinancialTransaction financialtransaction) { - boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction); - return balanced; - } -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -1,14 +0,0 @@ -package org.chorem.lima.ui.financialtransaction; - -public class SearchFinancialTransactionViewHandler { - - - protected void addCriteriaWidget() { - - } - - protected void doSearch() { - - } - -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx 2010-06-03 10:51:13 UTC (rev 2929) @@ -1,60 +0,0 @@ -<!-- ##% Lima Swing - Copyright (C) 2008 - 2010 CodeLutin - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - ##% --> - -<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}" - onWindowClosing="windowClosing()" - defaultCloseOperation="do_nothing_on_close" - iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'> - <script> - protected void addCriteriaWidget() {}; - protected void doSearch() {}; - protected void windowClosing() {}; - </script> - <JScrollPane> - <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1"> - <row> - <cell> - <JButton id="addButton" text="lima.common.add" width="100" onActionPerformed="addCriteriaWidget()"/> - </cell> - <cell> - <JLabel text="lima.search.items.where" width="200"/> - </cell> - <cell> - <JAXXComboBox id="criteriaAllAnyComboBox" width="200"> - <item value='all' label='{_("lima.all.criteria")}' selected="true"/> - <item value='any' label='{_("lima.any.criteria")}'/> - </JAXXComboBox> - </cell> - </row> - <row> - <cell columns="3"> - <VBox id="criteriaWidgetPanel" - border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}' - /> - </cell> - </row> - <row> - <cell> - <JButton id="okButton" onActionPerformed="doSearch()" text="lima.common.ok"/> - </cell> - <cell> - <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="windowClosing()"/> - </cell> - </row> - </Table> - </JScrollPane> -</JFrame> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -264,10 +264,10 @@ result = null; // position break; case 6: - result = amountDebit;//FinancialTransactionHelper.getDebit(currentRow); + result = amountDebit; break; case 7: - result = amountCredit;//FinancialTransactionHelper.getCredit(currentRow); + result = amountCredit; break; case 8: result = amountDebit - amountCredit; Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -1,84 +0,0 @@ -/* *##% Lima Main - * Copyright (C) 2008 - 2010 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.ui.financialtransactionunbalanced; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel; - -/** - * TODO add comment here. - * - * @author chatellier - * @version $Revision: 2901 $ - * - * Last update : $Date: 2010-05-19 12:52:43 +0200 (mer. 19 mai 2010) $ - * By : $Author: jpepin $ - */ -public class FinancialTransactionUnbalancedHelper { - /** log. */ - private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class); - - /** - * Get total credit for a transaction. - * - * @param transaction transaction to get credit - * @return total credit - */ - public static double getCredit(FinancialTransaction financialtransaction) { - double credit = 0; - for (Entry entry : financialtransaction.getEntry()) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (!entry.getDebit()) { - credit += entry.getAmount(); - } - } - return credit; - } - - /** - * Get total debit for a transaction. - * - * @param transaction transaction to get debit - * @return total debit - */ - public static double getDebit(FinancialTransaction financialtransaction) { - double debit = 0; - for (Entry entry : financialtransaction.getEntry()) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (entry.getDebit()) { - debit += entry.getAmount(); - } - } - return debit; - } - - /** - * Return true if transaction is balanced (credit == debit). - * - * @param transaction transaction to test - * @return {@code true} if transaction is balanced - */ - public static boolean isBalanced(FinancialTransaction financialtransaction) { - boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction); - return balanced; - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -45,7 +45,6 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.financialtransaction.FinancialTransactionHelper; import org.chorem.lima.util.ErrorHelper; /** @@ -237,7 +236,9 @@ result = cacheDataList.get(row); if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; + FinancialTransaction currentRow = (FinancialTransaction)result; + Double amountDebit = currentRow.getAmountDebit(); + Double amountCredit = currentRow.getAmountCredit(); switch (column) { case 0: @@ -259,14 +260,13 @@ result = null; // position break; case 6: - result = FinancialTransactionHelper.getDebit(currentRow); + result = amountDebit; break; case 7: - result = FinancialTransactionHelper.getCredit(currentRow); + result = amountCredit; break; case 8: - result = FinancialTransactionHelper.getDebit(currentRow) - - FinancialTransactionHelper.getCredit(currentRow); + result = amountDebit - amountCredit; break; } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-03 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -22,6 +22,7 @@ import javax.swing.JOptionPane; +import javax.swing.ListSelectionModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -63,6 +64,13 @@ Object selectedValue = model.getElementAt(indexSelectedRow); try { model.addEmptyEntry(selectedValue, indexSelectedRow); + //select the new line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow+1, indexSelectedRow+1); + //focus on second column + table.changeSelection(indexSelectedRow+1, 1, false, false); + table.requestFocusInWindow(); } catch (LimaException ex){ if (log.isErrorEnabled()) { log.error("Can't add emptyentry", ex); @@ -110,6 +118,10 @@ try { model.removeObject(selectedValue, indexSelectedRow); + //select the upper line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow-1, indexSelectedRow-1); } catch (LimaException ex) { if (log.isErrorEnabled()) { log.error("Can't remove transaction or entry", ex); Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -0,0 +1,216 @@ +/* + * *##% Lima Main + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.ledger; + +import static org.nuiton.i18n.I18n._; +import java.text.SimpleDateFormat; +import java.util.Date; +import javax.swing.table.AbstractTableModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.entity.Entry; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.ErrorHelper; + +/** + * Entry book table model. + * + * @author ore + * @author chatellier + * @version $Revision: 2865 $ + * + * Last update : $Date: 2010-04-19 15:19:30 +0200 (lun. 19 avril 2010) $ + * By : $Author: jpepin $ + */ +public class LedgerTableModel extends AbstractTableModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 7578692417919755647L; + + /** log. */ + private static final Log log = LogFactory.getLog(LedgerTableModel.class); + + /** Services. */ + protected ReportService reportService; + + /** Account. */ + protected EntryBook selectedEntryBook; + + /** Begin Date. */ + protected Date selectedBeginDate; + + /** EndDate. */ + protected Date selectedEndDate; + + /** data cache */ + protected ReportsDatas cacheDataList; + + /** + * Constructor. + */ + public LedgerTableModel() { + + reportService = + LimaServiceFactory.getInstance().getReportService(); + } + + @Override + public int getRowCount() { + int result = 0; + + // just prevent too much result + if (selectedEntryBook != null) { + result = cacheDataList.getListEntry().size(); + } + else { + if (log.isDebugEnabled()) { + log.debug("No account selected skip table model update"); + } + } + + return result; + } + + @Override + public int getColumnCount() { + return 6; + } + + @Override + public String getColumnName(int column) { + String res = "n/a"; + switch (column) { + case 0: + res = _("lima.transaction.column.date"); //Date + break; + case 1: + res = _("lima.transaction.column.account"); //Account + break; + case 2: + res = _("lima.transaction.column.voucher"); // Voucher + break; + case 3: + res = _("lima.transaction.column.description"); //Description + break; + case 4: + res = _("lima.transaction.column.debit"); //Debit + break; + case 5: + res = _("lima.transaction.column.credit"); //Credit + 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) { + case 0: + result = simpleDateFormat. + format(currentRow.getFinancialTransaction().getTransactionDate()); + break; + case 1: + if (currentRow.getAccount() != null){ + result = currentRow.getAccount().getAccountNumber(); + } + else { + result = null; + } + break; + case 2: + result = currentRow.getVoucher(); + break; + case 3: + result = currentRow.getDescription(); + break; + case 4: + result = currentRow.getDebit() ? currentRow.getAmount() : 0; + break; + case 5: + result = currentRow.getDebit() ? 0 : currentRow.getAmount(); + break; + } + } + else { + if (log.isDebugEnabled()) { + log.debug("No EntryBook selected skip table model update"); + } + } + + return result; + } + + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + // Just read, no write + return false; + } + + public void setBeginDate(Date date){ + log.debug("setBeginDate"); + selectedBeginDate = date; + log.debug(selectedBeginDate); + cacheDataList=getDataList(); + fireTableDataChanged(); + } + + public void setEndDate(Date date){ + log.debug("setEndDate"); + selectedEndDate = date; + log.debug(selectedEndDate); + cacheDataList=getDataList(); + fireTableDataChanged(); + } + + + public void setEntryBook(EntryBook entryBook) { + selectedEntryBook = entryBook; + cacheDataList=getDataList(); + fireTableDataChanged(); + } + + public ReportsDatas getDataList(){ + ReportsDatas results = new ReportsDatasImpl(); + try { + results = + reportService.generateEntryBooksReports(selectedEntryBook, selectedBeginDate, selectedEndDate); + } + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.debug("Can't update model", eee); + } + ErrorHelper.showErrorDialog("Can't get entries list", eee); + } + return results; + } + +} Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-06-03 10:51:13 UTC (rev 2929) @@ -0,0 +1,96 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 CodeLutin + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<Table> + <LedgerViewHandler id="handler" javaBean="new LedgerViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/> + <org.chorem.lima.ui.ledger.LedgerTableModel id="modelTable"/> + <script> + <![CDATA[ + + import org.apache.commons.lang.time.DateUtils; + import java.util.Calendar; + + // 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); + getModelTable().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + getModelTable().setEndDate(endDate); + + getBeginDatePicker().setDate(beginDate); + getEndDatePicker().setDate(endDate); + + ]]> + </script> + <row fill="horizontal" weightx="1" weighty="0" anchor="center"> + <cell> + <JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/> + </cell> + <cell> + <org.jdesktop.swingx.JXDatePicker id="beginDatePicker" + onActionPerformed="getModelTable().setBeginDate(beginDatePicker.getDate()); + getHandler().updateFooterLabel()" /> + </cell> + <cell> + <JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/> + </cell> + <cell> + <org.jdesktop.swingx.JXDatePicker id="endDatePicker" + onActionPerformed="getModelTable().setEndDate(endDatePicker.getDate()); + getHandler().updateFooterLabel()"/> + </cell> + </row> + <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"/> + <javax.swing.ListSelectionModel javaBean="getTable().getSelectionModel()"/> + </JScrollPane> + </cell> + </row> + <row fill="horizontal" anchor="center"> + <cell> + <JLabel text="lima.amountdebit" /> + </cell> + <cell> + <JLabel id="amountDebitLabel" /> + </cell> + <cell> + <JLabel text="lima.amountcredit"/> + </cell> + <cell> + <JLabel id="amountCreditLabel" /> + </cell> + <cell> + <JLabel id="soldeLabel" text="lima.solde"/> + </cell> + <cell> + <JLabel id="amountSoldeLabel"/> + </cell> + </row> +</Table> \ No newline at end of file Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929) @@ -0,0 +1,85 @@ +/* *##% 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 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.ui.ReportsHelper; + + +/** + * Handler associated with accounts reports view. + * + * @author chatellier + * @version $Revision: 2884 $ + * + * Last update : $Date: 2010-05-06 11:57:19 +0200 (jeu. 06 mai 2010) $ + * By : $Author: jpepin $ + */ +public class LedgerViewHandler { + + /** log. */ + private static final Log log = + LogFactory.getLog(LedgerViewHandler.class); + + protected LedgerView view; + + /** Helper **/ + protected ReportsHelper helper; + + protected LedgerViewHandler(LedgerView view) { + this.view = view; + } + + + /* + * set text and amounts of labels credit, debit, solde + */ + public void updateFooterLabel(){ + LedgerTableModel tablemodel = + (LedgerTableModel) view.getTable().getModel(); + + ReportsDatas cacheDataList = tablemodel.cacheDataList; + + if (cacheDataList != null){ + // set amounts credit, debit and solde + view.amountCreditLabel.setText(String.valueOf(cacheDataList.getAmountCredit())); + view.amountDebitLabel.setText(String.valueOf(cacheDataList.getAmountDebit())); + Double amountSolde = cacheDataList.getAmountSolde(); + view.amountSoldeLabel.setText(String.valueOf(amountSolde)); + + + if (amountSolde == 0){ + view.soldeLabel.setText(_("lima.solde")); + } + else { + // set label solde: credit or debit + if (cacheDataList.getSoldeDebit()) { + view.soldeLabel.setText(_("lima.soldedebit")); + } + else { + 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 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-03 10:51:13 UTC (rev 2929) @@ -41,7 +41,6 @@ lima.amountcredit= lima.amountdebit= lima.any.criteria=Any criteria are met -lima.balance=Balance lima.balance.account.libelle=Title lima.balance.account.number=N\u00B0 account lima.balance.move.credit=Credit @@ -291,7 +290,9 @@ lima.remove.transaction=Remove a transaction lima.reports=Reports lima.reports.accounts=Edit account +lima.reports.balance=Balance lima.reports.entrybooks=Edit entrybook +lima.reports.ledger=Ledger lima.response.no=No lima.response.yes=Yes lima.result=Result 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 09:59:29 UTC (rev 2928) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-06-03 10:51:13 UTC (rev 2929) @@ -40,7 +40,6 @@ lima.amountcredit=Total Cr\u00E9dit lima.amountdebit=Total D\u00E9bit lima.any.criteria=Au moins un crit\u00E8re correspond -lima.balance=Balance lima.balance.account.libelle=Libell\u00E9 lima.balance.account.number=N\u00B0 de compte lima.balance.move.credit=Mouvement au cr\u00E9dit @@ -275,7 +274,9 @@ lima.remove.transaction=Supprimer une transaction lima.reports=Rapports lima.reports.accounts=Edition compte +lima.reports.balance=Balance lima.reports.entrybooks=Edition journal +lima.reports.ledger=Grand Livre lima.response.no=Non lima.response.yes=Oui lima.result=Compte de r\u00E9sultat @@ -301,19 +302,11 @@ lima.subledger.label= lima.subledger.type= lima.success=Succ\u00E8s -lima.tab.account=Plan Comptable -lima.tab.accounts= -lima.tab.balance=Balance -lima.tab.bilan=Bilan -lima.tab.blocked=Block\u00E9 -lima.tab.financialperiod= -lima.tab.fiscalperiod=Exercice +lima.tab.bilan= +lima.tab.fiscalperiod= lima.tab.home=Accueil -lima.tab.lettering=Lettrage -lima.tab.reports=Rapports -lima.tab.result=Compte de r\u00E9sultat -lima.tab.search.result=Recherche -lima.tab.transaction=Ecriture +lima.tab.reports= +lima.tab.result= lima.title=Lutin Invoice Monitoring and Accounting lima.title.about=A propos de Lima... lima.to=A
participants (1)
-
jpepin@users.chorem.org