r2892 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: accountsreports balance entrybooksreports
Author: jpepin Date: 2010-05-11 12:01:59 +0200 (Tue, 11 May 2010) New Revision: 2892 Url: http://chorem.org/repositories/revision/lima/2892 Log: affichage des totaux credit, debit, et soldes dans la visualisation de la balance 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/AccountsReportsView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 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-05-10 16:38:31 UTC (rev 2891) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-11 10:01:59 UTC (rev 2892) @@ -77,7 +77,8 @@ */ public AccountsReportsTableModel() { - financialTransactionService = LimaServiceFactory.getInstance().getTransactionService(); + financialTransactionService = + LimaServiceFactory.getInstance().getTransactionService(); } @Override @@ -202,7 +203,9 @@ public List<Entry> getDataList(){ List<Entry> results = new ArrayList<Entry>(); try { - results = financialTransactionService.getAllEntriesForAccount(selectedAccount, selectedBeginDate, selectedEndDate); + results = + financialTransactionService.getAllEntriesForAccount( + selectedAccount, selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { 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 2010-05-10 16:38:31 UTC (rev 2891) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-11 10:01:59 UTC (rev 2892) @@ -82,23 +82,22 @@ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" columnControlVisible="true"/> - <javax.swing.ListSelectionModel javaBean="getAccountsReportsTable().getSelectionModel()" - onValueChanged="setSelectedRow(accountsReportsTable.getSelectedRow() != -1)"/> + <javax.swing.ListSelectionModel javaBean="getAccountsReportsTable().getSelectionModel()"/> </JScrollPane> </cell> </row> <row fill="horizontal" anchor="center"> <cell> - <JLabel text="lima.amountcredit"/> + <JLabel text="lima.amountdebit" /> </cell> <cell> - <JLabel id="amountCreditLabel" /> + <JLabel id="amountDebitLabel" /> </cell> <cell> - <JLabel text="lima.amountdebit" /> + <JLabel text="lima.amountcredit"/> </cell> <cell> - <JLabel id="amountDebitLabel" /> + <JLabel id="amountCreditLabel" /> </cell> <cell> <JLabel id="soldeLabel" text="lima.solde"/> 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-05-10 16:38:31 UTC (rev 2891) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-05-11 10:01:59 UTC (rev 2892) @@ -25,8 +25,6 @@ import java.util.Date; import java.util.List; -import javassist.bytecode.stackmap.BasicBlock.Catch; - import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; @@ -77,20 +75,14 @@ /** data cache */ protected List<Account> cacheDataList; - /** amount debit */ - protected Double amountDebit; - - /** amount credit */ - protected Double amountCredit; - /** * Constructor. */ public BalanceTableModel() { accountService = LimaServiceFactory.getInstance().getAccountService(); - financialTransactionService = LimaServiceFactory.getInstance().getTransactionService(); - amountCredit=0.00; - amountDebit=0.00; + financialTransactionService = + LimaServiceFactory.getInstance().getTransactionService(); + } @Override @@ -135,7 +127,9 @@ Account currentRow = cacheDataList.get(row); //get entries for the period for the current row try { - List<Entry> entries = financialTransactionService.getAllEntriesForAccount(currentRow, selectedBeginDate, selectedEndDate); + List<Entry> entries = + financialTransactionService.getAllEntriesForAccount(currentRow, + selectedBeginDate, selectedEndDate); Double solde = helper.getSolde(entries); Double debit = helper.getTotalDebit(entries); Double credit = helper.getTotalCredit(entries); @@ -185,7 +179,6 @@ } public void setBeginDate(Date date){ - log.debug("setBeginDate"); selectedBeginDate = date; log.debug(selectedBeginDate); cacheDataList=getDataList(); @@ -193,15 +186,19 @@ } public void setEndDate(Date date){ - log.debug("setEndDate"); selectedEndDate = date; log.debug(selectedEndDate); cacheDataList=getDataList(); fireTableDataChanged(); } + /** + * get all account fot the selected period + * @return + */ public List<Account> getDataList(){ - List<Account> results = new ArrayList<Account>(); + List<Account> results = new ArrayList<Account>(); + try { results = accountService.getAllAccounts(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-05-10 16:38:31 UTC (rev 2891) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-05-11 10:01:59 UTC (rev 2892) @@ -40,6 +40,11 @@ getBeginDatePicker().setDate(beginDate); getEndDatePicker().setDate(endDate); + + void $afterCompleteSetup() { + getHandler().updateFooterLabel(); + } + ]]> </script> @@ -69,23 +74,22 @@ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" columnControlVisible="true"/> - <javax.swing.ListSelectionModel javaBean="getBalanceTable().getSelectionModel()" - onValueChanged="setSelectedRow(balanceTable.getSelectedRow() != -1)"/> + <javax.swing.ListSelectionModel javaBean="getBalanceTable().getSelectionModel()"/> </JScrollPane> </cell> </row> <row fill="horizontal" anchor="center"> <cell> - <JLabel text="lima.amountcredit"/> + <JLabel text="lima.amountdebit" /> </cell> <cell> - <JLabel id="amountCreditLabel" /> + <JLabel id="amountDebitLabel" /> </cell> <cell> - <JLabel text="lima.amountdebit" /> + <JLabel text="lima.amountcredit"/> </cell> <cell> - <JLabel id="amountDebitLabel" /> + <JLabel id="amountCreditLabel" /> </cell> <cell> <JLabel id="soldeLabel" text="lima.solde"/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-05-10 16:38:31 UTC (rev 2891) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-05-11 10:01:59 UTC (rev 2892) @@ -24,7 +24,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialTransactionService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; +import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.ReportsHelper; @@ -44,37 +48,61 @@ LogFactory.getLog(BalanceViewHandler.class); protected BalanceView view; + + /** service **/ + protected FinancialTransactionService financialTransactionService; /** Helper **/ protected ReportsHelper helper; protected BalanceViewHandler(BalanceView view) { this.view = view; + financialTransactionService = + LimaServiceFactory.getInstance().getTransactionService(); + } + /** + * update the labels credit, debit, solde on the footer + * get all entries for all accounts on the selected period + */ public void updateFooterLabel(){ + Double totalCredit = 0.00, totalDebit = 0.00, solde = 0.00; BalanceTableModel tablemodel = (BalanceTableModel) view.getBalanceTable().getModel(); - Double amountCredit = tablemodel.amountCredit; - Double amountDebit = tablemodel.amountDebit; - view.amountCreditLabel.setText(String.valueOf(amountCredit)); - view.amountDebitLabel.setText(String.valueOf(amountDebit)); - - Double amountSolde = amountDebit - amountCredit; - view.amountSoldeLabel.setText(String.valueOf(amountSolde)); - - if (amountSolde <0){ - //solde debiteur - view.soldeLabel.setText(_("lima.soldecredit")); + try { + for (Account account : tablemodel.cacheDataList) { + List<Entry> entries; + entries = financialTransactionService. + getAllEntriesForAccount(account, + tablemodel.selectedBeginDate, + tablemodel.selectedEndDate); + totalCredit += helper.getTotalCredit(entries); + totalDebit += helper.getTotalDebit(entries); + solde += helper.getSolde(entries); + } + + view.amountCreditLabel.setText(String.valueOf(totalCredit)); + view.amountDebitLabel.setText(String.valueOf(totalDebit)); + view.amountSoldeLabel.setText(String.valueOf(solde)); + if (solde <0){ + //solde debiteur + view.soldeLabel.setText(_("lima.soldecredit")); + } + else if(solde > 0) { + //solde créditeur + view.soldeLabel.setText(_("lima.soldedebit")); + } + else { + //solde = 0 + view.soldeLabel.setText(_("lima.solde")); + } } - else if(amountSolde > 0) { - //solde créditeur - view.soldeLabel.setText(_("lima.soldedebit")); + catch (LimaException eee){ + if (log.isDebugEnabled()){ + log.debug("Can't update footer labels",eee); + } } - else { - //solde = 0 - view.soldeLabel.setText(_("lima.solde")); - } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-05-10 16:38:31 UTC (rev 2891) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-05-11 10:01:59 UTC (rev 2892) @@ -77,7 +77,8 @@ */ public EntryBooksReportsTableModel() { - financialTransactionService = LimaServiceFactory.getInstance().getTransactionService(); + financialTransactionService = + LimaServiceFactory.getInstance().getTransactionService(); } @Override @@ -202,7 +203,9 @@ public List<Entry> getDataList(){ List<Entry> results = new ArrayList<Entry>(); try { - results = financialTransactionService.getAllEntriesForEntryBook(selectedEntryBook, selectedBeginDate, selectedEndDate); + results = + financialTransactionService.getAllEntriesForEntryBook( + selectedEntryBook, selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { 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 2010-05-10 16:38:31 UTC (rev 2891) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-05-11 10:01:59 UTC (rev 2892) @@ -82,23 +82,22 @@ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" columnControlVisible="true"/> - <javax.swing.ListSelectionModel javaBean="getEntryBooksReportsTable().getSelectionModel()" - onValueChanged="setSelectedRow(entryBooksReportsTable.getSelectedRow() != -1)"/> + <javax.swing.ListSelectionModel javaBean="getEntryBooksReportsTable().getSelectionModel()"/> </JScrollPane> </cell> </row> <row fill="horizontal" anchor="center"> <cell> - <JLabel text="lima.amountcredit"/> + <JLabel text="lima.amountdebit" /> </cell> <cell> - <JLabel id="amountCreditLabel" /> + <JLabel id="amountDebitLabel" /> </cell> <cell> - <JLabel text="lima.amountdebit" /> + <JLabel text="lima.amountcredit"/> </cell> <cell> - <JLabel id="amountDebitLabel" /> + <JLabel id="amountCreditLabel" /> </cell> <cell> <JLabel id="soldeLabel" text="lima.solde"/>
participants (1)
-
jpepin@users.chorem.org