r2940 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport lima-swing/src/main/resources/i18n
Author: jpepin Date: 2010-06-15 19:35:55 +0200 (Tue, 15 Jun 2010) New Revision: 2940 Url: http://chorem.org/repositories/revision/lima/2940 Log: G?\195?\169n?\195?\169ration du bilan et compte de r?\195?\169sultat, ajout m?\195?\169thode de calcul dans le business, ajout affichage dans l'UI. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementViewHandler.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialStatementService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.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/ReportServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo 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/financialstatementchart/FinancialStatementHeaderForm.jaxx 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/AccountServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceLocal.java 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountServiceLocal.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -19,8 +19,13 @@ package org.chorem.lima.business; +import java.util.List; + import javax.ejb.Local; +import org.chorem.lima.entity.Account; +import org.nuiton.topia.TopiaContext; + /** * Account service. * @@ -34,5 +39,6 @@ @Local public interface AccountServiceLocal extends AccountService{ + public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, TopiaContext topiaContext) throws LimaException; } \ No newline at end of file Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialStatementService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialStatementService.java 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialStatementService.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -19,6 +19,7 @@ package org.chorem.lima.business; +import java.util.Date; import java.util.List; import javax.ejb.Remote; @@ -28,14 +29,16 @@ @Remote public interface FinancialStatementService { - void createFinancialStatementHeader(FinancialStatementHeader masterFinancialStatementHeader, FinancialStatementHeader financialStatementHeader) throws LimaException, LimaBusinessException; - void updateFinancialStatementHeader(FinancialStatementHeader financialStatementHeader) throws LimaException, LimaBusinessException; - void removeFinancialStatementHeader(FinancialStatementHeader financialStatementHeader) throws LimaException, LimaBusinessException; + public void createFinancialStatementHeader(FinancialStatementHeader masterFinancialStatementHeader, FinancialStatementHeader financialStatementHeader) throws LimaException, LimaBusinessException; + public void updateFinancialStatementHeader(FinancialStatementHeader financialStatementHeader) throws LimaException, LimaBusinessException; + public void removeFinancialStatementHeader(FinancialStatementHeader financialStatementHeader) throws LimaException, LimaBusinessException; - void createFinancialStatementMovement(FinancialStatementHeader masterFinancialStatementHeader, FinancialStatementMovement financialStatementMovement) throws LimaException, LimaBusinessException; - void updateFinancialStatementMovement(FinancialStatementMovement financialStatementMovement) throws LimaException, LimaBusinessException; - void removeFinancialStatementMovement(FinancialStatementMovement financialStatementMovement) throws LimaException, LimaBusinessException; + public void createFinancialStatementMovement(FinancialStatementHeader masterFinancialStatementHeader, FinancialStatementMovement financialStatementMovement) throws LimaException, LimaBusinessException; + public void updateFinancialStatementMovement(FinancialStatementMovement financialStatementMovement) throws LimaException, LimaBusinessException; + public void removeFinancialStatementMovement(FinancialStatementMovement financialStatementMovement) throws LimaException, LimaBusinessException; public List<Object> getChildrenFinancialStatement(FinancialStatementHeader financialStatementHeader) throws LimaException; - List<Object> getAllChildrenFinancialStatement(FinancialStatementHeader financialStatementHeader, List<Object> objects) throws LimaException, LimaBusinessException; + public List<Object> getAllChildrenFinancialStatement(FinancialStatementHeader financialStatementHeader, List<Object> objects) throws LimaException, LimaBusinessException; + + public List<Object> financialStatementReports(Date selectedBeginDate, Date selectedEndDate) throws LimaException; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceLocal.java 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportServiceLocal.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -19,9 +19,15 @@ package org.chorem.lima.business; +import java.util.Date; + import javax.ejb.Local; +import org.chorem.lima.beans.ReportsDatas; +import org.chorem.lima.entity.Account; +import org.nuiton.topia.TopiaContext; + /** * Service de generation des rapports. * @@ -41,4 +47,6 @@ @Local public interface ReportServiceLocal extends ReportService { + public ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException; + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -22,8 +22,13 @@ import static org.nuiton.i18n.I18n._; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.StringTokenizer; + import javax.ejb.Stateless; + +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountService; @@ -369,16 +374,63 @@ commitTransaction(transaction); } catch (TopiaException ex) { - if (log.isErrorEnabled()) { - log.error("Error during update account", ex); - } - throw new LimaException("Can't update account", ex); + doCatch(transaction, ex, log); } finally { doFinally(transaction, log); } } + + /** + * Convert string of extends number to list of accounts + * Example '22, 45-48, 67' -> [22, 45, 46, 47, 48, 67] + */ + @Override + public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, TopiaContext topiaContext) throws LimaException{ + List<Account> accounts = new ArrayList<Account>(); + if (selectedAccounts != null){ + try { + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(topiaContext); + //Remove Spaces + selectedAccounts = StringUtils.deleteWhitespace(selectedAccounts); + //use hashset for delete duplicate numbers + HashSet<String> accountNumbers = new HashSet<String>(); + //Split comma + StringTokenizer stComma = new StringTokenizer(selectedAccounts, ","); + while (stComma.hasMoreTokens()) { + String s = stComma.nextToken(); + if (s.contains("-")){ + //Split hypen + String stringHypen[] = s.split("-"); + int lowAccount=Integer.parseInt(stringHypen[0]); + int highAccount=Integer.parseInt(stringHypen[1]); + for (int i=lowAccount; i <= highAccount; i++) { + accountNumbers.add(String.valueOf(i)); + } + } + else{ + accountNumbers.add(s); + } + } + + for (String accountNumber : accountNumbers) { + Account accountFilter = accountDAO.findByAccountNumber(accountNumber); + //add account if exist + if (accountFilter != null){ + accounts.add(accountFilter); + } + } + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + } + + return accounts; + } + protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database // TODO move it into JTA 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 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -21,16 +21,24 @@ import static org.nuiton.i18n.I18n._; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import javax.ejb.EJB; import javax.ejb.Stateless; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.beans.FinancialStatementAmounts; +import org.chorem.lima.beans.FinancialStatementAmountsImpl; +import org.chorem.lima.beans.ReportsDatas; +import org.chorem.lima.business.AccountServiceLocal; import org.chorem.lima.business.AccountingRules; import org.chorem.lima.business.FinancialStatementService; import org.chorem.lima.business.FinancialStatementServiceLocal; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ReportServiceLocal; +import org.chorem.lima.entity.Account; import org.chorem.lima.entity.FinancialStatementHeader; import org.chorem.lima.entity.FinancialStatementHeaderDAO; import org.chorem.lima.entity.FinancialStatementMovement; @@ -52,6 +60,12 @@ protected AccountingRules accountingRules; + @EJB + AccountServiceLocal accountServiceLocal; + + @EJB + ReportServiceLocal reportServiceLocal; + public FinancialStatementServiceImpl() { LimaConfig config = LimaConfig.getInstance(); try { @@ -215,9 +229,14 @@ @Override public List<Object> getAllChildrenFinancialStatement(FinancialStatementHeader financialStatementHeader, List<Object> objects) throws LimaException, LimaBusinessException { - return objects; - // TODO Auto-generated method stub - } + List<Object> childFinancialStatement = getChildrenFinancialStatement(financialStatementHeader); + for (Object child : childFinancialStatement) { + objects.add(child); + if (child instanceof FinancialStatementHeader){ + getAllChildrenFinancialStatement((FinancialStatementHeader) child, objects); + } + } + return objects; } @Override public List<Object> getChildrenFinancialStatement(FinancialStatementHeader masterFinancialStatementHeader) throws LimaException { @@ -231,10 +250,13 @@ LimaCallaoDAOHelper.getFinancialStatementHeaderDAO(transaction); - TopiaQuery query = financialStatementHeaderDAO.createQuery(); + + + TopiaQuery query = financialStatementHeaderDAO.createQuery(); if (masterFinancialStatementHeader == null){ query.addEquals("masterFinancialStatementHeader", masterFinancialStatementHeader); } + //TODO virer addwhere, garder addEquals else { query.addWhere("masterFinancialStatementHeader = :value") .addParam("value", masterFinancialStatementHeader); @@ -276,10 +298,7 @@ commitTransaction(transaction); } catch (TopiaException ex) { - if (log.isErrorEnabled()) { - log.error("Error during update financialStatementHeader", ex); - } - throw new LimaException("Can't update financialStatementHeader", ex); + doCatch(transaction, ex, log); } finally { doFinally(transaction, log); @@ -301,16 +320,95 @@ commitTransaction(transaction); } catch (TopiaException ex) { - if (log.isErrorEnabled()) { - log.error("Error during update financialStatementMovement", ex); - } - throw new LimaException("Can't update financialStatementMovement", ex); + doCatch(transaction, ex, log); } finally { doFinally(transaction, log); } } + + @Override + public List<Object> financialStatementReports(Date selectedBeginDate, Date selectedEndDate) throws LimaException { + List<Object> result = new ArrayList<Object>(); + TopiaContext transaction = null; + try { + transaction = beginTransaction(); + List<Object> financialStatementList = getAllChildrenFinancialStatement(null, new ArrayList<Object>()); + + for (Object object : financialStatementList) { + if (object instanceof FinancialStatementMovement){ + FinancialStatementAmounts financialStatementAmounts = financialStatementMovementAmounts((FinancialStatementMovement) object, selectedBeginDate, selectedEndDate, transaction); + result.add(financialStatementAmounts); + } + else { + result.add(object); + } + } + } + catch (TopiaException ex) { + doCatch(transaction, ex, log); + } + finally { + doFinally(transaction, log); + } + + return result; + } + + public FinancialStatementAmounts financialStatementMovementAmounts(FinancialStatementMovement financialStatementMovement, Date selectedBeginDate, Date selectedEndDate, TopiaContext topiaContext) throws LimaException{ + FinancialStatementAmounts financialStatementAmounts = new FinancialStatementAmountsImpl(); + + try { + String accountsString = financialStatementMovement.getAccounts(); + List<Account> accountsList = accountServiceLocal. + stringToListAccountsWithTransaction(accountsString, topiaContext); + Double amount = 0.0; + for (Account account : accountsList) { + ReportsDatas reportsDatas = reportServiceLocal.generateAccountReportsWithTransaction(account, selectedBeginDate, selectedEndDate, topiaContext); + amount += reportsDatas.getAmountSolde(); + } + + String creditAccountsString = financialStatementMovement.getCreditAccounts(); + List<Account> creditAccountsList = accountServiceLocal. + stringToListAccountsWithTransaction(creditAccountsString, topiaContext); + Double creditAmount = 0.0; + for (Account account : creditAccountsList) { + ReportsDatas reportsDatas = reportServiceLocal.generateAccountReportsWithTransaction(account, selectedBeginDate, selectedEndDate, topiaContext); + creditAmount += reportsDatas.getAmountCredit(); + } + + String debitAccountsString = financialStatementMovement.getDebitAccounts(); + List<Account> debitAccountsList = accountServiceLocal. + stringToListAccountsWithTransaction(debitAccountsString, topiaContext); + Double debitAmount = 0.0; + for (Account account : debitAccountsList) { + ReportsDatas reportsDatas = reportServiceLocal.generateAccountReportsWithTransaction(account, selectedBeginDate, selectedEndDate, topiaContext); + debitAmount += reportsDatas.getAmountCredit(); + } + + String provisionDeprecationAccountsString = + financialStatementMovement.getProvisionDeprecationAccounts(); + List<Account> provisionDeprecationAccountsList = accountServiceLocal. + stringToListAccountsWithTransaction(provisionDeprecationAccountsString, topiaContext); + Double provisionDeprecationAmount = 0.0; + for (Account account : provisionDeprecationAccountsList) { + ReportsDatas reportsDatas = reportServiceLocal.generateAccountReportsWithTransaction(account, selectedBeginDate, selectedEndDate, topiaContext); + provisionDeprecationAmount += reportsDatas.getAmountSolde(); + } + + financialStatementAmounts.setGrossAmount(amount+creditAmount+debitAmount); + financialStatementAmounts.setLabel(financialStatementMovement.getLabel()); + financialStatementAmounts.setProvisionDeprecationAmount(provisionDeprecationAmount); + + } + catch (LimaException ex) { + doCatch(topiaContext, ex, log); + } + + return financialStatementAmounts; + } + protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database // TODO move it into JTA 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-09 17:27:20 UTC (rev 2939) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -21,9 +21,8 @@ import java.util.ArrayList; import java.util.Date; -import java.util.HashSet; import java.util.List; -import java.util.StringTokenizer; +import javax.ejb.EJB; import javax.ejb.Stateless; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -32,6 +31,7 @@ import org.chorem.lima.beans.BalanceTrialImpl; import org.chorem.lima.beans.ReportsDatas; import org.chorem.lima.beans.ReportsDatasImpl; +import org.chorem.lima.business.AccountServiceLocal; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ReportService; @@ -56,6 +56,9 @@ private TopiaContext rootContext; + @EJB + AccountServiceLocal accountServiceLocal; + public ReportServiceImpl() { LimaConfig config = LimaConfig.getInstance(); try { @@ -97,7 +100,8 @@ * - for subaccount * - for a foldaccounts, contains many accounts */ - protected ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException{ + @Override + public ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException{ ReportsDatas reportsDatas = new ReportsDatasImpl(); double credit = 0, debit = 0, solde = 0; if (account != null){ @@ -422,33 +426,7 @@ } //build list account from selectedAccounts else{ - accounts = new ArrayList<Account>(); - //use hashset for delete duplicate numbers - HashSet<String> accountNumbers = new HashSet<String>(); - //Split comma - StringTokenizer stComma = new StringTokenizer(selectedAccounts, ","); - while (stComma.hasMoreTokens()) { - String s = stComma.nextToken(); - if (s.contains("-")){ - //Split hypen - String stringHypen[] = s.split("-"); - int lowAccount=Integer.parseInt(stringHypen[0]); - int highAccount=Integer.parseInt(stringHypen[1]); - for (int i=lowAccount; i <= highAccount; i++) { - accountNumbers.add(String.valueOf(i)); - } - } - else{ - accountNumbers.add(s); - } - } - - for (String accountNumber : accountNumbers) { - Account accountFilter = accountDAO.findByAccountNumber(accountNumber); - if (accountFilter != null){ - accounts.add(accountFilter); - } - } + accounts=accountServiceLocal.stringToListAccountsWithTransaction(selectedAccounts, topiaTransaction); } for (Account account : accounts) { ReportsDatas reportsDatas = Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) 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-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-06-15 17:35:55 UTC (rev 2940) @@ -145,9 +145,8 @@ <JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(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)'/> + <JMenuItem text="lima.financialstatementreports" onActionPerformed='getHandler().showFinancialStatementReportsView(this)' actionIcon='rapport'/> + </JMenu> 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-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -41,7 +41,8 @@ import org.chorem.lima.ui.entrybooksreports.EntryBooksReportsView; import org.chorem.lima.ui.financialperiod.FinancialPeriodView; import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; -import org.chorem.lima.ui.financialstatement.FinancialStatementView; +import org.chorem.lima.ui.financialstatementchart.FinancialStatementChartView; +import org.chorem.lima.ui.financialstatementreport.FinancialStatementReportView; import org.chorem.lima.ui.financialtransaction.FinancialTransactionView; import org.chorem.lima.ui.financialtransaction.LetteringView; import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedView; @@ -325,7 +326,7 @@ */ public void showFinancialStatementView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - FinancialStatementView financialStatementView = new FinancialStatementView(mainView); + FinancialStatementChartView financialStatementView = new FinancialStatementChartView(mainView); mainView.showTab(_("lima.charts.financialstatement"), financialStatementView); } @@ -378,16 +379,12 @@ mainView.showTab(_("lima.reports.ledger"), ledgerView); } - public void showBilanView(JAXXContext rootContext) { + public void showFinancialStatementReportsView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - // BilanView bilanView = new BilanView(mainView); - // mainView.showTab(_("lima.tab.bilan"), bilanView); + FinancialStatementReportView financialStatementReportView= new FinancialStatementReportView(mainView); + mainView.showTab(_("lima.reports.financialstatement"), financialStatementReportView); } - public void showClosureTimeSpanView(JAXXContext rootContext) { - //getClosureView().initBlockForm(); - } - public void showImportView(String type) { /*if (!getImportView(type).isEnabled()) { getImportView(type).setEnabled(true); @@ -413,12 +410,6 @@ getSearchView().setVisible(true);*/ } - public void showReportsView(JAXXContext rootContext) { - MainView mainView = getUI(rootContext); - //ReportsView reportsView = new ReportsView(mainView); - // mainView.showTab(_("lima.tab.reports"), reportsView); - } - public void showResultView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); //ResultView resultView = new ResultView(mainView); Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -1,86 +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; - -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.Entry; -import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel; - -/** - * TODO add comment here. - * - * @author chatellier - * @version $Revision: 2864 $ - * - * Last update : $Date: 2010-04-16 12:26:55 +0200 (ven. 16 avril 2010) $ - * By : $Author: jpepin $ - */ -public class ReportsHelper { - - /** log. */ - private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class); - - /** - * Get total credit for entries. - * - * @param list entries to calculate - * @return total credit - */ - public static double getTotalCredit(List<Entry> entries) { - double credit = 0; - for (Entry entry : entries) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (!entry.getDebit()) { - credit += entry.getAmount(); - } - } - return credit; - } - - /** - * Get total debit for entries. - * - * @param list entries to calculate - * @return total debit - */ - public static double getTotalDebit(List<Entry> entries) { - double debit = 0; - for (Entry entry : entries) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (entry.getDebit()) { - debit += entry.getAmount(); - } - } - return debit; - } - - /** - * Return amount of debit - credit - * - * @param list entries to calculate - * @return Solde - */ - public static double getSolde(List<Entry> entries) { - double balanced = getTotalDebit(entries) - getTotalCredit(entries); - return balanced; - } -} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java (from rev 2939, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/FinancialStatementTreeTableModel.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -0,0 +1,269 @@ +/* *##% 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.financialstatementchart; + +import static org.nuiton.i18n.I18n._; +import java.util.List; +import javax.swing.tree.TreePath; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialStatementService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.FinancialStatementHeader; +import org.chorem.lima.entity.FinancialStatementHeaderImpl; +import org.chorem.lima.entity.FinancialStatementMovement; +import org.chorem.lima.service.LimaServiceFactory; +import org.jdesktop.swingx.treetable.AbstractTreeTableModel; + +/** + * Tree table model for account edition. + * + * @author ore + * @author chatellier + * @version $Revision: 2934 $ + * + * Last update : $Date: 2010-06-08 11:55:04 +0200 (mar., 08 juin 2010) $ + * By : $Author: jpepin $ + */ +public class FinancialStatementChartTreeTableModel extends AbstractTreeTableModel { + + /** log. */ + private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); + + /** Account service. */ + protected final FinancialStatementService financialStatementService; + + /** + * Model constructor. Init account service used here. + */ + public FinancialStatementChartTreeTableModel() { + //create root for the tree + super(new FinancialStatementHeaderImpl()); + // Gets factory service + financialStatementService = LimaServiceFactory.getInstance().getFinancialStatementService(); + } + + + @Override + public int getColumnCount() { + return 1; + } + + @Override + public String getColumnName(int column) { + String res = null; + switch (column) { + case 0: + res = _("lima.account.label"); + break; + } + return res; + } + + @Override + public int getChildCount(Object node) { + int result = 0; + if (node == getRoot()) { + try { + result = financialStatementService. + getChildrenFinancialStatement(null).size(); + } catch (LimaException eee) { + log.debug("Can't count child", eee); + } + } + else { + if (node instanceof FinancialStatementHeader){ + FinancialStatementHeader parentFinancialStatementHeader = + (FinancialStatementHeader) node; + try { + result = financialStatementService.getChildrenFinancialStatement( + parentFinancialStatementHeader).size(); + } catch (LimaException eee) { + log.debug("Can't count child", eee); + } + } + } + return result; + } + + @Override + public Object getChild(Object parent, int index) { + Object result = null; + if (parent == getRoot()) { + try { + List<Object> allObjects = + financialStatementService.getChildrenFinancialStatement(null); + result = allObjects.get(index); + } catch (LimaException eee) { + log.debug("Can't get child", eee); + } + } + else { + FinancialStatementHeader parentFinancialStatementHeader = + (FinancialStatementHeader) parent; + try { + List<Object> objects = financialStatementService. + getChildrenFinancialStatement(parentFinancialStatementHeader); + result = objects.get(index); + } catch (LimaException eee) { + log.debug("Can't get child", eee); + } + } + return result; + } + + @Override + public int getIndexOfChild(Object parent, Object child) { + int result = 0; + + if (parent == getRoot()) { + try { + List<Object> allObjects = + financialStatementService.getChildrenFinancialStatement(null); + result = allObjects.indexOf(child); + } catch (LimaException eee) { + log.debug("Can't get index child", eee); + } + } + else { + FinancialStatementHeader parentFinancialStatementHeader = + (FinancialStatementHeader) parent; + try { + List<Object> objects = financialStatementService. + getChildrenFinancialStatement(parentFinancialStatementHeader); + result = objects.indexOf(child); + } catch (LimaException eee) { + log.debug("Can't get index child", eee); + } + } + return result; + } + + @Override + public Object getValueAt(Object node, int column) { + Object result = "n/a"; + if (node instanceof FinancialStatementHeader) { + FinancialStatementHeader financialStatementHeader = (FinancialStatementHeader) node; + switch (column) { + case 0: + result = financialStatementHeader.getLabel(); + break; + } + } + else { + FinancialStatementMovement financialStatementMovement = (FinancialStatementMovement) node; + switch (column) { + case 0: + result = financialStatementMovement.getLabel(); + break; + } + } + return result; + } + + @Override + public boolean isCellEditable(Object node, int column) { + return false; + } + + @Override + public boolean isLeaf(Object node) { + return getChildCount(node) == 0; + } + + /** + * Add FinancialStatementHeader (path can be null). + * + * @param path + * @param account + * @throws LimaException + */ + public void addFinancialStatementHeader(TreePath path, FinancialStatementHeader financialStatementHeader) throws LimaException { + // Calling account service + FinancialStatementHeader parentFinancialStatementHeader = + (FinancialStatementHeader) path.getLastPathComponent(); + if (parentFinancialStatementHeader == getRoot()) { + parentFinancialStatementHeader = null; + } + financialStatementService.createFinancialStatementHeader( + parentFinancialStatementHeader, financialStatementHeader); + modelSupport.fireTreeStructureChanged(path.getParentPath()); + } + + /** + * Add FinancialStatementMovement (path can't be null). + * + * @param path + * @param account + * @throws LimaException + */ + public void addFinancialStatementMovement(TreePath path, FinancialStatementMovement financialStatementMovement) throws LimaException { + // Calling account service + FinancialStatementHeader parentFinancialStatementHeader = + (FinancialStatementHeader) path.getLastPathComponent(); + if (parentFinancialStatementHeader != getRoot()) { + financialStatementService.createFinancialStatementMovement(parentFinancialStatementHeader, financialStatementMovement); + modelSupport.fireTreeStructureChanged(path); + } + } + + /** + * Update financialStatementHeader. + * + * @param path + * @param account + * @throws LimaException + */ + public void updateFinancialStatement(TreePath path, Object object) throws LimaException { + + int index = getIndexOfChild( + path.getParentPath().getLastPathComponent(), object); + if (object instanceof FinancialStatementHeader){ + financialStatementService.updateFinancialStatementHeader((FinancialStatementHeader) object); + } + else { + financialStatementService.updateFinancialStatementMovement((FinancialStatementMovement) object); + } + modelSupport.fireTreeStructureChanged(path); + } + + + + /** + * Remove financialStatementHeader or financialStatementMovement + * + * @param path + * @param object + * @throws LimaException + */ + public void removeFinancialStatementObject(TreePath path, Object object) throws LimaException { + // Calling account service + int index = getIndexOfChild( + path.getParentPath().getLastPathComponent(), object); + if (object instanceof FinancialStatementHeader){ + financialStatementService.removeFinancialStatementHeader((FinancialStatementHeader) object); + } + else { + financialStatementService.removeFinancialStatementMovement((FinancialStatementMovement) object); + } + + modelSupport.fireChildRemoved(path.getParentPath(), index, object); + } + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx (from rev 2939, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/FinancialStatementView.jaxx) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2010-06-15 17:35:55 UTC (rev 2940) @@ -0,0 +1,67 @@ +<!-- ##% 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> + + <FinancialStatementChartViewHandler id="handler" javaBean="new FinancialStatementChartViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + + <script> + <![CDATA[ + //getHandler().init(); + ]]> + </script> + + <row> + <cell fill="both" weightx="1" weighty="1" rows='4'> + <JScrollPane> + <org.jdesktop.swingx.JXTreeTable id="treeTable" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" + treeTableModel="{new org.chorem.lima.ui.financialstatementchart.FinancialStatementChartTreeTableModel()}" + highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" /> + <javax.swing.ListSelectionModel + javaBean="getTreeTable().getSelectionModel()" + onValueChanged="setSelectedRow(treeTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + <cell fill="horizontal"> + <JButton id="addFinancialStatementHeader" text="lima.financialstatement.header.add" + onActionPerformed="getHandler().addFinancialStatementHeader()"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JButton id="addFinancialStatementMovement" text="lima.financialstatement.movement.add" + onActionPerformed="getHandler().addFinancialStatementMovement()" + enabled="{isSelectedRow()}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JButton id="updateButton" text="lima.common.update" + onActionPerformed="getHandler().updateFinancialStatement()" + enabled="{isSelectedRow()}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JButton id="removeButton" text="lima.common.remove" + onActionPerformed="getHandler().removeFinancialStatement()" + enabled="{isSelectedRow()}"/> + </cell> + </row> +</Table> \ No newline at end of file Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java (from rev 2939, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/FinancialStatementViewHandler.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -0,0 +1,239 @@ +/* *##% 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.financialstatementchart; + +import static org.nuiton.i18n.I18n._; +import javax.swing.JOptionPane; +import javax.swing.tree.TreePath; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.LimaBusinessException; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.FinancialStatementHeader; +import org.chorem.lima.entity.FinancialStatementHeaderImpl; +import org.chorem.lima.entity.FinancialStatementMovement; +import org.chorem.lima.entity.FinancialStatementMovementImpl; +import org.chorem.lima.ui.financialstatementchart.FinancialStatementHeaderForm; +import org.chorem.lima.ui.financialstatementchart.FinancialStatementMovementForm; +import org.chorem.lima.util.DialogHelper; +import org.chorem.lima.util.ErrorHelper; +import org.jdesktop.swingx.JXTreeTable; + +/** + * Handler associated with account view. + * + * @author chatellier + * @version $Revision: 2934 $ + * + * Last update : $Date: 2010-06-08 11:55:04 +0200 (mar., 08 juin 2010) $ + * By : $Author: jpepin $ + */ +public class FinancialStatementChartViewHandler { + + /** log. */ + private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); + + protected FinancialStatementChartView view; + + protected JXTreeTable treeTable; + + protected FinancialStatementChartTreeTableModel treeTableModel; + + protected FinancialStatementChartViewHandler(FinancialStatementChartView view) { + this.view = view; + } + + /** + * Add new account with account form. + */ + public void addFinancialStatementHeader() { + treeTable = view.getTreeTable(); + treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + + FinancialStatementHeader newFinancialStatementHeader = new FinancialStatementHeaderImpl(); + FinancialStatementHeaderForm financialStatementHeaderForm = new FinancialStatementHeaderForm(view); + financialStatementHeaderForm.setHeader(newFinancialStatementHeader); + // jaxx constructor don't call super() ? + financialStatementHeaderForm.setLocationRelativeTo(view); + financialStatementHeaderForm.setVisible(true); + + // null == cancel action + newFinancialStatementHeader = financialStatementHeaderForm.getHeader(); + if (newFinancialStatementHeader != null) { + // get current selection path + TreePath treePath = null; + int selectedRow = treeTable.getSelectedRow(); + if ( selectedRow != -1) { + treePath = treeTable.getPathForRow(selectedRow); + } else { + treePath = new TreePath(treeTableModel.getRoot()); + } + + // add it + try { + treeTableModel.addFinancialStatementHeader(treePath, newFinancialStatementHeader); + } catch (LimaBusinessException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add financialStatementHeader", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + + } + + catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't add financialStatementHeader", ex); + } + ErrorHelper.showErrorDialog("Can't add financialStatementHeader", ex); + } + } + }; + + public void addFinancialStatementMovement(){ + + treeTable = view.getTreeTable(); + treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + + FinancialStatementMovement newFinancialStatementMovement = new FinancialStatementMovementImpl(); + FinancialStatementMovementForm financialStatementMovementForm = new FinancialStatementMovementForm(view); + financialStatementMovementForm.setMovement(newFinancialStatementMovement); + // jaxx constructor don't call super() ? + financialStatementMovementForm.setLocationRelativeTo(view); + financialStatementMovementForm.setVisible(true); + newFinancialStatementMovement=financialStatementMovementForm.getMovement(); + + // null == cancel action + if (newFinancialStatementMovement != null) { + // get current selection path + TreePath treePath = null; + int selectedRow = view.treeTable.getSelectedRow(); + treePath = view.treeTable.getPathForRow(selectedRow); + // add it + try { + treeTableModel. + addFinancialStatementMovement(treePath, newFinancialStatementMovement); + } catch (LimaBusinessException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add FinancialStatementMovement", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add FinancialStatementMovement", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + } + } + + /** + * Open account form with selected account. + * Verifiy if it's an account or a subledger + */ + public void updateFinancialStatement() { + + treeTable = view.getTreeTable(); + treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + + // get selected account + int selectedRow = view.treeTable.getSelectedRow(); + TreePath treePath = view.treeTable.getPathForRow(selectedRow); // not null + Object selectedObject = treePath.getLastPathComponent(); + //update Account or update SubLedger + if (selectedObject != null) { + // get current selection path + if ( selectedRow != -1) { + treePath = view.treeTable.getPathForRow(selectedRow); + } else { + treePath = new TreePath(treeTableModel.getRoot()); + } + //test if selectedrow is account or ledger + if (selectedObject instanceof FinancialStatementHeader){ + FinancialStatementHeaderForm financialStatementHeaderForm = new FinancialStatementHeaderForm(view); + financialStatementHeaderForm.setHeader((FinancialStatementHeader) selectedObject); + // jaxx constructor don't call super() ? + financialStatementHeaderForm.setLocationRelativeTo(view); + financialStatementHeaderForm.setVisible(true); + // null == cancel action + selectedObject = financialStatementHeaderForm.getHeader(); + } + // else is a subledger + else{ + FinancialStatementMovementForm financialStatementMovementForm = new FinancialStatementMovementForm(view); + financialStatementMovementForm.setMovement((FinancialStatementMovement) selectedObject); + // jaxx constructor don't call super() ? + financialStatementMovementForm.setLocationRelativeTo(view); + financialStatementMovementForm.setVisible(true); + // null == cancel action + selectedObject = financialStatementMovementForm.getMovement(); + } + //if action confirmed + if (selectedObject != null){ + // update it + try { + treeTableModel.updateFinancialStatement(treePath, selectedObject); + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add update", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + } + } + } + + /** + * Ask for user to remove for selected account, and remove it if confirmed. + */ + public void removeFinancialStatement() { + treeTable = view.getTreeTable(); + treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + + // Any row selected + int selectedRow = view.treeTable.getSelectedRow(); + if ( selectedRow != -1) { + int n = JOptionPane.showConfirmDialog(view, + _("lima.question.remove.account"), + _("lima.question"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (n == JOptionPane.YES_OPTION) { + // update view of treetable + TreePath treePath = view.treeTable.getPathForRow(selectedRow); + Object object = treePath.getLastPathComponent(); + + try{ + treeTableModel.removeFinancialStatementObject(treePath, object); + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't delete account", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + } + } + }; + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementHeaderForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/FinancialStatementHeaderForm.jaxx 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementHeaderForm.jaxx 2010-06-15 17:35:55 UTC (rev 2940) @@ -41,6 +41,17 @@ onRemoveUpdate='getHeader().setLabel(getDescriptionTextField().getText())' /> </cell> </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.financialstatement.style"/> + </cell> + <cell fill="horizontal"> + <JTextField id="styleTextField" text="{getHeader().getStyle()}"/> + <javax.swing.text.Document javaBean="getStyleTextField().getDocument()" + onInsertUpdate='getHeader().setStyle(getStyleTextField().getText())' + onRemoveUpdate='getHeader().setStyle(getStyleTextField().getText())' /> + </cell> + </row> <row> <cell fill="none"> <JButton text="lima.common.ok" onActionPerformed="dispose()"/> Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/FinancialStatementTreeTableModel.java 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementTreeTableModel.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -1,269 +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. - * ##%*/ - -package org.chorem.lima.ui.financialstatement; - -import static org.nuiton.i18n.I18n._; -import java.util.List; -import javax.swing.tree.TreePath; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.FinancialStatementService; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.entity.FinancialStatementHeader; -import org.chorem.lima.entity.FinancialStatementHeaderImpl; -import org.chorem.lima.entity.FinancialStatementMovement; -import org.chorem.lima.service.LimaServiceFactory; -import org.jdesktop.swingx.treetable.AbstractTreeTableModel; - -/** - * Tree table model for account edition. - * - * @author ore - * @author chatellier - * @version $Revision: 2934 $ - * - * Last update : $Date: 2010-06-08 11:55:04 +0200 (mar., 08 juin 2010) $ - * By : $Author: jpepin $ - */ -public class FinancialStatementTreeTableModel extends AbstractTreeTableModel { - - /** log. */ - private static final Log log = LogFactory.getLog(FinancialStatementViewHandler.class); - - /** Account service. */ - protected final FinancialStatementService financialStatementService; - - /** - * Model constructor. Init account service used here. - */ - public FinancialStatementTreeTableModel() { - //create root for the tree - super(new FinancialStatementHeaderImpl()); - // Gets factory service - financialStatementService = LimaServiceFactory.getInstance().getFinancialStatementService(); - } - - - @Override - public int getColumnCount() { - return 1; - } - - @Override - public String getColumnName(int column) { - String res = null; - switch (column) { - case 0: - res = _("lima.account.label"); - break; - } - return res; - } - - @Override - public int getChildCount(Object node) { - int result = 0; - if (node == getRoot()) { - try { - result = financialStatementService. - getChildrenFinancialStatement(null).size(); - } catch (LimaException eee) { - log.debug("Can't count child", eee); - } - } - else { - if (node instanceof FinancialStatementHeader){ - FinancialStatementHeader parentFinancialStatementHeader = - (FinancialStatementHeader) node; - try { - result = financialStatementService.getChildrenFinancialStatement( - parentFinancialStatementHeader).size(); - } catch (LimaException eee) { - log.debug("Can't count child", eee); - } - } - } - return result; - } - - @Override - public Object getChild(Object parent, int index) { - Object result = null; - if (parent == getRoot()) { - try { - List<Object> allObjects = - financialStatementService.getChildrenFinancialStatement(null); - result = allObjects.get(index); - } catch (LimaException eee) { - log.debug("Can't get child", eee); - } - } - else { - FinancialStatementHeader parentFinancialStatementHeader = - (FinancialStatementHeader) parent; - try { - List<Object> objects = financialStatementService. - getChildrenFinancialStatement(parentFinancialStatementHeader); - result = objects.get(index); - } catch (LimaException eee) { - log.debug("Can't get child", eee); - } - } - return result; - } - - @Override - public int getIndexOfChild(Object parent, Object child) { - int result = 0; - - if (parent == getRoot()) { - try { - List<Object> allObjects = - financialStatementService.getChildrenFinancialStatement(null); - result = allObjects.indexOf(child); - } catch (LimaException eee) { - log.debug("Can't get index child", eee); - } - } - else { - FinancialStatementHeader parentFinancialStatementHeader = - (FinancialStatementHeader) parent; - try { - List<Object> objects = financialStatementService. - getChildrenFinancialStatement(parentFinancialStatementHeader); - result = objects.indexOf(child); - } catch (LimaException eee) { - log.debug("Can't get index child", eee); - } - } - return result; - } - - @Override - public Object getValueAt(Object node, int column) { - Object result = "n/a"; - if (node instanceof FinancialStatementHeader) { - FinancialStatementHeader financialStatementHeader = (FinancialStatementHeader) node; - switch (column) { - case 0: - result = financialStatementHeader.getLabel(); - break; - } - } - else { - FinancialStatementMovement financialStatementMovement = (FinancialStatementMovement) node; - switch (column) { - case 0: - result = financialStatementMovement.getLabel(); - break; - } - } - return result; - } - - @Override - public boolean isCellEditable(Object node, int column) { - return false; - } - - @Override - public boolean isLeaf(Object node) { - return getChildCount(node) == 0; - } - - /** - * Add FinancialStatementHeader (path can be null). - * - * @param path - * @param account - * @throws LimaException - */ - public void addFinancialStatementHeader(TreePath path, FinancialStatementHeader financialStatementHeader) throws LimaException { - // Calling account service - FinancialStatementHeader parentFinancialStatementHeader = - (FinancialStatementHeader) path.getLastPathComponent(); - if (parentFinancialStatementHeader == getRoot()) { - parentFinancialStatementHeader = null; - } - financialStatementService.createFinancialStatementHeader( - parentFinancialStatementHeader, financialStatementHeader); - modelSupport.fireTreeStructureChanged(path.getParentPath()); - } - - /** - * Add FinancialStatementMovement (path can't be null). - * - * @param path - * @param account - * @throws LimaException - */ - public void addFinancialStatementMovement(TreePath path, FinancialStatementMovement financialStatementMovement) throws LimaException { - // Calling account service - FinancialStatementHeader parentFinancialStatementHeader = - (FinancialStatementHeader) path.getLastPathComponent(); - if (parentFinancialStatementHeader != getRoot()) { - financialStatementService.createFinancialStatementMovement(parentFinancialStatementHeader, financialStatementMovement); - modelSupport.fireTreeStructureChanged(path); - } - } - - /** - * Update financialStatementHeader. - * - * @param path - * @param account - * @throws LimaException - */ - public void updateFinancialStatement(TreePath path, Object object) throws LimaException { - - int index = getIndexOfChild( - path.getParentPath().getLastPathComponent(), object); - if (object instanceof FinancialStatementHeader){ - financialStatementService.updateFinancialStatementHeader((FinancialStatementHeader) object); - } - else { - financialStatementService.updateFinancialStatementMovement((FinancialStatementMovement) object); - } - modelSupport.fireTreeStructureChanged(path); - } - - - - /** - * Remove financialStatementHeader or financialStatementMovement - * - * @param path - * @param object - * @throws LimaException - */ - public void removeFinancialStatementObject(TreePath path, Object object) throws LimaException { - // Calling account service - int index = getIndexOfChild( - path.getParentPath().getLastPathComponent(), object); - if (object instanceof FinancialStatementHeader){ - financialStatementService.removeFinancialStatementHeader((FinancialStatementHeader) object); - } - else { - financialStatementService.removeFinancialStatementMovement((FinancialStatementMovement) object); - } - - modelSupport.fireChildRemoved(path.getParentPath(), index, object); - } - -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/FinancialStatementView.jaxx 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementView.jaxx 2010-06-15 17:35:55 UTC (rev 2940) @@ -1,67 +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. - ##% --> - -<Table> - - <FinancialStatementViewHandler id="handler" javaBean="new FinancialStatementViewHandler(this)" /> - <Boolean id="selectedRow" javaBean="false" /> - - <script> - <![CDATA[ - //getHandler().init(); - ]]> - </script> - - <row> - <cell fill="both" weightx="1" weighty="1" rows='4'> - <JScrollPane> - <org.jdesktop.swingx.JXTreeTable id="treeTable" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" - treeTableModel="{new org.chorem.lima.ui.financialstatement.FinancialStatementTreeTableModel()}" - highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" /> - <javax.swing.ListSelectionModel - javaBean="getTreeTable().getSelectionModel()" - onValueChanged="setSelectedRow(treeTable.getSelectedRow() != -1)"/> - </JScrollPane> - </cell> - <cell fill="horizontal"> - <JButton id="addFinancialStatementHeader" text="lima.add.financialstatementheader" - onActionPerformed="getHandler().addFinancialStatementHeader()"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JButton id="addFinancialStatementMovement" text="lima.add.financialstatementmovement" - onActionPerformed="getHandler().addFinancialStatementMovement()" - enabled="{isSelectedRow()}"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JButton id="updateButton" text="lima.common.update" - onActionPerformed="getHandler().updateFinancialStatement()" - enabled="{isSelectedRow()}"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JButton id="removeButton" text="lima.common.remove" - onActionPerformed="getHandler().removeFinancialStatement()" - enabled="{isSelectedRow()}"/> - </cell> - </row> -</Table> \ No newline at end of file Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatement/FinancialStatementViewHandler.java 2010-06-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementViewHandler.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -1,237 +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. - * ##%*/ - -package org.chorem.lima.ui.financialstatement; - -import static org.nuiton.i18n.I18n._; -import javax.swing.JOptionPane; -import javax.swing.tree.TreePath; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaBusinessException; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.entity.FinancialStatementHeader; -import org.chorem.lima.entity.FinancialStatementHeaderImpl; -import org.chorem.lima.entity.FinancialStatementMovement; -import org.chorem.lima.entity.FinancialStatementMovementImpl; -import org.chorem.lima.util.DialogHelper; -import org.chorem.lima.util.ErrorHelper; -import org.jdesktop.swingx.JXTreeTable; - -/** - * Handler associated with account view. - * - * @author chatellier - * @version $Revision: 2934 $ - * - * Last update : $Date: 2010-06-08 11:55:04 +0200 (mar., 08 juin 2010) $ - * By : $Author: jpepin $ - */ -public class FinancialStatementViewHandler { - - /** log. */ - private static final Log log = LogFactory.getLog(FinancialStatementViewHandler.class); - - protected FinancialStatementView view; - - protected JXTreeTable treeTable; - - protected FinancialStatementTreeTableModel treeTableModel; - - protected FinancialStatementViewHandler(FinancialStatementView view) { - this.view = view; - } - - /** - * Add new account with account form. - */ - public void addFinancialStatementHeader() { - treeTable = view.getTreeTable(); - treeTableModel = - (FinancialStatementTreeTableModel) treeTable.getTreeTableModel(); - - FinancialStatementHeader newFinancialStatementHeader = new FinancialStatementHeaderImpl(); - FinancialStatementHeaderForm financialStatementHeaderForm = new FinancialStatementHeaderForm(view); - financialStatementHeaderForm.setHeader(newFinancialStatementHeader); - // jaxx constructor don't call super() ? - financialStatementHeaderForm.setLocationRelativeTo(view); - financialStatementHeaderForm.setVisible(true); - - // null == cancel action - newFinancialStatementHeader = financialStatementHeaderForm.getHeader(); - if (newFinancialStatementHeader != null) { - // get current selection path - TreePath treePath = null; - int selectedRow = treeTable.getSelectedRow(); - if ( selectedRow != -1) { - treePath = treeTable.getPathForRow(selectedRow); - } else { - treePath = new TreePath(treeTableModel.getRoot()); - } - - // add it - try { - treeTableModel.addFinancialStatementHeader(treePath, newFinancialStatementHeader); - } catch (LimaBusinessException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add financialStatementHeader", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - - } - - catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't add financialStatementHeader", ex); - } - ErrorHelper.showErrorDialog("Can't add financialStatementHeader", ex); - } - } - }; - - public void addFinancialStatementMovement(){ - - treeTable = view.getTreeTable(); - treeTableModel = - (FinancialStatementTreeTableModel) treeTable.getTreeTableModel(); - - FinancialStatementMovement newFinancialStatementMovement = new FinancialStatementMovementImpl(); - FinancialStatementMovementForm financialStatementMovementForm = new FinancialStatementMovementForm(view); - financialStatementMovementForm.setMovement(newFinancialStatementMovement); - // jaxx constructor don't call super() ? - financialStatementMovementForm.setLocationRelativeTo(view); - financialStatementMovementForm.setVisible(true); - newFinancialStatementMovement=financialStatementMovementForm.getMovement(); - - // null == cancel action - if (newFinancialStatementMovement != null) { - // get current selection path - TreePath treePath = null; - int selectedRow = view.treeTable.getSelectedRow(); - treePath = view.treeTable.getPathForRow(selectedRow); - // add it - try { - treeTableModel. - addFinancialStatementMovement(treePath, newFinancialStatementMovement); - } catch (LimaBusinessException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add FinancialStatementMovement", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - - catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add FinancialStatementMovement", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - } - - /** - * Open account form with selected account. - * Verifiy if it's an account or a subledger - */ - public void updateFinancialStatement() { - - treeTable = view.getTreeTable(); - treeTableModel = - (FinancialStatementTreeTableModel) treeTable.getTreeTableModel(); - - // get selected account - int selectedRow = view.treeTable.getSelectedRow(); - TreePath treePath = view.treeTable.getPathForRow(selectedRow); // not null - Object selectedObject = treePath.getLastPathComponent(); - //update Account or update SubLedger - if (selectedObject != null) { - // get current selection path - if ( selectedRow != -1) { - treePath = view.treeTable.getPathForRow(selectedRow); - } else { - treePath = new TreePath(treeTableModel.getRoot()); - } - //test if selectedrow is account or ledger - if (selectedObject instanceof FinancialStatementHeader){ - FinancialStatementHeaderForm financialStatementHeaderForm = new FinancialStatementHeaderForm(view); - financialStatementHeaderForm.setHeader((FinancialStatementHeader) selectedObject); - // jaxx constructor don't call super() ? - financialStatementHeaderForm.setLocationRelativeTo(view); - financialStatementHeaderForm.setVisible(true); - // null == cancel action - selectedObject = financialStatementHeaderForm.getHeader(); - } - // else is a subledger - else{ - FinancialStatementMovementForm financialStatementMovementForm = new FinancialStatementMovementForm(view); - financialStatementMovementForm.setMovement((FinancialStatementMovement) selectedObject); - // jaxx constructor don't call super() ? - financialStatementMovementForm.setLocationRelativeTo(view); - financialStatementMovementForm.setVisible(true); - // null == cancel action - selectedObject = financialStatementMovementForm.getMovement(); - } - //if action confirmed - if (selectedObject != null){ - // update it - try { - treeTableModel.updateFinancialStatement(treePath, selectedObject); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add update", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - } - } - - /** - * Ask for user to remove for selected account, and remove it if confirmed. - */ - public void removeFinancialStatement() { - treeTable = view.getTreeTable(); - treeTableModel = - (FinancialStatementTreeTableModel) treeTable.getTreeTableModel(); - - // Any row selected - int selectedRow = view.treeTable.getSelectedRow(); - if ( selectedRow != -1) { - int n = JOptionPane.showConfirmDialog(view, - _("lima.question.remove.account"), - _("lima.question"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (n == JOptionPane.YES_OPTION) { - // update view of treetable - TreePath treePath = view.treeTable.getPathForRow(selectedRow); - Object object = treePath.getLastPathComponent(); - - try{ - treeTableModel.removeFinancialStatementObject(treePath, object); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't delete account", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - } - }; - -} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -0,0 +1,205 @@ +/* + * *##% 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.financialstatementreport; + +import static org.nuiton.i18n.I18n._; + +import java.util.ArrayList; +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.FinancialStatementAmounts; +import org.chorem.lima.beans.ReportsDatas; +import org.chorem.lima.business.FinancialStatementService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ReportService; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.FinancialStatementHeader; +import org.chorem.lima.entity.FinancialStatementMovement; +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 FinancialStatementReportTableModel extends AbstractTableModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 7578692417919755647L; + + /** log. */ + private static final Log log = LogFactory.getLog(FinancialStatementReportTableModel.class); + + /** Services. */ + protected FinancialStatementService financialStatementService; + + /** DatePicker Begin Date. */ + protected Date selectedBeginDate; + + /** DatePicker EndDate. */ + protected Date selectedEndDate; + + /** Text field Accounts */ + protected String selectedAccounts; + + /** data cache */ + protected List<Object> cacheDataList; + + /** + * Constructor. + */ + public FinancialStatementReportTableModel() { + financialStatementService = LimaServiceFactory.getInstance().getFinancialStatementService(); + } + + @Override + public int getRowCount() { + int result = 0; + if (cacheDataList != null){ + result = cacheDataList.size(); + } + return result; + } + + @Override + public int getColumnCount() { + return 4; + } + + @Override + public String getColumnName(int column) { + String res = "n/a"; + switch (column) { + case 0: + res = _("lima.table.label"); + break; + case 1: + res = _("lima.table.grossamount"); + break; + case 2: + res = _("lima.table.provisiondeprecationamount"); + break; + case 3: + res = _("lima.table.netamount"); + break; + } + return res; + } + + @Override + public Object getValueAt(int row, int column) { + Object result = cacheDataList.get(row); + //get entries for the period for the current row + if (result instanceof FinancialStatementHeader) { + FinancialStatementHeader currentRow = (FinancialStatementHeader) result; + switch (column) { + case 0: + result = currentRow.getLabel(); + break; + case 1: + result = null; + break; + case 2: + result = null; + break; + case 3: + result = null; + break; + } + } + else { + FinancialStatementAmounts currentRow = (FinancialStatementAmounts) result; + Double grossAmount = currentRow.getGrossAmount(); + Double provisionDeprecationAmount = currentRow.getProvisionDeprecationAmount(); + switch (column) { + case 0: + result = currentRow.getLabel(); + break; + case 1: + result = grossAmount; + break; + case 2: + result = provisionDeprecationAmount; + break; + case 3: + result = grossAmount-provisionDeprecationAmount; + break; + } + } + + return result; + } + + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + // Just read, no write + return false; + } + + public void setBeginDate(Date date){ + selectedBeginDate = date; + } + + public void setEndDate(Date date){ + selectedEndDate = date; + } + + public void setAccountFilter(String accounts) { + selectedAccounts = accounts; + } + + /** + * get all account fot the selected period + * @return + */ + public List<Object> getDataList(){ + List<Object> results = null; + + try { + //results = financialStatementService.getAllChildrenFinancialStatement(null, new ArrayList<Object>()); + results = financialStatementService.financialStatementReports(selectedBeginDate, selectedEndDate); + //results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, selectedAccounts, false); + } + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.debug("Can't update model", eee); + } + ErrorHelper.showErrorDialog("Can't get entries list", eee); + } + return results; + } + + public void refresh(){ + cacheDataList = getDataList(); + fireTableDataChanged(); + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java ___________________________________________________________________ Added: svn:executable + * Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2010-06-15 17:35:55 UTC (rev 2940) @@ -0,0 +1,112 @@ +<!-- ##% 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> + <FinancialStatementReportViewHandler id="handler" javaBean="new FinancialStatementReportViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + <org.chorem.lima.ui.financialstatementreport.FinancialStatementReportTableModel id="modelTable"/> + <script> + <![CDATA[ + + import org.chorem.lima.entity.Account; + 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); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + + getBeginDatePicker().setDate(beginDate); + getEndDatePicker().setDate(endDate); + getModelTable().setBeginDate(beginDate); + getModelTable().setEndDate(endDate); + + void $afterCompleteSetup() { + getHandler().refresh(); + } + + + ]]> + </script> + <row weightx="1" weighty="0" anchor="center"> + <cell anchor="west"> + <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/> + </cell> + <cell anchor="east"> + <JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/> + </cell> + <cell anchor="west"> + <org.jdesktop.swingx.JXDatePicker id="beginDatePicker" + onActionPerformed="getModelTable().setBeginDate(beginDatePicker.getDate()); + getHandler().refresh()" /> + </cell> + <cell anchor="east"> + <JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/> + </cell> + <cell anchor="west"> + <org.jdesktop.swingx.JXDatePicker id="endDatePicker" + onActionPerformed="getModelTable().setEndDate(endDatePicker.getDate()); + getHandler().refresh()"/> + </cell> + <cell anchor="east"> + <JTextField id="accountFilter"/> + </cell> + <cell anchor="west"> + <JButton text="lima.accountsreports.accountfilter" + onActionPerformed="getModelTable().setAccountFilter(accountFilter.getText()); + getHandler().refresh()"/> + </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 Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx ___________________________________________________________________ Added: svn:executable + * Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2010-06-15 17:35:55 UTC (rev 2940) @@ -0,0 +1,90 @@ +/* *##% 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.financialstatementreport; + +import static org.nuiton.i18n.I18n._; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.beans.BalanceTrial; +import org.chorem.lima.business.FinancialTransactionService; +import org.chorem.lima.service.LimaServiceFactory; + + +/** + * 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 FinancialStatementReportViewHandler { + + /** log. */ + private static final Log log = + LogFactory.getLog(FinancialStatementReportViewHandler.class); + + protected FinancialStatementReportView view; + + /** service **/ + protected FinancialTransactionService financialTransactionService; + + protected FinancialStatementReportTableModel model; + + protected FinancialStatementReportViewHandler(FinancialStatementReportView view) { + this.view = view; + financialTransactionService = + LimaServiceFactory.getInstance().getTransactionService(); + } + + public void refresh(){ + model = view.getModelTable(); + model.refresh(); + + /** + * update the labels credit, debit, solde on the footer + * get all entries for all accounts on the selected period + * + BalanceTrial cacheDataList = model.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")); + } + } + }*/ + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java ___________________________________________________________________ Added: svn:executable + * 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-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-15 17:35:55 UTC (rev 2940) @@ -168,8 +168,12 @@ lima.financialstatement.accounts= lima.financialstatement.creditaccounts= lima.financialstatement.debitaccounts= +lima.financialstatement.header.add= lima.financialstatement.label= +lima.financialstatement.movement.add= lima.financialstatement.provisiondeprecationaccounts= +lima.financialstatement.style= +lima.financialstatementreports= lima.find.transaction=Find transaction lima.fiscalperiod.addFiscalPeriod= lima.fiscalperiod.block= @@ -302,6 +306,7 @@ lima.reports.accounts=Edit account lima.reports.balance=Balance lima.reports.entrybooks=Edit entrybook +lima.reports.financialstatement= lima.reports.ledger=Ledger lima.response.no=No lima.response.yes=Yes @@ -344,6 +349,10 @@ lima.tab.search.result=Search result lima.tab.subledgers= lima.tab.transaction=Transaction +lima.table.grossamount= +lima.table.label= +lima.table.netamount= +lima.table.provisiondeprecationamount= lima.title=Lutin Invoice Monitoring and Accounting lima.title.about=About Lima... lima.to=To 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-09 17:27:20 UTC (rev 2939) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-06-15 17:35:55 UTC (rev 2940) @@ -34,8 +34,7 @@ lima.action.normalscreen=Ecran normal lima.action.normalscreen.tip=Revenir en \u00E9cran normal lima.add.entry=Ajouter entr\u00E9e -lima.add.financialstatementheader= -lima.add.financialstatementmovement= +lima.add.financialstatement.movement.add=Mouvement lima.add.lettering= lima.add.transaction=Ajouter transaction lima.all=Tous @@ -167,8 +166,12 @@ lima.financialstatement.accounts= lima.financialstatement.creditaccounts= lima.financialstatement.debitaccounts= +lima.financialstatement.header.add=Regrouprement lima.financialstatement.label= +lima.financialstatement.movement.add= lima.financialstatement.provisiondeprecationaccounts= +lima.financialstatement.style= +lima.financialstatementreports= lima.find.transaction=Rechercher transaction lima.fiscalperiod.addFiscalPeriod=Nouvel exercice lima.fiscalperiod.block=Cloturer un exercice @@ -287,6 +290,7 @@ lima.reports.accounts=Edition compte lima.reports.balance=Balance lima.reports.entrybooks=Edition journal +lima.reports.financialstatement= lima.reports.ledger=Grand Livre lima.response.no=Non lima.response.yes=Oui @@ -318,6 +322,10 @@ lima.tab.home=Accueil lima.tab.reports= lima.tab.result= +lima.table.grossamount= +lima.table.label= +lima.table.netamount= +lima.table.provisiondeprecationamount= lima.title=Lutin Invoice Monitoring and Accounting lima.title.about=A propos de Lima... lima.to=A
participants (1)
-
jpepin@users.chorem.org