Author: echatellier Date: 2010-11-29 15:57:16 +0100 (Mon, 29 Nov 2010) New Revision: 3051 Url: http://chorem.org/repositories/revision/lima/3051 Log: Replace tab character Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceListener.java trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ExportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.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/EntryBooksReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -166,7 +166,7 @@ @Override public void setFinal(boolean finalBoolean){ - this.finalBoolean=finalBoolean; + this.finalBoolean=finalBoolean; } @Override Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceListener.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceListener.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceListener.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,6 +27,6 @@ public interface ServiceListener { - void notifyMethod(String serviceName, String methodeName); + void notifyMethod(String serviceName, String methodeName); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -26,6 +26,6 @@ package org.chorem.lima.business; public interface ServiceMonitorable { - void addListener(ServiceListener l); - void removeListener(ServiceListener l); + void addListener(ServiceListener l); + void removeListener(ServiceListener l); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -137,12 +137,12 @@ /** * Check if entrybook have financial transaction */ - @Override + @Override public void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException { try { - FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); + FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); // Check if entrybook have entries - int nbfinancialtransaction = financialTransactionDAO.findAllByEntryBook(entryBook).size(); + int nbfinancialtransaction = financialTransactionDAO.findAllByEntryBook(entryBook).size(); if (nbfinancialtransaction != 0) { throw new LimaBusinessException("Can't delete entryBook with financialtransaction"); } @@ -159,7 +159,7 @@ */ @Override public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException { - //check financial period locked + //check financial period locked if (financialTransaction.getFinancialPeriod().getLocked()){ throw new LimaBusinessException("The financial period is blocked"); } @@ -202,25 +202,25 @@ throws LimaException { List<FinancialTransaction> result = null; - try { + try { FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); TopiaQuery query = financialTransactionDAO.createQuery("E"); query.addWhere("E.amountCredit != E.amountDebit") .addEquals(FinancialTransaction.ENTRY_BOOK, - closedPeriodicEntryBook.getEntryBook()) + closedPeriodicEntryBook.getEntryBook()) .addEquals(FinancialTransaction.FINANCIAL_PERIOD, - closedPeriodicEntryBook.getFinancialPeriod()); + closedPeriodicEntryBook.getFinancialPeriod()); result = financialTransactionDAO.findAllByQuery(query); if (result.size()>0){ throw new LimaBusinessException("Can't block financialperiod/entrybook contain financialtransaction not equilibrate"); } - } + } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } + } } /** @@ -279,9 +279,9 @@ public void updateFinancialTransactionDateRules( FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld, TopiaContext topiaContext) throws LimaException { - FinancialPeriod financialPeriod = financialTransaction.getFinancialPeriod(); - FinancialPeriod financialPeriodOld = financialTransactionOld.getFinancialPeriod(); - + FinancialPeriod financialPeriod = financialTransaction.getFinancialPeriod(); + FinancialPeriod financialPeriodOld = financialTransactionOld.getFinancialPeriod(); + //1. check old financial period locked if (financialPeriodOld.getLocked()){ throw new LimaBusinessException("The financial period of this transaction is blocked"); @@ -300,7 +300,7 @@ //3. the actual entrybook belong to a blocked closedPeriodicEntryBook ClosedPeriodicEntryBook closedPeriodicEntryBookOld = closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod( - financialTransactionOld.getEntryBook(), financialPeriod); + financialTransactionOld.getEntryBook(), financialPeriod); if (closedPeriodicEntryBookOld.getLocked()){ throw new LimaBusinessException("Can't update financialtransaction : financialperiod of this entrybook is closed"); } @@ -316,7 +316,7 @@ //5. the actual entrybook belong to a blocked closedPeriodicEntryBook ClosedPeriodicEntryBook closedPeriodicEntryBookOld2 = closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod( - financialTransactionOld.getEntryBook(), financialPeriodOld); + financialTransactionOld.getEntryBook(), financialPeriodOld); if (closedPeriodicEntryBookOld2.getLocked()){ throw new LimaBusinessException("Can't update financialtransaction : the new financialperiod of this entrybook is closed"); } @@ -328,13 +328,13 @@ if (closedPeriodicEntryBook2.getLocked()){ throw new LimaBusinessException("Can't update financialtransaction : this financialperiod of new entrybook is closed"); } - + //7. check if date are on fiscal period FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext); - //search fiscalperiod have financialperiod in params + //search fiscalperiod have financialperiod in params TopiaQuery query = fiscalPeriodDAO.createQuery() .addInElements(":financialPeriod", "financialPeriod") .addParam("financialPeriod", financialPeriod); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -114,9 +114,9 @@ /** * Rules to check before create subledger */ - public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException { - super.createSubLedgerRules(masterAccount, account); - + public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException { + super.createSubLedgerRules(masterAccount, account); + // check if the master account number is begin with 4 if (!masterAccount.getAccountNumber().startsWith("4")){ throw new LimaBusinessException( @@ -161,7 +161,7 @@ //check the new fiscal period adjoining the last Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate(); dateLastFiscalPeriod = DateUtils. - addDays(dateLastFiscalPeriod, 1); + addDays(dateLastFiscalPeriod, 1); dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE); Date dateFiscalPeriod=fiscalPeriod.getBeginDate(); if(dateLastFiscalPeriod.compareTo(dateFiscalPeriod)!=0){ @@ -214,7 +214,7 @@ * Règles de vérification de fermeture d'un exercice, appliquées à la comptabilité française */ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException { - try{ + try{ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); @@ -250,23 +250,23 @@ */ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaTransaction) throws LimaException { super.blockClosedPeriodicEntryBookRules( - closedPeriodicEntryBook, topiaTransaction); + closedPeriodicEntryBook, topiaTransaction); FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod(); List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = - new ArrayList<ClosedPeriodicEntryBook>(); + new ArrayList<ClosedPeriodicEntryBook>(); try { - + // Get all closedperiod between for the period and entrybook Date endDate = closedPeriodicEntryBook. getFinancialPeriod().getBeginDate(); endDate = DateUtils.addMonths(endDate, -1); FiscalPeriodDAO fiscalPeriodDAO = - LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaTransaction); + LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaTransaction); - //search fiscalperiod have financialperiod in params + //search fiscalperiod have financialperiod in params TopiaQuery query1 = fiscalPeriodDAO.createQuery() .addInElements(":financialPeriod", "financialPeriod") .addParam("financialPeriod", financialPeriod); 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -79,44 +79,44 @@ } - @Override - public void createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException { + @Override + public void createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException { - try { - // check if account number already exist - AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(topiaContext); - - Account existAccount = - accountDAO.findByAccountNumber(account.getAccountNumber()); - if (existAccount != null) { - throw new LimaBusinessException(_( - "lima-business.account.accountalreardyexist", - account.getAccountNumber())); - } - - //create it - accountDAO.create(account); - - Account masterAccountUpdate = null; - if (masterAccount != null){ - masterAccountUpdate = accountDAO.findByAccountNumber(masterAccount.getAccountNumber()); - } - - // check if parent account exist; - if (masterAccountUpdate != null) { - masterAccountUpdate.addSubAccounts(account); - accountDAO.update(masterAccountUpdate); - } - - commitTransaction(topiaContext); - } - catch (TopiaException ex) { - doCatch(topiaContext, ex, log); - } - } + try { + // check if account number already exist + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(topiaContext); + Account existAccount = + accountDAO.findByAccountNumber(account.getAccountNumber()); + if (existAccount != null) { + throw new LimaBusinessException(_( + "lima-business.account.accountalreardyexist", + account.getAccountNumber())); + } + //create it + accountDAO.create(account); + + Account masterAccountUpdate = null; + if (masterAccount != null){ + masterAccountUpdate = accountDAO.findByAccountNumber(masterAccount.getAccountNumber()); + } + + // check if parent account exist; + if (masterAccountUpdate != null) { + masterAccountUpdate.addSubAccounts(account); + accountDAO.update(masterAccountUpdate); + } + + commitTransaction(topiaContext); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + } + + /** * Permet de créer un nouveau compte dans le PCG de l'application. * ATTENTION : le compte masterAccount, c'est à dire le compte père, doit @@ -128,7 +128,7 @@ */ @Override public void createAccount(Account masterAccount, Account account) throws LimaException { - + //check rules before create the account accountingRules.createAccountRules(masterAccount, account); @@ -148,15 +148,15 @@ } - @Override - public void createSubLedgerWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException { + @Override + public void createSubLedgerWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException { - try { - // check if the accountnumber already exist + try { + // check if the accountnumber already exist AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(topiaContext); + LimaCallaoDAOHelper.getAccountDAO(topiaContext); Account existAccount = - accountDAO.findByAccountNumber(account.getAccountNumber()); + accountDAO.findByAccountNumber(account.getAccountNumber()); if (existAccount != null) { throw new LimaBusinessException(_( "lima-business.account.accountalreardyexist", @@ -168,12 +168,12 @@ Account masterAccountUpdate = null; if (masterAccount != null){ - masterAccountUpdate = accountDAO.findByAccountNumber(masterAccount.getAccountNumber()); + masterAccountUpdate = accountDAO.findByAccountNumber(masterAccount.getAccountNumber()); } // check if the masteraccount exist; if (masterAccount != null) { - masterAccountUpdate.addSubLedgers(account); + masterAccountUpdate.addSubLedgers(account); accountDAO.update(masterAccountUpdate); } @@ -182,18 +182,18 @@ catch (TopiaException ex) { doCatch(topiaContext, ex, log); } - } + } /** * Permet de créer des comptes tiers */ - @Override - public void createSubLedger(Account masterAccount, Account account) - throws LimaException { + @Override + public void createSubLedger(Account masterAccount, Account account) + throws LimaException { //check rules before create the account accountingRules.createSubLedgerRules(masterAccount, account); - + TopiaContext transaction = null; try { transaction = beginTransaction(); @@ -206,8 +206,8 @@ finally { doFinally(transaction, log); } - - } + + } /** @@ -223,7 +223,7 @@ transaction = beginTransaction(); AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(transaction); + LimaCallaoDAOHelper.getAccountDAO(transaction); accountsList = accountDAO.findAll(); Collections.sort(accountsList, new AccountComparator()); @@ -282,12 +282,12 @@ transaction = beginTransaction(); AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(transaction); + LimaCallaoDAOHelper.getAccountDAO(transaction); TopiaQuery query = accountDAO.createQuery(); if (masterAccount == null){ query.addEquals("masterAccount", masterAccount); - query.addWhere("generalLedger", TopiaQuery.Op.EQ, null); + query.addWhere("generalLedger", TopiaQuery.Op.EQ, null); } else { query.addWhere("masterAccount = :value or generalLedger = :value") @@ -342,23 +342,23 @@ accountingRules.removeAccountRules(account, transaction); // remove account - Account accountToDelete = accountDAO.findByTopiaId(account.getTopiaId()); + Account accountToDelete = accountDAO.findByTopiaId(account.getTopiaId()); //get all subaccounts List<Account> accounts = - getAllChildrenAccounts(accountToDelete, new ArrayList<Account>()); + getAllChildrenAccounts(accountToDelete, new ArrayList<Account>()); //if account have sub accounts if (accounts.size() > 0){ for (Account subAccount : accounts) { // Check rules for subaccount if have entries accountingRules.removeAccountRules(subAccount, transaction); - Account subAccountToDelete = - accountDAO.findByTopiaId(subAccount.getTopiaId()); - accountDAO.delete(subAccountToDelete); + Account subAccountToDelete = + accountDAO.findByTopiaId(subAccount.getTopiaId()); + accountDAO.delete(subAccountToDelete); } } - accountDAO.delete(accountToDelete); + accountDAO.delete(accountToDelete); //commit commitTransaction(transaction); } @@ -372,10 +372,10 @@ @Override public void removeAllAccount() throws LimaException{ - List<Account> accounts = getChildrenAccounts(null); - for (Account account : accounts) { - removeAccount(account); - } + List<Account> accounts = getChildrenAccounts(null); + for (Account account : accounts) { + removeAccount(account); + } } @@ -400,12 +400,12 @@ // DAO AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(transaction); + LimaCallaoDAOHelper.getAccountDAO(transaction); Account subAccount = accountDAO.findByTopiaId(account.getTopiaId()); //check rules account if ledger or account if (account.getGeneralLedger() == null){ - - //get masteraccount, search account have account in params in all subaccounts collection + + //get masteraccount, search account have account in params in all subaccounts collection TopiaQuery query = accountDAO.createQuery() .addInElements(":account", "subAccounts") .addParam("account", account); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -91,7 +91,7 @@ public class DocumentServiceImpl implements DocumentService, DocumentServiceLocal { private static final Log log = - LogFactory.getLog(DocumentServiceImpl.class); + LogFactory.getLog(DocumentServiceImpl.class); private TopiaContext rootContext; @@ -109,28 +109,28 @@ //SDFs private static SimpleDateFormat dateFormat = - new SimpleDateFormat("dd/MM/yyyy"); + new SimpleDateFormat("dd/MM/yyyy"); private static SimpleDateFormat hourFormat = - new SimpleDateFormat("HH:mm"); + new SimpleDateFormat("HH:mm"); private static SimpleDateFormat filedateFormat = - new SimpleDateFormat("dd-MM-yyyy_HH-mm"); + new SimpleDateFormat("dd-MM-yyyy_HH-mm"); private static SimpleDateFormat monthYearFormat = - new SimpleDateFormat("MMM yyyy"); + new SimpleDateFormat("MMM yyyy"); //FONTs private static Font titleFont = - new Font(Font.HELVETICA, 14, Font.BOLD, Color.BLACK); + new Font(Font.HELVETICA, 14, Font.BOLD, Color.BLACK); private static Font normalFont = - new Font(Font.HELVETICA, 9, Font.NORMAL, Color.BLACK); - private static Font boldFont = - new Font(Font.HELVETICA, 9, Font.BOLD, Color.BLACK); + new Font(Font.HELVETICA, 9, Font.NORMAL, Color.BLACK); + private static Font boldFont = + new Font(Font.HELVETICA, 9, Font.BOLD, Color.BLACK); private static Font italicFont = - new Font(Font.HELVETICA, 9, Font.ITALIC, Color.BLACK); + new Font(Font.HELVETICA, 9, Font.ITALIC, Color.BLACK); private static Font bolditalicFont = - new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK); + new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK); - + public DocumentServiceImpl() { LimaConfig config = LimaConfig.getInstance(); try { @@ -140,655 +140,655 @@ log.error("Can't init topia context", ex); } } - path = LimaConfig.getInstance().getReportsDir(); + path = LimaConfig.getInstance().getReportsDir(); } - public Paragraph createHeaderPage(String title, Identity identity, String beginDate, String endDate){ - Paragraph paragraphHeaderPage = new Paragraph(); - Table t = null; - try { - - //define table - t = new Table(4, 5); - t.setWidth(100f); - float[] widths = {0.25f, 0.45f, 0.12f, 0.18f}; - t.setWidths(widths); - t.setPadding(1.5f); + public Paragraph createHeaderPage(String title, Identity identity, String beginDate, String endDate){ + Paragraph paragraphHeaderPage = new Paragraph(); + Table t = null; + try { + + //define table + t = new Table(4, 5); + t.setWidth(100f); + float[] widths = {0.25f, 0.45f, 0.12f, 0.18f}; + t.setWidths(widths); + t.setPadding(1.5f); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.NO_BORDER); - t.setDefaultCell(cell); - - //line 1 - t.addCell(new Phrase(identity.getName(), bolditalicFont)); - Cell titleCell = new Cell(new Phrase(title, titleFont)); - titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); - titleCell.setHorizontalAlignment(Element.ALIGN_CENTER); - titleCell.setRowspan(2); - t.addCell(titleCell); - t.addCell(new Phrase(_("lima-business.document.businessnumber"), - bolditalicFont)); - t.addCell(new Phrase(identity.getBusinessNumber(), italicFont)); - //line 2 - t.addCell(new Phrase(identity.getDescription(), italicFont)); - t.addCell(new Phrase(_("lima-business.document.classificationcode"), - bolditalicFont)); - t.addCell(new Phrase(identity.getClassificationCode(), italicFont)); - //line 3 - t.addCell(new Phrase(identity.getAddress(), italicFont)); - t.addCell(""); - t.addCell(new Phrase(_("lima-business.document.vatnumber"), - bolditalicFont)); - t.addCell(new Phrase(identity.getVatNumber(), italicFont)); - //line 4 - t.addCell(new Phrase(identity.getAddress2(), italicFont)); - t.addCell(""); - t.addCell(new Phrase(_("lima-business.document.period1"), - bolditalicFont)); - t.addCell(new Phrase(beginDate, italicFont)); - //line 5 - t.addCell(new Phrase(identity.getZipCode() + " " + identity.getCity(), - italicFont)); - t.addCell(""); - t.addCell(new Phrase(_("lima-business.document.period2"), - bolditalicFont)); - t.addCell(new Phrase(endDate, italicFont)); - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - - paragraphHeaderPage.add(t); - return paragraphHeaderPage; - } + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.NO_BORDER); + t.setDefaultCell(cell); + + //line 1 + t.addCell(new Phrase(identity.getName(), bolditalicFont)); + Cell titleCell = new Cell(new Phrase(title, titleFont)); + titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); + titleCell.setHorizontalAlignment(Element.ALIGN_CENTER); + titleCell.setRowspan(2); + t.addCell(titleCell); + t.addCell(new Phrase(_("lima-business.document.businessnumber"), + bolditalicFont)); + t.addCell(new Phrase(identity.getBusinessNumber(), italicFont)); + //line 2 + t.addCell(new Phrase(identity.getDescription(), italicFont)); + t.addCell(new Phrase(_("lima-business.document.classificationcode"), + bolditalicFont)); + t.addCell(new Phrase(identity.getClassificationCode(), italicFont)); + //line 3 + t.addCell(new Phrase(identity.getAddress(), italicFont)); + t.addCell(""); + t.addCell(new Phrase(_("lima-business.document.vatnumber"), + bolditalicFont)); + t.addCell(new Phrase(identity.getVatNumber(), italicFont)); + //line 4 + t.addCell(new Phrase(identity.getAddress2(), italicFont)); + t.addCell(""); + t.addCell(new Phrase(_("lima-business.document.period1"), + bolditalicFont)); + t.addCell(new Phrase(beginDate, italicFont)); + //line 5 + t.addCell(new Phrase(identity.getZipCode() + " " + identity.getCity(), + italicFont)); + t.addCell(""); + t.addCell(new Phrase(_("lima-business.document.period2"), + bolditalicFont)); + t.addCell(new Phrase(endDate, italicFont)); + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + + paragraphHeaderPage.add(t); + return paragraphHeaderPage; + } - - public Paragraph createNumberPage (int nbPages, String dateS, String hourS) throws BadElementException{ - //n° page - Paragraph paragraphPage = new Paragraph(); - Table infos = new Table(2); - infos.setWidth(100f); - infos.setBorder(Rectangle.NO_BORDER); - infos.setOffset(2); - Cell c = new Cell(); - c.setBorder(Rectangle.NO_BORDER); - c.setHorizontalAlignment(Element.ALIGN_CENTER); - infos.setDefaultCell(c); - infos.addCell(new Phrase(_("lima-business.document.createdate1") - + dateS + _("lima-business.document.createdate2") - + hourS, normalFont)); - infos.addCell(new Phrase(_("lima-business.document.pagenumber") - + nbPages, normalFont)); - paragraphPage.add(infos); - return paragraphPage; - } - + + public Paragraph createNumberPage (int nbPages, String dateS, String hourS) throws BadElementException{ + //n° page + Paragraph paragraphPage = new Paragraph(); + Table infos = new Table(2); + infos.setWidth(100f); + infos.setBorder(Rectangle.NO_BORDER); + infos.setOffset(2); + Cell c = new Cell(); + c.setBorder(Rectangle.NO_BORDER); + c.setHorizontalAlignment(Element.ALIGN_CENTER); + infos.setDefaultCell(c); + infos.addCell(new Phrase(_("lima-business.document.createdate1") + + dateS + _("lima-business.document.createdate2") + + hourS, normalFont)); + infos.addCell(new Phrase(_("lima-business.document.pagenumber") + + nbPages, normalFont)); + paragraphPage.add(infos); + return paragraphPage; + } + //############## FinancialStatements ############## @Override public void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { - Document document = new Document(PageSize.A4, 8, 8, 8, 8); - - List<FinancialStatementAmounts> financialStatementAmounts = - financialStatementService.financialStatementReport(beginDate, endDate); - - try { - Date newDate = new Date(); - String dateS = dateFormat.format(newDate); - String hourS = hourFormat.format(newDate); - - String filePath = path+File.separator+DocumentsEnum.FINANCIALSTATEMENT.getFileName(); - FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); - switch (format) { - case HTML: - HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); - break; - case PDF: - PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); - break; - } - document.open(); - int nbpages = 1; - - Identity identity = identityService.getIdentity(); - - //Split list by financialstatement type - List<List<FinancialStatementAmounts>> listList = - new ArrayList<List<FinancialStatementAmounts>>(); - Boolean first = true; - int min=0; - int size = financialStatementAmounts.size(); - for (int i=0;i<size;i++) { - FinancialStatementAmounts fStatementAmounts = - financialStatementAmounts.get(i); - if (fStatementAmounts.getLevel() == 1 && !fStatementAmounts.getSubAmount()){ - if (first){ - first=false; - } - else{ - listList.add(financialStatementAmounts.subList(min, i-1)); - } - min=i; - } - } - listList.add(financialStatementAmounts.subList(min, size)); - - //create pages - for (List<FinancialStatementAmounts> list : listList) { - String title = list.get(0).getLabel(); - int i = 0; - int n = list.size(); - int max = n; - // alloc nb rows max for pdf documents on one page - if (format == FormatsEnum.PDF){ - max = 35; - } - while (i < n){ - int j = i + max; - if (j > n){ - j = n; - } - List <FinancialStatementAmounts> subFinancialStatementAmounts = - list.subList(i, j); - //create page : header + table + footer - Table headerTable = createFinancialStatementsHeaderTable(); - Table table = createFinancialStatementsTable( - subFinancialStatementAmounts); - //new page - Chapter chapter = new Chapter(0); - //headerPage - chapter.add(createHeaderPage(title, identity, - dateFormat.format(beginDate), dateFormat.format(endDate))); - //n° page - chapter.add(createNumberPage(nbpages, dateS, hourS)); - //headerTable - Paragraph paragraphHeaderTable = new Paragraph(); - paragraphHeaderTable.add(headerTable); - chapter.add(paragraphHeaderTable); - //table - Paragraph paragraphTable = new Paragraph(); - paragraphTable.add(table); - chapter.add(paragraphTable); - //add page - document.add(chapter); - i = i + max; - nbpages++; - } - } - - document.close(); - - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } - } - - public Table createFinancialStatementsHeaderTable(){ - Table t = null; - try { - t = new Table(4,1); - float[] widths = {0.4f, 0.2f, 0.2f, 0.2f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3f); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - t.setDefaultCell(cell); - t.setOffset(8); - t.addCell(new Phrase(_("lima-business.document.label"), - boldFont)); - t.addCell(new Phrase(_("lima-business.document.grossamount"), - boldFont)); - t.addCell(new Phrase(_("lima-business.document.provisiondeprecationamount"), - boldFont)); - t.addCell(new Phrase(_("lima-business.document.netamount"), - boldFont)); - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - - } - - public Table createFinancialStatementsTable(List<FinancialStatementAmounts> financialStatementAmounts){ - int nbrow = financialStatementAmounts.size(); - Table t = null; - try { - //define table - t = new Table(4,nbrow); - t.setWidth(100f); - float[] widths = {0.4f, 0.2f, 0.2f, 0.2f}; - t.setWidths(widths); - t.setPadding(1.5f); - t.setBorderWidth(1); - t.setOffset(0); - //define default cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); - - for (FinancialStatementAmounts financialStatementAmount : financialStatementAmounts) { - - String label = financialStatementAmount.getLabel(); - int level = financialStatementAmount.getLevel(); - BigDecimal grossAmount = - financialStatementAmount.getGrossAmount(); - if (grossAmount == null){ - grossAmount = new BigDecimal(0); - } - BigDecimal provisionDeprecationAmount = - financialStatementAmount.getProvisionDeprecationAmount(); - if (provisionDeprecationAmount == null){ - provisionDeprecationAmount = new BigDecimal(0); - } - - if (financialStatementAmount.getSubAmount() && level==1){ - cell.setGrayFill(0.88f); - } - else if (financialStatementAmount.getSubAmount()){ - cell.setGrayFill(0.94f); - } - else { - cell.setGrayFill(1f); - } - if (label == null){ - t.addCell(""); - t.addCell(""); - t.addCell(""); - t.addCell(""); - } - else { - //cell1 - StringBuffer tab = new StringBuffer(); - for (int i = 0; i < level; i++) { - tab.append("\t"); - } - Phrase phrase = null; - if (financialStatementAmount.getHeader()){ - phrase = new Phrase(tab+label, boldFont); - } - else { - phrase = new Phrase(tab+label, normalFont); - } - Cell c = new Cell(phrase); - c.setHorizontalAlignment(Element.ALIGN_LEFT); - t.addCell(c); - //cell2 - if (grossAmount.doubleValue() != 0){ - phrase = new Phrase(String.valueOf( - grossAmount), normalFont); - } - else { - phrase = new Phrase(""); - } - t.addCell(phrase); - //cell 3 - if (provisionDeprecationAmount.doubleValue() != 0){ - phrase = new Phrase(String.valueOf( - provisionDeprecationAmount), normalFont); - } - else { - phrase = new Phrase(""); - } - t.addCell(phrase); - //cell 4 - BigDecimal solde = grossAmount; - solde = solde.subtract(provisionDeprecationAmount); - if (solde.doubleValue() != 0){ - phrase = new Phrase(solde.toString(), normalFont); - } - else { - phrase = new Phrase(""); - } - t.addCell(phrase); - } - } - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - } - - - + Document document = new Document(PageSize.A4, 8, 8, 8, 8); + + List<FinancialStatementAmounts> financialStatementAmounts = + financialStatementService.financialStatementReport(beginDate, endDate); + + try { + Date newDate = new Date(); + String dateS = dateFormat.format(newDate); + String hourS = hourFormat.format(newDate); + + String filePath = path+File.separator+DocumentsEnum.FINANCIALSTATEMENT.getFileName(); + FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); + switch (format) { + case HTML: + HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); + break; + case PDF: + PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); + break; + } + document.open(); + int nbpages = 1; + + Identity identity = identityService.getIdentity(); + + //Split list by financialstatement type + List<List<FinancialStatementAmounts>> listList = + new ArrayList<List<FinancialStatementAmounts>>(); + Boolean first = true; + int min=0; + int size = financialStatementAmounts.size(); + for (int i=0;i<size;i++) { + FinancialStatementAmounts fStatementAmounts = + financialStatementAmounts.get(i); + if (fStatementAmounts.getLevel() == 1 && !fStatementAmounts.getSubAmount()){ + if (first){ + first=false; + } + else{ + listList.add(financialStatementAmounts.subList(min, i-1)); + } + min=i; + } + } + listList.add(financialStatementAmounts.subList(min, size)); + + //create pages + for (List<FinancialStatementAmounts> list : listList) { + String title = list.get(0).getLabel(); + int i = 0; + int n = list.size(); + int max = n; + // alloc nb rows max for pdf documents on one page + if (format == FormatsEnum.PDF){ + max = 35; + } + while (i < n){ + int j = i + max; + if (j > n){ + j = n; + } + List <FinancialStatementAmounts> subFinancialStatementAmounts = + list.subList(i, j); + //create page : header + table + footer + Table headerTable = createFinancialStatementsHeaderTable(); + Table table = createFinancialStatementsTable( + subFinancialStatementAmounts); + //new page + Chapter chapter = new Chapter(0); + //headerPage + chapter.add(createHeaderPage(title, identity, + dateFormat.format(beginDate), dateFormat.format(endDate))); + //n° page + chapter.add(createNumberPage(nbpages, dateS, hourS)); + //headerTable + Paragraph paragraphHeaderTable = new Paragraph(); + paragraphHeaderTable.add(headerTable); + chapter.add(paragraphHeaderTable); + //table + Paragraph paragraphTable = new Paragraph(); + paragraphTable.add(table); + chapter.add(paragraphTable); + //add page + document.add(chapter); + i = i + max; + nbpages++; + } + } + + document.close(); + + } catch (FileNotFoundException eeFNFE) { + log.error("Can't create pdf file", eeFNFE); + } catch (DocumentException eeDE) { + log.error("Can't create document", eeDE); + } + } + + public Table createFinancialStatementsHeaderTable(){ + Table t = null; + try { + t = new Table(4,1); + float[] widths = {0.4f, 0.2f, 0.2f, 0.2f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3f); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + t.setDefaultCell(cell); + t.setOffset(8); + t.addCell(new Phrase(_("lima-business.document.label"), + boldFont)); + t.addCell(new Phrase(_("lima-business.document.grossamount"), + boldFont)); + t.addCell(new Phrase(_("lima-business.document.provisiondeprecationamount"), + boldFont)); + t.addCell(new Phrase(_("lima-business.document.netamount"), + boldFont)); + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + + } + + public Table createFinancialStatementsTable(List<FinancialStatementAmounts> financialStatementAmounts){ + int nbrow = financialStatementAmounts.size(); + Table t = null; + try { + //define table + t = new Table(4,nbrow); + t.setWidth(100f); + float[] widths = {0.4f, 0.2f, 0.2f, 0.2f}; + t.setWidths(widths); + t.setPadding(1.5f); + t.setBorderWidth(1); + t.setOffset(0); + //define default cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); + + for (FinancialStatementAmounts financialStatementAmount : financialStatementAmounts) { + + String label = financialStatementAmount.getLabel(); + int level = financialStatementAmount.getLevel(); + BigDecimal grossAmount = + financialStatementAmount.getGrossAmount(); + if (grossAmount == null){ + grossAmount = new BigDecimal(0); + } + BigDecimal provisionDeprecationAmount = + financialStatementAmount.getProvisionDeprecationAmount(); + if (provisionDeprecationAmount == null){ + provisionDeprecationAmount = new BigDecimal(0); + } + + if (financialStatementAmount.getSubAmount() && level==1){ + cell.setGrayFill(0.88f); + } + else if (financialStatementAmount.getSubAmount()){ + cell.setGrayFill(0.94f); + } + else { + cell.setGrayFill(1f); + } + if (label == null){ + t.addCell(""); + t.addCell(""); + t.addCell(""); + t.addCell(""); + } + else { + //cell1 + StringBuffer tab = new StringBuffer(); + for (int i = 0; i < level; i++) { + tab.append("\t"); + } + Phrase phrase = null; + if (financialStatementAmount.getHeader()){ + phrase = new Phrase(tab+label, boldFont); + } + else { + phrase = new Phrase(tab+label, normalFont); + } + Cell c = new Cell(phrase); + c.setHorizontalAlignment(Element.ALIGN_LEFT); + t.addCell(c); + //cell2 + if (grossAmount.doubleValue() != 0){ + phrase = new Phrase(String.valueOf( + grossAmount), normalFont); + } + else { + phrase = new Phrase(""); + } + t.addCell(phrase); + //cell 3 + if (provisionDeprecationAmount.doubleValue() != 0){ + phrase = new Phrase(String.valueOf( + provisionDeprecationAmount), normalFont); + } + else { + phrase = new Phrase(""); + } + t.addCell(phrase); + //cell 4 + BigDecimal solde = grossAmount; + solde = solde.subtract(provisionDeprecationAmount); + if (solde.doubleValue() != 0){ + phrase = new Phrase(solde.toString(), normalFont); + } + else { + phrase = new Phrase(""); + } + t.addCell(phrase); + } + } + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + } + + + //############## Ledger ############## - - @Override - public void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { - Document document = new Document(PageSize.A4, 8, 8, 8, 8); - List<Object> list = new ArrayList<Object>(); - try { - + + @Override + public void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { + Document document = new Document(PageSize.A4, 8, 8, 8, 8); + List<Object> list = new ArrayList<Object>(); + try { + BalanceTrial balanceTrial = reportService.generateLedger(beginDate, endDate, null, true); - if (balanceTrial.getReportsDatas() != null){ - for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) { - list.add(reportsDatas); - List<Entry> entries = (List<Entry>) reportsDatas.getListEntry(); - if (entries != null){ - Collections.sort(entries, new EntryComparator()); - list.addAll(entries); - } - } - } - - Date newDate = new Date(); - String dateS = dateFormat.format(newDate); - String hourS = hourFormat.format(newDate); + if (balanceTrial.getReportsDatas() != null){ + for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) { + list.add(reportsDatas); + List<Entry> entries = (List<Entry>) reportsDatas.getListEntry(); + if (entries != null){ + Collections.sort(entries, new EntryComparator()); + list.addAll(entries); + } + } + } + + Date newDate = new Date(); + String dateS = dateFormat.format(newDate); + String hourS = hourFormat.format(newDate); - BigDecimal currentAmountDebit = new BigDecimal(0); - BigDecimal currentAmountCredit = new BigDecimal(0); - String accountcarry =""; - - String filePath = path+File.separator+DocumentsEnum.LEDGER.getFileName(); - FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); - switch (format) { - case HTML: - HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); - break; - case PDF: - PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); - break; - } - document.open(); - int nbpages = 1; - Identity identity = identityService.getIdentity(); + BigDecimal currentAmountDebit = new BigDecimal(0); + BigDecimal currentAmountCredit = new BigDecimal(0); + String accountcarry =""; + + String filePath = path+File.separator+DocumentsEnum.LEDGER.getFileName(); + FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); + switch (format) { + case HTML: + HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); + break; + case PDF: + PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); + break; + } + document.open(); + int nbpages = 1; + Identity identity = identityService.getIdentity(); - //create pages - int i = 0; - int n = list.size(); - int max = n; - // alloc nb rows max for pdf documents on one page - if (format == FormatsEnum.PDF){ - max = 32; - } - while (i < n){ - int j = i + max; - if (j > n){ - j = n; - } - List <Object> subList = list.subList(i, j); - //create page : header + table + footer - Table headerTable = createLedgerHeaderTable(); - //new page - Chapter chapter = new Chapter(0); - //headerPage - chapter.add(createHeaderPage(DocumentsEnum.LEDGER.getDescription(), identity, - dateFormat.format(beginDate), dateFormat.format(endDate))); - //n° page - chapter.add(createNumberPage(nbpages, dateS, hourS)); - //headerTable - Paragraph paragraphHeaderTable = new Paragraph(); - paragraphHeaderTable.add(headerTable); - chapter.add(paragraphHeaderTable); - //backward amounts - if (n>max && nbpages>1){ - Paragraph backwardParagraph = new Paragraph(); - backwardParagraph.add(createLedgerAmountTable( - accountcarry, _("lima-business.document.carryback"), - currentAmountDebit, currentAmountCredit)); - chapter.add(backwardParagraph); - } - //table - Paragraph paragraphTable = new Paragraph(); - Table table = createLedgerTable(subList); - paragraphTable.add(table); - chapter.add(paragraphTable); - for (Object object : subList) { - if (object instanceof Entry){ - Entry entry = (Entry) object; - if (entry.getDebit()){ - currentAmountDebit = currentAmountDebit.add(entry.getAmount()); - } - else { - currentAmountCredit = currentAmountCredit.add(entry.getAmount()); - } - } - else { - ReportsDatas reportsDatas = (ReportsDatas) object; - Account account = reportsDatas.getAccount(); - if ( account != null){ - accountcarry = account.getAccountNumber() - + " " + account.getLabel() + " "; - } - } - } - //forward amounts - if (n > max && i <= n-max){ - Paragraph forwardParagraph = new Paragraph(); - forwardParagraph.add(createLedgerAmountTable("", - _("lima-business.document.carryforward"), - currentAmountDebit, currentAmountCredit)); - chapter.add(forwardParagraph); - } - //final amounts - if (i >= n-max){ - Paragraph finalAmountParagraph = new Paragraph(); - finalAmountParagraph.add(createLedgerAmountTable("", - _("lima-business.document.amounts"), - currentAmountDebit, currentAmountCredit)); - chapter.add(finalAmountParagraph); - } - //add page - document.add(chapter); - i = i + max; - nbpages++; - } - document.close(); - - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } - } - - public Table createLedgerHeaderTable(){ - Table t = null; - try { - t = new Table(7,1); - float[] widths = {0.1f, 0.05f, 0.1f, 0.3f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3.5f); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - t.setDefaultCell(cell); - t.setOffset(8); - t.addCell(new Phrase(_("lima-business.document.date"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.entrybook"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.voucher"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.description"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.debit"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.credit"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.solde"), boldFont)); - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - - } - - public Table createLedgerTable(List<Object> subList){ - int nbrow = subList.size(); - Table t = null; - try { - //define table - t = new Table(7, nbrow); - t.setWidth(100f); - float[] widths = {0.1f, 0.05f, 0.1f, 0.3f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setPadding(1.5f); - t.setBorderWidth(1); - t.setOffset(0); - //define default cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); - - for (Object object : subList) { - if (object instanceof ReportsDatas) { + //create pages + int i = 0; + int n = list.size(); + int max = n; + // alloc nb rows max for pdf documents on one page + if (format == FormatsEnum.PDF){ + max = 32; + } + while (i < n){ + int j = i + max; + if (j > n){ + j = n; + } + List <Object> subList = list.subList(i, j); + //create page : header + table + footer + Table headerTable = createLedgerHeaderTable(); + //new page + Chapter chapter = new Chapter(0); + //headerPage + chapter.add(createHeaderPage(DocumentsEnum.LEDGER.getDescription(), identity, + dateFormat.format(beginDate), dateFormat.format(endDate))); + //n° page + chapter.add(createNumberPage(nbpages, dateS, hourS)); + //headerTable + Paragraph paragraphHeaderTable = new Paragraph(); + paragraphHeaderTable.add(headerTable); + chapter.add(paragraphHeaderTable); + //backward amounts + if (n>max && nbpages>1){ + Paragraph backwardParagraph = new Paragraph(); + backwardParagraph.add(createLedgerAmountTable( + accountcarry, _("lima-business.document.carryback"), + currentAmountDebit, currentAmountCredit)); + chapter.add(backwardParagraph); + } + //table + Paragraph paragraphTable = new Paragraph(); + Table table = createLedgerTable(subList); + paragraphTable.add(table); + chapter.add(paragraphTable); + for (Object object : subList) { + if (object instanceof Entry){ + Entry entry = (Entry) object; + if (entry.getDebit()){ + currentAmountDebit = currentAmountDebit.add(entry.getAmount()); + } + else { + currentAmountCredit = currentAmountCredit.add(entry.getAmount()); + } + } + else { + ReportsDatas reportsDatas = (ReportsDatas) object; + Account account = reportsDatas.getAccount(); + if ( account != null){ + accountcarry = account.getAccountNumber() + + " " + account.getLabel() + " "; + } + } + } + //forward amounts + if (n > max && i <= n-max){ + Paragraph forwardParagraph = new Paragraph(); + forwardParagraph.add(createLedgerAmountTable("", + _("lima-business.document.carryforward"), + currentAmountDebit, currentAmountCredit)); + chapter.add(forwardParagraph); + } + //final amounts + if (i >= n-max){ + Paragraph finalAmountParagraph = new Paragraph(); + finalAmountParagraph.add(createLedgerAmountTable("", + _("lima-business.document.amounts"), + currentAmountDebit, currentAmountCredit)); + chapter.add(finalAmountParagraph); + } + //add page + document.add(chapter); + i = i + max; + nbpages++; + } + document.close(); + + } catch (FileNotFoundException eeFNFE) { + log.error("Can't create pdf file", eeFNFE); + } catch (DocumentException eeDE) { + log.error("Can't create document", eeDE); + } + } + + public Table createLedgerHeaderTable(){ + Table t = null; + try { + t = new Table(7,1); + float[] widths = {0.1f, 0.05f, 0.1f, 0.3f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3.5f); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + t.setDefaultCell(cell); + t.setOffset(8); + t.addCell(new Phrase(_("lima-business.document.date"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.entrybook"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.voucher"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.description"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.debit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.credit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.solde"), boldFont)); + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + + } + + public Table createLedgerTable(List<Object> subList){ + int nbrow = subList.size(); + Table t = null; + try { + //define table + t = new Table(7, nbrow); + t.setWidth(100f); + float[] widths = {0.1f, 0.05f, 0.1f, 0.3f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setPadding(1.5f); + t.setBorderWidth(1); + t.setOffset(0); + //define default cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); + + for (Object object : subList) { + if (object instanceof ReportsDatas) { - ReportsDatas reportsDatas = (ReportsDatas) object; - - String accountS = ""; - Account account = reportsDatas.getAccount(); - if (account != null){ - accountS = account.getAccountNumber()+"\t"+account.getLabel(); - } - BigDecimal amountCredit = reportsDatas.getAmountCredit(); - BigDecimal amountDebit = reportsDatas.getAmountDebit(); - - Cell c = new Cell(new Phrase(accountS, boldFont)); - c.setColspan(4); - c.setHorizontalAlignment(Element.ALIGN_LEFT); - t.addCell(c); - t.addCell(new Phrase(String.valueOf(amountDebit), boldFont)); - t.addCell(new Phrase(String.valueOf(amountCredit), boldFont)); - BigDecimal solde = amountDebit; - solde = solde.subtract(amountCredit); - t.addCell(new Phrase(String.valueOf(solde), boldFont)); - } - else { - Entry entry = (Entry) object; - - String entryBookCode = ""; - EntryBook entryBook = entry.getFinancialTransaction().getEntryBook(); - if (entryBook != null){ - entryBookCode = entryBook.getCode(); - } - BigDecimal amountDebit = new BigDecimal(0), - amountCredit = new BigDecimal(0); - if (entry.getDebit()){ - amountDebit = entry.getAmount(); - } - else { - amountCredit = entry.getAmount(); - } - - t.addCell(new Phrase(dateFormat.format( - entry.getFinancialTransaction().getTransactionDate()), - normalFont)); - t.addCell(new Phrase(entryBookCode, normalFont)); - t.addCell(new Phrase(entry.getVoucher(), normalFont)); - t.addCell(new Phrase(entry.getDescription(), normalFont)); - t.addCell(new Phrase(amountDebit.toString(), - normalFont)); - t.addCell(new Phrase(amountCredit.toString(), - normalFont)); - BigDecimal solde = amountDebit.subtract(amountCredit); - t.addCell(new Phrase(solde.toString(), - normalFont)); - - } - } - } catch (DocumentException eeDE) { - log.error("Can't create table", eeDE); + ReportsDatas reportsDatas = (ReportsDatas) object; + + String accountS = ""; + Account account = reportsDatas.getAccount(); + if (account != null){ + accountS = account.getAccountNumber()+"\t"+account.getLabel(); + } + BigDecimal amountCredit = reportsDatas.getAmountCredit(); + BigDecimal amountDebit = reportsDatas.getAmountDebit(); + + Cell c = new Cell(new Phrase(accountS, boldFont)); + c.setColspan(4); + c.setHorizontalAlignment(Element.ALIGN_LEFT); + t.addCell(c); + t.addCell(new Phrase(String.valueOf(amountDebit), boldFont)); + t.addCell(new Phrase(String.valueOf(amountCredit), boldFont)); + BigDecimal solde = amountDebit; + solde = solde.subtract(amountCredit); + t.addCell(new Phrase(String.valueOf(solde), boldFont)); + } + else { + Entry entry = (Entry) object; + + String entryBookCode = ""; + EntryBook entryBook = entry.getFinancialTransaction().getEntryBook(); + if (entryBook != null){ + entryBookCode = entryBook.getCode(); + } + BigDecimal amountDebit = new BigDecimal(0), + amountCredit = new BigDecimal(0); + if (entry.getDebit()){ + amountDebit = entry.getAmount(); + } + else { + amountCredit = entry.getAmount(); + } + + t.addCell(new Phrase(dateFormat.format( + entry.getFinancialTransaction().getTransactionDate()), + normalFont)); + t.addCell(new Phrase(entryBookCode, normalFont)); + t.addCell(new Phrase(entry.getVoucher(), normalFont)); + t.addCell(new Phrase(entry.getDescription(), normalFont)); + t.addCell(new Phrase(amountDebit.toString(), + normalFont)); + t.addCell(new Phrase(amountCredit.toString(), + normalFont)); + BigDecimal solde = amountDebit.subtract(amountCredit); + t.addCell(new Phrase(solde.toString(), + normalFont)); + + } + } + } catch (DocumentException eeDE) { + log.error("Can't create table", eeDE); - } - return t; - } - - public Table createLedgerAmountTable(String account, String title, BigDecimal debit, BigDecimal credit){ - Table t = null; - try { - t = new Table(5,1); - float[] widths = {0.4f,0.15f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3f); - t.setOffset(0); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.RIGHT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); - Cell accountCell = new Cell(new Phrase(account, boldFont)); - accountCell.setHorizontalAlignment(Element.ALIGN_LEFT); - accountCell.setBorder(Rectangle.NO_BORDER); - t.addCell(accountCell); - t.addCell(new Phrase(title, boldFont)); - t.addCell(new Phrase(debit.toString(), boldFont)); - t.addCell(new Phrase(credit.toString(), boldFont)); - BigDecimal solde = debit.subtract(credit); - t.addCell(new Phrase(solde.toString(), boldFont)); - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - } - + } + return t; + } + + public Table createLedgerAmountTable(String account, String title, BigDecimal debit, BigDecimal credit){ + Table t = null; + try { + t = new Table(5,1); + float[] widths = {0.4f,0.15f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3f); + t.setOffset(0); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.RIGHT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); + Cell accountCell = new Cell(new Phrase(account, boldFont)); + accountCell.setHorizontalAlignment(Element.ALIGN_LEFT); + accountCell.setBorder(Rectangle.NO_BORDER); + t.addCell(accountCell); + t.addCell(new Phrase(title, boldFont)); + t.addCell(new Phrase(debit.toString(), boldFont)); + t.addCell(new Phrase(credit.toString(), boldFont)); + BigDecimal solde = debit.subtract(credit); + t.addCell(new Phrase(solde.toString(), boldFont)); + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + } + //############## EntryBooks ############## - - - + + + @Override - public void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { - Document document = new Document(PageSize.A4, 8, 8, 8, 8); + public void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { + Document document = new Document(PageSize.A4, 8, 8, 8, 8); TopiaContext transaction = null; - try { - transaction = beginTransaction(); - - Date newDate = new Date(); - String dateS = dateFormat.format(newDate); - String hourS = hourFormat.format(newDate); - - String filePath = path+File.separator+DocumentsEnum.ENTRYBOOKS.getFileName(); - FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); - switch (format) { - case HTML: - HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); - break; - case PDF: - PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); - break; - } - document.open(); - int nbpages = 1; - - Identity identity = identityService.getIdentity(); - - ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = - LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction); - //Split list by financialstatement type - List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = - closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate); - for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) { - - TopiaQuery query = entryDAO.createQuery(); - String financialPeriodProperty = - TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, - FinancialTransaction.FINANCIAL_PERIOD); - String entryBookProperty = - TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, - FinancialTransaction.ENTRY_BOOK); - query.addWhere(financialPeriodProperty, Op.EQ, - closedPeriodicEntryBook.getFinancialPeriod()) - .addWhere(entryBookProperty, Op.EQ, - closedPeriodicEntryBook.getEntryBook()); - - List<Entry> entries = entryDAO.findAllByQuery(query); - - List<Object[]> results = new ArrayList<Object[]>(); - BigDecimal debit = new BigDecimal(0); - BigDecimal credit = new BigDecimal(0); - query.setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")"); - query.addGroup(Entry.DEBIT); + try { + transaction = beginTransaction(); + + Date newDate = new Date(); + String dateS = dateFormat.format(newDate); + String hourS = hourFormat.format(newDate); + + String filePath = path+File.separator+DocumentsEnum.ENTRYBOOKS.getFileName(); + FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); + switch (format) { + case HTML: + HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); + break; + case PDF: + PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); + break; + } + document.open(); + int nbpages = 1; + + Identity identity = identityService.getIdentity(); + + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction); + //Split list by financialstatement type + List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = + closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate); + for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) { + + TopiaQuery query = entryDAO.createQuery(); + String financialPeriodProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.FINANCIAL_PERIOD); + String entryBookProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.ENTRY_BOOK); + query.addWhere(financialPeriodProperty, Op.EQ, + closedPeriodicEntryBook.getFinancialPeriod()) + .addWhere(entryBookProperty, Op.EQ, + closedPeriodicEntryBook.getEntryBook()); + + List<Entry> entries = entryDAO.findAllByQuery(query); + + List<Object[]> results = new ArrayList<Object[]>(); + BigDecimal debit = new BigDecimal(0); + BigDecimal credit = new BigDecimal(0); + query.setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")"); + query.addGroup(Entry.DEBIT); results = query.execute(transaction); int nbAmount = results.size(); if(nbAmount==2){ @@ -803,644 +803,644 @@ credit = (BigDecimal)results.get(0)[1]; } } - - //create pages - String title = closedPeriodicEntryBook.getEntryBook().getLabel() - + "\n" + monthYearFormat.format( - closedPeriodicEntryBook.getFinancialPeriod().getBeginDate()); - //list = list.subList(1, list.size()); - int i = 0; - int n = entries.size(); - int max = n; - // alloc nb rows max for pdf documents on one page - if (format == FormatsEnum.PDF){ - max = 35; - } - while (i < n){ - int j = i + max; - if (j > n){ - j = n; - } - List <Entry> subEntries = - entries.subList(i, j); - //create page : header + table + footer - Table headerTable = createEntryBooksHeaderTable(); - Table table = createEntryBooksTable(subEntries); - //new page - Chapter chapter = new Chapter(0); - //headerPage - chapter.add(createHeaderPage(title, identity, - dateFormat.format(beginDate), dateFormat.format(endDate))); - //n° page - chapter.add(createNumberPage(nbpages, dateS, hourS)); - //headerTable - Paragraph paragraphHeaderTable = new Paragraph(); - paragraphHeaderTable.add(headerTable); - chapter.add(paragraphHeaderTable); - //table - Paragraph paragraphTable = new Paragraph(); - paragraphTable.add(table); - chapter.add(paragraphTable); - //final amounts - if (i>=n-max){ - Paragraph finalAmountParagraph = new Paragraph(); - finalAmountParagraph.add(createEntryBooksAmountTable( - _("lima-business.document.amounts"), debit, credit)); - chapter.add(finalAmountParagraph); - } - //add page - document.add(chapter); - i = i + max; - nbpages++; - } - } - - document.close(); - - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } catch (TopiaException eeTE) { - log.error("Can't get entries", eeTE); + + //create pages + String title = closedPeriodicEntryBook.getEntryBook().getLabel() + + "\n" + monthYearFormat.format( + closedPeriodicEntryBook.getFinancialPeriod().getBeginDate()); + //list = list.subList(1, list.size()); + int i = 0; + int n = entries.size(); + int max = n; + // alloc nb rows max for pdf documents on one page + if (format == FormatsEnum.PDF){ + max = 35; + } + while (i < n){ + int j = i + max; + if (j > n){ + j = n; + } + List <Entry> subEntries = + entries.subList(i, j); + //create page : header + table + footer + Table headerTable = createEntryBooksHeaderTable(); + Table table = createEntryBooksTable(subEntries); + //new page + Chapter chapter = new Chapter(0); + //headerPage + chapter.add(createHeaderPage(title, identity, + dateFormat.format(beginDate), dateFormat.format(endDate))); + //n° page + chapter.add(createNumberPage(nbpages, dateS, hourS)); + //headerTable + Paragraph paragraphHeaderTable = new Paragraph(); + paragraphHeaderTable.add(headerTable); + chapter.add(paragraphHeaderTable); + //table + Paragraph paragraphTable = new Paragraph(); + paragraphTable.add(table); + chapter.add(paragraphTable); + //final amounts + if (i>=n-max){ + Paragraph finalAmountParagraph = new Paragraph(); + finalAmountParagraph.add(createEntryBooksAmountTable( + _("lima-business.document.amounts"), debit, credit)); + chapter.add(finalAmountParagraph); + } + //add page + document.add(chapter); + i = i + max; + nbpages++; + } + } + + document.close(); + + } catch (FileNotFoundException eeFNFE) { + log.error("Can't create pdf file", eeFNFE); + } catch (DocumentException eeDE) { + log.error("Can't create document", eeDE); + } catch (TopiaException eeTE) { + log.error("Can't get entries", eeTE); - } - - } + } + + } - public Table createEntryBooksHeaderTable(){ - Table t = null; - try { - t = new Table(6,1); - float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3f); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - t.setDefaultCell(cell); - t.setOffset(8); - t.addCell(new Phrase(_("lima-business.document.date"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.accountnumber"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.voucher"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.description"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.debit"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.credit"), boldFont)); - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - - } + public Table createEntryBooksHeaderTable(){ + Table t = null; + try { + t = new Table(6,1); + float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3f); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + t.setDefaultCell(cell); + t.setOffset(8); + t.addCell(new Phrase(_("lima-business.document.date"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.accountnumber"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.voucher"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.description"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.debit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.credit"), boldFont)); + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + + } - public Table createEntryBooksTable(List<Entry> entries){ - int nbrow = entries.size(); - Table t = null; - try { - //define table - t = new Table(6,nbrow); - t.setWidth(100f); - float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setPadding(1.5f); - t.setBorderWidth(1); - t.setOffset(0); - //define default cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); - - for (Entry entry : entries) { - t.addCell(new Phrase(dateFormat.format( - entry.getFinancialTransaction().getTransactionDate()), - normalFont)); - String account = ""; - if (entry.getAccount() != null){ - account = entry.getAccount().getAccountNumber(); - } - t.addCell(new Phrase(account, normalFont)); - t.addCell(new Phrase(entry.getVoucher(), normalFont)); - t.addCell(new Phrase(entry.getDescription(), normalFont)); - t.addCell(new Phrase(String.valueOf( - entry.getDebit() ? entry.getAmount() : 0), normalFont)); - t.addCell(new Phrase(String.valueOf( - entry.getDebit() ? entry.getAmount() : 0), normalFont)); - } - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - } + public Table createEntryBooksTable(List<Entry> entries){ + int nbrow = entries.size(); + Table t = null; + try { + //define table + t = new Table(6,nbrow); + t.setWidth(100f); + float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setPadding(1.5f); + t.setBorderWidth(1); + t.setOffset(0); + //define default cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); + + for (Entry entry : entries) { + t.addCell(new Phrase(dateFormat.format( + entry.getFinancialTransaction().getTransactionDate()), + normalFont)); + String account = ""; + if (entry.getAccount() != null){ + account = entry.getAccount().getAccountNumber(); + } + t.addCell(new Phrase(account, normalFont)); + t.addCell(new Phrase(entry.getVoucher(), normalFont)); + t.addCell(new Phrase(entry.getDescription(), normalFont)); + t.addCell(new Phrase(String.valueOf( + entry.getDebit() ? entry.getAmount() : 0), normalFont)); + t.addCell(new Phrase(String.valueOf( + entry.getDebit() ? entry.getAmount() : 0), normalFont)); + } + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + } - public Table createEntryBooksAmountTable(String title, BigDecimal credit, BigDecimal debit){ - Table t = null; - try { - t = new Table(3,1); - float[] widths = {0.7f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3f); - t.setOffset(0); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.RIGHT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); + public Table createEntryBooksAmountTable(String title, BigDecimal credit, BigDecimal debit){ + Table t = null; + try { + t = new Table(3,1); + float[] widths = {0.7f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3f); + t.setOffset(0); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.RIGHT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); - t.addCell(new Phrase(title, boldFont)); - t.addCell(new Phrase(debit.toString(), boldFont)); - t.addCell(new Phrase(credit.toString(), boldFont)); - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - } - + t.addCell(new Phrase(title, boldFont)); + t.addCell(new Phrase(debit.toString(), boldFont)); + t.addCell(new Phrase(credit.toString(), boldFont)); + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + } + //############## Balance ############## - @Override - public void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { - Document document = new Document(PageSize.A4, 8, 8, 8, 8); - - BalanceTrial balanceTrial = - reportService.generateBalanceTrial(beginDate, endDate, null, false, true); + @Override + public void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { + Document document = new Document(PageSize.A4, 8, 8, 8, 8); + + BalanceTrial balanceTrial = + reportService.generateBalanceTrial(beginDate, endDate, null, false, true); - List<ReportsDatas> list = (List<ReportsDatas>) balanceTrial.getReportsDatas(); - - try { - Date newDate = new Date(); - String dateS = dateFormat.format(newDate); - String hourS = hourFormat.format(newDate); - String fileDateS = filedateFormat.format(newDate); + List<ReportsDatas> list = (List<ReportsDatas>) balanceTrial.getReportsDatas(); + + try { + Date newDate = new Date(); + String dateS = dateFormat.format(newDate); + String hourS = hourFormat.format(newDate); + String fileDateS = filedateFormat.format(newDate); - BigDecimal currentAmountDebit = new BigDecimal(0); - BigDecimal currentAmountCredit = new BigDecimal(0); - BigDecimal currentSoldeDebit = new BigDecimal(0); - BigDecimal currentSoldeCredit = new BigDecimal(0); - - String filePath = path+File.separator+DocumentsEnum.BALANCE.getFileName(); - FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); - switch (format) { - case HTML: - HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); - break; - case PDF: - PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); - break; - } - document.open(); - int nbpages = 1; - Identity identity = identityService.getIdentity(); + BigDecimal currentAmountDebit = new BigDecimal(0); + BigDecimal currentAmountCredit = new BigDecimal(0); + BigDecimal currentSoldeDebit = new BigDecimal(0); + BigDecimal currentSoldeCredit = new BigDecimal(0); + + String filePath = path+File.separator+DocumentsEnum.BALANCE.getFileName(); + FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); + switch (format) { + case HTML: + HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); + break; + case PDF: + PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); + break; + } + document.open(); + int nbpages = 1; + Identity identity = identityService.getIdentity(); - //create pages - int i = 0; - int n = list.size(); - int max = n; - // alloc nb rows max for pdf documents on one page - if (format == FormatsEnum.PDF){ - max = 26; - } - while (i < n){ - int j = i + max; - if (j > n){ - j = n; - } - List <ReportsDatas> subList = list.subList(i, j); - //create page : header + table + footer - Table headerTable = createBalanceHeaderTable(); - //new page - Chapter chapter = new Chapter(0); - //headerPage - chapter.add(createHeaderPage(DocumentsEnum.BALANCE.getDescription(), identity, dateFormat.format(beginDate), dateFormat.format(endDate))); - //n° page - chapter.add(createNumberPage(nbpages, dateS, hourS)); - //headerTable - Paragraph paragraphHeaderTable = new Paragraph(); - paragraphHeaderTable.add(headerTable); - chapter.add(paragraphHeaderTable); - //backward amounts - if (n>max && nbpages>1){ - Paragraph backwardParagraph = new Paragraph(); - backwardParagraph.add(createBalanceAmountTable( - _("lima-business.document.carryback"), - currentAmountDebit, currentAmountCredit, - currentSoldeDebit, currentSoldeCredit)); - chapter.add(backwardParagraph); - } - //table - Paragraph paragraphTable = new Paragraph(); - Table table = createBalanceTable(subList); - paragraphTable.add(table); - chapter.add(paragraphTable); - for (ReportsDatas reportsDatas : subList){ - currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit()); - currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit()); - if (reportsDatas.getSoldeDebit()){ - currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde()); - } - else { - currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde()); - } - } - //forward amounts - if (n > max && i <= n-max){ - Paragraph forwardParagraph = new Paragraph(); - forwardParagraph.add(createBalanceAmountTable( - _("lima-business.document.carryforward"), - currentAmountDebit, currentAmountCredit, - currentSoldeDebit, currentSoldeCredit)); - chapter.add(forwardParagraph); - } - //final amounts - if (i >= n-max){ - Paragraph finalAmountParagraph = new Paragraph(); - finalAmountParagraph.add(createBalanceAmountTable( - _("lima-business.document.amounts"), - currentAmountDebit, currentAmountCredit, - currentSoldeDebit, currentSoldeCredit)); - chapter.add(finalAmountParagraph); - } - //add page - document.add(chapter); - i = i + max; - nbpages++; - } - document.close(); - - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } - } - - public Table createBalanceHeaderTable(){ - Table t = null; - try { - t = new Table(6,1); - float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3.5f); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - t.setDefaultCell(cell); - t.setOffset(8); - t.addCell(new Phrase(_("lima-business.document.accountnumber"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.description"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.movementdebit"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.movementcredit"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.soldedebit"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.soldecredit"), boldFont)); - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - - } - - public Table createBalanceTable(List<ReportsDatas> subList){ - int nbrow = subList.size(); - Table t = null; - try { - //define table - t = new Table(6, nbrow); - t.setWidth(100f); - float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setPadding(1.5f); - t.setBorderWidth(1); - t.setOffset(0); - //define default cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); - - for (ReportsDatas reportsDatas : subList) { - - String soldeDebit = String.valueOf(reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0); - String soldeCredit = String.valueOf(reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde()); - - t.addCell(new Phrase(reportsDatas.getAccount().getAccountNumber(), normalFont)); - t.addCell(new Phrase(reportsDatas.getAccount().getLabel(), normalFont)); - t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountDebit()), normalFont)); - t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountCredit()), normalFont)); - t.addCell(new Phrase(soldeDebit, normalFont)); - t.addCell(new Phrase(soldeCredit, normalFont)); - } - } catch (DocumentException eeDE) { - log.error("Can't create table", eeDE); + //create pages + int i = 0; + int n = list.size(); + int max = n; + // alloc nb rows max for pdf documents on one page + if (format == FormatsEnum.PDF){ + max = 26; + } + while (i < n){ + int j = i + max; + if (j > n){ + j = n; + } + List <ReportsDatas> subList = list.subList(i, j); + //create page : header + table + footer + Table headerTable = createBalanceHeaderTable(); + //new page + Chapter chapter = new Chapter(0); + //headerPage + chapter.add(createHeaderPage(DocumentsEnum.BALANCE.getDescription(), identity, dateFormat.format(beginDate), dateFormat.format(endDate))); + //n° page + chapter.add(createNumberPage(nbpages, dateS, hourS)); + //headerTable + Paragraph paragraphHeaderTable = new Paragraph(); + paragraphHeaderTable.add(headerTable); + chapter.add(paragraphHeaderTable); + //backward amounts + if (n>max && nbpages>1){ + Paragraph backwardParagraph = new Paragraph(); + backwardParagraph.add(createBalanceAmountTable( + _("lima-business.document.carryback"), + currentAmountDebit, currentAmountCredit, + currentSoldeDebit, currentSoldeCredit)); + chapter.add(backwardParagraph); + } + //table + Paragraph paragraphTable = new Paragraph(); + Table table = createBalanceTable(subList); + paragraphTable.add(table); + chapter.add(paragraphTable); + for (ReportsDatas reportsDatas : subList){ + currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit()); + currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit()); + if (reportsDatas.getSoldeDebit()){ + currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde()); + } + else { + currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde()); + } + } + //forward amounts + if (n > max && i <= n-max){ + Paragraph forwardParagraph = new Paragraph(); + forwardParagraph.add(createBalanceAmountTable( + _("lima-business.document.carryforward"), + currentAmountDebit, currentAmountCredit, + currentSoldeDebit, currentSoldeCredit)); + chapter.add(forwardParagraph); + } + //final amounts + if (i >= n-max){ + Paragraph finalAmountParagraph = new Paragraph(); + finalAmountParagraph.add(createBalanceAmountTable( + _("lima-business.document.amounts"), + currentAmountDebit, currentAmountCredit, + currentSoldeDebit, currentSoldeCredit)); + chapter.add(finalAmountParagraph); + } + //add page + document.add(chapter); + i = i + max; + nbpages++; + } + document.close(); + + } catch (FileNotFoundException eeFNFE) { + log.error("Can't create pdf file", eeFNFE); + } catch (DocumentException eeDE) { + log.error("Can't create document", eeDE); + } + } + + public Table createBalanceHeaderTable(){ + Table t = null; + try { + t = new Table(6,1); + float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3.5f); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + t.setDefaultCell(cell); + t.setOffset(8); + t.addCell(new Phrase(_("lima-business.document.accountnumber"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.description"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.movementdebit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.movementcredit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.soldedebit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.soldecredit"), boldFont)); + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + + } + + public Table createBalanceTable(List<ReportsDatas> subList){ + int nbrow = subList.size(); + Table t = null; + try { + //define table + t = new Table(6, nbrow); + t.setWidth(100f); + float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setPadding(1.5f); + t.setBorderWidth(1); + t.setOffset(0); + //define default cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); + + for (ReportsDatas reportsDatas : subList) { + + String soldeDebit = String.valueOf(reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0); + String soldeCredit = String.valueOf(reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde()); + + t.addCell(new Phrase(reportsDatas.getAccount().getAccountNumber(), normalFont)); + t.addCell(new Phrase(reportsDatas.getAccount().getLabel(), normalFont)); + t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountDebit()), normalFont)); + t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountCredit()), normalFont)); + t.addCell(new Phrase(soldeDebit, normalFont)); + t.addCell(new Phrase(soldeCredit, normalFont)); + } + } catch (DocumentException eeDE) { + log.error("Can't create table", eeDE); - } - return t; - } - - public Table createBalanceAmountTable(String title, BigDecimal amountDebit, BigDecimal amountCredit, BigDecimal soldeDebit, BigDecimal soldeCredit){ - Table t = null; - try { - t = new Table(5,1); - float[] widths = {0.4f,0.15f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3f); - t.setOffset(0); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.RIGHT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); + } + return t; + } + + public Table createBalanceAmountTable(String title, BigDecimal amountDebit, BigDecimal amountCredit, BigDecimal soldeDebit, BigDecimal soldeCredit){ + Table t = null; + try { + t = new Table(5,1); + float[] widths = {0.4f,0.15f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3f); + t.setOffset(0); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.RIGHT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); - t.addCell(new Phrase(title, boldFont)); - t.addCell(new Phrase(amountDebit.toString(), boldFont)); - t.addCell(new Phrase(amountCredit.toString(), boldFont)); - t.addCell(new Phrase(soldeDebit.toString(), boldFont)); - t.addCell(new Phrase(soldeCredit.toString(), boldFont)); - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - } - - //############## General EntryBook ############## - - - @Override - public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { - Document document = new Document(PageSize.A4, 8, 8, 8, 8); + t.addCell(new Phrase(title, boldFont)); + t.addCell(new Phrase(amountDebit.toString(), boldFont)); + t.addCell(new Phrase(amountCredit.toString(), boldFont)); + t.addCell(new Phrase(soldeDebit.toString(), boldFont)); + t.addCell(new Phrase(soldeCredit.toString(), boldFont)); + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + } + + //############## General EntryBook ############## + + + @Override + public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException { + Document document = new Document(PageSize.A4, 8, 8, 8, 8); TopiaContext transaction = null; - try { - transaction = beginTransaction(); - - Date newDate = new Date(); - String dateS = dateFormat.format(newDate); - String hourS = hourFormat.format(newDate); - - String filePath = path+File.separator+DocumentsEnum.GENERAL_ENTRYBOOK.getFileName(); - FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); - switch (format) { - case HTML: - HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); - break; - case PDF: - PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); - break; - } - document.open(); - int nbpages = 1; - - Identity identity = identityService.getIdentity(); - - FinancialPeriodDAO financialPeriodDAO = - LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction); - ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = - LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction); + try { + transaction = beginTransaction(); + + Date newDate = new Date(); + String dateS = dateFormat.format(newDate); + String hourS = hourFormat.format(newDate); + + String filePath = path+File.separator+DocumentsEnum.GENERAL_ENTRYBOOK.getFileName(); + FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension()); + switch (format) { + case HTML: + HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut); + break; + case PDF: + PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut); + break; + } + document.open(); + int nbpages = 1; + + Identity identity = identityService.getIdentity(); + + FinancialPeriodDAO financialPeriodDAO = + LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction); + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction); - - TopiaQuery financialPeriodsQuery = financialPeriodDAO.createQuery(); - String beginDateProperty = TopiaQuery.getProperty(FinancialPeriod.BEGIN_DATE); - String endDateProperty = TopiaQuery.getProperty(FinancialPeriod.BEGIN_DATE); - financialPeriodsQuery.addWhere(beginDateProperty, Op.GE, beginDate) - .addWhere(endDateProperty, Op.LE, endDate) - .addOrder(beginDateProperty); - List<FinancialPeriod> financialPeriods = - financialPeriodDAO.findAllByQuery(financialPeriodsQuery); - - List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>(); - BigDecimal amountDebit = new BigDecimal(0); - BigDecimal amountCredit = new BigDecimal(0); - for (FinancialPeriod financialPeriod : financialPeriods) { - List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = - closedPeriodicEntryBookDAO.findAllByDates( - financialPeriod.getBeginDate(), financialPeriod.getEndDate()); - - BigDecimal subAmountDebit = new BigDecimal(0); - BigDecimal subAmountCredit = new BigDecimal(0); - for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) { - - List<Object[]> results = new ArrayList<Object[]>(); - TopiaQuery query = entryDAO.createQuery(); - BigDecimal debit = new BigDecimal(0); - BigDecimal credit = new BigDecimal(0); - - String financialPeriodProperty = TopiaQuery.getProperty( - Entry.FINANCIAL_TRANSACTION, - FinancialTransaction.FINANCIAL_PERIOD); - String entryBookProperty = TopiaQuery.getProperty( - Entry.FINANCIAL_TRANSACTION, - FinancialTransaction.ENTRY_BOOK); - query.addWhere(financialPeriodProperty, Op.EQ, - closedPeriodicEntryBook.getFinancialPeriod()) - .addWhere(entryBookProperty, Op.EQ, - closedPeriodicEntryBook.getEntryBook()) - .setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")") - .addGroup(Entry.DEBIT); - results = query.execute(transaction); - - int nbAmount = results.size(); - if(nbAmount == 2){ - debit = (BigDecimal)results.get(0)[1]; - credit = (BigDecimal)results.get(1)[1]; - } - if (nbAmount == 1){ - if ((Boolean)results.get(0)[0]){ - debit = (BigDecimal)results.get(0)[1]; - } - else { - credit = (BigDecimal)results.get(0)[1]; - } - } - GeneralEntryBooksDatas generalEntryBooksDatas = - new GeneralEntryBooksDatasImpl(); - generalEntryBooksDatas.setCode( - closedPeriodicEntryBook.getEntryBook().getCode()); - generalEntryBooksDatas.setDescription( - closedPeriodicEntryBook.getEntryBook().getLabel()); - generalEntryBooksDatas.setPeriod( - monthYearFormat.format(financialPeriod.getBeginDate())); - generalEntryBooksDatas.setCredit(credit); - generalEntryBooksDatas.setDebit(debit); - list.add(generalEntryBooksDatas); - subAmountCredit = subAmountCredit.add(credit); - subAmountDebit = subAmountDebit.add(debit); - } + + TopiaQuery financialPeriodsQuery = financialPeriodDAO.createQuery(); + String beginDateProperty = TopiaQuery.getProperty(FinancialPeriod.BEGIN_DATE); + String endDateProperty = TopiaQuery.getProperty(FinancialPeriod.BEGIN_DATE); + financialPeriodsQuery.addWhere(beginDateProperty, Op.GE, beginDate) + .addWhere(endDateProperty, Op.LE, endDate) + .addOrder(beginDateProperty); + List<FinancialPeriod> financialPeriods = + financialPeriodDAO.findAllByQuery(financialPeriodsQuery); + + List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>(); + BigDecimal amountDebit = new BigDecimal(0); + BigDecimal amountCredit = new BigDecimal(0); + for (FinancialPeriod financialPeriod : financialPeriods) { + List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = + closedPeriodicEntryBookDAO.findAllByDates( + financialPeriod.getBeginDate(), financialPeriod.getEndDate()); + + BigDecimal subAmountDebit = new BigDecimal(0); + BigDecimal subAmountCredit = new BigDecimal(0); + for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) { + + List<Object[]> results = new ArrayList<Object[]>(); + TopiaQuery query = entryDAO.createQuery(); + BigDecimal debit = new BigDecimal(0); + BigDecimal credit = new BigDecimal(0); + + String financialPeriodProperty = TopiaQuery.getProperty( + Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.FINANCIAL_PERIOD); + String entryBookProperty = TopiaQuery.getProperty( + Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.ENTRY_BOOK); + query.addWhere(financialPeriodProperty, Op.EQ, + closedPeriodicEntryBook.getFinancialPeriod()) + .addWhere(entryBookProperty, Op.EQ, + closedPeriodicEntryBook.getEntryBook()) + .setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")") + .addGroup(Entry.DEBIT); + results = query.execute(transaction); + + int nbAmount = results.size(); + if(nbAmount == 2){ + debit = (BigDecimal)results.get(0)[1]; + credit = (BigDecimal)results.get(1)[1]; + } + if (nbAmount == 1){ + if ((Boolean)results.get(0)[0]){ + debit = (BigDecimal)results.get(0)[1]; + } + else { + credit = (BigDecimal)results.get(0)[1]; + } + } + GeneralEntryBooksDatas generalEntryBooksDatas = + new GeneralEntryBooksDatasImpl(); + generalEntryBooksDatas.setCode( + closedPeriodicEntryBook.getEntryBook().getCode()); + generalEntryBooksDatas.setDescription( + closedPeriodicEntryBook.getEntryBook().getLabel()); + generalEntryBooksDatas.setPeriod( + monthYearFormat.format(financialPeriod.getBeginDate())); + generalEntryBooksDatas.setCredit(credit); + generalEntryBooksDatas.setDebit(debit); + list.add(generalEntryBooksDatas); + subAmountCredit = subAmountCredit.add(credit); + subAmountDebit = subAmountDebit.add(debit); + } GeneralEntryBooksDatas generalEntryBooksDatas = - new GeneralEntryBooksDatasImpl(); + new GeneralEntryBooksDatasImpl(); generalEntryBooksDatas.setSubAmount(true); generalEntryBooksDatas.setCredit(subAmountCredit); generalEntryBooksDatas.setDebit(subAmountDebit); generalEntryBooksDatas.setPeriod( - monthYearFormat.format(financialPeriod.getBeginDate())); + monthYearFormat.format(financialPeriod.getBeginDate())); list.add(generalEntryBooksDatas); amountCredit = amountCredit.add(subAmountCredit); amountDebit = amountDebit.add(subAmountDebit); - } + } GeneralEntryBooksDatas generalEntryBooksDatas = - new GeneralEntryBooksDatasImpl(); + new GeneralEntryBooksDatasImpl(); generalEntryBooksDatas.setAmount(true); generalEntryBooksDatas.setCredit(amountCredit); generalEntryBooksDatas.setDebit(amountDebit); list.add(generalEntryBooksDatas); - - //create pages - int i = 0; - int n = list.size(); - int max = n; - // alloc nb rows max for pdf documents on one page - if (format == FormatsEnum.PDF){ - max = 35; - } - while (i < n){ - int j = i + max; - if (j > n){ - j = n; - } - List <GeneralEntryBooksDatas> subList = - list.subList(i, j); - //create page : header + table + footer - Table headerTable = createGeneralEntryBooksHeaderTable(); - Table table = createGeneralEntryBooksTable(subList); - //new page - Chapter chapter = new Chapter(0); - //headerPage - chapter.add(createHeaderPage( - DocumentsEnum.GENERAL_ENTRYBOOK.getDescription(), - identity, dateFormat.format(beginDate), - dateFormat.format(endDate))); - //n° page - chapter.add(createNumberPage(nbpages, dateS, hourS)); - //headerTable - Paragraph paragraphHeaderTable = new Paragraph(); - paragraphHeaderTable.add(headerTable); - chapter.add(paragraphHeaderTable); - //table - Paragraph paragraphTable = new Paragraph(); - paragraphTable.add(table); - chapter.add(paragraphTable); - //add page - document.add(chapter); - i = i + max; - nbpages++; - } - - document.close(); - - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } catch (TopiaException eeTE) { - log.error("Can't get entries", eeTE); - } - - } + + //create pages + int i = 0; + int n = list.size(); + int max = n; + // alloc nb rows max for pdf documents on one page + if (format == FormatsEnum.PDF){ + max = 35; + } + while (i < n){ + int j = i + max; + if (j > n){ + j = n; + } + List <GeneralEntryBooksDatas> subList = + list.subList(i, j); + //create page : header + table + footer + Table headerTable = createGeneralEntryBooksHeaderTable(); + Table table = createGeneralEntryBooksTable(subList); + //new page + Chapter chapter = new Chapter(0); + //headerPage + chapter.add(createHeaderPage( + DocumentsEnum.GENERAL_ENTRYBOOK.getDescription(), + identity, dateFormat.format(beginDate), + dateFormat.format(endDate))); + //n° page + chapter.add(createNumberPage(nbpages, dateS, hourS)); + //headerTable + Paragraph paragraphHeaderTable = new Paragraph(); + paragraphHeaderTable.add(headerTable); + chapter.add(paragraphHeaderTable); + //table + Paragraph paragraphTable = new Paragraph(); + paragraphTable.add(table); + chapter.add(paragraphTable); + //add page + document.add(chapter); + i = i + max; + nbpages++; + } + + document.close(); + + } catch (FileNotFoundException eeFNFE) { + log.error("Can't create pdf file", eeFNFE); + } catch (DocumentException eeDE) { + log.error("Can't create document", eeDE); + } catch (TopiaException eeTE) { + log.error("Can't get entries", eeTE); + } + + } - public Table createGeneralEntryBooksHeaderTable(){ - Table t = null; - try { - t = new Table(5,1); - float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setWidth(100f); - t.setPadding(3f); - //defaut cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - t.setDefaultCell(cell); - t.setOffset(8); - t.addCell(new Phrase(_("lima-business.document.entrybook"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.label"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.date"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.debit"), boldFont)); - t.addCell(new Phrase(_("lima-business.document.credit"), boldFont)); - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - - } + public Table createGeneralEntryBooksHeaderTable(){ + Table t = null; + try { + t = new Table(5,1); + float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setWidth(100f); + t.setPadding(3f); + //defaut cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + t.setDefaultCell(cell); + t.setOffset(8); + t.addCell(new Phrase(_("lima-business.document.entrybook"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.label"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.date"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.debit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.credit"), boldFont)); + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + + } - public Table createGeneralEntryBooksTable(List <GeneralEntryBooksDatas> list){ - int nbrow = list.size(); - Table t = null; - try { - //define table - t = new Table(5,nbrow); - t.setWidth(100f); - float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f}; - t.setWidths(widths); - t.setPadding(1.5f); - t.setBorderWidth(1); - t.setOffset(0); - //define default cell - Cell cell = new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); - - for (GeneralEntryBooksDatas generalEntryBooksDatas : list) { - if (!generalEntryBooksDatas.getAmount() && !generalEntryBooksDatas.getSubAmount()){ - t.addCell(new Phrase( - generalEntryBooksDatas.getCode(), normalFont)); - t.addCell(new Phrase( - generalEntryBooksDatas.getDescription(), normalFont)); - t.addCell(new Phrase( - generalEntryBooksDatas.getPeriod(), normalFont)); - t.addCell(new Phrase( - String.valueOf(generalEntryBooksDatas.getDebit()), - normalFont)); - t.addCell(new Phrase( - String.valueOf(generalEntryBooksDatas.getCredit()), - normalFont)); - } - else { - Phrase phrase = null; - if (generalEntryBooksDatas.getAmount()){ - phrase = new Phrase(_("lima-business.document.amounts"), - boldFont); - } - else { - phrase = new Phrase(_("lima-business.document.amounts") - + " " + generalEntryBooksDatas.getPeriod(), - boldFont); - } - Cell cell2 = new Cell(phrase); - cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM); - cell2.setColspan(3); - t.addCell(cell2); - cell2 = new Cell(new Phrase( - String.valueOf(generalEntryBooksDatas.getDebit()), - boldFont)); - cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM); - t.addCell(cell2); - cell2 = new Cell(new Phrase( - String.valueOf(generalEntryBooksDatas.getCredit()), - boldFont)); - cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM); - t.addCell(cell2); - } - } - - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; - } - - protected TopiaContext beginTransaction() throws TopiaException { + public Table createGeneralEntryBooksTable(List <GeneralEntryBooksDatas> list){ + int nbrow = list.size(); + Table t = null; + try { + //define table + t = new Table(5,nbrow); + t.setWidth(100f); + float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f}; + t.setWidths(widths); + t.setPadding(1.5f); + t.setBorderWidth(1); + t.setOffset(0); + //define default cell + Cell cell = new Cell(); + cell.setBorder(Rectangle.LEFT); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + t.setDefaultCell(cell); + + for (GeneralEntryBooksDatas generalEntryBooksDatas : list) { + if (!generalEntryBooksDatas.getAmount() && !generalEntryBooksDatas.getSubAmount()){ + t.addCell(new Phrase( + generalEntryBooksDatas.getCode(), normalFont)); + t.addCell(new Phrase( + generalEntryBooksDatas.getDescription(), normalFont)); + t.addCell(new Phrase( + generalEntryBooksDatas.getPeriod(), normalFont)); + t.addCell(new Phrase( + String.valueOf(generalEntryBooksDatas.getDebit()), + normalFont)); + t.addCell(new Phrase( + String.valueOf(generalEntryBooksDatas.getCredit()), + normalFont)); + } + else { + Phrase phrase = null; + if (generalEntryBooksDatas.getAmount()){ + phrase = new Phrase(_("lima-business.document.amounts"), + boldFont); + } + else { + phrase = new Phrase(_("lima-business.document.amounts") + + " " + generalEntryBooksDatas.getPeriod(), + boldFont); + } + Cell cell2 = new Cell(phrase); + cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM); + cell2.setColspan(3); + t.addCell(cell2); + cell2 = new Cell(new Phrase( + String.valueOf(generalEntryBooksDatas.getDebit()), + boldFont)); + cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM); + t.addCell(cell2); + cell2 = new Cell(new Phrase( + String.valueOf(generalEntryBooksDatas.getCredit()), + boldFont)); + cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM); + t.addCell(cell2); + } + } + + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + } + + protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database // TODO move it into JTA TopiaContext topiaTransaction; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -78,11 +78,11 @@ } - @Override - public void createEntryBookWithTransaction(EntryBook entryBook, TopiaContext topiaContext) - throws LimaException { + @Override + public void createEntryBookWithTransaction(EntryBook entryBook, TopiaContext topiaContext) + throws LimaException { - try { + try { // check if entrybook with is name already exist EntryBookDAO entryBookDAO = @@ -122,8 +122,8 @@ catch (TopiaException ex) { doCatch(topiaContext, ex, log); } - - } + + } /** * Création d'un EntryBook. Il peut être unique sur son label (au choix). Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -75,7 +75,7 @@ public class ExportServiceImpl extends AbstractLimaService implements ExportService, ExportServiceLocal { private static final Log log = - LogFactory.getLog(ExportServiceImpl.class); + LogFactory.getLog(ExportServiceImpl.class); private TopiaContext rootContext; @@ -100,82 +100,82 @@ */ @Override public String exportEntriesAsEBP() throws LimaException { - TopiaContext topiaContext = null; - SimpleDateFormat epbDateFormat = new SimpleDateFormat("ddMMyyyy"); - StringBuffer result = new StringBuffer(); - int num = 0; - - try { - topiaContext = beginTransaction(); - //export entries - FinancialTransactionDAO financialTransactionDAO = - LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); - List<FinancialTransaction> listFinancialTransaction = - financialTransactionDAO.findAll(); - // For all financialTransaction - for (FinancialTransaction financialTransaction : listFinancialTransaction) { - String date = epbDateFormat.format(financialTransaction.getTransactionDate()); - String entrybookCode = ""; - EntryBook entryBook = financialTransaction.getEntryBook(); - - if (entryBook != null){ - entrybookCode = entryBook.getCode(); - } - - String[] nextLine = new String[11]; - for (Entry entry : financialTransaction.getEntry()) { - num++; - Account account = entry.getAccount(); - - String accountNumber = ""; - if (account != null){ - accountNumber = entry.getAccount().getAccountNumber(); - } - - String debitcredit = ""; - if (entry.getDebit()){ - debitcredit = "D"; - } - else { - debitcredit = "C"; - } - - nextLine[0] = String.valueOf(num); - nextLine[1] = date; - nextLine[2] = entrybookCode; - nextLine[3] = accountNumber; - nextLine[5] = '"'+entry.getDescription()+'"'; - nextLine[6] = '"'+entry.getVoucher()+'"'; - nextLine[7] = entry.getAmount().toString(); - nextLine[8] = debitcredit; + TopiaContext topiaContext = null; + SimpleDateFormat epbDateFormat = new SimpleDateFormat("ddMMyyyy"); + StringBuffer result = new StringBuffer(); + int num = 0; + + try { + topiaContext = beginTransaction(); + //export entries + FinancialTransactionDAO financialTransactionDAO = + LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); + List<FinancialTransaction> listFinancialTransaction = + financialTransactionDAO.findAll(); + // For all financialTransaction + for (FinancialTransaction financialTransaction : listFinancialTransaction) { + String date = epbDateFormat.format(financialTransaction.getTransactionDate()); + String entrybookCode = ""; + EntryBook entryBook = financialTransaction.getEntryBook(); + + if (entryBook != null){ + entrybookCode = entryBook.getCode(); + } + + String[] nextLine = new String[11]; + for (Entry entry : financialTransaction.getEntry()) { + num++; + Account account = entry.getAccount(); + + String accountNumber = ""; + if (account != null){ + accountNumber = entry.getAccount().getAccountNumber(); + } + + String debitcredit = ""; + if (entry.getDebit()){ + debitcredit = "D"; + } + else { + debitcredit = "C"; + } + + nextLine[0] = String.valueOf(num); + nextLine[1] = date; + nextLine[2] = entrybookCode; + nextLine[3] = accountNumber; + nextLine[5] = '"'+entry.getDescription()+'"'; + nextLine[6] = '"'+entry.getVoucher()+'"'; + nextLine[7] = entry.getAmount().toString(); + nextLine[8] = debitcredit; - // Ajoute la ligne au fichier - for (int i=0; i<9; i++){ - String string = ""; - String nextln = nextLine[i]; - if (nextln != null){ - string = nextln; - } - if (i==8){ - result.append(string+"\r\n"); - } - else { - result.append(string+","); - } - } - } - } - } - catch (TopiaException eeeTE){ - doCatch(topiaContext, eeeTE, log); - } - /*catch (IOException eeeIO) { - log.debug("Can't create new CSV Writer",eeeIO); - }*/ - finally { - doFinally(topiaContext, log); - } - return result.toString(); + // Ajoute la ligne au fichier + for (int i=0; i<9; i++){ + String string = ""; + String nextln = nextLine[i]; + if (nextln != null){ + string = nextln; + } + if (i==8){ + result.append(string+"\r\n"); + } + else { + result.append(string+","); + } + } + } + } + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + /*catch (IOException eeeIO) { + log.debug("Can't create new CSV Writer",eeeIO); + }*/ + finally { + doFinally(topiaContext, log); + } + return result.toString(); } /** @@ -186,446 +186,446 @@ */ @Override public String exportAccountsAsEBP() throws LimaException { - TopiaContext topiaContext = null; + TopiaContext topiaContext = null; StringWriter out = new StringWriter(); CSVWriter csvWriter; - - try { - topiaContext = beginTransaction(); - csvWriter = new CSVWriter(out, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER); - //export accounts - String[] nextLine = new String[10]; - // Récupère tous les comptes - AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(topiaContext); - List<Account> listAccount = accountDAO.findAll(); - // Pour tous les comptes - for (Account account : listAccount) { - nextLine[0] = account.getAccountNumber(); - nextLine[1] = StringUtils.remove(account.getLabel(), ","); - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - } - // Write cache in string - csvWriter.flush(); - csvWriter.close(); - } - catch (TopiaException eeeTE){ - doCatch(topiaContext, eeeTE, log); - } - catch (IOException eeeIO) { - log.error("Can't create new CSV Writer",eeeIO); - } - finally { - doFinally(topiaContext, log); - } - return out.getBuffer().toString(); + + try { + topiaContext = beginTransaction(); + csvWriter = new CSVWriter(out, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER); + //export accounts + String[] nextLine = new String[10]; + // Récupère tous les comptes + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(topiaContext); + List<Account> listAccount = accountDAO.findAll(); + // Pour tous les comptes + for (Account account : listAccount) { + nextLine[0] = account.getAccountNumber(); + nextLine[1] = StringUtils.remove(account.getLabel(), ","); + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + // Write cache in string + csvWriter.flush(); + csvWriter.close(); + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + catch (IOException eeeIO) { + log.error("Can't create new CSV Writer",eeeIO); + } + finally { + doFinally(topiaContext, log); + } + return out.getBuffer().toString(); } //############## EXPORT CSV - + /** * Export integrality of database in CSV */ @Override public String exportAsCSV() throws LimaException { - TopiaContext topiaContext = null; + TopiaContext topiaContext = null; StringWriter out = new StringWriter(); CSVWriter csvWriter; - - try { - topiaContext = beginTransaction(); - csvWriter = new CSVWriter(out, ';'); - exportAccountsChartAsCSV(csvWriter, topiaContext); - exportEntryBookChartAsCSV(csvWriter, topiaContext); - exportFinancialStatementChartAsCSV(csvWriter, topiaContext); - exportFiscalPeriodAsCSV(csvWriter, topiaContext); - exportClosedPeriodicEntryBooksAsCSV(csvWriter, topiaContext); - exportFinancialTransactionsAndEntriesAsCSV(csvWriter, topiaContext); - exportIdentityAsCSV(csvWriter, topiaContext); - // Write cache in string - csvWriter.flush(); - csvWriter.close(); - } - catch (TopiaException eeeTE){ - doCatch(topiaContext, eeeTE, log); - } - catch (IOException eeeIO) { - log.error("Can't create new CSV Writer",eeeIO); - } - finally { - doFinally(topiaContext, log); - } - return out.getBuffer().toString(); + + try { + topiaContext = beginTransaction(); + csvWriter = new CSVWriter(out, ';'); + exportAccountsChartAsCSV(csvWriter, topiaContext); + exportEntryBookChartAsCSV(csvWriter, topiaContext); + exportFinancialStatementChartAsCSV(csvWriter, topiaContext); + exportFiscalPeriodAsCSV(csvWriter, topiaContext); + exportClosedPeriodicEntryBooksAsCSV(csvWriter, topiaContext); + exportFinancialTransactionsAndEntriesAsCSV(csvWriter, topiaContext); + exportIdentityAsCSV(csvWriter, topiaContext); + // Write cache in string + csvWriter.flush(); + csvWriter.close(); + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + catch (IOException eeeIO) { + log.error("Can't create new CSV Writer",eeeIO); + } + finally { + doFinally(topiaContext, log); + } + return out.getBuffer().toString(); } /** * Remote methode call from UI. */ - @Override - public String exportFinancialStatementChartAsCSV() throws LimaException { - TopiaContext topiaContext = null; + @Override + public String exportFinancialStatementChartAsCSV() throws LimaException { + TopiaContext topiaContext = null; StringWriter out = new StringWriter(); CSVWriter csvWriter; - - try { - topiaContext = beginTransaction(); - csvWriter = new CSVWriter(out, ';'); - exportFinancialStatementChartAsCSV(csvWriter, topiaContext); - // Write cache in file - csvWriter.flush(); - csvWriter.close(); - } - catch (TopiaException eeeTE){ - doCatch(topiaContext, eeeTE, log); - } - catch (IOException eeeIO) { - log.error("Can't create new CSV Writer",eeeIO); - } - finally { - doFinally(topiaContext, log); - } - return out.getBuffer().toString(); - } + + try { + topiaContext = beginTransaction(); + csvWriter = new CSVWriter(out, ';'); + exportFinancialStatementChartAsCSV(csvWriter, topiaContext); + // Write cache in file + csvWriter.flush(); + csvWriter.close(); + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + catch (IOException eeeIO) { + log.error("Can't create new CSV Writer",eeeIO); + } + finally { + doFinally(topiaContext, log); + } + return out.getBuffer().toString(); + } - - /** - * Local methode, export financialstatements from database - * structure : TYPE | Label | Header | Accounts | DebitAccounts - * | CreditAccounts | ProvisionDeprecationAccounts | SubAmount - * | HeaderAmount | MasterFinancialStatement - */ - public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { - try { - String[] nextLine = new String[11]; - // Get all Financialstatements - FinancialStatementDAO financialStatementDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext); - + + /** + * Local methode, export financialstatements from database + * structure : TYPE | Label | Header | Accounts | DebitAccounts + * | CreditAccounts | ProvisionDeprecationAccounts | SubAmount + * | HeaderAmount | MasterFinancialStatement + */ + public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { + try { + String[] nextLine = new String[11]; + // Get all Financialstatements + FinancialStatementDAO financialStatementDAO = + LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext); + TopiaQuery query = financialStatementDAO.createQuery(); - query.addOrder(FinancialStatement.TOPIA_CREATE_DATE); - List<FinancialStatement> listFinancialStatements = - financialStatementDAO.findAllByQuery(query); - - // For all Financialstatements - for (FinancialStatement financialStatement : listFinancialStatements) { - nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel(); - nextLine[1] = financialStatement.getLabel(); - nextLine[2] = Boolean.toString( - financialStatement.getHeader()); - nextLine[3] = financialStatement.getAccounts(); - nextLine[4] = financialStatement.getDebitAccounts(); - nextLine[5] = financialStatement.getCreditAccounts(); - nextLine[6] = financialStatement. - getProvisionDeprecationAccounts(); - nextLine[7] = Boolean.toString( - financialStatement.getSubAmount()); - nextLine[8] = Boolean.toString( - financialStatement.getHeaderAmount()); - FinancialStatement masterFinancialStatement = - financialStatement.getMasterFinancialStatement(); - String masterFinancialStatementString = ""; - if (masterFinancialStatement != null){ - masterFinancialStatementString = - masterFinancialStatement.getLabel(); - } - nextLine[9] = masterFinancialStatementString; - FinancialStatementWayEnum financialStatementWayEnum = financialStatement.getWay(); - String financialStatementWay = ""; - if (financialStatementWayEnum != null){ - financialStatementWay = financialStatementWayEnum.name(); - } - nextLine[10] = financialStatementWay; - // Add line in file - csvWriter.writeNext(nextLine); - } - } - catch (TopiaException eeeTE){ - doCatch(topiaContext, eeeTE, log); - } - } + query.addOrder(FinancialStatement.TOPIA_CREATE_DATE); + List<FinancialStatement> listFinancialStatements = + financialStatementDAO.findAllByQuery(query); + + // For all Financialstatements + for (FinancialStatement financialStatement : listFinancialStatements) { + nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel(); + nextLine[1] = financialStatement.getLabel(); + nextLine[2] = Boolean.toString( + financialStatement.getHeader()); + nextLine[3] = financialStatement.getAccounts(); + nextLine[4] = financialStatement.getDebitAccounts(); + nextLine[5] = financialStatement.getCreditAccounts(); + nextLine[6] = financialStatement. + getProvisionDeprecationAccounts(); + nextLine[7] = Boolean.toString( + financialStatement.getSubAmount()); + nextLine[8] = Boolean.toString( + financialStatement.getHeaderAmount()); + FinancialStatement masterFinancialStatement = + financialStatement.getMasterFinancialStatement(); + String masterFinancialStatementString = ""; + if (masterFinancialStatement != null){ + masterFinancialStatementString = + masterFinancialStatement.getLabel(); + } + nextLine[9] = masterFinancialStatementString; + FinancialStatementWayEnum financialStatementWayEnum = financialStatement.getWay(); + String financialStatementWay = ""; + if (financialStatementWayEnum != null){ + financialStatementWay = financialStatementWayEnum.name(); + } + nextLine[10] = financialStatementWay; + // Add line in file + csvWriter.writeNext(nextLine); + } + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + } - + /** * Remote methode call from UI. */ - @Override - public String exportEntryBookChartAsCSV() throws LimaException { + @Override + public String exportEntryBookChartAsCSV() throws LimaException { TopiaContext topiaContext = null; StringWriter out = new StringWriter(); CSVWriter csvWriter; try { - topiaContext = beginTransaction(); - csvWriter = new CSVWriter(out, ';'); - exportEntryBookChartAsCSV(csvWriter, topiaContext); - // Write cache in file - csvWriter.flush(); - csvWriter.close(); - } - catch (TopiaException eeeTE){ + topiaContext = beginTransaction(); + csvWriter = new CSVWriter(out, ';'); + exportEntryBookChartAsCSV(csvWriter, topiaContext); + // Write cache in file + csvWriter.flush(); + csvWriter.close(); + } + catch (TopiaException eeeTE){ doCatch(topiaContext, eeeTE, log); - } - catch (IOException eeeIO) { + } + catch (IOException eeeIO) { log.error("Can't create new CSV Writer",eeeIO); - } + } finally { doFinally(topiaContext, log); } - return out.getBuffer().toString(); - } - - - /** - * Local methode, export entrybooks from database - * Structure : TYPE | Code | Label | Type - */ - public void exportEntryBookChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { + return out.getBuffer().toString(); + } + + + /** + * Local methode, export entrybooks from database + * Structure : TYPE | Code | Label | Type + */ + public void exportEntryBookChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { try { - String[] nextLine = new String[3]; - // Get all entrybook - EntryBookDAO entryBookDAO = - LimaCallaoDAOHelper.getEntryBookDAO(topiaContext); - List<EntryBook> listEntryBook = entryBookDAO.findAll(); - // For all EntryBook - for (EntryBook entryBook : listEntryBook) { - nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel(); - nextLine[1] = entryBook.getCode(); - nextLine[2] = entryBook.getLabel(); - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - } - } - catch (TopiaException eeeTE){ + String[] nextLine = new String[3]; + // Get all entrybook + EntryBookDAO entryBookDAO = + LimaCallaoDAOHelper.getEntryBookDAO(topiaContext); + List<EntryBook> listEntryBook = entryBookDAO.findAll(); + // For all EntryBook + for (EntryBook entryBook : listEntryBook) { + nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel(); + nextLine[1] = entryBook.getCode(); + nextLine[2] = entryBook.getLabel(); + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + } + catch (TopiaException eeeTE){ doCatch(topiaContext, eeeTE, log); - } - } + } + } - + /** * Remote methode call from UI. */ - @Override - public String exportAccountsChartAsCSV() throws LimaException { + @Override + public String exportAccountsChartAsCSV() throws LimaException { TopiaContext topiaContext = null; StringWriter out = new StringWriter(); CSVWriter csvWriter; try { - topiaContext = beginTransaction(); - csvWriter = new CSVWriter(out, ';'); - exportAccountsChartAsCSV(csvWriter, topiaContext); - // Write cache in file - csvWriter.flush(); - csvWriter.close(); - } - catch (TopiaException eeeTE){ + topiaContext = beginTransaction(); + csvWriter = new CSVWriter(out, ';'); + exportAccountsChartAsCSV(csvWriter, topiaContext); + // Write cache in file + csvWriter.flush(); + csvWriter.close(); + } + catch (TopiaException eeeTE){ doCatch(topiaContext, eeeTE, log); - } - catch (IOException eeeIO) { + } + catch (IOException eeeIO) { log.error("Can't create new CSV Writer",eeeIO); - } + } finally { doFinally(topiaContext, log); } - return out.getBuffer().toString(); - } + return out.getBuffer().toString(); + } - - /** - * Local methode, export accounts from database - * Structure : TYPE | AccountNumber | Label | ThirdParty | MasterAccount | GeneralLedger - */ - public void exportAccountsChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { + + /** + * Local methode, export accounts from database + * Structure : TYPE | AccountNumber | Label | ThirdParty | MasterAccount | GeneralLedger + */ + public void exportAccountsChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { try { - String[] nextLine = new String[6]; - // Récupère tous les comptes - AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(topiaContext); - List<Account> listAccount = accountDAO.findAll(); - // Pour tous les comptes - for (Account account : listAccount) { - nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel(); - nextLine[1] = account.getAccountNumber(); - nextLine[2] = account.getLabel(); - nextLine[3] = account.getThirdParty(); - Account masterAccount = account.getMasterAccount(); - Account generalLedger = account.getGeneralLedger(); - String masterAccountString = ""; - String generalLedgerString = ""; - if (masterAccount != null){ - masterAccountString = masterAccount.getAccountNumber(); - } - nextLine[4] = masterAccountString; - if (generalLedger != null){ - generalLedgerString = generalLedger.getAccountNumber(); - } - nextLine[5] = generalLedgerString; + String[] nextLine = new String[6]; + // Récupère tous les comptes + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(topiaContext); + List<Account> listAccount = accountDAO.findAll(); + // Pour tous les comptes + for (Account account : listAccount) { + nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel(); + nextLine[1] = account.getAccountNumber(); + nextLine[2] = account.getLabel(); + nextLine[3] = account.getThirdParty(); + Account masterAccount = account.getMasterAccount(); + Account generalLedger = account.getGeneralLedger(); + String masterAccountString = ""; + String generalLedgerString = ""; + if (masterAccount != null){ + masterAccountString = masterAccount.getAccountNumber(); + } + nextLine[4] = masterAccountString; + if (generalLedger != null){ + generalLedgerString = generalLedger.getAccountNumber(); + } + nextLine[5] = generalLedgerString; - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - } - } - catch (TopiaException eeeTE){ + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + } + catch (TopiaException eeeTE){ doCatch(topiaContext, eeeTE, log); - } - } + } + } - - /** - * Local methode, export financialtransactions from database - * Structure : TYPE | TransactionDate | AmountDebit | AmountCredit - * | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code - */ - public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { + + /** + * Local methode, export financialtransactions from database + * Structure : TYPE | TransactionDate | AmountDebit | AmountCredit + * | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code + */ + public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { int numTransaction = 0; // Get all financialtransactions try { - FinancialTransactionDAO financialTransactionDAO = - LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); - List<FinancialTransaction> listFinancialTransaction = - financialTransactionDAO.findAll(); - // For all financialTransaction - for (FinancialTransaction financialTransaction : listFinancialTransaction) { - String[] nextLine = new String[8]; - nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel(); - nextLine[1] = String.valueOf(numTransaction); - nextLine[2] = - SDATEFORMAT.format(financialTransaction.getTransactionDate()); - nextLine[3] = financialTransaction.getAmountDebit().toString(); - nextLine[4] = financialTransaction.getAmountCredit().toString(); - nextLine[5] = - SDATEFORMAT.format(financialTransaction.getFinancialPeriod(). - getBeginDate()); - nextLine[6] = - SDATEFORMAT.format(financialTransaction.getFinancialPeriod(). - getEndDate()); - EntryBook entryBook = financialTransaction.getEntryBook(); - if (entryBook != null){ - nextLine[7] = entryBook.getCode(); - } - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - - nextLine = new String[10]; - for (Entry entry : financialTransaction.getEntry()) { - nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel(); - nextLine[1] = String.valueOf(numTransaction); - nextLine[2] = entry.getDescription(); - nextLine[3] = entry.getAmount().toString(); - nextLine[4] = Boolean.toString(entry.getDebit()); - nextLine[5] = entry.getLetter().getCode(); - nextLine[6] = entry.getDetail(); - nextLine[7] = entry.getVoucher(); - nextLine[8] = entry.getPosition(); - nextLine[9] = entry.getAccount().getAccountNumber(); - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - } - numTransaction++; - } + FinancialTransactionDAO financialTransactionDAO = + LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); + List<FinancialTransaction> listFinancialTransaction = + financialTransactionDAO.findAll(); + // For all financialTransaction + for (FinancialTransaction financialTransaction : listFinancialTransaction) { + String[] nextLine = new String[8]; + nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel(); + nextLine[1] = String.valueOf(numTransaction); + nextLine[2] = + SDATEFORMAT.format(financialTransaction.getTransactionDate()); + nextLine[3] = financialTransaction.getAmountDebit().toString(); + nextLine[4] = financialTransaction.getAmountCredit().toString(); + nextLine[5] = + SDATEFORMAT.format(financialTransaction.getFinancialPeriod(). + getBeginDate()); + nextLine[6] = + SDATEFORMAT.format(financialTransaction.getFinancialPeriod(). + getEndDate()); + EntryBook entryBook = financialTransaction.getEntryBook(); + if (entryBook != null){ + nextLine[7] = entryBook.getCode(); + } + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + + nextLine = new String[10]; + for (Entry entry : financialTransaction.getEntry()) { + nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel(); + nextLine[1] = String.valueOf(numTransaction); + nextLine[2] = entry.getDescription(); + nextLine[3] = entry.getAmount().toString(); + nextLine[4] = Boolean.toString(entry.getDebit()); + nextLine[5] = entry.getLetter().getCode(); + nextLine[6] = entry.getDetail(); + nextLine[7] = entry.getVoucher(); + nextLine[8] = entry.getPosition(); + nextLine[9] = entry.getAccount().getAccountNumber(); + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + numTransaction++; + } } - catch (TopiaException eeeTE){ + catch (TopiaException eeeTE){ doCatch(topiaContext, eeeTE, log); - } - } + } + } - - /** - * Local methode, export fiscalperiods from database - * Structure : TYPE | BeginDate | EndDate | Locked - */ - public void exportFiscalPeriodAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { + + /** + * Local methode, export fiscalperiods from database + * Structure : TYPE | BeginDate | EndDate | Locked + */ + public void exportFiscalPeriodAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { try { - String[] nextLine = new String[4]; - // Get all fiscalperiod - FiscalPeriodDAO fiscalPeriodDAO = - LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext); - List<FiscalPeriod> listFiscalPeriod = - fiscalPeriodDAO.findAll(); - // For all Entry - for (FiscalPeriod fiscalPeriod : listFiscalPeriod) { - nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel(); - nextLine[1] = SDATEFORMAT.format(fiscalPeriod.getBeginDate()); - nextLine[2] = SDATEFORMAT.format(fiscalPeriod.getEndDate()); - nextLine[3] = Boolean.toString(fiscalPeriod.getLocked()); - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - } - } - catch (TopiaException eeeTE){ + String[] nextLine = new String[4]; + // Get all fiscalperiod + FiscalPeriodDAO fiscalPeriodDAO = + LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext); + List<FiscalPeriod> listFiscalPeriod = + fiscalPeriodDAO.findAll(); + // For all Entry + for (FiscalPeriod fiscalPeriod : listFiscalPeriod) { + nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel(); + nextLine[1] = SDATEFORMAT.format(fiscalPeriod.getBeginDate()); + nextLine[2] = SDATEFORMAT.format(fiscalPeriod.getEndDate()); + nextLine[3] = Boolean.toString(fiscalPeriod.getLocked()); + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + } + catch (TopiaException eeeTE){ doCatch(topiaContext, eeeTE, log); - } - } - - - /** - * Local methode, export ClosedPeriodicEntryBooks from database - * Structure : TYPE | Locked | FinancialPeriod beginDate | FinancialPeriod endDate | EntryBook Code - */ - public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { + } + } + + + /** + * Local methode, export ClosedPeriodicEntryBooks from database + * Structure : TYPE | Locked | FinancialPeriod beginDate | FinancialPeriod endDate | EntryBook Code + */ + public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException { try { - String[] nextLine = new String[5]; - // Get all fiscalperiod - ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = - LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext); - List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook = - closedPeriodicEntryBookDAO.findAll(); - // For all Entry - for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) { - nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel(); - nextLine[1] = Boolean.toString( - closedPeriodicEntryBook.getLocked()); - nextLine[2] = - SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod(). - getBeginDate()); - nextLine[3] = - SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod(). - getEndDate()); - nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode(); - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - } - } - catch (TopiaException eeeTE){ + String[] nextLine = new String[5]; + // Get all fiscalperiod + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext); + List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook = + closedPeriodicEntryBookDAO.findAll(); + // For all Entry + for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) { + nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel(); + nextLine[1] = Boolean.toString( + closedPeriodicEntryBook.getLocked()); + nextLine[2] = + SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod(). + getBeginDate()); + nextLine[3] = + SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod(). + getEndDate()); + nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode(); + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + } + catch (TopiaException eeeTE){ doCatch(topiaContext, eeeTE, log); - } - } - - public void exportIdentityAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException{ - try { - String[] nextLine = new String[12]; - // Get identity - IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext); - List<Identity> identities = identityDAO.findAll(); - if (identities.size() != 0){ - - Identity identity = identities.get(0); - nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel(); - nextLine[1] = identity.getName(); - nextLine[2] = identity.getDescription(); - nextLine[3] = identity.getAddress(); - nextLine[4] = identity.getAddress2(); - nextLine[5] = identity.getCity(); - nextLine[6] = identity.getPhoneNumber(); - nextLine[7] = identity.getEmail(); - nextLine[8] = identity.getZipCode(); - nextLine[9] = identity.getVatNumber(); - nextLine[10] = identity.getClassificationCode(); - nextLine[11] = identity.getBusinessNumber(); - // Ajoute la ligne au fichier - csvWriter.writeNext(nextLine); - } - } - catch (TopiaException eeeTE){ - doCatch(topiaContext, eeeTE, log); - } - } + } + } + + public void exportIdentityAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException{ + try { + String[] nextLine = new String[12]; + // Get identity + IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext); + List<Identity> identities = identityDAO.findAll(); + if (identities.size() != 0){ + + Identity identity = identities.get(0); + nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel(); + nextLine[1] = identity.getName(); + nextLine[2] = identity.getDescription(); + nextLine[3] = identity.getAddress(); + nextLine[4] = identity.getAddress2(); + nextLine[5] = identity.getCity(); + nextLine[6] = identity.getPhoneNumber(); + nextLine[7] = identity.getEmail(); + nextLine[8] = identity.getZipCode(); + nextLine[9] = identity.getVatNumber(); + nextLine[10] = identity.getClassificationCode(); + nextLine[11] = identity.getBusinessNumber(); + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + } protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -173,11 +173,11 @@ } - @Override - public void blockClosedPeriodicEntryBookWithTransaction( - ClosedPeriodicEntryBook closedPeriodicEntryBook, - TopiaContext topiaContext) throws LimaException { - try { + @Override + public void blockClosedPeriodicEntryBookWithTransaction( + ClosedPeriodicEntryBook closedPeriodicEntryBook, + TopiaContext topiaContext) throws LimaException { + try { //check rules before create the account accountingRules.blockClosedPeriodicEntryBookRules( closedPeriodicEntryBook, topiaContext); @@ -196,8 +196,8 @@ } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } - } + } + } @Override public void blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException { 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -86,29 +86,29 @@ } accountingRules = config.getAccountingRules(); } - - @Override - public void createFinancialStatementWithTransaction( - FinancialStatement masterFinancialStatement, - FinancialStatement financialStatement, TopiaContext topiaContext) - throws LimaException { + + @Override + public void createFinancialStatementWithTransaction( + FinancialStatement masterFinancialStatement, + FinancialStatement financialStatement, TopiaContext topiaContext) + throws LimaException { - try { + try { FinancialStatementDAO financialStatementDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext); + LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext); financialStatementDAO.create(financialStatement); FinancialStatement masterfinancialStatementUpdate = null; if (masterFinancialStatement != null){ - masterfinancialStatementUpdate = financialStatementDAO.findByLabel(masterFinancialStatement.getLabel()); + masterfinancialStatementUpdate = financialStatementDAO.findByLabel(masterFinancialStatement.getLabel()); } // check if parent account exist; if (masterfinancialStatementUpdate != null) { - masterfinancialStatementUpdate.addSubFinancialStatements(financialStatement); - financialStatementDAO.update(masterfinancialStatementUpdate); + masterfinancialStatementUpdate.addSubFinancialStatements(financialStatement); + financialStatementDAO.update(masterfinancialStatementUpdate); } commitTransaction(topiaContext); @@ -116,12 +116,12 @@ catch (TopiaException ex) { doCatch(topiaContext, ex, log); } - - } + + } - @Override - public void createFinancialStatement(FinancialStatement masterFinancialStatement, FinancialStatement financialStatement) throws LimaException { - + @Override + public void createFinancialStatement(FinancialStatement masterFinancialStatement, FinancialStatement financialStatement) throws LimaException { + TopiaContext transaction = null; try { transaction = beginTransaction(); @@ -134,41 +134,41 @@ finally { doFinally(transaction, log); } - } + } - - @Override - public void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException { + + @Override + public void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException { TopiaContext transaction = null; try { transaction = beginTransaction(); FinancialStatementDAO financialStatementDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); + LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); // remove financialstatement - FinancialStatement financialStatementToDelete = - financialStatementDAO.findByTopiaId( - financialStatement.getTopiaId()); - financialStatementDAO.delete(financialStatementToDelete); + FinancialStatement financialStatementToDelete = + financialStatementDAO.findByTopiaId( + financialStatement.getTopiaId()); + financialStatementDAO.delete(financialStatementToDelete); //get all subFinancialStatement List<FinancialStatement> financialStatements = - getAllChildrenFinancialStatement(financialStatement, - new ArrayList<FinancialStatement>()); + getAllChildrenFinancialStatement(financialStatement, + new ArrayList<FinancialStatement>()); //if FinancialStatement have subFinancialStatement if (financialStatements.size() > 0){ - for (FinancialStatement subFinancialStatement : financialStatements) { - FinancialStatement subFinancialStatementToDelete = - financialStatementDAO.findByTopiaId( - subFinancialStatement.getTopiaId()); - financialStatementDAO.delete(subFinancialStatementToDelete); - } + for (FinancialStatement subFinancialStatement : financialStatements) { + FinancialStatement subFinancialStatementToDelete = + financialStatementDAO.findByTopiaId( + subFinancialStatement.getTopiaId()); + financialStatementDAO.delete(subFinancialStatementToDelete); + } } - //commit + //commit commitTransaction(transaction); } @@ -178,46 +178,46 @@ finally { doFinally(transaction, log); } - } + } - - - @Override - public void removeAllFinancialStatement() throws LimaException { - for (FinancialStatement financialStatement : getChildrenFinancialStatement(null)) { - removeFinancialStatement(financialStatement); - } - } + + + @Override + public void removeAllFinancialStatement() throws LimaException { + for (FinancialStatement financialStatement : getChildrenFinancialStatement(null)) { + removeFinancialStatement(financialStatement); + } + } - @Override - public List<FinancialStatement> getAllFinancialStatements() throws LimaException { + @Override + public List<FinancialStatement> getAllFinancialStatements() throws LimaException { TopiaContext transaction = null; List<FinancialStatement> financialStatements = null; try { transaction = beginTransaction(); FinancialStatementDAO financialStatementDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); + LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); financialStatements = financialStatementDAO.findAll(); } catch (TopiaException ex) { doCatch(transaction, ex, log); } return financialStatements; - } + } - @Override - public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement, List<FinancialStatement> result) throws LimaException { + @Override + public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement, List<FinancialStatement> result) throws LimaException { List<FinancialStatement> childFinancialStatements = - getChildrenFinancialStatement(financialStatement); + getChildrenFinancialStatement(financialStatement); for (FinancialStatement childFinancialStatement: childFinancialStatements) { - result.add(childFinancialStatement); - getAllChildrenFinancialStatement(childFinancialStatement, result); + result.add(childFinancialStatement); + getAllChildrenFinancialStatement(childFinancialStatement, result); } return result; } - - @Override - public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) throws LimaException { + + @Override + public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) throws LimaException { List<FinancialStatement> financialStatements = null; TopiaContext transaction = null; @@ -225,7 +225,7 @@ transaction = beginTransaction(); FinancialStatementDAO financialStatementDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); + LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); TopiaQuery query = financialStatementDAO.createQuery(); query.addEquals("masterFinancialStatement", masterFinancialStatement) @@ -239,18 +239,18 @@ doFinally(transaction, log); } return financialStatements; - } - - - @Override - public void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException { + } + + + @Override + public void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException { TopiaContext transaction = null; try { transaction = beginTransaction(); // DAO FinancialStatementDAO financialStatementHeaderDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); + LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); //update financialStatementHeaderDAO.update(financialStatement); //commit @@ -261,311 +261,311 @@ } finally { doFinally(transaction, log); - } - } + } + } - - /** - * remote methode to get list of financial statement - */ - @Override - public List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate, Date selectedEndDate) throws LimaException{ + + /** + * remote methode to get list of financial statement + */ + @Override + public List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate, Date selectedEndDate) throws LimaException{ TopiaContext transaction = null; List<FinancialStatementAmounts> result = null; try { transaction = beginTransaction(); //create list form tree - result = financialStatementReport(null, selectedBeginDate, - selectedEndDate, new FinancialStatementDatasImpl(), - transaction).getListResult(); + result = financialStatementReport(null, selectedBeginDate, + selectedEndDate, new FinancialStatementDatasImpl(), + transaction).getListResult(); - } + } catch (TopiaException ex) { doCatch(transaction, ex, log); } finally { doFinally(transaction, log); } - return result; - } + return result; + } - /** - * Créé la liste de postes contenant les calculs de comptes - */ - public FinancialStatementDatas financialStatementReport(FinancialStatement financialStatement, Date selectedBeginDate, Date selectedEndDate,FinancialStatementDatas result, TopiaContext topiaContext) throws LimaException{ - + /** + * Créé la liste de postes contenant les calculs de comptes + */ + public FinancialStatementDatas financialStatementReport(FinancialStatement financialStatement, Date selectedBeginDate, Date selectedEndDate,FinancialStatementDatas result, TopiaContext topiaContext) throws LimaException{ + List<FinancialStatement> financialStatements = - getChildrenFinancialStatement(financialStatement); - try { - BigDecimal grossAmount = new BigDecimal(0), - provisionDeprecationAmount = new BigDecimal(0); - List<FinancialStatementAmounts> subResult = - new ArrayList<FinancialStatementAmounts>(); - for (FinancialStatement subFinancialStatement : financialStatements) { - FinancialStatementAmounts financialStatementAmounts = - financialStatementAmounts(subFinancialStatement, - selectedBeginDate, selectedEndDate, topiaContext); - if (!subFinancialStatement.getHeader()){ - //on calcul - grossAmount = - grossAmount.add(financialStatementAmounts.getGrossAmount()); - provisionDeprecationAmount = provisionDeprecationAmount.add( - financialStatementAmounts.getProvisionDeprecationAmount()); - subResult.add(financialStatementAmounts); - } - else { - FinancialStatementDatas financialStatementDatas = - financialStatementReport(subFinancialStatement, - selectedBeginDate, selectedEndDate, result, topiaContext); - grossAmount = grossAmount.add(financialStatementDatas. - getFinancialStatementAmounts().getGrossAmount()); - provisionDeprecationAmount = provisionDeprecationAmount. - add(financialStatementDatas.getFinancialStatementAmounts(). - getProvisionDeprecationAmount()); + getChildrenFinancialStatement(financialStatement); + try { + BigDecimal grossAmount = new BigDecimal(0), + provisionDeprecationAmount = new BigDecimal(0); + List<FinancialStatementAmounts> subResult = + new ArrayList<FinancialStatementAmounts>(); + for (FinancialStatement subFinancialStatement : financialStatements) { + FinancialStatementAmounts financialStatementAmounts = + financialStatementAmounts(subFinancialStatement, + selectedBeginDate, selectedEndDate, topiaContext); + if (!subFinancialStatement.getHeader()){ + //on calcul + grossAmount = + grossAmount.add(financialStatementAmounts.getGrossAmount()); + provisionDeprecationAmount = provisionDeprecationAmount.add( + financialStatementAmounts.getProvisionDeprecationAmount()); + subResult.add(financialStatementAmounts); + } + else { + FinancialStatementDatas financialStatementDatas = + financialStatementReport(subFinancialStatement, + selectedBeginDate, selectedEndDate, result, topiaContext); + grossAmount = grossAmount.add(financialStatementDatas. + getFinancialStatementAmounts().getGrossAmount()); + provisionDeprecationAmount = provisionDeprecationAmount. + add(financialStatementDatas.getFinancialStatementAmounts(). + getProvisionDeprecationAmount()); - FinancialStatementAmounts headerfinancialStatementAmounts = - financialStatementDatas.getFinancialStatementAmounts(); - //Si sous-total - if (subFinancialStatement.getSubAmount()){ - FinancialStatementAmounts header = - new FinancialStatementAmountsImpl(); - header.setLabel(headerfinancialStatementAmounts.getLabel()); - header.setLevel(headerfinancialStatementAmounts.getLevel()); - header.setHeader(true); - //ajoute header - subResult.add(header); - //ajoute liste - if (financialStatementDatas.getListResult() != null){ - subResult.addAll(financialStatementDatas.getListResult()); - } - //ajoute sstotal - FinancialStatementAmounts subAmount = - new FinancialStatementAmountsImpl(); - subAmount.setLabel( - "TOTAL "+headerfinancialStatementAmounts.getLabel()); - subAmount.setLevel( - headerfinancialStatementAmounts.getLevel()); - subAmount.setGrossAmount( - headerfinancialStatementAmounts.getGrossAmount()); - subAmount.setProvisionDeprecationAmount( - headerfinancialStatementAmounts. - getProvisionDeprecationAmount()); - subAmount.setSubAmount(true); - subResult.add(subAmount); - //ajoute une ligne vide - subResult.add(new FinancialStatementAmountsImpl()); - - }//sinon - else { + FinancialStatementAmounts headerfinancialStatementAmounts = + financialStatementDatas.getFinancialStatementAmounts(); + //Si sous-total + if (subFinancialStatement.getSubAmount()){ + FinancialStatementAmounts header = + new FinancialStatementAmountsImpl(); + header.setLabel(headerfinancialStatementAmounts.getLabel()); + header.setLevel(headerfinancialStatementAmounts.getLevel()); + header.setHeader(true); + //ajoute header + subResult.add(header); + //ajoute liste + if (financialStatementDatas.getListResult() != null){ + subResult.addAll(financialStatementDatas.getListResult()); + } + //ajoute sstotal + FinancialStatementAmounts subAmount = + new FinancialStatementAmountsImpl(); + subAmount.setLabel( + "TOTAL "+headerfinancialStatementAmounts.getLabel()); + subAmount.setLevel( + headerfinancialStatementAmounts.getLevel()); + subAmount.setGrossAmount( + headerfinancialStatementAmounts.getGrossAmount()); + subAmount.setProvisionDeprecationAmount( + headerfinancialStatementAmounts. + getProvisionDeprecationAmount()); + subAmount.setSubAmount(true); + subResult.add(subAmount); + //ajoute une ligne vide + subResult.add(new FinancialStatementAmountsImpl()); + + }//sinon + else { - if (subFinancialStatement.getHeaderAmount()){ - subResult.add(headerfinancialStatementAmounts); - } - else { - headerfinancialStatementAmounts. - setGrossAmount(new BigDecimal(0)); - headerfinancialStatementAmounts. - setProvisionDeprecationAmount(new BigDecimal(0)); - subResult.add(headerfinancialStatementAmounts); - } - //ajoute liste - if (financialStatementDatas.getListResult() != null){ - subResult.addAll(financialStatementDatas.getListResult()); - } - } - } - } - FinancialStatementAmounts financialStatementAmounts = - new FinancialStatementAmountsImpl(); - financialStatementAmounts.setGrossAmount(grossAmount); - financialStatementAmounts.setProvisionDeprecationAmount( - provisionDeprecationAmount); - if (financialStatement != null){ - financialStatementAmounts.setLabel(financialStatement.getLabel()); - financialStatementAmounts.setHeader(financialStatement.getHeader()); - financialStatementAmounts.setLevel(financialStatement.getLevel()); - } - result.setFinancialStatementAmounts(financialStatementAmounts); - result.setListResult(subResult); - } - catch (LimaException eee) { + if (subFinancialStatement.getHeaderAmount()){ + subResult.add(headerfinancialStatementAmounts); + } + else { + headerfinancialStatementAmounts. + setGrossAmount(new BigDecimal(0)); + headerfinancialStatementAmounts. + setProvisionDeprecationAmount(new BigDecimal(0)); + subResult.add(headerfinancialStatementAmounts); + } + //ajoute liste + if (financialStatementDatas.getListResult() != null){ + subResult.addAll(financialStatementDatas.getListResult()); + } + } + } + } + FinancialStatementAmounts financialStatementAmounts = + new FinancialStatementAmountsImpl(); + financialStatementAmounts.setGrossAmount(grossAmount); + financialStatementAmounts.setProvisionDeprecationAmount( + provisionDeprecationAmount); + if (financialStatement != null){ + financialStatementAmounts.setLabel(financialStatement.getLabel()); + financialStatementAmounts.setHeader(financialStatement.getHeader()); + financialStatementAmounts.setLevel(financialStatement.getLevel()); + } + result.setFinancialStatementAmounts(financialStatementAmounts); + result.setListResult(subResult); + } + catch (LimaException eee) { doCatch(topiaContext, eee, log); - } - return result; - } - - - /** - * Permet de calculer le montant de tous les comptes contenu dans un mouvement - */ - public FinancialStatementAmounts financialStatementAmounts(FinancialStatement financialStatement, Date selectedBeginDate, Date selectedEndDate, TopiaContext topiaContext) throws LimaException{ - FinancialStatementAmounts financialStatementAmounts = - new FinancialStatementAmountsImpl(); - BigDecimal amount = new BigDecimal(0); - BigDecimal debitAmount = new BigDecimal(0); - BigDecimal creditAmount = new BigDecimal(0); - BigDecimal provisionDeprecationAmount = new BigDecimal(0); - - FinancialStatement masterFinancialStatement = - financialStatement.getMasterFinancialStatement(); - FinancialStatementWayEnum financialStatementWayEnum = - FinancialStatementWayEnum.BOTH; - if (masterFinancialStatement != null){ - financialStatementWayEnum = masterFinancialStatement.getWay(); - } + } + return result; + } + + + /** + * Permet de calculer le montant de tous les comptes contenu dans un mouvement + */ + public FinancialStatementAmounts financialStatementAmounts(FinancialStatement financialStatement, Date selectedBeginDate, Date selectedEndDate, TopiaContext topiaContext) throws LimaException{ + FinancialStatementAmounts financialStatementAmounts = + new FinancialStatementAmountsImpl(); + BigDecimal amount = new BigDecimal(0); + BigDecimal debitAmount = new BigDecimal(0); + BigDecimal creditAmount = new BigDecimal(0); + BigDecimal provisionDeprecationAmount = new BigDecimal(0); + + FinancialStatement masterFinancialStatement = + financialStatement.getMasterFinancialStatement(); + FinancialStatementWayEnum financialStatementWayEnum = + FinancialStatementWayEnum.BOTH; + if (masterFinancialStatement != null){ + financialStatementWayEnum = masterFinancialStatement.getWay(); + } - // DEBIT & CREDIT ACCOUNTS LIST - Amounts amounts = new AmountsImpl(); - String accountsString = financialStatement.getAccounts(); - if (accountsString != null && !accountsString.equals("")){ - amounts = amountFromAccountList(accountsString, - selectedBeginDate, selectedEndDate, topiaContext); - debitAmount = debitAmount.add(amounts.getDebit()); - creditAmount = creditAmount.add(amounts.getCredit()); - } - // DEBIT ACCOUNTS LIST - String debitAccountsString = financialStatement.getDebitAccounts(); - if (debitAccountsString != null && !debitAccountsString.equals("")){ - amounts = amountFromAccountList(debitAccountsString, - selectedBeginDate, selectedEndDate, topiaContext); - debitAmount = debitAmount.add(amounts.getDebit()); - } - //CREDIT ACCOUNTS LIST - String creditAccountsString = financialStatement.getCreditAccounts(); - if (creditAccountsString != null && !creditAccountsString.equals("")){ - amounts = amountFromAccountList(creditAccountsString, - selectedBeginDate, selectedEndDate, topiaContext); - creditAmount = creditAmount.add(amounts.getCredit()); - } - // PROVISION & DEPRECATION - String provisionDeprecationAccountsString = - financialStatement.getProvisionDeprecationAccounts(); - if (provisionDeprecationAccountsString != null && !provisionDeprecationAccountsString.equals("")){ - amounts = amountFromAccountList( - provisionDeprecationAccountsString, selectedBeginDate, - selectedEndDate, topiaContext); - provisionDeprecationAmount = - provisionDeprecationAmount.add(amounts.getCredit()); - provisionDeprecationAmount = - provisionDeprecationAmount.subtract(amounts.getDebit()); - } - switch (financialStatementWayEnum) { - case BOTH: - amount = amount.add(debitAmount); - amount = amount.subtract(creditAmount); - amount = amount.abs(); - break; - case CREDIT: - amount = amount.add(creditAmount); - amount = amount.subtract(debitAmount); - break; - case DEBIT: - amount = amount.add(debitAmount); - amount = amount.subtract(creditAmount); - } - - financialStatementAmounts.setGrossAmount(amount); - financialStatementAmounts.setLabel(financialStatement.getLabel()); - financialStatementAmounts.setProvisionDeprecationAmount( - provisionDeprecationAmount); - financialStatementAmounts.setLevel( - financialStatement.getLevel()); - - return financialStatementAmounts; - } - - - public Amounts amountFromAccountList(String accountsNumberList, Date selectedBeginDate, Date selectedEndDate, TopiaContext topiaContext) throws LimaException{ - Amounts amounts = new AmountsImpl(); - BigDecimal debit = new BigDecimal(0); - BigDecimal credit = new BigDecimal(0); - Boolean substract = false; - try { - AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); - //Remove Spaces - String result = StringUtils.deleteWhitespace(accountsNumberList); - StringTokenizer stQuote = new StringTokenizer(result, "-"); - while (stQuote.hasMoreTokens()) { - String s = stQuote.nextToken(); - List<Account> accountsList = accountDAO.stringToListAccounts(s, false); - BigDecimal debitTemp = new BigDecimal(0); - BigDecimal creditTemp = new BigDecimal(0); - for (Account account : accountsList) { - ReportsDatas reportsDatas = reportServiceLocal. - generateAccountReportsWithTransaction(account, true, - selectedBeginDate, selectedEndDate, topiaContext); - if (reportsDatas.getSoldeDebit()){ - debitTemp = debitTemp.add(reportsDatas.getAmountSolde()); - } - else { - creditTemp = creditTemp.add(reportsDatas.getAmountSolde()); - } - } - if (!substract){ - debit = debitTemp; - credit = creditTemp; - } - //compte(s) précédé du signe - - else { - debit = debit.subtract(debitTemp); - credit = credit.subtract(creditTemp); - } - substract = true; - } - amounts.setCredit(credit); - amounts.setDebit(debit); - } catch (TopiaException e) { - doCatch(topiaContext, e, log); - } - return amounts; - } - + // DEBIT & CREDIT ACCOUNTS LIST + Amounts amounts = new AmountsImpl(); + String accountsString = financialStatement.getAccounts(); + if (accountsString != null && !accountsString.equals("")){ + amounts = amountFromAccountList(accountsString, + selectedBeginDate, selectedEndDate, topiaContext); + debitAmount = debitAmount.add(amounts.getDebit()); + creditAmount = creditAmount.add(amounts.getCredit()); + } + // DEBIT ACCOUNTS LIST + String debitAccountsString = financialStatement.getDebitAccounts(); + if (debitAccountsString != null && !debitAccountsString.equals("")){ + amounts = amountFromAccountList(debitAccountsString, + selectedBeginDate, selectedEndDate, topiaContext); + debitAmount = debitAmount.add(amounts.getDebit()); + } + //CREDIT ACCOUNTS LIST + String creditAccountsString = financialStatement.getCreditAccounts(); + if (creditAccountsString != null && !creditAccountsString.equals("")){ + amounts = amountFromAccountList(creditAccountsString, + selectedBeginDate, selectedEndDate, topiaContext); + creditAmount = creditAmount.add(amounts.getCredit()); + } + // PROVISION & DEPRECATION + String provisionDeprecationAccountsString = + financialStatement.getProvisionDeprecationAccounts(); + if (provisionDeprecationAccountsString != null && !provisionDeprecationAccountsString.equals("")){ + amounts = amountFromAccountList( + provisionDeprecationAccountsString, selectedBeginDate, + selectedEndDate, topiaContext); + provisionDeprecationAmount = + provisionDeprecationAmount.add(amounts.getCredit()); + provisionDeprecationAmount = + provisionDeprecationAmount.subtract(amounts.getDebit()); + } + switch (financialStatementWayEnum) { + case BOTH: + amount = amount.add(debitAmount); + amount = amount.subtract(creditAmount); + amount = amount.abs(); + break; + case CREDIT: + amount = amount.add(creditAmount); + amount = amount.subtract(debitAmount); + break; + case DEBIT: + amount = amount.add(debitAmount); + amount = amount.subtract(creditAmount); + } + + financialStatementAmounts.setGrossAmount(amount); + financialStatementAmounts.setLabel(financialStatement.getLabel()); + financialStatementAmounts.setProvisionDeprecationAmount( + provisionDeprecationAmount); + financialStatementAmounts.setLevel( + financialStatement.getLevel()); + + return financialStatementAmounts; + } + + + public Amounts amountFromAccountList(String accountsNumberList, Date selectedBeginDate, Date selectedEndDate, TopiaContext topiaContext) throws LimaException{ + Amounts amounts = new AmountsImpl(); + BigDecimal debit = new BigDecimal(0); + BigDecimal credit = new BigDecimal(0); + Boolean substract = false; + try { + AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); + //Remove Spaces + String result = StringUtils.deleteWhitespace(accountsNumberList); + StringTokenizer stQuote = new StringTokenizer(result, "-"); + while (stQuote.hasMoreTokens()) { + String s = stQuote.nextToken(); + List<Account> accountsList = accountDAO.stringToListAccounts(s, false); + BigDecimal debitTemp = new BigDecimal(0); + BigDecimal creditTemp = new BigDecimal(0); + for (Account account : accountsList) { + ReportsDatas reportsDatas = reportServiceLocal. + generateAccountReportsWithTransaction(account, true, + selectedBeginDate, selectedEndDate, topiaContext); + if (reportsDatas.getSoldeDebit()){ + debitTemp = debitTemp.add(reportsDatas.getAmountSolde()); + } + else { + creditTemp = creditTemp.add(reportsDatas.getAmountSolde()); + } + } + if (!substract){ + debit = debitTemp; + credit = creditTemp; + } + //compte(s) précédé du signe - + else { + debit = debit.subtract(debitTemp); + credit = credit.subtract(creditTemp); + } + substract = true; + } + amounts.setCredit(credit); + amounts.setDebit(debit); + } catch (TopiaException e) { + doCatch(topiaContext, e, log); + } + return amounts; + } + @Override - public String checkFinancialStatementChart() throws LimaException { + public String checkFinancialStatementChart() throws LimaException { StringBuffer result = - new StringBuffer(_("lima-business.financialstatement.check.warn")); + new StringBuffer(_("lima-business.financialstatement.check.warn")); TopiaContext transaction = null; try { - transaction = beginTransaction(); - AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(transaction); - FinancialStatementDAO financialStatementDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); - - List<Account> accountsList = accountDAO.findAllSubAccounts(); + transaction = beginTransaction(); + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(transaction); + FinancialStatementDAO financialStatementDAO = + LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); + + List<Account> accountsList = accountDAO.findAllSubAccounts(); List<FinancialStatement> financialStatementsList = - financialStatementDAO.findAll(); + financialStatementDAO.findAll(); for (FinancialStatement financialStatement : financialStatementsList) { - - accountsList.removeAll( - accountDAO.stringToListAccounts( - financialStatement.getAccounts(), true)); - - accountsList.removeAll( - accountDAO.stringToListAccounts( - financialStatement.getCreditAccounts(), true)); - - accountsList.removeAll( - accountDAO.stringToListAccounts( - financialStatement.getDebitAccounts(), true)); - - accountsList.removeAll( - accountDAO.stringToListAccounts( - financialStatement.getProvisionDeprecationAccounts(), true)); - } + + accountsList.removeAll( + accountDAO.stringToListAccounts( + financialStatement.getAccounts(), true)); + + accountsList.removeAll( + accountDAO.stringToListAccounts( + financialStatement.getCreditAccounts(), true)); + + accountsList.removeAll( + accountDAO.stringToListAccounts( + financialStatement.getDebitAccounts(), true)); + + accountsList.removeAll( + accountDAO.stringToListAccounts( + financialStatement.getProvisionDeprecationAccounts(), true)); + } - for (Account account : accountsList) { - - result.append(_("lima-business.financialstatement.check.nothing", - account.getAccountNumber(), account.getLabel())); - } - + for (Account account : accountsList) { + + result.append(_("lima-business.financialstatement.check.nothing", + account.getAccountNumber(), account.getLabel())); + } + } catch (TopiaException ex) { doCatch(transaction, ex, log); @@ -573,34 +573,34 @@ finally { doFinally(transaction, log); } - return result.toString(); - } + return result.toString(); + } public List<FinancialStatement> findFinancialStatementByAccountNumber(String accountNumber, TopiaContext topiaContext) throws TopiaException{ - - FinancialStatementDAO financialStatementDAO = - LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext); - TopiaQuery query = financialStatementDAO.createQuery(); - - String accountProperty = - TopiaQuery.getProperty(FinancialStatement.ACCOUNTS); - String creditAccountProperty = - TopiaQuery.getProperty(FinancialStatement.CREDIT_ACCOUNTS); - String debitAccountProperty = - TopiaQuery.getProperty(FinancialStatement.DEBIT_ACCOUNTS); - String provisionDeprecationProperty = - TopiaQuery.getProperty(FinancialStatement.PROVISION_DEPRECATION_ACCOUNTS); - String likeCondition = " " + Op.LIKE + " '%"+accountNumber + "%'"; - - query.addWhere(accountProperty + likeCondition - + " OR " + creditAccountProperty + likeCondition - + " OR " + debitAccountProperty + likeCondition - + " OR " + provisionDeprecationProperty + likeCondition); + + FinancialStatementDAO financialStatementDAO = + LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext); + TopiaQuery query = financialStatementDAO.createQuery(); + + String accountProperty = + TopiaQuery.getProperty(FinancialStatement.ACCOUNTS); + String creditAccountProperty = + TopiaQuery.getProperty(FinancialStatement.CREDIT_ACCOUNTS); + String debitAccountProperty = + TopiaQuery.getProperty(FinancialStatement.DEBIT_ACCOUNTS); + String provisionDeprecationProperty = + TopiaQuery.getProperty(FinancialStatement.PROVISION_DEPRECATION_ACCOUNTS); + String likeCondition = " " + Op.LIKE + " '%"+accountNumber + "%'"; + + query.addWhere(accountProperty + likeCondition + + " OR " + creditAccountProperty + likeCondition + + " OR " + debitAccountProperty + likeCondition + + " OR " + provisionDeprecationProperty + likeCondition); - return financialStatementDAO.findAllByQuery(query); + return financialStatementDAO.findAllByQuery(query); } - protected TopiaContext beginTransaction() throws TopiaException { + protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database // TODO move it into JTA TopiaContext topiaTransaction; @@ -619,5 +619,5 @@ throw eee; } } - + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -91,11 +91,11 @@ accountingRules = config.getAccountingRules(); } - @Override - public void createFinancialTransactionWithTransaction( - FinancialTransaction financialtransaction, TopiaContext topiaContext) - throws LimaException { - try { + @Override + public void createFinancialTransactionWithTransaction( + FinancialTransaction financialtransaction, TopiaContext topiaContext) + throws LimaException { + try { //check if the financial period is blocked accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction( financialtransaction, topiaContext); @@ -109,8 +109,8 @@ } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } - } + } + } /** * Permet de créer une transaction comptable contenant des entrées @@ -122,7 +122,7 @@ TopiaContext topiaContext = null; try { topiaContext = beginTransaction(); - + createFinancialTransactionWithTransaction(financialtransaction, topiaContext); } catch (TopiaException ex) { @@ -155,9 +155,9 @@ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); - String financialPeriodProperty = TopiaQuery.getProperty(FinancialTransaction.FINANCIAL_PERIOD); - String entryBookLabelProperty = TopiaQuery.getProperty(FinancialTransaction.ENTRY_BOOK); - + String financialPeriodProperty = TopiaQuery.getProperty(FinancialTransaction.FINANCIAL_PERIOD); + String entryBookLabelProperty = TopiaQuery.getProperty(FinancialTransaction.ENTRY_BOOK); + // filter with topia query TopiaQuery query = transactionDAO.createQuery("T"); @@ -172,8 +172,8 @@ .addOrder("T."+FinancialTransaction.TOPIA_CREATE_DATE) //load for lazy .addLoad(financialPeriodProperty) - .addLoad(entryBookLabelProperty) - .addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true) + .addLoad(entryBookLabelProperty) + .addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true) .addFetch("E."+Entry.ACCOUNT) .addFetch("E."+Entry.LETTER); financialTransactions = transactionDAO.findAllByQuery(query); @@ -202,10 +202,10 @@ FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); - String financialPeriodProperty = TopiaQuery.getProperty(FinancialTransaction.FINANCIAL_PERIOD); - String entryBookLabelProperty = TopiaQuery.getProperty(FinancialTransaction.ENTRY_BOOK); - - + String financialPeriodProperty = TopiaQuery.getProperty(FinancialTransaction.FINANCIAL_PERIOD); + String entryBookLabelProperty = TopiaQuery.getProperty(FinancialTransaction.ENTRY_BOOK); + + TopiaQuery query = financialTransactionDAO.createQuery("T"); query.addDistinct() .addOrder("T."+FinancialTransaction.TOPIA_CREATE_DATE) @@ -218,7 +218,7 @@ .addFetch("E."+Entry.ACCOUNT) .addFetch("E."+Entry.LETTER) .addLoad(financialPeriodProperty) - .addLoad(entryBookLabelProperty); + .addLoad(entryBookLabelProperty); result = financialTransactionDAO.findAllByQuery(query); @@ -239,7 +239,7 @@ List<FinancialTransaction> result = null; try { topiaContext = beginTransaction(); - result = getAllFinancialTransactionsBalanced(fiscalPeriod, topiaContext); + result = getAllFinancialTransactionsBalanced(fiscalPeriod, topiaContext); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); @@ -259,7 +259,7 @@ try { FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); - + // WARN No load lazy, modify query with addLoad or addFetch if loading is necessary TopiaQuery query = financialTransactionDAO.createQuery("T"); query.addFrom(FiscalPeriod.class, "F") @@ -341,7 +341,7 @@ financialTransactionOld.setAmountCredit( financialtransaction.getAmountCredit()); financialTransactionOld.setEntryBook( - financialtransaction.getEntryBook()); + financialtransaction.getEntryBook()); transactionDAO.update(financialTransactionOld); } catch (TopiaException ex) { @@ -382,10 +382,10 @@ } - @Override - public void createEntryWithTransaction(Entry entry, - TopiaContext topiaContext) throws LimaException { - + @Override + public void createEntryWithTransaction(Entry entry, + TopiaContext topiaContext) throws LimaException { + try { //check if the financial period is blocked @@ -401,26 +401,26 @@ Boolean entryAmountIsDebit = entry.getDebit(); BigDecimal entryDebit = new BigDecimal(0), entryCredit = new BigDecimal(0); if (entryAmountIsDebit){ - entryDebit = entryAmount; + entryDebit = entryAmount; } else { - entryCredit = entryAmount; + entryCredit = entryAmount; } //calculate financial transaction amounts FinancialTransaction financialTransaction = - entry.getFinancialTransaction(); + entry.getFinancialTransaction(); BigDecimal amountDebit = financialTransaction.getAmountDebit(); if (amountDebit == null){ - amountDebit = new BigDecimal(0); + amountDebit = new BigDecimal(0); } amountDebit = amountDebit.add(entryDebit); financialTransaction.setAmountDebit(amountDebit); BigDecimal amountCredit = financialTransaction.getAmountCredit(); if (amountCredit == null){ - amountCredit = new BigDecimal(0); + amountCredit = new BigDecimal(0); } amountCredit = amountCredit.add(entryCredit); financialTransaction.setAmountCredit(amountCredit); @@ -434,8 +434,8 @@ } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } - } + } + } /** * Create new entry @@ -484,10 +484,10 @@ Boolean entryAmountIsDebit = entry.getDebit(); BigDecimal entryDebit = new BigDecimal(0), entryCredit = new BigDecimal(0); if (entryAmountIsDebit){ - entryDebit = entryAmount; + entryDebit = entryAmount; } else { - entryCredit = entryAmount; + entryCredit = entryAmount; } //get old entry amounts @@ -495,10 +495,10 @@ Boolean entryAmountOldIsDebit = entryOld.getDebit(); BigDecimal entryDebitOld = new BigDecimal(0), entryCreditOld = new BigDecimal(0); if (entryAmountOldIsDebit){ - entryDebitOld = entryAmountOld; + entryDebitOld = entryAmountOld; } else { - entryCreditOld = entryAmountOld; + entryCreditOld = entryAmountOld; } //FIXME PEPIN 20100520 conflict object already instanciate @@ -562,10 +562,10 @@ Boolean entryAmountIsDebit = entry.getDebit(); BigDecimal entryDebit = new BigDecimal(0), entryCredit = new BigDecimal(0); if (entryAmountIsDebit){ - entryDebit = entryAmount; + entryDebit = entryAmount; } else { - entryCredit = entryAmount; + entryCredit = entryAmount; } //calculate financial transaction amounts @@ -603,20 +603,20 @@ * 1 -> A, 2 -> B, 26 -> Z, 27 -> AA, 28 -> AB, ... */ @Override - public Letter getNewLetter() throws LimaException { - Letter letter = new LetterImpl(); + public Letter getNewLetter() throws LimaException { + Letter letter = new LetterImpl(); TopiaContext topiaContext = null; try { - topiaContext = beginTransaction(); - LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); - int n = letterDAO.count(); - String res = numberToString(n, null); - - //if already exist - while (letterDAO.findByCode(res) != null){ - res = numberToString(n++, null); - } - letter.setCode(res); + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + int n = letterDAO.count(); + String res = numberToString(n, null); + + //if already exist + while (letterDAO.findByCode(res) != null){ + res = numberToString(n++, null); + } + letter.setCode(res); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); @@ -624,23 +624,23 @@ finally { doFinally(topiaContext, log); } - return letter; - } + return letter; + } - public static String numberToString(int n, StringBuffer result){ - if (result == null){ - result = new StringBuffer(); - } - int mod = (n-1) % 26; - int div = (n-1) / 26; - if (div > 0){ - result.append(numberToString(div, result)); - } - return (result.append((char) (mod+65))).toString(); - } + public static String numberToString(int n, StringBuffer result){ + if (result == null){ + result = new StringBuffer(); + } + int mod = (n-1) % 26; + int div = (n-1) / 26; + if (div > 0){ + result.append(numberToString(div, result)); + } + return (result.append((char) (mod+65))).toString(); + } - @Override - public void createLetter(Letter letter) throws LimaException { + @Override + public void createLetter(Letter letter) throws LimaException { TopiaContext topiaContext = null; try { topiaContext = beginTransaction(); @@ -652,26 +652,26 @@ finally { doFinally(topiaContext, log); } - } + } public void createLetterWithTransaction(Letter letter, TopiaContext topiaContext) throws LimaException { - try { - LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); - letterDAO.create(letter); - commitTransaction(topiaContext); - } catch (TopiaException ex) { + try { + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letterDAO.create(letter); + commitTransaction(topiaContext); + } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } + } } - @Override - public void removeLetter(Letter letter) throws LimaException { + @Override + public void removeLetter(Letter letter) throws LimaException { TopiaContext topiaContext = null; try { - topiaContext = beginTransaction(); - LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); - letterDAO.delete(letter); - commitTransaction(topiaContext); + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letterDAO.delete(letter); + commitTransaction(topiaContext); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); @@ -679,17 +679,17 @@ finally { doFinally(topiaContext, log); } - } + } - - @Override - public List<Letter> getAllLetters() throws LimaException { - List<Letter> letters = null; + + @Override + public List<Letter> getAllLetters() throws LimaException { + List<Letter> letters = null; TopiaContext topiaContext = null; try { - topiaContext = beginTransaction(); - LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); - letters = letterDAO.findAll(); + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letters = letterDAO.findAll(); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); @@ -698,169 +698,169 @@ doFinally(topiaContext, log); } return letters; - } + } - - - @Override - public void setEntryLetter(Entry entry, Letter letter) throws LimaException { - + + + @Override + public void setEntryLetter(Entry entry, Letter letter) throws LimaException { + TopiaContext topiaContext = null; try { - topiaContext = beginTransaction(); - LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); - Letter letterOld = letterDAO.findByCode(letter.getCode()); - if (letterOld == null){ - createLetterWithTransaction(letter, topiaContext); - letterOld = letter; - } - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId()); - entryOld.setLetter(letterOld); - commitTransaction(topiaContext); + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + Letter letterOld = letterDAO.findByCode(letter.getCode()); + if (letterOld == null){ + createLetterWithTransaction(letter, topiaContext); + letterOld = letter; + } + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId()); + entryOld.setLetter(letterOld); + commitTransaction(topiaContext); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); } finally { doFinally(topiaContext, log); - } - } - - + } + } + + - @Override - public void removeEntryLetter(Entry entry) throws LimaException { + @Override + public void removeEntryLetter(Entry entry) throws LimaException { TopiaContext topiaContext = null; try { - topiaContext = beginTransaction(); - - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId()); - entryOld.setLetter(null); - commitTransaction(topiaContext); + topiaContext = beginTransaction(); + + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId()); + entryOld.setLetter(null); + commitTransaction(topiaContext); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); } finally { doFinally(topiaContext, log); - } - } + } + } - @Override - public List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException { - List<Object> result = new ArrayList<Object>(); - List<FinancialTransaction> financialTransactions = null; + @Override + public List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException { + List<Object> result = new ArrayList<Object>(); + List<FinancialTransaction> financialTransactions = null; TopiaContext topiaContext = null; try { topiaContext = beginTransaction(); FinancialTransactionDAO financialTransactionDAO = - LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); + LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); TopiaQuery query = financialTransactionDAO.createQuery("T"); - String dateProperty = TopiaQuery.getProperty(FinancialTransaction.TRANSACTION_DATE); - String accountNumberProperty = TopiaQuery.getProperty(Entry.ACCOUNT, Account.ACCOUNT_NUMBER); - - query.addDistinct(); - query.addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true); - //Load for lazy - query.addLoad(FinancialTransaction.ENTRY_BOOK) - .addLoad(FinancialTransaction.FINANCIAL_PERIOD); - - Date beginDate = financialTransactionSearch.getBeginDate(); - Date endDate = financialTransactionSearch.getEndDate(); + String dateProperty = TopiaQuery.getProperty(FinancialTransaction.TRANSACTION_DATE); + String accountNumberProperty = TopiaQuery.getProperty(Entry.ACCOUNT, Account.ACCOUNT_NUMBER); + + query.addDistinct(); + query.addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true); + //Load for lazy + query.addLoad(FinancialTransaction.ENTRY_BOOK) + .addLoad(FinancialTransaction.FINANCIAL_PERIOD); + + Date beginDate = financialTransactionSearch.getBeginDate(); + Date endDate = financialTransactionSearch.getEndDate(); if (beginDate != null && endDate != null){ - query.addBetween(dateProperty, beginDate, endDate); + query.addBetween(dateProperty, beginDate, endDate); } else if (beginDate != null){ - query.addEquals(dateProperty, beginDate); + query.addEquals(dateProperty, beginDate); } String voucher = financialTransactionSearch.getVoucher(); if (voucher != null){ - query.addWhere("E.voucher", Op.LIKE, "%"+voucher+"%"); + query.addWhere("E.voucher", Op.LIKE, "%"+voucher+"%"); } String description = financialTransactionSearch.getDescription(); if (description != null){ - query.addWhere("E.description", Op.LIKE, "%"+description+"%"); + query.addWhere("E.description", Op.LIKE, "%"+description+"%"); } Letter letter = financialTransactionSearch.getLetter(); if (letter != null){ - query.addEquals("E.letter", letter); + query.addEquals("E.letter", letter); } Account account = financialTransactionSearch.getAccount(); String accountsList = financialTransactionSearch.getAccountList(); if (account != null){ - query.addEquals("E.account", account); + query.addEquals("E.account", account); } else if (accountsList != null){ - AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); - List<Account> accounts = - accountDAO.stringToListAccounts(accountsList, false); - StringBuffer accountNumbers = new StringBuffer("0,"); - int max = accounts.size(); - for (int i = 1; i <= max; i++) { - accountNumbers.append(accounts.get(i-1).getAccountNumber()); - if (i != max){ - accountNumbers.append(","); - } - } - if (accounts.size() > 0){ - query.addWhere("E."+accountNumberProperty + " in (" + accountNumbers + ")"); - } - + AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); + List<Account> accounts = + accountDAO.stringToListAccounts(accountsList, false); + StringBuffer accountNumbers = new StringBuffer("0,"); + int max = accounts.size(); + for (int i = 1; i <= max; i++) { + accountNumbers.append(accounts.get(i-1).getAccountNumber()); + if (i != max){ + accountNumbers.append(","); + } + } + if (accounts.size() > 0){ + query.addWhere("E."+accountNumberProperty + " in (" + accountNumbers + ")"); + } + } EntryBook entryBook = financialTransactionSearch.getEntryBook(); String amount = financialTransactionSearch.getAmount(); String amount2 = financialTransactionSearch.getAmount2(); String operator = financialTransactionSearch.getOperator(); FinancialStatementWayEnum fStWayEnum = financialTransactionSearch.getAmountWayEnum(); - if (entryBook != null){ - query.addEquals("T."+FinancialTransaction.ENTRY_BOOK, entryBook); - } - if (amount != null){ - if (amount2 != null){ - BigDecimal value1 = new BigDecimal(amount); - BigDecimal value2 = new BigDecimal(amount2); - query.addBetween("E.amount", value1, value2); - } - else if (operator != null) { - query.addWhere("E.amount"+" "+operator+" "+amount); - } - switch (fStWayEnum) { - case CREDIT: - query.addEquals("E.debit", false); - break; - case DEBIT: - query.addEquals("E.debit", true); - break; - } - } - financialTransactions = financialTransactionDAO.findAllByQuery(query); - - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - for (FinancialTransaction financialTransaction : financialTransactions) { - result.add(financialTransaction); - - TopiaQuery query2 = entryDAO.createQuery(); - query2.addEquals(Entry.FINANCIAL_TRANSACTION, financialTransaction); - //Load for lazy - query2.addLoad(Entry.ACCOUNT, Entry.LETTER); - List<Entry> entries = entryDAO.findAllByQuery(query2); - result.addAll(entries); - } - } - catch (TopiaException ex) { - doCatch(topiaContext, ex, log); - } - finally { - doFinally(topiaContext, log); - } - return result; - } + if (entryBook != null){ + query.addEquals("T."+FinancialTransaction.ENTRY_BOOK, entryBook); + } + if (amount != null){ + if (amount2 != null){ + BigDecimal value1 = new BigDecimal(amount); + BigDecimal value2 = new BigDecimal(amount2); + query.addBetween("E.amount", value1, value2); + } + else if (operator != null) { + query.addWhere("E.amount"+" "+operator+" "+amount); + } + switch (fStWayEnum) { + case CREDIT: + query.addEquals("E.debit", false); + break; + case DEBIT: + query.addEquals("E.debit", true); + break; + } + } + financialTransactions = financialTransactionDAO.findAllByQuery(query); + + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + for (FinancialTransaction financialTransaction : financialTransactions) { + result.add(financialTransaction); + + TopiaQuery query2 = entryDAO.createQuery(); + query2.addEquals(Entry.FINANCIAL_TRANSACTION, financialTransaction); + //Load for lazy + query2.addLoad(Entry.ACCOUNT, Entry.LETTER); + List<Entry> entries = entryDAO.findAllByQuery(query2); + result.addAll(entries); + } + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + return result; + } - protected TopiaContext beginTransaction() throws TopiaException { + protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database // TODO move it into JTA TopiaContext topiaTransaction; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -82,20 +82,20 @@ } - @Override - public void createFiscalPeriodWithTransaction(FiscalPeriod fiscalPeriod, TopiaContext topiaContext) throws LimaException { + @Override + public void createFiscalPeriodWithTransaction(FiscalPeriod fiscalPeriod, TopiaContext topiaContext) throws LimaException { try { - Date beginDate = fiscalPeriod.getBeginDate(); + Date beginDate = fiscalPeriod.getBeginDate(); beginDate = DateUtils.truncate(beginDate, Calendar.DATE); Date endDate = fiscalPeriod.getEndDate(); - endDate = DateUtils.addDays(endDate, 1); - endDate = DateUtils.truncate(endDate, Calendar.DATE); - endDate = DateUtils.addMilliseconds(endDate,-1); + endDate = DateUtils.addDays(endDate, 1); + endDate = DateUtils.truncate(endDate, Calendar.DATE); + endDate = DateUtils.addMilliseconds(endDate,-1); - fiscalPeriod.setBeginDate(beginDate); - fiscalPeriod.setEndDate(endDate); - + fiscalPeriod.setBeginDate(beginDate); + fiscalPeriod.setEndDate(endDate); + //check rules before create the account List<FinancialPeriod> financialPeriods = accountingRules.createFiscalPeriodRules(fiscalPeriod, topiaContext); @@ -103,17 +103,17 @@ createFinancialPeriodsWithTransaction(financialPeriods, topiaContext); FiscalPeriodDAO fiscalPeriodDAO = - LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext); + LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext); - //create + //create fiscalPeriodDAO.create(fiscalPeriod); commitTransaction(topiaContext); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } - } + } + } /** * To create a fiscalperiod @@ -149,7 +149,7 @@ transaction = beginTransaction(); FiscalPeriodDAO fiscalPeriodDAO = - LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); + LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); result = fiscalPeriodDAO.findAll(); } catch (TopiaException ex) { Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -64,7 +64,7 @@ public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService, HttpServerServiceLocal { private static final Log log = LogFactory.getLog(HttpServerServiceImpl.class); - + @EJB private DocumentService documentService; @@ -75,11 +75,11 @@ protected int port; private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd"); - + public HttpServerServiceImpl() { - path = LimaConfig.getInstance().getReportsDir(); - port = LimaConfig.getInstance().getHttpPort(); - } + path = LimaConfig.getInstance().getReportsDir(); + port = LimaConfig.getInstance().getHttpPort(); + } @@ -87,123 +87,123 @@ @Override public void start() { if (server == null) { - new File(path).mkdir(); - try { - server = new Server(port); - - Context root = new Context(server, "/", Context.NO_SESSIONS); - root.addServlet(new ServletHolder((Servlet) new MainServlet()), "/"); - server.start(); - - log.info("Web server are running on port: "+port); - - } catch (Exception eee) { - log.error("error while booting http server", eee); - } + new File(path).mkdir(); + try { + server = new Server(port); + + Context root = new Context(server, "/", Context.NO_SESSIONS); + root.addServlet(new ServletHolder((Servlet) new MainServlet()), "/"); + server.start(); + + log.info("Web server are running on port: "+port); + + } catch (Exception eee) { + log.error("error while booting http server", eee); + } } } @Override - public int getHttpPort() { - return port; - } + public int getHttpPort() { + return port; + } - /** this servlet send a static html page */ + /** this servlet send a static html page */ public class MainServlet extends HttpServlet { private static final long serialVersionUID = 1L; private String serverAddressConfig = LimaConfig.getInstance().getAddressServer(); @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - - try { - //get all params - String imageParam = req.getParameter("img"); - String model = req.getParameter("model"); + + try { + //get all params + String imageParam = req.getParameter("img"); + String model = req.getParameter("model"); String format = req.getParameter("format"); String beginDate = req.getParameter("beginDate"); - String endDate = req.getParameter("endDate"); + String endDate = req.getParameter("endDate"); - //if image - if (imageParam != null){ - URL image = Resource.getURLOrNull("images/"+imageParam); - if (image != null){ - resp.setContentType("image/png"); - InputStream in = image.openStream(); - OutputStream out = resp.getOutputStream(); - IOUtils.copy(in, out); - } - } - //if doc pdf or html - else if (model != null && format != null && beginDate != null && endDate != null){ - FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format); - URL doc = new URL("file:" + path + File.separator - + model +formatsEnum.getExtension()); - //create docs - try { - Date beginDateFormat = DATEFORMAT.parse(beginDate); - Date endDateFormat = DATEFORMAT.parse(endDate); - - switch (DocumentsEnum.valueOfLink(model)) { - case BALANCE: - documentService.createBalanceDocuments( - beginDateFormat, endDateFormat, formatsEnum); - break; - case ENTRYBOOKS: - documentService.createEntryBooksDocuments( - beginDateFormat, endDateFormat, formatsEnum); - break; - case FINANCIALSTATEMENT: - documentService.createFinancialStatementsDocuments( - beginDateFormat, endDateFormat, formatsEnum); - break; - case GENERAL_ENTRYBOOK: - documentService.createGeneralEntryBooksDocuments( - beginDateFormat, endDateFormat, formatsEnum); - break; - case LEDGER: - documentService.createLedgerDocuments( - beginDateFormat, endDateFormat, formatsEnum); - break; - } - } catch (LimaException eeeLE) { - log.error("Can't call document service for create html document", eeeLE); - } catch (ParseException eeePE) { - log.error("Can't parse date", eeePE); - } - resp.setContentType(formatsEnum.getMimeType()); - InputStream in = doc.openStream(); - OutputStream out = resp.getOutputStream(); - IOUtils.copy(in, out); - } - // else return home html - else { - resp.setContentType(FormatsEnum.HTML.getMimeType()); - StringBuffer pageContent = new StringBuffer(); - String serverAdress = "http://"; - - log.info("Page load"); - - /** create server Address : static config if exist or dynamical adress */ - if (serverAddressConfig.equals("")){ - serverAdress += req.getServerName() - + ":" + req.getServerPort(); - } - else { - serverAdress += serverAddressConfig + ":" - + LimaConfig.getInstance().getHttpPort(); - } - + //if image + if (imageParam != null){ + URL image = Resource.getURLOrNull("images/"+imageParam); + if (image != null){ + resp.setContentType("image/png"); + InputStream in = image.openStream(); + OutputStream out = resp.getOutputStream(); + IOUtils.copy(in, out); + } + } + //if doc pdf or html + else if (model != null && format != null && beginDate != null && endDate != null){ + FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format); + URL doc = new URL("file:" + path + File.separator + + model +formatsEnum.getExtension()); + //create docs + try { + Date beginDateFormat = DATEFORMAT.parse(beginDate); + Date endDateFormat = DATEFORMAT.parse(endDate); + + switch (DocumentsEnum.valueOfLink(model)) { + case BALANCE: + documentService.createBalanceDocuments( + beginDateFormat, endDateFormat, formatsEnum); + break; + case ENTRYBOOKS: + documentService.createEntryBooksDocuments( + beginDateFormat, endDateFormat, formatsEnum); + break; + case FINANCIALSTATEMENT: + documentService.createFinancialStatementsDocuments( + beginDateFormat, endDateFormat, formatsEnum); + break; + case GENERAL_ENTRYBOOK: + documentService.createGeneralEntryBooksDocuments( + beginDateFormat, endDateFormat, formatsEnum); + break; + case LEDGER: + documentService.createLedgerDocuments( + beginDateFormat, endDateFormat, formatsEnum); + break; + } + } catch (LimaException eeeLE) { + log.error("Can't call document service for create html document", eeeLE); + } catch (ParseException eeePE) { + log.error("Can't parse date", eeePE); + } + resp.setContentType(formatsEnum.getMimeType()); + InputStream in = doc.openStream(); + OutputStream out = resp.getOutputStream(); + IOUtils.copy(in, out); + } + // else return home html + else { + resp.setContentType(FormatsEnum.HTML.getMimeType()); + StringBuffer pageContent = new StringBuffer(); + String serverAdress = "http://"; + + log.info("Page load"); + + /** create server Address : static config if exist or dynamical adress */ + if (serverAddressConfig.equals("")){ + serverAdress += req.getServerName() + + ":" + req.getServerPort(); + } + else { + serverAdress += serverAddressConfig + ":" + + LimaConfig.getInstance().getHttpPort(); + } + Calendar calendar = Calendar.getInstance(); Date endDatePicker = calendar.getTime(); Date beginDatePicker = calendar.getTime(); beginDatePicker = - DateUtils.truncate(beginDatePicker, Calendar.YEAR); - - pageContent.append("<!DOCTYPE html>\n" + DateUtils.truncate(beginDatePicker, Calendar.YEAR); + + pageContent.append("<!DOCTYPE html>\n" + "<html lang=\"fr\">\n" + "<head>\n" + "<title>LIMA Documents Report</title>\n" @@ -213,7 +213,7 @@ + "table.padding td {padding-right:20px;}" + ".tdright {text-align: right;}" + "</style>" - + "</head>\n" + + "</head>\n" + "<body>\n" + "<table class=\"padding\">\n" + "<tr><td><img src=\"?img=puzzle_icon_mini.png\"/></td>\n" @@ -230,43 +230,43 @@ + "Format : <select name=\"format\">"); for (FormatsEnum formatsEnum : FormatsEnum.values()) { - pageContent.append("<option value=\"" - + formatsEnum.getExtension()+"\">" - + formatsEnum.getDescription()+"</option>\n"); - } + pageContent.append("<option value=\"" + + formatsEnum.getExtension()+"\">" + + formatsEnum.getDescription()+"</option>\n"); + } pageContent.append("</select>\n" + "Documents : <select name=\"model\">"); - + for (DocumentsEnum documentsEnum : DocumentsEnum.values()) { - pageContent.append("<option value=\"" - + documentsEnum.getFileName()+"\">" - + documentsEnum.getDescription()+"</option>\n"); - } + pageContent.append("<option value=\"" + + documentsEnum.getFileName()+"\">" + + documentsEnum.getDescription()+"</option>\n"); + } pageContent.append("</select>\n" - + "<tr><td class=\"tdright\"><img src=\"?img=entries.png\"/></td></tr>\n" + + "<tr><td class=\"tdright\"><img src=\"?img=entries.png\"/></td></tr>\n" + "<tr><td class=\"tdright\"><img src=\"?img=accounts.png\"/></td></tr>\n" + "<tr><td class=\"tdright\"><img src=\"?img=entrybooks.png\"/></td>\n" - + "<td class=\"tdright\"><input type=\"submit\"></td></tr>" + + "<td class=\"tdright\"><input type=\"submit\"></td></tr>" + "</form>\n" + "<tr><td class=\"tdright\"><img src=\"?img=fiscalperiods.png\"/></td></tr>\n" + "</table>\n" - + "</body>\n" + + "</body>\n" + "</html>"); resp.getWriter().write(pageContent.toString()); - } - }catch (GenericJDBCException eee) { - log.error("Can't read db", eee); - } + } + }catch (GenericJDBCException eee) { + log.error("Can't read db", eee); + } } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - doGet(req, resp); - + throws ServletException, IOException { + doGet(req, resp); + } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -61,70 +61,70 @@ } } } - - @Override - public Identity getIdentityWithTransaction(TopiaContext topiaContext) - throws LimaException { + + @Override + public Identity getIdentityWithTransaction(TopiaContext topiaContext) + throws LimaException { Identity identity = null; try { - IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext); - List<Identity> identities = identityDAO.findAll(); - if (identities.size() != 0){ - identity = identities.get(0); - } + IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext); + List<Identity> identities = identityDAO.findAll(); + if (identities.size() != 0){ + identity = identities.get(0); + } } catch (TopiaException ex) { doCatch(topiaContext, ex, log); } return identity; - } + } - @Override - public Identity getIdentity() throws LimaException { + @Override + public Identity getIdentity() throws LimaException { TopiaContext topiaContext = null; Identity identity = null; try { - topiaContext = beginTransaction(); + topiaContext = beginTransaction(); - identity = getIdentityWithTransaction(topiaContext); + identity = getIdentityWithTransaction(topiaContext); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); } finally { doFinally(topiaContext, log); - } + } return identity; - } - - - @Override - public void updateIdentityWithTransaction(Identity identity, - TopiaContext topiaContext) throws LimaException { - try { - IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext); - List<Identity> identities = identityDAO.findAll(); - if (identities.size() != 0){ - identityDAO.delete(identities.get(0)); - } - identityDAO.create(identity); + } + + + @Override + public void updateIdentityWithTransaction(Identity identity, + TopiaContext topiaContext) throws LimaException { + try { + IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext); + List<Identity> identities = identityDAO.findAll(); + if (identities.size() != 0){ + identityDAO.delete(identities.get(0)); + } + identityDAO.create(identity); commitTransaction(topiaContext); } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } - } - - @Override - public void updateIdentity(Identity identity) throws LimaException { + } + } + + @Override + public void updateIdentity(Identity identity) throws LimaException { TopiaContext topiaContext = null; try { - topiaContext = beginTransaction(); + topiaContext = beginTransaction(); - updateIdentityWithTransaction(identity, topiaContext); + updateIdentityWithTransaction(identity, topiaContext); commitTransaction(topiaContext); } @@ -133,8 +133,8 @@ } finally { doFinally(topiaContext, log); - } - } + } + } protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database @@ -147,7 +147,7 @@ protected void commitTransaction(TopiaContext topiaContext) throws TopiaException { try { - topiaContext.commitTransaction(); + topiaContext.commitTransaction(); } catch (TopiaException eee) { if (log.isErrorEnabled()) { log.error("Error during commit context", eee); @@ -155,5 +155,5 @@ throw eee; } } - + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -123,1090 +123,1090 @@ */ @Stateless public class ImportServiceImpl extends AbstractLimaService implements - ImportService, ImportServiceLocal { + ImportService, ImportServiceLocal { - private static final Log log = LogFactory.getLog(ImportServiceImpl.class); + private static final Log log = LogFactory.getLog(ImportServiceImpl.class); - private TopiaContext rootContext; + private TopiaContext rootContext; - // Services + // Services - @EJB - private AccountServiceLocal accountService; + @EJB + private AccountServiceLocal accountService; - @EJB - private FiscalPeriodServiceLocal fiscalPeriodService; + @EJB + private FiscalPeriodServiceLocal fiscalPeriodService; - @EJB - private FinancialPeriodServiceLocal financialPeriodService; + @EJB + private FinancialPeriodServiceLocal financialPeriodService; - @EJB - private FinancialTransactionServiceLocal financialTransactionService; + @EJB + private FinancialTransactionServiceLocal financialTransactionService; - @EJB - private FinancialStatementServiceLocal financialStatementService; + @EJB + private FinancialStatementServiceLocal financialStatementService; - @EJB - private EntryBookServiceLocal entryBookService; + @EJB + private EntryBookServiceLocal entryBookService; - @EJB - private IdentityServiceLocal identityService; + @EJB + private IdentityServiceLocal identityService; - private static final SimpleDateFormat SDATEFORMAT = new SimpleDateFormat( - "dd,MM,yyyy HH:mm:ss"); + private static final SimpleDateFormat SDATEFORMAT = new SimpleDateFormat( + "dd,MM,yyyy HH:mm:ss"); - public ImportServiceImpl() { - LimaConfig config = LimaConfig.getInstance(); - try { - rootContext = TopiaContextFactory.getContext(config.getOptions()); - } catch (TopiaNotFoundException ex) { - if (log.isErrorEnabled()) { - log.error("Can't init topia context", ex); - } - } - } + public ImportServiceImpl() { + LimaConfig config = LimaConfig.getInstance(); + try { + rootContext = TopiaContextFactory.getContext(config.getOptions()); + } catch (TopiaNotFoundException ex) { + if (log.isErrorEnabled()) { + log.error("Can't init topia context", ex); + } + } + } - // ################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################ + // ################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################ - @Override - public String importEntriesFromEbp(String datas) throws LimaException { - SimpleDateFormat epbDateFormat = new SimpleDateFormat("dd/MM/yyyy"); - StringBuffer result = new StringBuffer(); + @Override + public String importEntriesFromEbp(String datas) throws LimaException { + SimpleDateFormat epbDateFormat = new SimpleDateFormat("dd/MM/yyyy"); + StringBuffer result = new StringBuffer(); - TopiaContext topiaContext = null; - try { - topiaContext = beginTransaction(); + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); - CSVReader csvReader = new CSVReader(new StringReader(datas)); - ColumnPositionMappingStrategy<EntryEBPImpl> strat = new ColumnPositionMappingStrategy<EntryEBPImpl>(); - strat.setType(EntryEBPImpl.class); - // read header to set strategy mapping - strat.setColumnMapping(csvReader.readNext()); + CSVReader csvReader = new CSVReader(new StringReader(datas)); + ColumnPositionMappingStrategy<EntryEBPImpl> strat = new ColumnPositionMappingStrategy<EntryEBPImpl>(); + strat.setType(EntryEBPImpl.class); + // read header to set strategy mapping + strat.setColumnMapping(csvReader.readNext()); - // check if file have a good header - List<String> headEntry = new ArrayList<String>(); - headEntry.add("Journal"); - headEntry.add("Compte"); - headEntry.add("DatEcr"); - headEntry.add("Piece"); - headEntry.add("Libelle"); - headEntry.add("Debit"); - headEntry.add("Credit"); - headEntry.add("Lettre"); - if (!Arrays.asList(strat.getColumnMapping()).containsAll( - headEntry)) { - throw new LimaBusinessException( - _("lima-business.import.ebpnoentry")); - } + // check if file have a good header + List<String> headEntry = new ArrayList<String>(); + headEntry.add("Journal"); + headEntry.add("Compte"); + headEntry.add("DatEcr"); + headEntry.add("Piece"); + headEntry.add("Libelle"); + headEntry.add("Debit"); + headEntry.add("Credit"); + headEntry.add("Lettre"); + if (!Arrays.asList(strat.getColumnMapping()).containsAll( + headEntry)) { + throw new LimaBusinessException( + _("lima-business.import.ebpnoentry")); + } - CsvToBean<EntryEBPImpl> csv = new CsvToBean<EntryEBPImpl>(); - List<EntryEBPImpl> list = csv.parse(strat, csvReader); - Collections.sort(list, new EntryEBPComparator()); + CsvToBean<EntryEBPImpl> csv = new CsvToBean<EntryEBPImpl>(); + List<EntryEBPImpl> list = csv.parse(strat, csvReader); + Collections.sort(list, new EntryEBPComparator()); - // DAOs - AccountDAO accountDAO = LimaCallaoDAOHelper - .getAccountDAO(topiaContext); - EntryBookDAO entryBookDAO = LimaCallaoDAOHelper - .getEntryBookDAO(topiaContext); - List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); - Collections.sort(fiscalPeriods, new FiscalPeriodComparator()); - int nbFiscalPeriods = fiscalPeriods.size(); - FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper - .getFinancialPeriodDAO(topiaContext); + // DAOs + AccountDAO accountDAO = LimaCallaoDAOHelper + .getAccountDAO(topiaContext); + EntryBookDAO entryBookDAO = LimaCallaoDAOHelper + .getEntryBookDAO(topiaContext); + List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); + Collections.sort(fiscalPeriods, new FiscalPeriodComparator()); + int nbFiscalPeriods = fiscalPeriods.size(); + FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper + .getFinancialPeriodDAO(topiaContext); - if (nbFiscalPeriods == 0) { - throw new LimaBusinessException( - _("lima-business.import.nofiscalperiodopen")); - } + if (nbFiscalPeriods == 0) { + throw new LimaBusinessException( + _("lima-business.import.nofiscalperiodopen")); + } - FinancialTransaction financialTransaction = null; - for (EntryEBP entryEBP : list) { - // create entry - Entry entry = new EntryImpl(); - Account account = accountDAO.findByAccountNumber(entryEBP - .getCompte()); - - Date date = epbDateFormat.parse(entryEBP.getDatEcr()); - Date beginDate = fiscalPeriods.get(0).getBeginDate(); - Date endDate = fiscalPeriods.get(nbFiscalPeriods-1).getEndDate(); + FinancialTransaction financialTransaction = null; + for (EntryEBP entryEBP : list) { + // create entry + Entry entry = new EntryImpl(); + Account account = accountDAO.findByAccountNumber(entryEBP + .getCompte()); + + Date date = epbDateFormat.parse(entryEBP.getDatEcr()); + Date beginDate = fiscalPeriods.get(0).getBeginDate(); + Date endDate = fiscalPeriods.get(nbFiscalPeriods-1).getEndDate(); - //if entry date have fiscalperiod open - if (date.compareTo(beginDate) < 0 || date.compareTo(endDate) > 0){ + //if entry date have fiscalperiod open + if (date.compareTo(beginDate) < 0 || date.compareTo(endDate) > 0){ - result.append(_("lima-business.import.entriesoutofdatesrange",date)); - } - // if account not exist not export - else if (account == null) { - throw new LimaBusinessException( - _("lima-business.import.ebpmissingaccount", - entryEBP.getCompte())); - } - //create entry - else { - entry.setAccount(account); - BigDecimal debit = new BigDecimal(entryEBP.getDebit()); - BigDecimal credit = new BigDecimal(entryEBP.getCredit()); - if (debit.doubleValue() == 0) { - entry.setDebit(false); - entry.setAmount(credit); - } else { - entry.setDebit(true); - entry.setAmount(debit); - } - entry.setDescription(entryEBP.getLibelle()); - entry.setVoucher(entryEBP.getPiece()); - - Letter letter = createLetter( - entryEBP.getLettre(), topiaContext); - entry.setLetter(letter); - - String entryBookCode = entryEBP.getJournal(); - EntryBook entryBook = entryBookDAO - .findByCode(entryBookCode); - // if entrybook not exist create it ! - if (entryBook == null) { - entryBook = new EntryBookImpl(); - entryBook.setCode(entryBookCode); - // create it - entryBookService.createEntryBook(entryBook); - result.append(_("lima-business.import.entrybooknotexist",entryBook)); - } - //create transaction - if (financialTransaction == null - || !(date.equals(financialTransaction.getTransactionDate()) - && entryBook.getCode().equals(financialTransaction.getEntryBook().getCode()))) { - - // update previous financial transaction before create - // new - if (financialTransaction != null) { - //call methode to calculte amounts - financialTransaction.setAmounts(); - financialTransactionService - .updateFinancialTransactionWithTransaction( - financialTransaction, topiaContext); - } - // create financial transaction - financialTransaction = new FinancialTransactionImpl(); - financialTransaction.setEntryBook(entryBook); - financialTransaction.setTransactionDate(date); - FinancialPeriod financialPeriod = financialPeriodDAO - .findByDate(date); - financialTransaction - .setFinancialPeriod(financialPeriod); - financialTransactionService - .createFinancialTransactionWithTransaction( - financialTransaction, topiaContext); - result.append(_("lima-business.import.transactionadded", date, entryBook.getCode())); + result.append(_("lima-business.import.entriesoutofdatesrange",date)); + } + // if account not exist not export + else if (account == null) { + throw new LimaBusinessException( + _("lima-business.import.ebpmissingaccount", + entryEBP.getCompte())); + } + //create entry + else { + entry.setAccount(account); + BigDecimal debit = new BigDecimal(entryEBP.getDebit()); + BigDecimal credit = new BigDecimal(entryEBP.getCredit()); + if (debit.doubleValue() == 0) { + entry.setDebit(false); + entry.setAmount(credit); + } else { + entry.setDebit(true); + entry.setAmount(debit); + } + entry.setDescription(entryEBP.getLibelle()); + entry.setVoucher(entryEBP.getPiece()); + + Letter letter = createLetter( + entryEBP.getLettre(), topiaContext); + entry.setLetter(letter); + + String entryBookCode = entryEBP.getJournal(); + EntryBook entryBook = entryBookDAO + .findByCode(entryBookCode); + // if entrybook not exist create it ! + if (entryBook == null) { + entryBook = new EntryBookImpl(); + entryBook.setCode(entryBookCode); + // create it + entryBookService.createEntryBook(entryBook); + result.append(_("lima-business.import.entrybooknotexist",entryBook)); + } + //create transaction + if (financialTransaction == null + || !(date.equals(financialTransaction.getTransactionDate()) + && entryBook.getCode().equals(financialTransaction.getEntryBook().getCode()))) { + + // update previous financial transaction before create + // new + if (financialTransaction != null) { + //call methode to calculte amounts + financialTransaction.setAmounts(); + financialTransactionService + .updateFinancialTransactionWithTransaction( + financialTransaction, topiaContext); + } + // create financial transaction + financialTransaction = new FinancialTransactionImpl(); + financialTransaction.setEntryBook(entryBook); + financialTransaction.setTransactionDate(date); + FinancialPeriod financialPeriod = financialPeriodDAO + .findByDate(date); + financialTransaction + .setFinancialPeriod(financialPeriod); + financialTransactionService + .createFinancialTransactionWithTransaction( + financialTransaction, topiaContext); + result.append(_("lima-business.import.transactionadded", date, entryBook.getCode())); - } - financialTransaction.addEntry(entry); - financialTransactionService.createEntryWithTransaction( - entry, topiaContext); - result.append(_("lima-business.import.entryadded", entry.getDescription(), entry.getAmount())); - } - } - // update last financial transaction - if (financialTransaction != null) { - financialTransaction.setAmounts(); - financialTransactionService - .updateFinancialTransactionWithTransaction( - financialTransaction, topiaContext); - } - // commit - commitTransaction(topiaContext); - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } catch (IOException eeeIO) { - log.error("Can't read string", eeeIO); - } catch (ParseException eeePE) { - log.error("Can't parse date", eeePE); - } finally { - doFinally(topiaContext, log); - } - return result.toString(); - } + } + financialTransaction.addEntry(entry); + financialTransactionService.createEntryWithTransaction( + entry, topiaContext); + result.append(_("lima-business.import.entryadded", entry.getDescription(), entry.getAmount())); + } + } + // update last financial transaction + if (financialTransaction != null) { + financialTransaction.setAmounts(); + financialTransactionService + .updateFinancialTransactionWithTransaction( + financialTransaction, topiaContext); + } + // commit + commitTransaction(topiaContext); + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } catch (IOException eeeIO) { + log.error("Can't read string", eeeIO); + } catch (ParseException eeePE) { + log.error("Can't parse date", eeePE); + } finally { + doFinally(topiaContext, log); + } + return result.toString(); + } - @Override - public String importAccountsChartFromEbp(String datas) throws LimaException { - StringBuffer result = new StringBuffer(); - TopiaContext topiaContext = null; + @Override + public String importAccountsChartFromEbp(String datas) throws LimaException { + StringBuffer result = new StringBuffer(); + TopiaContext topiaContext = null; - try { - topiaContext = beginTransaction(); - CSVReader csvReader = new CSVReader(new StringReader(datas)); - ColumnPositionMappingStrategy<AccountEBPImpl> strat = new ColumnPositionMappingStrategy<AccountEBPImpl>(); - strat.setType(AccountEBPImpl.class); - // read header to set strategy mapping - strat.setColumnMapping(csvReader.readNext()); + try { + topiaContext = beginTransaction(); + CSVReader csvReader = new CSVReader(new StringReader(datas)); + ColumnPositionMappingStrategy<AccountEBPImpl> strat = new ColumnPositionMappingStrategy<AccountEBPImpl>(); + strat.setType(AccountEBPImpl.class); + // read header to set strategy mapping + strat.setColumnMapping(csvReader.readNext()); - // check if file have a good header - List<String> headAccount = new ArrayList<String>(); - headAccount.add("Numero"); - headAccount.add("Intitule"); - if (!Arrays.asList(strat.getColumnMapping()).containsAll( - headAccount)) { - throw new LimaBusinessException( - _("lima-business.import.noaccount")); - } + // check if file have a good header + List<String> headAccount = new ArrayList<String>(); + headAccount.add("Numero"); + headAccount.add("Intitule"); + if (!Arrays.asList(strat.getColumnMapping()).containsAll( + headAccount)) { + throw new LimaBusinessException( + _("lima-business.import.noaccount")); + } - CsvToBean<AccountEBPImpl> csv = new CsvToBean<AccountEBPImpl>(); - List<AccountEBPImpl> list = csv.parse(strat, csvReader); - Collections.sort(list, new AccountEBPComparator()); + CsvToBean<AccountEBPImpl> csv = new CsvToBean<AccountEBPImpl>(); + List<AccountEBPImpl> list = csv.parse(strat, csvReader); + Collections.sort(list, new AccountEBPComparator()); - AccountDAO accountDAO = LimaCallaoDAOHelper - .getAccountDAO(topiaContext); - for (AccountEBP accountEBP : list) { - String accountNumber = accountEBP.getNumero(); - if (accountDAO.findByAccountNumber(accountNumber) != null) { - result.append(_("lima-business.import.accountalreadyexist", accountNumber)); - } else { - String label = accountEBP.getIntitule(); - Account account = new AccountImpl(); - account.setAccountNumber(accountNumber); - account.setLabel(label); + AccountDAO accountDAO = LimaCallaoDAOHelper + .getAccountDAO(topiaContext); + for (AccountEBP accountEBP : list) { + String accountNumber = accountEBP.getNumero(); + if (accountDAO.findByAccountNumber(accountNumber) != null) { + result.append(_("lima-business.import.accountalreadyexist", accountNumber)); + } else { + String label = accountEBP.getIntitule(); + Account account = new AccountImpl(); + account.setAccountNumber(accountNumber); + account.setLabel(label); - // if is thirdPart account - if (!StringUtils.isNumeric(accountNumber)){ - Account masterAccount = null; - int i = 1; - while (masterAccount == null) { - String masterAccountNumber = accountNumber - .substring(0, accountNumber.length() - i); - masterAccount = accountDAO - .findByAccountNumber(masterAccountNumber); - i++; - } - accountService.createSubLedgerWithTransaction( - masterAccount, account, topiaContext); - result.append(_("lima-business.import.accountadded", accountNumber, label)); - } - // else if account and exclude account start with 0 (fix from error on EBP) - else if (!accountNumber.startsWith("0")){ - // if account is class account : 1, 2, 3, 4, 5, 6, 7,… - int nbCharAccountNumber = accountNumber.length(); - if (nbCharAccountNumber == 1) { - accountService.createAccountWithTransaction(null, - account, topiaContext); - result.append(_("lima-business.import.accountadded", accountNumber, label)); - } - else { - Account masterAccount = null; - int i = 1; - while (masterAccount == null) { - String masterAccountNumber = accountNumber - .substring(0, accountNumber.length() - i); - masterAccount = accountDAO - .findByAccountNumber(masterAccountNumber); - i++; - } - accountService.createAccountWithTransaction( - masterAccount, account, topiaContext); - result.append(_("lima-business.import.accountadded", accountNumber, label)); - } - } - } - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } catch (IOException eeeIO) { - log.error("Can't read string", eeeIO); - } finally { - doFinally(topiaContext, log); - } + // if is thirdPart account + if (!StringUtils.isNumeric(accountNumber)){ + Account masterAccount = null; + int i = 1; + while (masterAccount == null) { + String masterAccountNumber = accountNumber + .substring(0, accountNumber.length() - i); + masterAccount = accountDAO + .findByAccountNumber(masterAccountNumber); + i++; + } + accountService.createSubLedgerWithTransaction( + masterAccount, account, topiaContext); + result.append(_("lima-business.import.accountadded", accountNumber, label)); + } + // else if account and exclude account start with 0 (fix from error on EBP) + else if (!accountNumber.startsWith("0")){ + // if account is class account : 1, 2, 3, 4, 5, 6, 7,… + int nbCharAccountNumber = accountNumber.length(); + if (nbCharAccountNumber == 1) { + accountService.createAccountWithTransaction(null, + account, topiaContext); + result.append(_("lima-business.import.accountadded", accountNumber, label)); + } + else { + Account masterAccount = null; + int i = 1; + while (masterAccount == null) { + String masterAccountNumber = accountNumber + .substring(0, accountNumber.length() - i); + masterAccount = accountDAO + .findByAccountNumber(masterAccountNumber); + i++; + } + accountService.createAccountWithTransaction( + masterAccount, account, topiaContext); + result.append(_("lima-business.import.accountadded", accountNumber, label)); + } + } + } + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } catch (IOException eeeIO) { + log.error("Can't read string", eeeIO); + } finally { + doFinally(topiaContext, log); + } - return result.toString(); - } + return result.toString(); + } - @Override - public void importAsCiel(byte[] data) throws LimaException { - // TODO Auto-generated method stub + @Override + public void importAsCiel(byte[] data) throws LimaException { + // TODO Auto-generated method stub - } + } - @Override - public void importAsSage(byte[] data) throws LimaException { - // TODO Auto-generated method stub + @Override + public void importAsSage(byte[] data) throws LimaException { + // TODO Auto-generated method stub - } + } - // ################ IMPORT ################ + // ################ IMPORT ################ - /** - * Remote methode to call all entities import from UI - */ - @Override - public String importAllAsCSV(String datas) throws LimaException { - StringBuffer result = new StringBuffer(); + /** + * Remote methode to call all entities import from UI + */ + @Override + public String importAllAsCSV(String datas) throws LimaException { + StringBuffer result = new StringBuffer(); - Map<String, AccountImport> accounts = new TreeMap<String, AccountImport>(); + Map<String, AccountImport> accounts = new TreeMap<String, AccountImport>(); - LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements = - new LinkedHashMap<String, ArrayList<FinancialStatementImport>>(); + LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements = + new LinkedHashMap<String, ArrayList<FinancialStatementImport>>(); - List<FiscalPeriod> fiscalPeriods = new ArrayList<FiscalPeriod>(); + List<FiscalPeriod> fiscalPeriods = new ArrayList<FiscalPeriod>(); - List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks = - new ArrayList<ClosedPeriodicEntryBookImport>(); + List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks = + new ArrayList<ClosedPeriodicEntryBookImport>(); - Map<Integer, FinancialTransactionImport> financialTransactions = - new HashMap<Integer, FinancialTransactionImport>(); + Map<Integer, FinancialTransactionImport> financialTransactions = + new HashMap<Integer, FinancialTransactionImport>(); - Map<Integer, List<EntryImport>> entries = - new HashMap<Integer, List<EntryImport>>(); + Map<Integer, List<EntryImport>> entries = + new HashMap<Integer, List<EntryImport>>(); - TopiaContext topiaContext = null; - try { - topiaContext = beginTransaction(); + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); - String[] nextLine = new String[1]; - CSVReader csvReader = new CSVReader(new StringReader(datas), ';'); + String[] nextLine = new String[1]; + CSVReader csvReader = new CSVReader(new StringReader(datas), ';'); - while ((nextLine = csvReader.readNext()) != null) { - ImportExportEntityEnum importExportEntityEnum = ImportExportEntityEnum - .valueOfLabel(nextLine[0]); - if (importExportEntityEnum != null) { - switch (importExportEntityEnum) { - case ACCOUNT: - result.append(importAccountsChartsCSV(nextLine, accounts, - topiaContext)); - break; - case ENTRYBOOK: - result.append(importEntryBooksChartCSV(nextLine, - topiaContext)); - break; - case FINANCIALSTATEMENT: - result.append(importFinancialsStatementChartCSV(nextLine, - financialStatements, topiaContext)); - break; - case FISCALPERIOD: - result.append(importFiscalPeriodCSV(nextLine, - fiscalPeriods, topiaContext)); - break; - case CLOSEDPERIODICENTRYBOOK: - importClosedPeriodicEntryBookCSV(nextLine, - closedPeriodicEntryBooks, topiaContext); - break; - case FINANCIALTRANSACTION: - importFinancialTransactionsCSV(nextLine, - financialTransactions, topiaContext); - break; - case ENTRY: - importEntriesCSV(nextLine, entries, topiaContext); - break; - case IDENTITY: - importIdentity(nextLine, topiaContext); - break; - } - } - } + while ((nextLine = csvReader.readNext()) != null) { + ImportExportEntityEnum importExportEntityEnum = ImportExportEntityEnum + .valueOfLabel(nextLine[0]); + if (importExportEntityEnum != null) { + switch (importExportEntityEnum) { + case ACCOUNT: + result.append(importAccountsChartsCSV(nextLine, accounts, + topiaContext)); + break; + case ENTRYBOOK: + result.append(importEntryBooksChartCSV(nextLine, + topiaContext)); + break; + case FINANCIALSTATEMENT: + result.append(importFinancialsStatementChartCSV(nextLine, + financialStatements, topiaContext)); + break; + case FISCALPERIOD: + result.append(importFiscalPeriodCSV(nextLine, + fiscalPeriods, topiaContext)); + break; + case CLOSEDPERIODICENTRYBOOK: + importClosedPeriodicEntryBookCSV(nextLine, + closedPeriodicEntryBooks, topiaContext); + break; + case FINANCIALTRANSACTION: + importFinancialTransactionsCSV(nextLine, + financialTransactions, topiaContext); + break; + case ENTRY: + importEntriesCSV(nextLine, entries, topiaContext); + break; + case IDENTITY: + importIdentity(nextLine, topiaContext); + break; + } + } + } - // create accounts - result.append(createAccounts(accounts, topiaContext)); - // create financialStatements - result.append(createFinancialStatements(financialStatements, - topiaContext)); - // create fiscalperiod - Collections.sort(fiscalPeriods, new FiscalPeriodComparator()); - result.append(createFiscalPeriod(fiscalPeriods, topiaContext)); - // update closedperiodicentrybooks - result.append(updateClosedPeriodicEntryBooks(closedPeriodicEntryBooks, - topiaContext)); - // create financialtransaction and entries - result.append(createFinancialTransactionsAndEntries( - financialTransactions, entries, topiaContext)); + // create accounts + result.append(createAccounts(accounts, topiaContext)); + // create financialStatements + result.append(createFinancialStatements(financialStatements, + topiaContext)); + // create fiscalperiod + Collections.sort(fiscalPeriods, new FiscalPeriodComparator()); + result.append(createFiscalPeriod(fiscalPeriods, topiaContext)); + // update closedperiodicentrybooks + result.append(updateClosedPeriodicEntryBooks(closedPeriodicEntryBooks, + topiaContext)); + // create financialtransaction and entries + result.append(createFinancialTransactionsAndEntries( + financialTransactions, entries, topiaContext)); - commitTransaction(topiaContext); + commitTransaction(topiaContext); - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } catch (IOException eeeIO) { - log.error("Can't create new CSV Reader", eeeIO); - } finally { - doFinally(topiaContext, log); - } - return result.toString(); - } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } catch (IOException eeeIO) { + log.error("Can't create new CSV Reader", eeeIO); + } finally { + doFinally(topiaContext, log); + } + return result.toString(); + } - /** - * Remote methode to call entity import from UI - * This methode let import just on type of entity - */ - @Override - public String importAsCSV(String datas, ImportExportEntityEnum importExportEntityEnum) throws LimaException { - StringBuffer result = new StringBuffer(); + /** + * Remote methode to call entity import from UI + * This methode let import just on type of entity + */ + @Override + public String importAsCSV(String datas, ImportExportEntityEnum importExportEntityEnum) throws LimaException { + StringBuffer result = new StringBuffer(); - // FinancialStatements - LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements = null; - // Accounts - Map<String, AccountImport> accounts = null; - - switch (importExportEntityEnum) { - case ACCOUNT: - accounts = new TreeMap<String, AccountImport>(); - break; - case FINANCIALSTATEMENT: - financialStatements = new LinkedHashMap<String, ArrayList<FinancialStatementImport>>(); - break; - } - - TopiaContext topiaContext = null; - try { - topiaContext = beginTransaction(); + // FinancialStatements + LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements = null; + // Accounts + Map<String, AccountImport> accounts = null; + + switch (importExportEntityEnum) { + case ACCOUNT: + accounts = new TreeMap<String, AccountImport>(); + break; + case FINANCIALSTATEMENT: + financialStatements = new LinkedHashMap<String, ArrayList<FinancialStatementImport>>(); + break; + } + + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); - String[] nextLine = new String[1]; - CSVReader csvReader = new CSVReader(new StringReader(datas), ';'); + String[] nextLine = new String[1]; + CSVReader csvReader = new CSVReader(new StringReader(datas), ';'); - while ((nextLine = csvReader.readNext()) != null) { - if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == importExportEntityEnum) { - switch (importExportEntityEnum) { - case ENTRYBOOK: - result.append(importEntryBooksChartCSV(nextLine, topiaContext)); - break; + while ((nextLine = csvReader.readNext()) != null) { + if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == importExportEntityEnum) { + switch (importExportEntityEnum) { + case ENTRYBOOK: + result.append(importEntryBooksChartCSV(nextLine, topiaContext)); + break; - case ACCOUNT: - result.append(importAccountsChartsCSV(nextLine, accounts, - topiaContext)); - break; - case FINANCIALSTATEMENT: + case ACCOUNT: + result.append(importAccountsChartsCSV(nextLine, accounts, + topiaContext)); + break; + case FINANCIALSTATEMENT: - result.append(importFinancialsStatementChartCSV(nextLine, - financialStatements, topiaContext)); - break; - } - } - } + result.append(importFinancialsStatementChartCSV(nextLine, + financialStatements, topiaContext)); + break; + } + } + } - //create entity - switch (importExportEntityEnum) { - case ACCOUNT: - result.append(createAccounts(accounts, topiaContext)); - break; - case FINANCIALSTATEMENT: - result.append(createFinancialStatements(financialStatements, - topiaContext)); - break; - } - - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } catch (IOException eeeIO) { - log.error("Can't create new CSV Reader", eeeIO); - } finally { - doFinally(topiaContext, log); - } - return result.toString(); - } - + //create entity + switch (importExportEntityEnum) { + case ACCOUNT: + result.append(createAccounts(accounts, topiaContext)); + break; + case FINANCIALSTATEMENT: + result.append(createFinancialStatements(financialStatements, + topiaContext)); + break; + } + + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } catch (IOException eeeIO) { + log.error("Can't create new CSV Reader", eeeIO); + } finally { + doFinally(topiaContext, log); + } + return result.toString(); + } + - // ################ Import entities an put to lists ################ + // ################ Import entities an put to lists ################ - /** - * Import and create accounts Structure : TYPE | accountNumber | label - * | thirdparty | masterAccountNumber | generalLedgerNumber - */ - public String importAccountsChartsCSV(String[] nextLine, - Map<String, AccountImport> accounts, TopiaContext topiaContext) - throws LimaException { - StringBuffer result = new StringBuffer(); - String accountNumber = nextLine[1]; - String label = nextLine[2]; - String thirdParty = nextLine[3]; - String masterAccountNumber = nextLine[4]; - String generalLedgerNumber = nextLine[5]; + /** + * Import and create accounts Structure : TYPE | accountNumber | label + * | thirdparty | masterAccountNumber | generalLedgerNumber + */ + public String importAccountsChartsCSV(String[] nextLine, + Map<String, AccountImport> accounts, TopiaContext topiaContext) + throws LimaException { + StringBuffer result = new StringBuffer(); + String accountNumber = nextLine[1]; + String label = nextLine[2]; + String thirdParty = nextLine[3]; + String masterAccountNumber = nextLine[4]; + String generalLedgerNumber = nextLine[5]; - try { - AccountDAO accountDAO = LimaCallaoDAOHelper - .getAccountDAO(topiaContext); + try { + AccountDAO accountDAO = LimaCallaoDAOHelper + .getAccountDAO(topiaContext); - // if not exist, create it - if (accountDAO.findByAccountNumber(accountNumber) == null) { - // create it - AccountImport accountImport = new AccountImportImpl(); - accountImport.setAccountNumber(accountNumber); - accountImport.setLabel(label); - accountImport.setThirdParty(thirdParty); - accountImport.setMasterAccount(masterAccountNumber); - accountImport.setGeneralLedger(generalLedgerNumber); - // put it in hashset - accounts.put(accountNumber, accountImport); - } else { - result.append(_("lima-business.import.accountalreadyexist", accountNumber)); - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return result.toString(); - } + // if not exist, create it + if (accountDAO.findByAccountNumber(accountNumber) == null) { + // create it + AccountImport accountImport = new AccountImportImpl(); + accountImport.setAccountNumber(accountNumber); + accountImport.setLabel(label); + accountImport.setThirdParty(thirdParty); + accountImport.setMasterAccount(masterAccountNumber); + accountImport.setGeneralLedger(generalLedgerNumber); + // put it in hashset + accounts.put(accountNumber, accountImport); + } else { + result.append(_("lima-business.import.accountalreadyexist", accountNumber)); + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } - /** - * Import and create fiscal period Structure : TYPE | BeginDate | EndDate - * | Locked - */ - public String importFiscalPeriodCSV(String[] nextLine, - List<FiscalPeriod> fiscalPeriods, TopiaContext topiaContext) - throws LimaException { - StringBuffer result = new StringBuffer(); - try { - FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper - .getFiscalPeriodDAO(topiaContext); + /** + * Import and create fiscal period Structure : TYPE | BeginDate | EndDate + * | Locked + */ + public String importFiscalPeriodCSV(String[] nextLine, + List<FiscalPeriod> fiscalPeriods, TopiaContext topiaContext) + throws LimaException { + StringBuffer result = new StringBuffer(); + try { + FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper + .getFiscalPeriodDAO(topiaContext); - FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); - Date beginDate = SDATEFORMAT.parse(nextLine[1]); - fiscalPeriod.setBeginDate(beginDate); - Date endDate = SDATEFORMAT.parse(nextLine[2]); - fiscalPeriod.setEndDate(endDate); - fiscalPeriod.setLocked(Boolean.parseBoolean(nextLine[3])); + FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); + Date beginDate = SDATEFORMAT.parse(nextLine[1]); + fiscalPeriod.setBeginDate(beginDate); + Date endDate = SDATEFORMAT.parse(nextLine[2]); + fiscalPeriod.setEndDate(endDate); + fiscalPeriod.setLocked(Boolean.parseBoolean(nextLine[3])); - // if not exist, skip - if (fiscalPeriodDAO.findByNaturalId(beginDate, endDate) == null) { - fiscalPeriods.add(fiscalPeriod); - } else { - result.append(_("lima-business.import.fiscalperiodalreadyexist", beginDate , endDate)); - } - } catch (ParseException eeePE) { - log.error("Can't parse date", eeePE); - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return result.toString(); - } + // if not exist, skip + if (fiscalPeriodDAO.findByNaturalId(beginDate, endDate) == null) { + fiscalPeriods.add(fiscalPeriod); + } else { + result.append(_("lima-business.import.fiscalperiodalreadyexist", beginDate , endDate)); + } + } catch (ParseException eeePE) { + log.error("Can't parse date", eeePE); + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } - /** - * Import and create entrybooks Structure : TYPE | Code | Label | Type - */ - public String importEntryBooksChartCSV(String[] nextLine, - TopiaContext topiaContext) throws LimaException { - StringBuffer result = new StringBuffer(); - try { + /** + * Import and create entrybooks Structure : TYPE | Code | Label | Type + */ + public String importEntryBooksChartCSV(String[] nextLine, + TopiaContext topiaContext) throws LimaException { + StringBuffer result = new StringBuffer(); + try { - EntryBookDAO entryBookDAO = LimaCallaoDAOHelper - .getEntryBookDAO(topiaContext); + EntryBookDAO entryBookDAO = LimaCallaoDAOHelper + .getEntryBookDAO(topiaContext); - EntryBook entryBook = new EntryBookImpl(); - entryBook.setCode(nextLine[1]); - entryBook.setLabel(nextLine[2]); + EntryBook entryBook = new EntryBookImpl(); + entryBook.setCode(nextLine[1]); + entryBook.setLabel(nextLine[2]); - // if exist, skip - if (entryBookDAO.findByCode(entryBook.getCode()) != null) { - result.append(_("lima-business.import.entrybookalreadyexist", entryBook.getLabel())); - } else { - // create it - entryBookService.createEntryBook(entryBook); - result.append(_("lima-business.import.financialstatementadded", entryBook.getLabel())); - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return result.toString(); - } - - - /** - * Import and create Letter : TYPE | Code - */ - public String importLetterCSV(String[] nextLine, - TopiaContext topiaContext) throws LimaException { - StringBuffer result = new StringBuffer(); - try { + // if exist, skip + if (entryBookDAO.findByCode(entryBook.getCode()) != null) { + result.append(_("lima-business.import.entrybookalreadyexist", entryBook.getLabel())); + } else { + // create it + entryBookService.createEntryBook(entryBook); + result.append(_("lima-business.import.financialstatementadded", entryBook.getLabel())); + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } + + + /** + * Import and create Letter : TYPE | Code + */ + public String importLetterCSV(String[] nextLine, + TopiaContext topiaContext) throws LimaException { + StringBuffer result = new StringBuffer(); + try { - LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); - Letter letter = new LetterImpl(); - String code = nextLine[1]; - letter.setCode(code); + Letter letter = new LetterImpl(); + String code = nextLine[1]; + letter.setCode(code); - // if exist, skip - if (letterDAO.findByCode(code) != null) { - result.append(_("lima-business.import.letteralreadyexist", code)); - } else { - // create it - financialTransactionService.createLetter(letter); - result.append(_("lima-business.import.letteradded",code)); - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return result.toString(); - } + // if exist, skip + if (letterDAO.findByCode(code) != null) { + result.append(_("lima-business.import.letteralreadyexist", code)); + } else { + // create it + financialTransactionService.createLetter(letter); + result.append(_("lima-business.import.letteradded",code)); + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } - /** - * Import and create closedperiodicentrybook import Structure : TYPE | - * BeginDate | EndDate | Locked - */ - public void importClosedPeriodicEntryBookCSV(String[] nextLine, - List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks, - TopiaContext topiaContext) throws LimaException { - String locked = nextLine[1]; - String beginDate = nextLine[2]; - String endDate = nextLine[3]; - String entryBookCode = nextLine[4]; + /** + * Import and create closedperiodicentrybook import Structure : TYPE | + * BeginDate | EndDate | Locked + */ + public void importClosedPeriodicEntryBookCSV(String[] nextLine, + List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks, + TopiaContext topiaContext) throws LimaException { + String locked = nextLine[1]; + String beginDate = nextLine[2]; + String endDate = nextLine[3]; + String entryBookCode = nextLine[4]; - if (Boolean.parseBoolean(locked)) { - ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport = new ClosedPeriodicEntryBookImportImpl(); - closedPeriodicEntryBookImport.setLocked(locked); - closedPeriodicEntryBookImport - .setBeginDateFinancialPeriod(beginDate); - closedPeriodicEntryBookImport.setEndDateFinancialPeriod(endDate); - closedPeriodicEntryBookImport.setCodeEntryBook(entryBookCode); + if (Boolean.parseBoolean(locked)) { + ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport = new ClosedPeriodicEntryBookImportImpl(); + closedPeriodicEntryBookImport.setLocked(locked); + closedPeriodicEntryBookImport + .setBeginDateFinancialPeriod(beginDate); + closedPeriodicEntryBookImport.setEndDateFinancialPeriod(endDate); + closedPeriodicEntryBookImport.setCodeEntryBook(entryBookCode); - closedPeriodicEntryBooks.add(closedPeriodicEntryBookImport); - } - } + closedPeriodicEntryBooks.add(closedPeriodicEntryBookImport); + } + } - /** - * Import and create financialstatement Structure : TYPE | label | header - * | accounts | debitAccount | creditAccount | - * provisitionDeprecationAccounts | subAmount | headerAmount - * | masterFinancialStatement - */ + /** + * Import and create financialstatement Structure : TYPE | label | header + * | accounts | debitAccount | creditAccount | + * provisitionDeprecationAccounts | subAmount | headerAmount + * | masterFinancialStatement + */ - public String importFinancialsStatementChartCSV(String[] nextLine, - LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements, - TopiaContext topiaContext) throws LimaException { - StringBuffer result = new StringBuffer(); + public String importFinancialsStatementChartCSV(String[] nextLine, + LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements, + TopiaContext topiaContext) throws LimaException { + StringBuffer result = new StringBuffer(); - String label = nextLine[1]; - String header = nextLine[2]; - String accounts = nextLine[3]; - String debitAccounts = nextLine[4]; - String creditAccounts = nextLine[5]; - String provisionDeprecationAccounts = nextLine[6]; - String subAmount = nextLine[7]; - String headerAmount = nextLine[8]; - String masterFinancialStatement = nextLine[9]; - String financialStatementWay = nextLine[10]; + String label = nextLine[1]; + String header = nextLine[2]; + String accounts = nextLine[3]; + String debitAccounts = nextLine[4]; + String creditAccounts = nextLine[5]; + String provisionDeprecationAccounts = nextLine[6]; + String subAmount = nextLine[7]; + String headerAmount = nextLine[8]; + String masterFinancialStatement = nextLine[9]; + String financialStatementWay = nextLine[10]; - try { - FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper - .getFinancialStatementDAO(topiaContext); + try { + FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper + .getFinancialStatementDAO(topiaContext); - // if exist, skip - if (financialStatementDAO.findByLabel(label) == null) { - // create it - FinancialStatementImport financialStatementImport = new FinancialStatementImportImpl(); - financialStatementImport.setLabel(label); - financialStatementImport.setHeader(header); - financialStatementImport.setAccounts(accounts); - financialStatementImport.setCreditAccounts(creditAccounts); - financialStatementImport.setDebitAccounts(debitAccounts); - financialStatementImport.setHeaderAmount(headerAmount); - financialStatementImport - .setProvisionDeprecationAccounts(provisionDeprecationAccounts); - financialStatementImport.setSubAmount(subAmount); - financialStatementImport - .setMasterFinancialStatement(masterFinancialStatement); - financialStatementImport.setWay(financialStatementWay); + // if exist, skip + if (financialStatementDAO.findByLabel(label) == null) { + // create it + FinancialStatementImport financialStatementImport = new FinancialStatementImportImpl(); + financialStatementImport.setLabel(label); + financialStatementImport.setHeader(header); + financialStatementImport.setAccounts(accounts); + financialStatementImport.setCreditAccounts(creditAccounts); + financialStatementImport.setDebitAccounts(debitAccounts); + financialStatementImport.setHeaderAmount(headerAmount); + financialStatementImport + .setProvisionDeprecationAccounts(provisionDeprecationAccounts); + financialStatementImport.setSubAmount(subAmount); + financialStatementImport + .setMasterFinancialStatement(masterFinancialStatement); + financialStatementImport.setWay(financialStatementWay); - // put it in hashlinkedlist - if (financialStatements.containsKey(label)){ - financialStatements.get(label).add(financialStatementImport); - } - else { - List<FinancialStatementImport> list = new ArrayList<FinancialStatementImport>(); - list.add(financialStatementImport); - financialStatements.put(label, (ArrayList<FinancialStatementImport>) list); - } - } else { - result.append(_("lima-business.import.financialstatementalreadyexist", label)); - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return result.toString(); - } + // put it in hashlinkedlist + if (financialStatements.containsKey(label)){ + financialStatements.get(label).add(financialStatementImport); + } + else { + List<FinancialStatementImport> list = new ArrayList<FinancialStatementImport>(); + list.add(financialStatementImport); + financialStatements.put(label, (ArrayList<FinancialStatementImport>) list); + } + } else { + result.append(_("lima-business.import.financialstatementalreadyexist", label)); + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } - /** - * Import and create financialtransactions Structue : TYPE | NumTransac | - * TransactionDate | AmountDebit | AmountCredit | FinancialPeriod BeginDate - * | FinancialPeriod EndDate | EntryBook Code - */ - public void importFinancialTransactionsCSV(String[] nextLine, - Map<Integer, FinancialTransactionImport> financialTransactions, - TopiaContext topiaContext) throws LimaException { - int num = new Integer(nextLine[1]); - FinancialTransactionImport financialTransactionImport = new FinancialTransactionImportImpl(); - financialTransactionImport.setDate(nextLine[2]); - financialTransactionImport.setAmountDebit(nextLine[3]); - financialTransactionImport.setAmountCredit(nextLine[4]); - financialTransactionImport.setBeginDateFinancialPeriod(nextLine[5]); - financialTransactionImport.setEndDateFinancialPeriod(nextLine[6]); - financialTransactionImport.setCodeEntryBook(nextLine[7]); + /** + * Import and create financialtransactions Structue : TYPE | NumTransac | + * TransactionDate | AmountDebit | AmountCredit | FinancialPeriod BeginDate + * | FinancialPeriod EndDate | EntryBook Code + */ + public void importFinancialTransactionsCSV(String[] nextLine, + Map<Integer, FinancialTransactionImport> financialTransactions, + TopiaContext topiaContext) throws LimaException { + int num = new Integer(nextLine[1]); + FinancialTransactionImport financialTransactionImport = new FinancialTransactionImportImpl(); + financialTransactionImport.setDate(nextLine[2]); + financialTransactionImport.setAmountDebit(nextLine[3]); + financialTransactionImport.setAmountCredit(nextLine[4]); + financialTransactionImport.setBeginDateFinancialPeriod(nextLine[5]); + financialTransactionImport.setEndDateFinancialPeriod(nextLine[6]); + financialTransactionImport.setCodeEntryBook(nextLine[7]); - financialTransactions.put(num, financialTransactionImport); - } + financialTransactions.put(num, financialTransactionImport); + } - /** - * Import and create entries Structure : TYPE | NumTransac | Description | - * Amount | Debit | Lettering | Detail | Voucher | Position - * | FinancialTransaction Date | FinancialTransaction EntryBookCode | - * FinancialTransaction AmountDebit | FinancialTransaction AmountCredit - */ - public void importEntriesCSV(String[] nextLine, - Map<Integer, List<EntryImport>> entries, TopiaContext topiaContext) - throws LimaException { - int num = new Integer(nextLine[1]); + /** + * Import and create entries Structure : TYPE | NumTransac | Description | + * Amount | Debit | Lettering | Detail | Voucher | Position + * | FinancialTransaction Date | FinancialTransaction EntryBookCode | + * FinancialTransaction AmountDebit | FinancialTransaction AmountCredit + */ + public void importEntriesCSV(String[] nextLine, + Map<Integer, List<EntryImport>> entries, TopiaContext topiaContext) + throws LimaException { + int num = new Integer(nextLine[1]); - EntryImport entryImport = new EntryImportImpl(); - entryImport.setDescription(nextLine[2]); - entryImport.setAmount(nextLine[3]); - entryImport.setDebit(nextLine[4]); - entryImport.setLettering(nextLine[5]); - entryImport.setDetail(nextLine[6]); - entryImport.setVoucher(nextLine[7]); - entryImport.setPosition(nextLine[8]); - entryImport.setAccount(nextLine[9]); + EntryImport entryImport = new EntryImportImpl(); + entryImport.setDescription(nextLine[2]); + entryImport.setAmount(nextLine[3]); + entryImport.setDebit(nextLine[4]); + entryImport.setLettering(nextLine[5]); + entryImport.setDetail(nextLine[6]); + entryImport.setVoucher(nextLine[7]); + entryImport.setPosition(nextLine[8]); + entryImport.setAccount(nextLine[9]); - if (entries.containsKey(num)) { - List<EntryImport> entryImports = entries.get(num); - entryImports.add(entryImport); - } else { - List<EntryImport> entryImports = new ArrayList<EntryImport>(); - entryImports.add(entryImport); - entries.put(num, entryImports); - } - } + if (entries.containsKey(num)) { + List<EntryImport> entryImports = entries.get(num); + entryImports.add(entryImport); + } else { + List<EntryImport> entryImports = new ArrayList<EntryImport>(); + entryImports.add(entryImport); + entries.put(num, entryImports); + } + } - // ################ CREATE ENTITY IN DB FOR IMPORT ################ + // ################ CREATE ENTITY IN DB FOR IMPORT ################ - public String createFinancialStatements(LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements, - TopiaContext topiaContext) throws LimaException { - StringBuffer result = new StringBuffer(); - try { + public String createFinancialStatements(LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements, + TopiaContext topiaContext) throws LimaException { + StringBuffer result = new StringBuffer(); + try { - FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper - .getFinancialStatementDAO(topiaContext); + FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper + .getFinancialStatementDAO(topiaContext); - while (financialStatements.size() > 0) { - for (Iterator<ArrayList<FinancialStatementImport>> itr = financialStatements - .values().iterator(); itr.hasNext();) { - List<FinancialStatementImport> financialStatementImports = - itr.next(); - - for (Iterator<FinancialStatementImport> itr2 = financialStatementImports.iterator(); itr2.hasNext();) { - FinancialStatementImport financialStatementImport = - itr2.next(); - String masterFinancialStatementLabel = financialStatementImport - .getMasterFinancialStatement(); - FinancialStatement masterFinancialStatement = financialStatementDAO - .findByLabel(masterFinancialStatementLabel); + while (financialStatements.size() > 0) { + for (Iterator<ArrayList<FinancialStatementImport>> itr = financialStatements + .values().iterator(); itr.hasNext();) { + List<FinancialStatementImport> financialStatementImports = + itr.next(); + + for (Iterator<FinancialStatementImport> itr2 = financialStatementImports.iterator(); itr2.hasNext();) { + FinancialStatementImport financialStatementImport = + itr2.next(); + String masterFinancialStatementLabel = financialStatementImport + .getMasterFinancialStatement(); + FinancialStatement masterFinancialStatement = financialStatementDAO + .findByLabel(masterFinancialStatementLabel); - if (masterFinancialStatementLabel.equals("") - || masterFinancialStatement != null) { - // create it - FinancialStatement financialStatement = new FinancialStatementImpl(); - financialStatement.setLabel(financialStatementImport - .getLabel()); - financialStatement.setHeader(Boolean - .parseBoolean(financialStatementImport - .getHeader())); - financialStatement.setAccounts(financialStatementImport - .getAccounts()); - financialStatement - .setDebitAccounts(financialStatementImport - .getDebitAccounts()); - financialStatement - .setCreditAccounts(financialStatementImport - .getCreditAccounts()); - financialStatement - .setProvisionDeprecationAccounts(financialStatementImport - .getProvisionDeprecationAccounts()); - financialStatement.setSubAmount(Boolean - .parseBoolean(financialStatementImport - .getSubAmount())); - financialStatement.setHeaderAmount(Boolean - .parseBoolean(financialStatementImport - .getHeaderAmount())); - String financialStatementWay = financialStatementImport.getWay(); - if (!financialStatementWay.equals("")){ - FinancialStatementWayEnum financialStatementWayEnum = - FinancialStatementWayEnum.valueOf(financialStatementWay); - financialStatement.setWay(financialStatementWayEnum); - } - + if (masterFinancialStatementLabel.equals("") + || masterFinancialStatement != null) { + // create it + FinancialStatement financialStatement = new FinancialStatementImpl(); + financialStatement.setLabel(financialStatementImport + .getLabel()); + financialStatement.setHeader(Boolean + .parseBoolean(financialStatementImport + .getHeader())); + financialStatement.setAccounts(financialStatementImport + .getAccounts()); + financialStatement + .setDebitAccounts(financialStatementImport + .getDebitAccounts()); + financialStatement + .setCreditAccounts(financialStatementImport + .getCreditAccounts()); + financialStatement + .setProvisionDeprecationAccounts(financialStatementImport + .getProvisionDeprecationAccounts()); + financialStatement.setSubAmount(Boolean + .parseBoolean(financialStatementImport + .getSubAmount())); + financialStatement.setHeaderAmount(Boolean + .parseBoolean(financialStatementImport + .getHeaderAmount())); + String financialStatementWay = financialStatementImport.getWay(); + if (!financialStatementWay.equals("")){ + FinancialStatementWayEnum financialStatementWayEnum = + FinancialStatementWayEnum.valueOf(financialStatementWay); + financialStatement.setWay(financialStatementWayEnum); + } + - financialStatementService - .createFinancialStatementWithTransaction( - masterFinancialStatement, - financialStatement, topiaContext); + financialStatementService + .createFinancialStatementWithTransaction( + masterFinancialStatement, + financialStatement, topiaContext); - result.append(_("lima-business.import.financialstatementadded", - financialStatementImport.getLabel())); - - itr2.remove(); - } else if (!financialStatements - .containsKey(masterFinancialStatementLabel)) { - result.append(_("lima-business.import.financialstatementalnomaster", - financialStatementImport.getLabel(), - masterFinancialStatementLabel)); - itr2.remove(); - } - } - if (financialStatementImports.isEmpty()){ - itr.remove(); - } - } - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return result.toString(); - } + result.append(_("lima-business.import.financialstatementadded", + financialStatementImport.getLabel())); + + itr2.remove(); + } else if (!financialStatements + .containsKey(masterFinancialStatementLabel)) { + result.append(_("lima-business.import.financialstatementalnomaster", + financialStatementImport.getLabel(), + masterFinancialStatementLabel)); + itr2.remove(); + } + } + if (financialStatementImports.isEmpty()){ + itr.remove(); + } + } + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } - public String createFiscalPeriod(List<FiscalPeriod> fiscalPeriods, - TopiaContext topiaContext) { - StringBuffer result = new StringBuffer(); - for (FiscalPeriod fiscalPeriod : fiscalPeriods) { - // create fiscalPeriod - try { - fiscalPeriodService.createFiscalPeriodWithTransaction( - fiscalPeriod, topiaContext); - result.append(_("lima-business.import.fiscalperiodadded", - fiscalPeriod.getBeginDate(), - fiscalPeriod.getEndDate())); - } catch (LimaException eee) { - result.append(_("lima-business.common.failed", eee.getMessage())); - } - } - return result.toString(); - } + public String createFiscalPeriod(List<FiscalPeriod> fiscalPeriods, + TopiaContext topiaContext) { + StringBuffer result = new StringBuffer(); + for (FiscalPeriod fiscalPeriod : fiscalPeriods) { + // create fiscalPeriod + try { + fiscalPeriodService.createFiscalPeriodWithTransaction( + fiscalPeriod, topiaContext); + result.append(_("lima-business.import.fiscalperiodadded", + fiscalPeriod.getBeginDate(), + fiscalPeriod.getEndDate())); + } catch (LimaException eee) { + result.append(_("lima-business.common.failed", eee.getMessage())); + } + } + return result.toString(); + } - - /** - * Dynamic letter creation used by CSV and EBP Import - */ - public Letter createLetter(String letterCode, TopiaContext topiaContext) throws LimaException{ - Letter letter = null; - try { - LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); - letter = letterDAO.findByCode(letterCode); - // if letter not exist create it ! - if (letter == null) { - letter = new LetterImpl(); - letter.setCode(letterCode); - financialTransactionService.createLetter(letter); - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return letter; - } - - public String createAccounts(Map<String, AccountImport> accounts, - TopiaContext topiaContext) throws LimaException { - StringBuffer result = new StringBuffer(); + + /** + * Dynamic letter creation used by CSV and EBP Import + */ + public Letter createLetter(String letterCode, TopiaContext topiaContext) throws LimaException{ + Letter letter = null; + try { + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letter = letterDAO.findByCode(letterCode); + // if letter not exist create it ! + if (letter == null) { + letter = new LetterImpl(); + letter.setCode(letterCode); + financialTransactionService.createLetter(letter); + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return letter; + } + + public String createAccounts(Map<String, AccountImport> accounts, + TopiaContext topiaContext) throws LimaException { + StringBuffer result = new StringBuffer(); - try { - AccountDAO accountDAO = LimaCallaoDAOHelper - .getAccountDAO(topiaContext); + try { + AccountDAO accountDAO = LimaCallaoDAOHelper + .getAccountDAO(topiaContext); - while (accounts.size() > 0) { - for (Iterator<AccountImport> itr = accounts.values().iterator(); itr - .hasNext();) { - AccountImport accountImport = itr.next(); - String masterAccountNumber = accountImport - .getMasterAccount(); - String generalLedgerNumber = accountImport - .getGeneralLedger(); - Account masterAccount = accountDAO - .findByAccountNumber(masterAccountNumber); - Account generalLedger = accountDAO - .findByAccountNumber(generalLedgerNumber); + while (accounts.size() > 0) { + for (Iterator<AccountImport> itr = accounts.values().iterator(); itr + .hasNext();) { + AccountImport accountImport = itr.next(); + String masterAccountNumber = accountImport + .getMasterAccount(); + String generalLedgerNumber = accountImport + .getGeneralLedger(); + Account masterAccount = accountDAO + .findByAccountNumber(masterAccountNumber); + Account generalLedger = accountDAO + .findByAccountNumber(generalLedgerNumber); - if ((masterAccountNumber.equals("") && generalLedgerNumber - .equals("")) - || masterAccount != null || generalLedger != null) { - // create it - Account account = new AccountImpl(); - account.setAccountNumber(accountImport - .getAccountNumber()); - account.setLabel(accountImport.getLabel()); - account.setThirdParty(accountImport.getThirdParty()); + if ((masterAccountNumber.equals("") && generalLedgerNumber + .equals("")) + || masterAccount != null || generalLedger != null) { + // create it + Account account = new AccountImpl(); + account.setAccountNumber(accountImport + .getAccountNumber()); + account.setLabel(accountImport.getLabel()); + account.setThirdParty(accountImport.getThirdParty()); - if (generalLedger != null) { - accountService.createSubLedgerWithTransaction( - generalLedger, account, topiaContext); - } else { - accountService.createAccountWithTransaction( - masterAccount, account, topiaContext); - } - result.append(_("lima-business.import.accountadded", - accountImport.getAccountNumber(), - accountImport.getLabel())); - itr.remove(); - } else if (!accounts.containsKey(masterAccountNumber) - && !accounts.containsKey(generalLedgerNumber)) { - result.append(_("lima-business.import.accountnomaster", - accountImport.getAccountNumber(), - masterAccountNumber)); - itr.remove(); - } - } - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } - return result.toString(); - } + if (generalLedger != null) { + accountService.createSubLedgerWithTransaction( + generalLedger, account, topiaContext); + } else { + accountService.createAccountWithTransaction( + masterAccount, account, topiaContext); + } + result.append(_("lima-business.import.accountadded", + accountImport.getAccountNumber(), + accountImport.getLabel())); + itr.remove(); + } else if (!accounts.containsKey(masterAccountNumber) + && !accounts.containsKey(generalLedgerNumber)) { + result.append(_("lima-business.import.accountnomaster", + accountImport.getAccountNumber(), + masterAccountNumber)); + itr.remove(); + } + } + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } - public String updateClosedPeriodicEntryBooks( - List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks, - TopiaContext topiaContext) throws LimaException { - StringBuffer result = new StringBuffer(); + public String updateClosedPeriodicEntryBooks( + List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks, + TopiaContext topiaContext) throws LimaException { + StringBuffer result = new StringBuffer(); - try { - FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper - .getFinancialPeriodDAO(topiaContext); - EntryBookDAO entryBookDAO = LimaCallaoDAOHelper - .getEntryBookDAO(topiaContext); - ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = LimaCallaoDAOHelper - .getClosedPeriodicEntryBookDAO(topiaContext); - for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) { - // update closedPeriodicEntryBook - Date beginDateFinancialPeriod = SDATEFORMAT - .parse(closedPeriodicEntryBookImport - .getBeginDateFinancialPeriod()); - Date endDateFinancialPeriod = SDATEFORMAT - .parse(closedPeriodicEntryBookImport - .getEndDateFinancialPeriod()); - FinancialPeriod financialPeriod = financialPeriodDAO - .findByNaturalId(beginDateFinancialPeriod, - endDateFinancialPeriod); - String codeEntryBook = closedPeriodicEntryBookImport - .getCodeEntryBook(); - EntryBook entryBook = entryBookDAO.findByCode(codeEntryBook); - ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookDAO - .findByEntryBookAndFinancialPeriod(entryBook, - financialPeriod); - try { - financialPeriodService - .blockClosedPeriodicEntryBookWithTransaction( - closedPeriodicEntryBook, topiaContext); - result.append(_("lima-business.import.closedperiodicentrybookupdated", - beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook)); - } catch (LimaException eee) { - result.append(_("lima-business.common.failed", eee)); - } - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } catch (ParseException eeePE) { - log.error("Can't parse date", eeePE); - } - return result.toString(); - } + try { + FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper + .getFinancialPeriodDAO(topiaContext); + EntryBookDAO entryBookDAO = LimaCallaoDAOHelper + .getEntryBookDAO(topiaContext); + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = LimaCallaoDAOHelper + .getClosedPeriodicEntryBookDAO(topiaContext); + for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) { + // update closedPeriodicEntryBook + Date beginDateFinancialPeriod = SDATEFORMAT + .parse(closedPeriodicEntryBookImport + .getBeginDateFinancialPeriod()); + Date endDateFinancialPeriod = SDATEFORMAT + .parse(closedPeriodicEntryBookImport + .getEndDateFinancialPeriod()); + FinancialPeriod financialPeriod = financialPeriodDAO + .findByNaturalId(beginDateFinancialPeriod, + endDateFinancialPeriod); + String codeEntryBook = closedPeriodicEntryBookImport + .getCodeEntryBook(); + EntryBook entryBook = entryBookDAO.findByCode(codeEntryBook); + ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookDAO + .findByEntryBookAndFinancialPeriod(entryBook, + financialPeriod); + try { + financialPeriodService + .blockClosedPeriodicEntryBookWithTransaction( + closedPeriodicEntryBook, topiaContext); + result.append(_("lima-business.import.closedperiodicentrybookupdated", + beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook)); + } catch (LimaException eee) { + result.append(_("lima-business.common.failed", eee)); + } + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } catch (ParseException eeePE) { + log.error("Can't parse date", eeePE); + } + return result.toString(); + } - public String createFinancialTransactionsAndEntries( - Map<Integer, FinancialTransactionImport> financialTransactions, - Map<Integer, List<EntryImport>> entries, TopiaContext topiaContext) - throws LimaException { - StringBuffer result = new StringBuffer(); - try { - EntryBookDAO entryBookDAO = LimaCallaoDAOHelper - .getEntryBookDAO(topiaContext); - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper - .getFinancialPeriodDAO(topiaContext); - FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper - .getFinancialTransactionDAO(topiaContext); - AccountDAO accountDAO = LimaCallaoDAOHelper - .getAccountDAO(topiaContext); + public String createFinancialTransactionsAndEntries( + Map<Integer, FinancialTransactionImport> financialTransactions, + Map<Integer, List<EntryImport>> entries, TopiaContext topiaContext) + throws LimaException { + StringBuffer result = new StringBuffer(); + try { + EntryBookDAO entryBookDAO = LimaCallaoDAOHelper + .getEntryBookDAO(topiaContext); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper + .getFinancialPeriodDAO(topiaContext); + FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper + .getFinancialTransactionDAO(topiaContext); + AccountDAO accountDAO = LimaCallaoDAOHelper + .getAccountDAO(topiaContext); - for (Map.Entry<Integer, FinancialTransactionImport> map : financialTransactions - .entrySet()) { - FinancialTransactionImport financialTransactionImport = map - .getValue(); - FinancialTransaction financialTransaction = new FinancialTransactionImpl(); - Date dateFinancialTransaction = SDATEFORMAT - .parse(financialTransactionImport.getDate()); - financialTransaction - .setTransactionDate(dateFinancialTransaction); - financialTransaction.setAmountDebit(new BigDecimal( - financialTransactionImport.getAmountDebit())); - financialTransaction.setAmountCredit(new BigDecimal( - financialTransactionImport.getAmountCredit())); - EntryBook entryBook = entryBookDAO - .findByCode(financialTransactionImport - .getCodeEntryBook()); - financialTransaction.setEntryBook(entryBook); + for (Map.Entry<Integer, FinancialTransactionImport> map : financialTransactions + .entrySet()) { + FinancialTransactionImport financialTransactionImport = map + .getValue(); + FinancialTransaction financialTransaction = new FinancialTransactionImpl(); + Date dateFinancialTransaction = SDATEFORMAT + .parse(financialTransactionImport.getDate()); + financialTransaction + .setTransactionDate(dateFinancialTransaction); + financialTransaction.setAmountDebit(new BigDecimal( + financialTransactionImport.getAmountDebit())); + financialTransaction.setAmountCredit(new BigDecimal( + financialTransactionImport.getAmountCredit())); + EntryBook entryBook = entryBookDAO + .findByCode(financialTransactionImport + .getCodeEntryBook()); + financialTransaction.setEntryBook(entryBook); - FinancialPeriod financialPeriod = financialPeriodDAO - .findByDate(dateFinancialTransaction); + FinancialPeriod financialPeriod = financialPeriodDAO + .findByDate(dateFinancialTransaction); - financialTransactionDAO.create(financialTransaction); - financialPeriod.addFinancialTransaction(financialTransaction); + financialTransactionDAO.create(financialTransaction); + financialPeriod.addFinancialTransaction(financialTransaction); - List<EntryImport> entryImports = entries.get(map.getKey()); - for (EntryImport entryImport : entryImports) { - Entry entry = new EntryImpl(); - Account account = accountDAO - .findByAccountNumber(entryImport.getAccount()); - entry.setAccount(account); - entry.setDescription(entryImport.getDescription()); - entry.setAmount(new BigDecimal(entryImport.getAmount())); - entry.setDebit(Boolean.parseBoolean(entryImport.getDebit())); - - Letter letter = createLetter( - entryImport.getLettering(), topiaContext); - entry.setLetter(letter); - - entry.setDetail(entryImport.getDetail()); - entry.setVoucher(entryImport.getVoucher()); - entry.setPosition(entryImport.getPosition()); - entryDAO.create(entry); - financialTransaction.addEntry(entry); - } - } - } catch (TopiaException eeeTE) { - doCatch(topiaContext, eeeTE, log); - } catch (ParseException eeePE) { - log.error("Can't parse date", eeePE); - } - return result.toString(); - } + List<EntryImport> entryImports = entries.get(map.getKey()); + for (EntryImport entryImport : entryImports) { + Entry entry = new EntryImpl(); + Account account = accountDAO + .findByAccountNumber(entryImport.getAccount()); + entry.setAccount(account); + entry.setDescription(entryImport.getDescription()); + entry.setAmount(new BigDecimal(entryImport.getAmount())); + entry.setDebit(Boolean.parseBoolean(entryImport.getDebit())); + + Letter letter = createLetter( + entryImport.getLettering(), topiaContext); + entry.setLetter(letter); + + entry.setDetail(entryImport.getDetail()); + entry.setVoucher(entryImport.getVoucher()); + entry.setPosition(entryImport.getPosition()); + entryDAO.create(entry); + financialTransaction.addEntry(entry); + } + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } catch (ParseException eeePE) { + log.error("Can't parse date", eeePE); + } + return result.toString(); + } - public String importIdentity(String[] nextLine, TopiaContext topiaContext) - throws LimaException { - StringBuffer result = new StringBuffer(); + public String importIdentity(String[] nextLine, TopiaContext topiaContext) + throws LimaException { + StringBuffer result = new StringBuffer(); - Identity identity = new IdentityImpl(); - nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel(); - identity.setName(nextLine[1]); - identity.setDescription(nextLine[2]); - identity.setAddress(nextLine[3]); - identity.setAddress2(nextLine[4]); - identity.setCity(nextLine[5]); - identity.setPhoneNumber(nextLine[6]); - identity.setEmail(nextLine[7]); - identity.setZipCode(nextLine[8]); - identity.setVatNumber(nextLine[9]); - identity.setClassificationCode(nextLine[10]); - identity.setBusinessNumber(nextLine[11]); + Identity identity = new IdentityImpl(); + nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel(); + identity.setName(nextLine[1]); + identity.setDescription(nextLine[2]); + identity.setAddress(nextLine[3]); + identity.setAddress2(nextLine[4]); + identity.setCity(nextLine[5]); + identity.setPhoneNumber(nextLine[6]); + identity.setEmail(nextLine[7]); + identity.setZipCode(nextLine[8]); + identity.setVatNumber(nextLine[9]); + identity.setClassificationCode(nextLine[10]); + identity.setBusinessNumber(nextLine[11]); - identityService.updateIdentityWithTransaction(identity, topiaContext); - // create it - result.append(_("lima-business.import.identityadded", identity.getName())); + identityService.updateIdentityWithTransaction(identity, topiaContext); + // create it + result.append(_("lima-business.import.identityadded", identity.getName())); - return result.toString(); - } + return result.toString(); + } - protected TopiaContext beginTransaction() throws TopiaException { - // basic check done, make check in database - // TODO move it into JTA - TopiaContext topiaTransaction; - topiaTransaction = rootContext.beginTransaction(); - log.trace("beginTransaction" + topiaTransaction); - return topiaTransaction; - } + protected TopiaContext beginTransaction() throws TopiaException { + // basic check done, make check in database + // TODO move it into JTA + TopiaContext topiaTransaction; + topiaTransaction = rootContext.beginTransaction(); + log.trace("beginTransaction" + topiaTransaction); + return topiaTransaction; + } - protected void commitTransaction(TopiaContext topiaTransaction) - throws TopiaException { - try { - topiaTransaction.commitTransaction(); - } catch (TopiaException eee) { - if (log.isErrorEnabled()) { - log.error("Error during commit context", eee); - } - throw eee; - } - } + protected void commitTransaction(TopiaContext topiaTransaction) + throws TopiaException { + try { + topiaTransaction.commitTransaction(); + } catch (TopiaException eee) { + if (log.isErrorEnabled()) { + log.error("Error during commit context", eee); + } + throw eee; + } + } } 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -112,7 +112,7 @@ List<Entry> entries = new ArrayList<Entry>(); if (account != null){ - //Get allsubaccounts and thirdParts accounts + //Get allsubaccounts and thirdParts accounts List<Account> accounts = (List<Account>) account.getSubAccounts(); if (thirdPartAccountsMode){ List<Account> thirdPartAccount = (List<Account>) account.getSubLedgers(); @@ -167,13 +167,13 @@ TopiaQuery query = entryDAO.createQuery(queryAlias); String transactionDateProperty = TopiaQuery.getProperty( - Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); + Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); String amountCreditProperty = TopiaQuery.getProperty( - Entry.FINANCIAL_TRANSACTION, FinancialTransaction.AMOUNT_CREDIT); + Entry.FINANCIAL_TRANSACTION, FinancialTransaction.AMOUNT_CREDIT); String amountDebitProperty = TopiaQuery.getProperty( - Entry.FINANCIAL_TRANSACTION, FinancialTransaction.AMOUNT_DEBIT); + Entry.FINANCIAL_TRANSACTION, FinancialTransaction.AMOUNT_DEBIT); String entryBookProperty = TopiaQuery.getProperty( - Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK); + Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK); query .addWhere(amountCreditProperty+" = "+amountDebitProperty) @@ -218,15 +218,15 @@ results = amountsQuery.execute(topiaContext); int nbAmount = results.size(); if(nbAmount==2){ - debit = (BigDecimal) results.get(0)[1]; + debit = (BigDecimal) results.get(0)[1]; credit = (BigDecimal)results.get(1)[1]; } if (nbAmount==1){ if ((Boolean)results.get(0)[0]){ - debit = (BigDecimal) results.get(0)[1]; + debit = (BigDecimal) results.get(0)[1]; } else { - credit = (BigDecimal)results.get(0)[1]; + credit = (BigDecimal)results.get(0)[1]; } } @@ -463,16 +463,16 @@ List<Account> accounts =null; - //Remove Spaces - String result = StringUtils.deleteWhitespace(selectedAccounts); + //Remove Spaces + String result = StringUtils.deleteWhitespace(selectedAccounts); //if no filter account if (result == null || result.equals("")){ - accounts = accountDAO.findAll(); + accounts = accountDAO.findAll(); } //build list account from selectedAccounts else{ - accounts = accountDAO.stringToListAccounts( - result, false); + accounts = accountDAO.stringToListAccounts( + result, false); } for (Account account : accounts) { ReportsDatas reportsDatas = @@ -481,13 +481,13 @@ reportsDatas.setAccount(account); BigDecimal amount = reportsDatas.getAmountSolde(); if (amount == null){ - amount = new BigDecimal(0); + amount = new BigDecimal(0); } if (movementedFilter){ - if (reportsDatas.getAmountCredit().doubleValue() != 0 || reportsDatas.getAmountDebit().doubleValue() != 0){ + if (reportsDatas.getAmountCredit().doubleValue() != 0 || reportsDatas.getAmountDebit().doubleValue() != 0){ // add balance sheet to balance trial balanceTrial.addReportsDatas(reportsDatas); - } + } } else { // add balance sheet to balance trial Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -40,9 +40,9 @@ public interface DocumentService { void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; - void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; - void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; - void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; - void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; + void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; + void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; + void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; + void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -46,5 +46,5 @@ public interface EntryBookServiceLocal extends EntryBookService { void createEntryBookWithTransaction(EntryBook entryBook, TopiaContext topiaContext) throws LimaException; - + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ExportService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ExportService.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ExportService.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -42,33 +42,33 @@ @Remote public interface ExportService { - + /** * Get database export as CSV; * * @return export as byte array * @throws LimaException */ - String exportAsCSV() throws LimaException; + String exportAsCSV() throws LimaException; /** * export entrybook chart as CSV. */ - String exportEntryBookChartAsCSV() throws LimaException; + String exportEntryBookChartAsCSV() throws LimaException; /** * export financialstatement chart as CSV. */ - String exportFinancialStatementChartAsCSV() throws LimaException; + String exportFinancialStatementChartAsCSV() throws LimaException; /** * export accounts chart as CSV. */ - String exportAccountsChartAsCSV() throws LimaException; - - /** - * export entries as EBP - */ + String exportAccountsChartAsCSV() throws LimaException; + + /** + * export entries as EBP + */ String exportEntriesAsEBP() throws LimaException; /** Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -35,8 +35,8 @@ @Remote public interface FinancialStatementService { - - void createFinancialStatement(FinancialStatement masterFinancialStatement, FinancialStatement financialStatement) throws LimaException; + + void createFinancialStatement(FinancialStatement masterFinancialStatement, FinancialStatement financialStatement) throws LimaException; void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException; void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException; void removeAllFinancialStatement() throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementServiceLocal.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementServiceLocal.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -33,8 +33,8 @@ @Local public interface FinancialStatementServiceLocal extends FinancialStatementService { - void createFinancialStatementWithTransaction(FinancialStatement masterFinancialStatement, - FinancialStatement financialStatement, TopiaContext topiaContext) throws LimaException; + void createFinancialStatementWithTransaction(FinancialStatement masterFinancialStatement, + FinancialStatement financialStatement, TopiaContext topiaContext) throws LimaException; - + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -58,13 +58,13 @@ * @return all transaction for entry book and period * @throws LimaException */ - + void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; - + List<FinancialTransaction> getAllFinancialTransactionsForFinancialPeriod( FinancialPeriod period) throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -43,11 +43,11 @@ @Local public interface FinancialTransactionServiceLocal extends FinancialTransactionService { - + void createFinancialTransactionWithTransaction(FinancialTransaction financialtransaction, TopiaContext topiaContext) throws LimaException; void updateFinancialTransactionWithTransaction(FinancialTransaction financialtransaction, TopiaContext topiaContext) throws LimaException; void createEntryWithTransaction(Entry entry, TopiaContext topiaContext) throws LimaException; - + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodServiceLocal.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodServiceLocal.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -44,5 +44,5 @@ void createFiscalPeriodWithTransaction(FiscalPeriod fiscalPeriod, TopiaContext topiaContext) throws LimaException; - + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,7 +30,7 @@ @Remote public interface HttpServerService { - void start(); - int getHttpPort(); - + void start(); + int getHttpPort(); + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -33,7 +33,7 @@ @Remote public interface IdentityService { - Identity getIdentity() throws LimaException; - void updateIdentity(Identity identity) throws LimaException; - + Identity getIdentity() throws LimaException; + void updateIdentity(Identity identity) throws LimaException; + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityServiceLocal.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityServiceLocal.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -34,7 +34,7 @@ @Local public interface IdentityServiceLocal { - void updateIdentityWithTransaction(Identity identity, TopiaContext topiaContext) throws LimaException; - Identity getIdentityWithTransaction(TopiaContext topiaContext) throws LimaException; - + void updateIdentityWithTransaction(Identity identity, TopiaContext topiaContext) throws LimaException; + Identity getIdentityWithTransaction(TopiaContext topiaContext) throws LimaException; + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -49,8 +49,8 @@ * @param data * @throws LimaException */ - String importEntriesFromEbp(String datas) throws LimaException; - String importAccountsChartFromEbp(String datas) throws LimaException; + String importEntriesFromEbp(String datas) throws LimaException; + String importAccountsChartFromEbp(String datas) throws LimaException; /** @@ -75,5 +75,5 @@ */ String importAllAsCSV(String path) throws LimaException; - String importAsCSV(String datas, ImportExportEntityEnum importExportEntityEnum) throws LimaException; + String importAsCSV(String datas, ImportExportEntityEnum importExportEntityEnum) throws LimaException; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportServiceLocal.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportServiceLocal.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -53,5 +53,5 @@ public interface ReportServiceLocal extends ReportService { ReportsDatas generateAccountReportsWithTransaction (Account account, Boolean thirdPartAccountsMode, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException; - + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -31,9 +31,9 @@ public class AccountComparator implements Serializable, Comparator<Account>{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** + /** * sort by accout number in lexicographical order */ @Override Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -32,11 +32,11 @@ public class AccountEBPComparator implements Serializable, Comparator<AccountEBP> { - private static final long serialVersionUID = 1L; - - @Override - public int compare(AccountEBP o1, AccountEBP o2) { + private static final long serialVersionUID = 1L; + + @Override + public int compare(AccountEBP o1, AccountEBP o2) { return o1.getNumero().compareTo(o2.getNumero()); - } + } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -29,40 +29,40 @@ public enum DocumentsEnum { - - GENERAL_ENTRYBOOK(_("lima-business.document.generalentrybook"),"lima_general_entybook"), - ENTRYBOOKS(_("lima-business.document.entrybook"),"lima_entrybooks"), - BALANCE(_("lima-business.document.balance"),"lima_balance"), - LEDGER(_("lima-business.document.ledger"),"lima_ledger"), - FINANCIALSTATEMENT(_("lima-business.document.financialstatement"),"lima_financialstatements"); - - private final String fileName; - - private final String description; - - private DocumentsEnum(String description, String fileName) { - this.description = description; - this.fileName = fileName; - } - - public String getFileName() { - return this.fileName; - } - - public String getDescription() { - return this.description; - } - - public static DocumentsEnum valueOfLink(String label){ - DocumentsEnum value = null; - - for (DocumentsEnum documentsEnum : DocumentsEnum.values()) { - if (label.equals(documentsEnum.fileName)){ - value = documentsEnum; - break; - } - } - return value; - } - + + GENERAL_ENTRYBOOK(_("lima-business.document.generalentrybook"),"lima_general_entybook"), + ENTRYBOOKS(_("lima-business.document.entrybook"),"lima_entrybooks"), + BALANCE(_("lima-business.document.balance"),"lima_balance"), + LEDGER(_("lima-business.document.ledger"),"lima_ledger"), + FINANCIALSTATEMENT(_("lima-business.document.financialstatement"),"lima_financialstatements"); + + private final String fileName; + + private final String description; + + private DocumentsEnum(String description, String fileName) { + this.description = description; + this.fileName = fileName; + } + + public String getFileName() { + return this.fileName; + } + + public String getDescription() { + return this.description; + } + + public static DocumentsEnum valueOfLink(String label){ + DocumentsEnum value = null; + + for (DocumentsEnum documentsEnum : DocumentsEnum.values()) { + if (label.equals(documentsEnum.fileName)){ + value = documentsEnum; + break; + } + } + return value; + } + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -31,7 +31,7 @@ public class EntryComparator implements Serializable, Comparator<Entry>{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; @Override public int compare(Entry o1, Entry o2) { Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -36,30 +36,30 @@ public class EntryEBPComparator implements Serializable, Comparator<EntryEBP>{ - private static final Log log = - LogFactory.getLog(EntryEBPComparator.class); + private static final Log log = + LogFactory.getLog(EntryEBPComparator.class); - private static final long serialVersionUID = 1L; - + private static final long serialVersionUID = 1L; + @Override public int compare(EntryEBP o1, EntryEBP o2) { - int result = 0; - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - try { - Date date1 = sdf.parse(o1.getDatEcr()); - Date date2 = sdf.parse(o2.getDatEcr()); - result = date1.compareTo(date2); - if(result==0){ - result = o1.getJournal().compareTo(o2.getJournal()); - } - } catch (ParseException eee) { - log.error("Can't parse date", eee); - } - - + int result = 0; + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + try { + Date date1 = sdf.parse(o1.getDatEcr()); + Date date2 = sdf.parse(o2.getDatEcr()); + result = date1.compareTo(date2); + if(result==0){ + result = o1.getJournal().compareTo(o2.getJournal()); + } + } catch (ParseException eee) { + log.error("Can't parse date", eee); + } + + - - return result; + + return result; } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -31,8 +31,8 @@ public class FiscalPeriodComparator implements Serializable, Comparator<FiscalPeriod>{ - private static final long serialVersionUID = 1L; - + private static final long serialVersionUID = 1L; + /** * sort by fiscal begin date */ Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,42 +27,42 @@ public enum FormatsEnum { - HTML(".html","text/html", "Page Html"), - PDF(".pdf","application/pdf", "Document PDF"); - - private final String extension; - private final String mimeType; - private final String description; - - private FormatsEnum(String extension, String mimeType, String description) { - this.extension = extension; - this.mimeType = mimeType; - this.description = description; - } - - public String getExtension() { - return this.extension; - } - - public String getMimeType() { - return this.mimeType; - } - - public String getDescription(){ - return this.description; - } - - public static FormatsEnum valueOfExtension(String extension){ - FormatsEnum value = null; - - for (FormatsEnum formatsEnum : FormatsEnum.values()) { - if (extension.equals(formatsEnum.getExtension())){ - value = formatsEnum; - break; - } - } - return value; - } - - + HTML(".html","text/html", "Page Html"), + PDF(".pdf","application/pdf", "Document PDF"); + + private final String extension; + private final String mimeType; + private final String description; + + private FormatsEnum(String extension, String mimeType, String description) { + this.extension = extension; + this.mimeType = mimeType; + this.description = description; + } + + public String getExtension() { + return this.extension; + } + + public String getMimeType() { + return this.mimeType; + } + + public String getDescription(){ + return this.description; + } + + public static FormatsEnum valueOfExtension(String extension){ + FormatsEnum value = null; + + for (FormatsEnum formatsEnum : FormatsEnum.values()) { + if (extension.equals(formatsEnum.getExtension())){ + value = formatsEnum; + break; + } + } + return value; + } + + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,31 +27,31 @@ public enum ImportExportEntityEnum { - ACCOUNT("ACCN"), ENTRYBOOK("ENBK"), FINANCIALSTATEMENT("FNST"), - FISCALPERIOD("FSCP"), CLOSEDPERIODICENTRYBOOK("CPEB"), - FINANCIALTRANSACTION("FTRC"), ENTRY("NTRY"), - IDENTITY("IDNT"); - private final String label; - - private ImportExportEntityEnum(String label) { - this.label = label; - } - - public String getLabel() { - return this.label; - } - - public static ImportExportEntityEnum valueOfLabel(String label){ - ImportExportEntityEnum value = null; - - for (ImportExportEntityEnum importExportEntityEnum : ImportExportEntityEnum.values()) { - if (label.equals(importExportEntityEnum.label)){ - value = importExportEntityEnum; - break; - } - } - return value; - } + ACCOUNT("ACCN"), ENTRYBOOK("ENBK"), FINANCIALSTATEMENT("FNST"), + FISCALPERIOD("FSCP"), CLOSEDPERIODICENTRYBOOK("CPEB"), + FINANCIALTRANSACTION("FTRC"), ENTRY("NTRY"), + IDENTITY("IDNT"); + private final String label; + + private ImportExportEntityEnum(String label) { + this.label = label; + } + + public String getLabel() { + return this.label; + } + + public static ImportExportEntityEnum valueOfLabel(String label){ + ImportExportEntityEnum value = null; + + for (ImportExportEntityEnum importExportEntityEnum : ImportExportEntityEnum.values()) { + if (label.equals(importExportEntityEnum.label)){ + value = importExportEntityEnum; + break; + } + } + return value; + } } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -29,40 +29,40 @@ public enum FinancialStatementWayEnum { - BOTH(_("lima.enum.comboboxamount.both")), - DEBIT(_("lima.enum.comboboxamount.debit")), - CREDIT(_("lima.enum.comboboxamount.credit")); - - private final String description; - - private FinancialStatementWayEnum(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - - public static String[] descriptions(){ - int nbElts = FinancialStatementWayEnum.values().length; - String[] descriptions = new String[nbElts]; - FinancialStatementWayEnum[] enums = FinancialStatementWayEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } - - public static FinancialStatementWayEnum valueOfDescription(String description){ - FinancialStatementWayEnum value = null; - - for (FinancialStatementWayEnum enums : FinancialStatementWayEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } - + BOTH(_("lima.enum.comboboxamount.both")), + DEBIT(_("lima.enum.comboboxamount.debit")), + CREDIT(_("lima.enum.comboboxamount.credit")); + + private final String description; + + private FinancialStatementWayEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = FinancialStatementWayEnum.values().length; + String[] descriptions = new String[nbElts]; + FinancialStatementWayEnum[] enums = FinancialStatementWayEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static FinancialStatementWayEnum valueOfDescription(String description){ + FinancialStatementWayEnum value = null; + + for (FinancialStatementWayEnum enums : FinancialStatementWayEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } + } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -38,8 +38,8 @@ public class AccountDAOImpl <E extends Account> extends AccountDAOAbstract<E> { - private static final Log log = LogFactory.getLog(AccountDAOImpl.class); - + private static final Log log = LogFactory.getLog(AccountDAOImpl.class); + /** * List all subaccounts (no folderaccounts, exclude accounts contains thirdpart accounts) * Sort by accout number in lexicographical order @@ -53,97 +53,97 @@ return (List<Account>) findAllByQuery(query); } - @Override - public Account findSubAccountByNumber(String number) throws TopiaException { + @Override + public Account findSubAccountByNumber(String number) throws TopiaException { TopiaQuery query = createQuery(); String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS); query.addWhere("not exists elements ("+subAccountsProperty+")") .addWhere("not exists elements ("+subLedgersProperty+")") .addEquals(Account.ACCOUNT_NUMBER, number); - return findByQuery(query); - } - - public List<Account> findIntervalAccountByNumber(String accountNumberLow, String accountNumberHigh) throws TopiaException { - TopiaQuery query = createQuery(); - query.addBetween(Account.ACCOUNT_NUMBER, accountNumberLow, accountNumberHigh); - return (List<Account>) findAllByQuery(query); - } - - @Override - public List<Account> stringToListAccounts(String selectedAccounts, - Boolean subAccountsMode) throws TopiaException { - HashSet<Account> accounts = new HashSet<Account>(); - if (selectedAccounts != null){ - //Remove Spaces - String result = StringUtils.deleteWhitespace(selectedAccounts); + return findByQuery(query); + } + + public List<Account> findIntervalAccountByNumber(String accountNumberLow, String accountNumberHigh) throws TopiaException { + TopiaQuery query = createQuery(); + query.addBetween(Account.ACCOUNT_NUMBER, accountNumberLow, accountNumberHigh); + return (List<Account>) findAllByQuery(query); + } + + @Override + public List<Account> stringToListAccounts(String selectedAccounts, + Boolean subAccountsMode) throws TopiaException { + HashSet<Account> accounts = new HashSet<Account>(); + if (selectedAccounts != null){ + //Remove Spaces + String result = StringUtils.deleteWhitespace(selectedAccounts); - Boolean first = true; - StringTokenizer stStar = new StringTokenizer(result, "-"); - while (stStar.hasMoreTokens()) { - String subString = stStar.nextToken(); - - //Split comma - StringTokenizer stComma = new StringTokenizer(subString, ","); - while (stComma.hasMoreTokens()) { - String s = stComma.nextToken(); - //if intervall account - if (s.contains("..") && !s.endsWith("..")){ - //Split .. - String stringDoubleDot[] = s.split("\\.\\."); - - List<Account> resultIntervall = - findIntervalAccountByNumber(stringDoubleDot[0], stringDoubleDot[1]); - - //if first add accounts, else remove - if (first){ - accounts.addAll(resultIntervall); - } - else { - accounts.removeAll(resultIntervall); - } - } - //else one account - else{ - Account account = null; - if (subAccountsMode){ - account = findSubAccountByNumber(s); - } - else { - account = findByAccountNumber(s); - } - //if exist - if (account != null){ - //if first - if (first){ - accounts.add(account); - } - else { - accounts.remove(account); - } - } - //search all account start with accountnumber - else { - TopiaQuery query = createQuery(); - String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); - query.addWhere("not exists elements ("+subAccountsProperty+")") - .addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, s+"%"); - List<Account> accountsResult = (List<Account>) findAllByQuery(query); - if (accountsResult != null){ - //if first - if (first){ - accounts.addAll(accountsResult); - } - else { - accounts.removeAll(accountsResult); - } - } - } - } - } - first=false; - } - } - return new ArrayList(accounts); - } + Boolean first = true; + StringTokenizer stStar = new StringTokenizer(result, "-"); + while (stStar.hasMoreTokens()) { + String subString = stStar.nextToken(); + + //Split comma + StringTokenizer stComma = new StringTokenizer(subString, ","); + while (stComma.hasMoreTokens()) { + String s = stComma.nextToken(); + //if intervall account + if (s.contains("..") && !s.endsWith("..")){ + //Split .. + String stringDoubleDot[] = s.split("\\.\\."); + + List<Account> resultIntervall = + findIntervalAccountByNumber(stringDoubleDot[0], stringDoubleDot[1]); + + //if first add accounts, else remove + if (first){ + accounts.addAll(resultIntervall); + } + else { + accounts.removeAll(resultIntervall); + } + } + //else one account + else{ + Account account = null; + if (subAccountsMode){ + account = findSubAccountByNumber(s); + } + else { + account = findByAccountNumber(s); + } + //if exist + if (account != null){ + //if first + if (first){ + accounts.add(account); + } + else { + accounts.remove(account); + } + } + //search all account start with accountnumber + else { + TopiaQuery query = createQuery(); + String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); + query.addWhere("not exists elements ("+subAccountsProperty+")") + .addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, s+"%"); + List<Account> accountsResult = (List<Account>) findAllByQuery(query); + if (accountsResult != null){ + //if first + if (first){ + accounts.addAll(accountsResult); + } + else { + accounts.removeAll(accountsResult); + } + } + } + } + } + first=false; + } + } + return new ArrayList(accounts); + } } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -42,7 +42,7 @@ private static final Log log = LogFactory.getLog(ClosedPeriodicEntryBookDAOImpl.class); - + /** * Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod */ @@ -61,19 +61,19 @@ return findByQuery(query); } - @Override - public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate, - Date endDate) throws TopiaException { - TopiaQuery query = createQuery(); - if (beginDate != null && endDate != null){ - String beginDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); - String endDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); - String entrybookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.ENTRY_BOOK, EntryBook.CODE); - query.addWhere(beginDateProperty, Op.GE, beginDate) - .addWhere(endDateProperty, Op.LE, endDate) - .addOrder(beginDateProperty, entrybookProperty); - } - return (List<ClosedPeriodicEntryBook>) findAllByQuery(query); - } + @Override + public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate, + Date endDate) throws TopiaException { + TopiaQuery query = createQuery(); + if (beginDate != null && endDate != null){ + String beginDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); + String endDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); + String entrybookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.ENTRY_BOOK, EntryBook.CODE); + query.addWhere(beginDateProperty, Op.GE, beginDate) + .addWhere(endDateProperty, Op.LE, endDate) + .addOrder(beginDateProperty, entrybookProperty); + } + return (List<ClosedPeriodicEntryBook>) findAllByQuery(query); + } } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,10 +27,10 @@ public class FinancialStatementImpl extends FinancialStatementAbstract{ - protected Integer level; - - @Override - public int getLevel() { + protected Integer level; + + @Override + public int getLevel() { if (level == null) { if (masterFinancialStatement != null){ level = masterFinancialStatement.getLevel() + 1; @@ -38,6 +38,6 @@ level = 1; } } - return level; - } + return level; + } } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,25 +30,25 @@ public class FinancialTransactionImpl extends FinancialTransactionAbstract { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override - public void setAmounts() { + @Override + public void setAmounts() { - if (amountDebit == null){ - amountDebit = new BigDecimal(0); - } - if (amountCredit == null){ - amountCredit = new BigDecimal(0); - } - for (Entry entryFT : entry) { - if (entryFT.getDebit()){ - amountDebit = amountDebit.add(entryFT.getAmount()); - } - else { - amountCredit = amountCredit.add(entryFT.getAmount()); - } - } - } + if (amountDebit == null){ + amountDebit = new BigDecimal(0); + } + if (amountCredit == null){ + amountCredit = new BigDecimal(0); + } + for (Entry entryFT : entry) { + if (entryFT.getDebit()){ + amountDebit = amountDebit.add(entryFT.getAmount()); + } + else { + amountCredit = amountCredit.add(entryFT.getAmount()); + } + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -304,7 +304,7 @@ @Override public void setFinal(boolean _final){ - this._final=_final; + this._final=_final; } @Override Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -77,7 +77,7 @@ } try { - + // init root context final LimaContext context = init(args); @@ -112,7 +112,7 @@ // update splash splash = new LimaSplash(); splash.initSplash(); - + // to enable javassist on webstart, must remove any securityManager, // see if this can be dangerous (should not be since jnlp is signed ?) // moreover it speeds up the loading :) @@ -167,8 +167,8 @@ protected static void launch(LimaContext context) throws Exception { - splash.drawVersion(config.getVersion()); - splash.updateProgression(0.1, _("lima.splash.1")); + splash.drawVersion(config.getVersion()); + splash.updateProgression(0.1, _("lima.splash.1")); // do init ui MainViewHandler uiHandler = context.getContextValue(MainViewHandler.class); @@ -186,8 +186,8 @@ LimaServiceFactory.getInstance().getService(HttpServerServiceMonitorable.class).start(); AccountService accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); List<Account> accounts = accountService.getChildrenAccounts(null); if (accounts.isEmpty()) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,19 +27,19 @@ public enum AccountsChartEnum { - IMPORT(""), IMPORTEBP(""), SHORTENED("pcg_shortened.csv"), BASE("pcg_base.csv"), DEVELOPED("pcg_developed.csv"); - - private final String filePath; - - private AccountsChartEnum(String filePath) { - this.filePath = filePath; - } - - public String getFilePath() { - String result = ""; - if (!this.filePath.equals("")){ - result=getClass().getResource("/import/"+this.filePath).getPath(); - } - return result; - } + IMPORT(""), IMPORTEBP(""), SHORTENED("pcg_shortened.csv"), BASE("pcg_base.csv"), DEVELOPED("pcg_developed.csv"); + + private final String filePath; + + private AccountsChartEnum(String filePath) { + this.filePath = filePath; + } + + public String getFilePath() { + String result = ""; + if (!this.filePath.equals("")){ + result=getClass().getResource("/import/"+this.filePath).getPath(); + } + return result; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,39 +30,39 @@ public enum ComboBoxAccountsEnum { - ALL(_("lima.enum.comboboxaccount.allaccount")), - ACCOUNT(_("lima.enum.comboboxaccount.account")), - ACCOUNT_LIST(_("lima.enum.comboboxaccount.accountlist")); - - private final String description; - - private ComboBoxAccountsEnum(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - - public static String[] descriptions(){ - int nbElts = ComboBoxAccountsEnum.values().length; - String[] descriptions = new String[nbElts]; - ComboBoxAccountsEnum[] enums = ComboBoxAccountsEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } - - public static ComboBoxAccountsEnum valueOfDescription(String description){ - ComboBoxAccountsEnum value = null; - - for (ComboBoxAccountsEnum enums : ComboBoxAccountsEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } + ALL(_("lima.enum.comboboxaccount.allaccount")), + ACCOUNT(_("lima.enum.comboboxaccount.account")), + ACCOUNT_LIST(_("lima.enum.comboboxaccount.accountlist")); + + private final String description; + + private ComboBoxAccountsEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxAccountsEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxAccountsEnum[] enums = ComboBoxAccountsEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxAccountsEnum valueOfDescription(String description){ + ComboBoxAccountsEnum value = null; + + for (ComboBoxAccountsEnum enums : ComboBoxAccountsEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,39 +30,39 @@ public enum ComboBoxDatesEnum { - FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), - FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")), - PERIOD(_("lima.enum.comboboxperiod.period")); - - private final String description; - - private ComboBoxDatesEnum(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - - public static String[] descriptions(){ - int nbElts = ComboBoxDatesEnum.values().length; - String[] descriptions = new String[nbElts]; - ComboBoxDatesEnum[] enums = ComboBoxDatesEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } - - public static ComboBoxDatesEnum valueOfDescription(String description){ - ComboBoxDatesEnum value = null; - - for (ComboBoxDatesEnum enums : ComboBoxDatesEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } + FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), + FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")), + PERIOD(_("lima.enum.comboboxperiod.period")); + + private final String description; + + private ComboBoxDatesEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxDatesEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxDatesEnum[] enums = ComboBoxDatesEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxDatesEnum valueOfDescription(String description){ + ComboBoxDatesEnum value = null; + + for (ComboBoxDatesEnum enums : ComboBoxDatesEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,38 +30,38 @@ public enum ComboBoxEntryBooksEnum { - ALL(_("lima.enum.comboboxentrybook.all")), - SELECT_ONE(_("lima.enum.comboboxentrybook.select_one")); - - private final String description; - - private ComboBoxEntryBooksEnum(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - - public static String[] descriptions(){ - int nbElts = ComboBoxEntryBooksEnum.values().length; - String[] descriptions = new String[nbElts]; - ComboBoxEntryBooksEnum[] enums = ComboBoxEntryBooksEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } - - public static ComboBoxEntryBooksEnum valueOfDescription(String description){ - ComboBoxEntryBooksEnum value = null; - - for (ComboBoxEntryBooksEnum enums : ComboBoxEntryBooksEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } + ALL(_("lima.enum.comboboxentrybook.all")), + SELECT_ONE(_("lima.enum.comboboxentrybook.select_one")); + + private final String description; + + private ComboBoxEntryBooksEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxEntryBooksEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxEntryBooksEnum[] enums = ComboBoxEntryBooksEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxEntryBooksEnum valueOfDescription(String description){ + ComboBoxEntryBooksEnum value = null; + + for (ComboBoxEntryBooksEnum enums : ComboBoxEntryBooksEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,38 +30,38 @@ public enum ComboBoxLetterEnum { - ALL(_("lima.enum.comboboxletter.all")), - SELECT_ONE(_("lima.enum.comboboxletter.selectone")); - - private final String description; - - private ComboBoxLetterEnum(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - - public static String[] descriptions(){ - int nbElts = ComboBoxLetterEnum.values().length; - String[] descriptions = new String[nbElts]; - ComboBoxLetterEnum[] enums = ComboBoxLetterEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } - - public static ComboBoxLetterEnum valueOfDescription(String description){ - ComboBoxLetterEnum value = null; - - for (ComboBoxLetterEnum enums : ComboBoxLetterEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } + ALL(_("lima.enum.comboboxletter.all")), + SELECT_ONE(_("lima.enum.comboboxletter.selectone")); + + private final String description; + + private ComboBoxLetterEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxLetterEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxLetterEnum[] enums = ComboBoxLetterEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxLetterEnum valueOfDescription(String description){ + ComboBoxLetterEnum value = null; + + for (ComboBoxLetterEnum enums : ComboBoxLetterEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,50 +30,50 @@ public enum ComboBoxOperatorsEnum { - EQUAL(_("lima.enum.comboboxoperator.equal"), "="), - SUPERIOR_OR_EQUAL(_("lima.enum.comboboxoperator.superiororequal"), ">="), - INFERIOR_OR_EQUAL(_("lima.enum.comboboxoperator.inferiororequal"), "<="), - SUPERIOR(_("lima.enum.comboboxoperator.superior"), ">"), - INFERIOR(_("lima.enum.comboboxoperator.inferior"), "<"), - INTERVAL(_("lima.enum.comboboxoperator.interval"), ""), - NOT_EQUAL(_("lima.enum.comboboxoperator.notequal"),"!="); - - private final String description; - private final String symbol; - - private ComboBoxOperatorsEnum(String description, String symbol) { - this.description = description; - this.symbol = symbol; - } - - public String getDescription() { - return this.description; - } - - public String getSymbol(){ - return this.symbol; - } - - public static String[] descriptions(){ - int nbElts = ComboBoxOperatorsEnum.values().length; - String[] descriptions = new String[nbElts]; - ComboBoxOperatorsEnum[] enums = ComboBoxOperatorsEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } + EQUAL(_("lima.enum.comboboxoperator.equal"), "="), + SUPERIOR_OR_EQUAL(_("lima.enum.comboboxoperator.superiororequal"), ">="), + INFERIOR_OR_EQUAL(_("lima.enum.comboboxoperator.inferiororequal"), "<="), + SUPERIOR(_("lima.enum.comboboxoperator.superior"), ">"), + INFERIOR(_("lima.enum.comboboxoperator.inferior"), "<"), + INTERVAL(_("lima.enum.comboboxoperator.interval"), ""), + NOT_EQUAL(_("lima.enum.comboboxoperator.notequal"),"!="); + + private final String description; + private final String symbol; + + private ComboBoxOperatorsEnum(String description, String symbol) { + this.description = description; + this.symbol = symbol; + } + + public String getDescription() { + return this.description; + } + + public String getSymbol(){ + return this.symbol; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxOperatorsEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxOperatorsEnum[] enums = ComboBoxOperatorsEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } - - public static ComboBoxOperatorsEnum valueOfDescription(String description){ - ComboBoxOperatorsEnum value = null; - - for (ComboBoxOperatorsEnum enums : ComboBoxOperatorsEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } + + public static ComboBoxOperatorsEnum valueOfDescription(String description){ + ComboBoxOperatorsEnum value = null; + + for (ComboBoxOperatorsEnum enums : ComboBoxOperatorsEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -30,40 +30,40 @@ public enum ComboBoxPeriodEnum { - PERIOD(_("lima.enum.comboboxperiod.period")), - DATE(_("lima.enum.comboboxperiod.date")), - FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), - FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")); - - private final String description; - - private ComboBoxPeriodEnum(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - - public static String[] descriptions(){ - int nbElts = ComboBoxPeriodEnum.values().length; - String[] descriptions = new String[nbElts]; - ComboBoxPeriodEnum[] enums = ComboBoxPeriodEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } - - public static ComboBoxPeriodEnum valueOfDescription(String description){ - ComboBoxPeriodEnum value = null; - - for (ComboBoxPeriodEnum enums : ComboBoxPeriodEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } + PERIOD(_("lima.enum.comboboxperiod.period")), + DATE(_("lima.enum.comboboxperiod.date")), + FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), + FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")); + + private final String description; + + private ComboBoxPeriodEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxPeriodEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxPeriodEnum[] enums = ComboBoxPeriodEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxPeriodEnum valueOfDescription(String description){ + ComboBoxPeriodEnum value = null; + + for (ComboBoxPeriodEnum enums : ComboBoxPeriodEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,45 +27,45 @@ public enum EncodingEnum { - UTF8("UTF-8", "UTF-8 Lima"), ISOLATIN1("ISO-8859-1", "ISO-Latin-1 Excel / Windows"), - MACROMAN("MacRoman", "MacRoman Excel / Mac"); - - private final String encoding; - private final String description; - - private EncodingEnum(String encoding, String description) { - this.encoding = encoding; - this.description = description; - } - - public String getEncoding() { - return this.encoding; - } - - public String getDescription(){ - return this.description; - } - - public static String[] descriptions(){ - int nbElts = EncodingEnum.values().length; - String[] descriptions = new String[nbElts]; - EncodingEnum[] encodingEnums = EncodingEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = encodingEnums[i].getDescription(); - } - return descriptions; - } - - public static EncodingEnum valueOfDescription(String description){ - EncodingEnum value = null; - - for (EncodingEnum encodingEnum : EncodingEnum.values()) { - if (description.equals(encodingEnum.description)){ - value = encodingEnum; - break; - } - } - return value; - } - + UTF8("UTF-8", "UTF-8 Lima"), ISOLATIN1("ISO-8859-1", "ISO-Latin-1 Excel / Windows"), + MACROMAN("MacRoman", "MacRoman Excel / Mac"); + + private final String encoding; + private final String description; + + private EncodingEnum(String encoding, String description) { + this.encoding = encoding; + this.description = description; + } + + public String getEncoding() { + return this.encoding; + } + + public String getDescription(){ + return this.description; + } + + public static String[] descriptions(){ + int nbElts = EncodingEnum.values().length; + String[] descriptions = new String[nbElts]; + EncodingEnum[] encodingEnums = EncodingEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = encodingEnums[i].getDescription(); + } + return descriptions; + } + + public static EncodingEnum valueOfDescription(String description){ + EncodingEnum value = null; + + for (EncodingEnum encodingEnum : EncodingEnum.values()) { + if (description.equals(encodingEnum.description)){ + value = encodingEnum; + break; + } + } + return value; + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,18 +27,18 @@ public enum EntryBooksChartEnum { - IMPORT(""), DEFAULT("eb_default.csv"); - - private final String filePath; - - private EntryBooksChartEnum(String filePath) { - this.filePath = filePath; - } - - public String getFilePath() { - String result = ""; - if (!this.filePath.equals("")){ - result=getClass().getResource("/import/"+this.filePath).getPath(); - } - return result; } + IMPORT(""), DEFAULT("eb_default.csv"); + + private final String filePath; + + private EntryBooksChartEnum(String filePath) { + this.filePath = filePath; + } + + public String getFilePath() { + String result = ""; + if (!this.filePath.equals("")){ + result=getClass().getResource("/import/"+this.filePath).getPath(); + } + return result; } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -27,20 +27,20 @@ public enum FinancialStatementsChartEnum { - IMPORT(""), SHORTENED("bcr_shortened.csv"), BASE("bcr_base.csv"), DEVELOPED("bcr_developed.csv"); - - private final String filePath; - - private FinancialStatementsChartEnum(String filePath) { - this.filePath = filePath; - - } - - public String getFilePath() { - String result = ""; - if (!this.filePath.equals("")){ - result=getClass().getResource("/import/"+this.filePath).getPath(); - } - return result; - } + IMPORT(""), SHORTENED("bcr_shortened.csv"), BASE("bcr_base.csv"), DEVELOPED("bcr_developed.csv"); + + private final String filePath; + + private FinancialStatementsChartEnum(String filePath) { + this.filePath = filePath; + + } + + public String getFilePath() { + String result = ""; + if (!this.filePath.equals("")){ + result=getClass().getResource("/import/"+this.filePath).getPath(); + } + return result; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -31,33 +31,33 @@ * */ public enum ImportExportEnum { - CSV_ALL_EXPORT(false, true), CSV_ALL_IMPORT(true, true), - CSV_ACCOUNTCHARTS_EXPORT(false, true), CSV_ENTRYBOOKS_EXPORT(false, true), CSV_FINANCIALSTATEMENTS_EXPORT(false, true), - CSV_ACCOUNTCHARTS_IMPORT(true, true), CSV_ENTRYBOOKS_IMPORT(true, true), CSV_FINANCIALSTATEMENTS_IMPORT(true, true), - EBP_ACCOUNTCHARTS_EXPORT(false, false), EBP_ENTRIES_EXPORT(false, false), - EBP_ACCOUNTCHARTS_IMPORT(true, false), EBP_ENTRIES_IMPORT(true, false); - - private final Boolean importMode; - private final Boolean encodingOption; - - /** - * import mode : - * true if import, false if export - */ - private ImportExportEnum(Boolean importMode, Boolean encodingOption) { - this.importMode = importMode; - this.encodingOption = encodingOption; - } - - /** - * encoding choice - * true if import or export methode let encoding option - */ - public Boolean getEncodingOption(){ - return this.encodingOption; - } - - public Boolean getImportMode() { - return this.importMode; - } + CSV_ALL_EXPORT(false, true), CSV_ALL_IMPORT(true, true), + CSV_ACCOUNTCHARTS_EXPORT(false, true), CSV_ENTRYBOOKS_EXPORT(false, true), CSV_FINANCIALSTATEMENTS_EXPORT(false, true), + CSV_ACCOUNTCHARTS_IMPORT(true, true), CSV_ENTRYBOOKS_IMPORT(true, true), CSV_FINANCIALSTATEMENTS_IMPORT(true, true), + EBP_ACCOUNTCHARTS_EXPORT(false, false), EBP_ENTRIES_EXPORT(false, false), + EBP_ACCOUNTCHARTS_IMPORT(true, false), EBP_ENTRIES_IMPORT(true, false); + + private final Boolean importMode; + private final Boolean encodingOption; + + /** + * import mode : + * true if import, false if export + */ + private ImportExportEnum(Boolean importMode, Boolean encodingOption) { + this.importMode = importMode; + this.encodingOption = encodingOption; + } + + /** + * encoding choice + * true if import or export methode let encoding option + */ + public Boolean getEncodingOption(){ + return this.encodingOption; + } + + public Boolean getImportMode() { + return this.importMode; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -94,13 +94,13 @@ return instance; } - public <M> M getService(Class<M> serviceMonitorableClass){ + public <M> M getService(Class<M> serviceMonitorableClass){ M result = (M) services.get(serviceMonitorableClass); if (result == null) { - Object ejbHome = null; - String serviceName = serviceMonitorableClass.getSimpleName().replace("Monitorable", "ImplRemote"); - try { - ejbHome = ctx.lookup(serviceName); + Object ejbHome = null; + String serviceName = serviceMonitorableClass.getSimpleName().replace("Monitorable", "ImplRemote"); + try { + ejbHome = ctx.lookup(serviceName); } catch (NamingException eee) { if (log.isErrorEnabled()) { log.error("Can't lookup for service : " + serviceName, eee); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -37,46 +37,46 @@ public class ServiceMonitorableHandler implements InvocationHandler { private static final Log log = LogFactory.getLog(ServiceMonitorableHandler.class); - - private Object service; - private List<ServiceListener> listeners; - - public ServiceMonitorableHandler(Object service){ - this.service = service; - listeners = new ArrayList<ServiceListener>(); - } - - public void addServiceListener(ServiceListener serviceListener){ - listeners.add(serviceListener); - } + + private Object service; + private List<ServiceListener> listeners; + + public ServiceMonitorableHandler(Object service){ + this.service = service; + listeners = new ArrayList<ServiceListener>(); + } + + public void addServiceListener(ServiceListener serviceListener){ + listeners.add(serviceListener); + } - public void removeServiceListener(ServiceListener serviceListener){ - listeners.remove(serviceListener); - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - Object result = null; - if (method.getName().equals("addListener")){ - addServiceListener((ServiceListener) args[0]); - } - else if (method.getName().equals("removeListener")){ - removeServiceListener((ServiceListener) args[0]); - } - else { - try { - result = method.invoke(service, args); - }catch (InvocationTargetException eee){ - throw eee.getCause(); - } - if (!method.getName().startsWith("get")){ - for (ServiceListener serviceListener : listeners) { - serviceListener.notifyMethod(service.toString(), method.getName()); - log.debug("proxy : " + service.toString() + " " + method.getName()); - } - } - } - return result; - } + public void removeServiceListener(ServiceListener serviceListener){ + listeners.remove(serviceListener); + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + Object result = null; + if (method.getName().equals("addListener")){ + addServiceListener((ServiceListener) args[0]); + } + else if (method.getName().equals("removeListener")){ + removeServiceListener((ServiceListener) args[0]); + } + else { + try { + result = method.invoke(service, args); + }catch (InvocationTargetException eee){ + throw eee.getCause(); + } + if (!method.getName().startsWith("get")){ + for (ServiceListener serviceListener : listeners) { + serviceListener.notifyMethod(service.toString(), method.getName()); + log.debug("proxy : " + service.toString() + " " + method.getName()); + } + } + } + return result; + } } 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -326,7 +326,7 @@ public void showFinancialPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialPeriodView financialPeriodView = - new FinancialPeriodView(mainView); + new FinancialPeriodView(mainView); mainView.showTab(_("lima.charts.financialperiod"), financialPeriodView); } @@ -337,7 +337,7 @@ public void showFinancialStatementView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialStatementChartView financialStatementView = - new FinancialStatementChartView(mainView); + new FinancialStatementChartView(mainView); mainView.showTab(_("lima.charts.financialstatement"), financialStatementView); } @@ -348,7 +348,7 @@ public void showAccountReports(JAXXContext rootContext) { MainView mainView = getUI(rootContext); AccountsReportsView accountsReportsView = - new AccountsReportsView(mainView); + new AccountsReportsView(mainView); mainView.showTab(_("lima.reports.accounts"), accountsReportsView); } @@ -386,7 +386,7 @@ } public void showLetteringView(JAXXContext rootContext){ - MainView mainView = getUI(rootContext); + MainView mainView = getUI(rootContext); LetteringView letteringView = new LetteringView(mainView); mainView.showTab(_("lima.entries.lettering"), letteringView); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -49,10 +49,10 @@ * By : $Author$ */ public class AccountTreeTableModel extends AbstractTreeTableModel { - + /** log. */ private static final Log log = LogFactory.getLog(AccountViewHandler.class); - + /** Account service. */ protected final AccountServiceMonitorable accountService; @@ -64,8 +64,8 @@ super(new AccountImpl()); // Gets factory service accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); } @@ -95,7 +95,7 @@ try { result = accountService.getChildrenAccounts(null).size(); } catch (LimaException eee) { - log.debug("Can't count child", eee); + log.debug("Can't count child", eee); } } else { @@ -103,7 +103,7 @@ try { result = accountService.getChildrenAccounts(parentAccount).size(); } catch (LimaException eee) { - log.debug("Can't count child", eee); + log.debug("Can't count child", eee); } } return result; @@ -115,10 +115,10 @@ if (parent == getRoot()) { try { List<Account> allAccounts = - accountService.getChildrenAccounts(null); + accountService.getChildrenAccounts(null); result = allAccounts.get(index); } catch (LimaException eee) { - log.debug("Can't get child", eee); + log.debug("Can't get child", eee); } } else { @@ -127,10 +127,10 @@ // FIXME sub account is a collection ? try { List<Account> subaccounts = - accountService.getChildrenAccounts(parentAccount); + accountService.getChildrenAccounts(parentAccount); result = subaccounts.get(index); } catch (LimaException eee) { - log.debug("Can't get child", eee); + log.debug("Can't get child", eee); } } return result; @@ -145,20 +145,20 @@ if (parent == getRoot()) { try { List<Account> allAccounts = - accountService.getChildrenAccounts(null); + accountService.getChildrenAccounts(null); result = allAccounts.indexOf(child); } catch (LimaException eee) { - log.debug("Can't get index child", eee); + log.debug("Can't get index child", eee); } } else { // FIXME sub account is a collection ? try { List<Account> subaccounts = - accountService.getChildrenAccounts(parentAccount); + accountService.getChildrenAccounts(parentAccount); result = subaccounts.indexOf(childAccount); } catch (LimaException eee) { - log.debug("Can't get index child", eee); + log.debug("Can't get index child", eee); } } return result; @@ -234,14 +234,14 @@ */ public void updateAccount(TreePath path, Account account) throws LimaException { // Calling account service - //FIXME Force fire for no update if error. Where is the cache ? - try{ + //FIXME Force fire for no update if error. Where is the cache ? + try{ accountService.updateAccount(account); - } - catch (LimaBusinessException eee) { + } + catch (LimaBusinessException eee) { modelSupport.fireTreeStructureChanged(path); - throw eee; - } + throw eee; + } modelSupport.fireTreeStructureChanged(path); } @@ -264,7 +264,7 @@ public void removeAccount(TreePath path, Account account) throws LimaException { // Calling account service int index = getIndexOfChild( - path.getParentPath().getLastPathComponent(), account); + path.getParentPath().getLastPathComponent(), account); accountService.removeAccount(account); modelSupport.fireChildRemoved(path.getParentPath(), index, account); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -68,8 +68,8 @@ protected AccountViewHandler(AccountView view) { this.view = view; // Gets factory service - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } /** @@ -79,7 +79,7 @@ JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); Account newAccount = new AccountImpl(); AccountForm accountForm = new AccountForm(view); @@ -97,8 +97,8 @@ if ( selectedRow != -1) { treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); } else { - //FIXME Get root created on model with Impl() - //Can best not create root in model, and verify if root is null ? + //FIXME Get root created on model with Impl() + //Can best not create root in model, and verify if root is null ? treePath = new TreePath(accountsTreeTableModel.getRoot()); } @@ -123,9 +123,9 @@ }; public void addSubLedger(){ - JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); + JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); Account newAccount = new AccountImpl(); SubLedgerForm subledgerForm = new SubLedgerForm(view); @@ -144,7 +144,7 @@ // add it try { accountsTreeTableModel. - addSubLedger(treePath, newAccount); + addSubLedger(treePath, newAccount); } catch (LimaBusinessException eee) { if (log.isErrorEnabled()) { log.error("Can't add subledger", eee); @@ -168,54 +168,54 @@ public void updateAccount() { JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); // get selected account int selectedRow = view.getAccountsTreeTable().getSelectedRow(); TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // not null Account selectedObject = (Account)treePath.getLastPathComponent(); - //update Account or update SubLedger - if (selectedObject != null) { - // get current selection path - if ( selectedRow != -1) { - treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); - } else { - treePath = new TreePath(accountsTreeTableModel.getRoot()); - } - //test if selectedrow is account or ledger - if (selectedObject.getGeneralLedger()==null){ - AccountForm accountForm = new AccountForm(view); - accountForm.setAccount(selectedObject); - // jaxx constructor don't call super() ? - accountForm.setLocationRelativeTo(view); - accountForm.setVisible(true); - // null == cancel action - selectedObject = accountForm.getAccount(); - } - // else is a subledger - else{ - SubLedgerForm subLedgerForm = new SubLedgerForm(view); - subLedgerForm.setAccount(selectedObject); - // jaxx constructor don't call super() ? - subLedgerForm.setLocationRelativeTo(view); - subLedgerForm.setVisible(true); - // null == cancel action - selectedObject = subLedgerForm.getAccount(); - } - //if action confirmed - if (selectedObject != null){ - // update it - try { - accountsTreeTableModel. - updateAccount(treePath, selectedObject); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add update", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - } + //update Account or update SubLedger + if (selectedObject != null) { + // get current selection path + if ( selectedRow != -1) { + treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); + } else { + treePath = new TreePath(accountsTreeTableModel.getRoot()); + } + //test if selectedrow is account or ledger + if (selectedObject.getGeneralLedger()==null){ + AccountForm accountForm = new AccountForm(view); + accountForm.setAccount(selectedObject); + // jaxx constructor don't call super() ? + accountForm.setLocationRelativeTo(view); + accountForm.setVisible(true); + // null == cancel action + selectedObject = accountForm.getAccount(); + } + // else is a subledger + else{ + SubLedgerForm subLedgerForm = new SubLedgerForm(view); + subLedgerForm.setAccount(selectedObject); + // jaxx constructor don't call super() ? + subLedgerForm.setLocationRelativeTo(view); + subLedgerForm.setVisible(true); + // null == cancel action + selectedObject = subLedgerForm.getAccount(); + } + //if action confirmed + if (selectedObject != null){ + // update it + try { + accountsTreeTableModel. + updateAccount(treePath, selectedObject); + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add update", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + } + } } @@ -227,7 +227,7 @@ // maybe this code can be factorised JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); // Any row selected int selectedRow = view.getAccountsTreeTable().getSelectedRow(); @@ -240,7 +240,7 @@ if (n == JOptionPane.YES_OPTION) { // update view of treetable TreePath treePath = view.getAccountsTreeTable(). - getPathForRow(selectedRow); + getPathForRow(selectedRow); Account account = (Account) treePath.getLastPathComponent(); try{ @@ -258,53 +258,53 @@ public void refresh(){ JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); - try { - accountsTreeTableModel.refreshTree(); - } catch (LimaException eee) { - if(log.isDebugEnabled()){ - log.debug("Can't refresh model", eee); - } - } - //refresh view - view.repaint(); + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + try { + accountsTreeTableModel.refreshTree(); + } catch (LimaException eee) { + if(log.isDebugEnabled()){ + log.debug("Can't refresh model", eee); + } + } + //refresh view + view.repaint(); } public void importAccountsChart(){ - - AccountImportForm form = new AccountImportForm(); - // - form.setLocationRelativeTo(view); - form.setVisible(true); - - ImportExport importExport = ImportExport.getInstance(view); + + AccountImportForm form = new AccountImportForm(); + // + form.setLocationRelativeTo(view); + form.setVisible(true); + + ImportExport importExport = ImportExport.getInstance(view); - Object value = form.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - AccountsChartEnum defaultAccountsChartEnum = - (AccountsChartEnum) value; - //Import accounts chart - switch (defaultAccountsChartEnum) { - case IMPORTEBP: - importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; + Object value = form.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null){ + AccountsChartEnum defaultAccountsChartEnum = + (AccountsChartEnum) value; + //Import accounts chart + switch (defaultAccountsChartEnum) { + case IMPORTEBP: + importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; - default: - importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; - } - } + default: + importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; + } + } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - - if (methodeName.contains("importAccounts") || methodeName.contains("importAll") || methodeName.contains("importAsCSV")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + + if (methodeName.contains("importAccounts") || methodeName.contains("importAll") || methodeName.contains("importAsCSV")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -40,76 +40,76 @@ public class AccountComboBox extends JComboBox implements KeyListener, ActionListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(AccountComboBox.class); - - protected AccountsReportsViewHandler handler; - - public AccountComboBox(AccountsReportsViewHandler handler) { - this.handler = handler; - AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); - AccountRenderer accountRenderer = new AccountRenderer(); - setModel(accountComboBoxModel); - setRenderer(accountRenderer); - setEditable(true); - AutoCompleteDecorator.decorate(this, AccountToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); - } + + protected AccountsReportsViewHandler handler; + + public AccountComboBox(AccountsReportsViewHandler handler) { + this.handler = handler; + AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); + AccountRenderer accountRenderer = new AccountRenderer(); + setModel(accountComboBoxModel); + setRenderer(accountRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, AccountToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } - public void back(){ - int row = this.getSelectedIndex(); - log.debug(row); - if (row > 0){ - this.getEditor().setItem(this.getItemAt(row-1)); - handler.setAccount((Account) this.getSelectedItem()); - } - } - - public void next(){ - int size = this.getModel().getSize(); - int row = this.getSelectedIndex(); - log.debug(row); - - if (row < size-1){ - this.getEditor().setItem(this.getItemAt(row+1)); - handler.setAccount((Account) this.getSelectedItem()); - } - } - - @Override - public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Account){ - handler.setAccount((Account) this.getSelectedItem()); - } - } + public void back(){ + int row = this.getSelectedIndex(); + log.debug(row); + if (row > 0){ + this.getEditor().setItem(this.getItemAt(row-1)); + handler.setAccount((Account) this.getSelectedItem()); + } + } + + public void next(){ + int size = this.getModel().getSize(); + int row = this.getSelectedIndex(); + log.debug(row); + + if (row < size-1){ + this.getEditor().setItem(this.getItemAt(row+1)); + handler.setAccount((Account) this.getSelectedItem()); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Account){ + handler.setAccount((Account) this.getSelectedItem()); + } + } - @Override - public void keyPressed(KeyEvent e) { - - } + @Override + public void keyPressed(KeyEvent e) { + + } - @Override - public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Account){ - handler.setAccount((Account) this.getSelectedItem()); - } - - // delegate popup list menu + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Account){ + handler.setAccount((Account) this.getSelectedItem()); + } + + // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) { - firePopupMenuCanceled(); + firePopupMenuCanceled(); } - } + } - @Override - public void keyTyped(KeyEvent e) { - - } - + @Override + public void keyTyped(KeyEvent e) { + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -46,114 +46,114 @@ import org.jdesktop.swingx.JXDatePicker; public class AccountsReportsPeriodSearchPanel extends JPanel { - + private static final Log log = LogFactory.getLog(AccountsReportsPeriodSearchPanel.class); - - protected AccountsReportsViewHandler handler; - - public AccountsReportsPeriodSearchPanel(AccountsReportsViewHandler handler) { - this.handler = handler; - - //init date + + protected AccountsReportsViewHandler handler; + + public AccountsReportsPeriodSearchPanel(AccountsReportsViewHandler handler) { + this.handler = handler; + + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); - } - - static final long serialVersionUID = 1L; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - - switch (comboBoxPeriodEnum) { - case PERIOD: - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); - //handler().setBeginDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - Date endDate = calendarEnd.getTime(); - //handler().setEndDate(endDate); - JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); - final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); - ActionListener beginDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(beginDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(beginDatePicker.getDate()); - beginDatePicker.addActionListener(beginDateActionListener); - - JLabel endDateLabel = new JLabel(_("lima.common.enddate")); - final JXDatePicker endDatePicker = new JXDatePicker(endDate); - ActionListener endDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setEndDate(endDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); - fiscalPeriod.setEditable(false); - ActionListener fiscalPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ + + switch (comboBoxPeriodEnum) { + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setEndDate(endDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + handler.refresh(); + + this.removeAll(); + this.add(beginDateLabel); + this.add(beginDatePicker); + this.add(endDateLabel); + this.add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); - financialPeriod.setEditable(false); - ActionListener financialPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); - if (fPeriod !=null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); - break; - } - - } - + this.removeAll(); + this.add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod !=null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + this.removeAll(); + this.add(financialPeriod); + break; + } + + } + } 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -55,9 +55,9 @@ // just prevent too much result if (cacheDataList != null) { - if (cacheDataList.getListEntry() != null){ + if (cacheDataList.getListEntry() != null){ result = cacheDataList.getListEntry().size(); - } + } } return result; @@ -72,9 +72,9 @@ public String getColumnName(int column) { String res = "n/a"; switch (column) { - case 0: - res = _("lima.table.account"); //Account Number - break; + case 0: + res = _("lima.table.account"); //Account Number + break; case 1: res = _("lima.table.date"); //Date break; @@ -109,9 +109,9 @@ = new SimpleDateFormat("dd MMMMM yyyy"); switch (column) { - case 0: - result = currentRow.getAccount().getAccountNumber(); - break; + case 0: + result = currentRow.getAccount().getAccountNumber(); + break; case 1: result = simpleDateFormat. format(currentRow.getFinancialTransaction().getTransactionDate()); @@ -131,13 +131,13 @@ result = currentRow.getDescription(); break; case 5: - if (currentRow.getLetter() != null){ - result = currentRow.getLetter().getCode(); - } - else { - result = null; - } - break; + if (currentRow.getLetter() != null){ + result = currentRow.getLetter().getCode(); + } + else { + result = null; + } + break; case 6: result = currentRow.getDebit() ? currentRow.getAmount() : 0; break; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -74,12 +74,12 @@ this.view = view; reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class).addListener(this); } public void setBeginDate(Date date){ @@ -117,48 +117,48 @@ } public void refresh(){ - - if (selectedBeginDate != null && selectedEndDate != null && selectedAccount != null){ - ReportsDatas datasList = getDataList(); - - tableModel = view.getModelAccountsReportsTable(); - tableModel.refresh(datasList); - - /** - * set text and amounts of labels credit, debit, solde - */ - - if (datasList != null){ - // set amounts credit and debit and solde - view.amountCreditLabel.setText( - datasList.getAmountCredit().toString()); - view.amountDebitLabel.setText( - datasList.getAmountDebit().toString()); - BigDecimal amountSolde = datasList.getAmountSolde(); - view.amountSoldeLabel.setText(amountSolde.toString()); - - - if (amountSolde.doubleValue() == 0){ - view.soldeLabel.setText(_("lima.common.solde")); - } - else { - // set label solde: credit or debit - if (datasList.getSoldeDebit()) { - view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { - view.soldeLabel.setText(_("lima.common.soldecredit")); - } - } - } - } + + if (selectedBeginDate != null && selectedEndDate != null && selectedAccount != null){ + ReportsDatas datasList = getDataList(); + + tableModel = view.getModelAccountsReportsTable(); + tableModel.refresh(datasList); + + /** + * set text and amounts of labels credit, debit, solde + */ + + if (datasList != null){ + // set amounts credit and debit and solde + view.amountCreditLabel.setText( + datasList.getAmountCredit().toString()); + view.amountDebitLabel.setText( + datasList.getAmountDebit().toString()); + BigDecimal amountSolde = datasList.getAmountSolde(); + view.amountSoldeLabel.setText(amountSolde.toString()); + + + if (amountSolde.doubleValue() == 0){ + view.soldeLabel.setText(_("lima.common.solde")); + } + else { + // set label solde: credit or debit + if (datasList.getSoldeDebit()) { + view.soldeLabel.setText(_("lima.common.soldedebit")); + } + else { + view.soldeLabel.setText(_("lima.common.soldecredit")); + } + } + } + } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -46,115 +46,115 @@ import org.jdesktop.swingx.JXDatePicker; public class BalancePeriodSearchPanel extends JPanel { - + private static final Log log = LogFactory.getLog(BalancePeriodSearchPanel.class); - - protected BalanceViewHandler handler; - - public BalancePeriodSearchPanel(BalanceViewHandler handler) { - this.handler = handler; - - //init date + + protected BalanceViewHandler handler; + + public BalancePeriodSearchPanel(BalanceViewHandler handler) { + this.handler = handler; + + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); - } - - static final long serialVersionUID = 1L; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - - switch (comboBoxPeriodEnum) { + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ + + switch (comboBoxPeriodEnum) { - case PERIOD: - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); - //handler().setBeginDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - Date endDate = calendarEnd.getTime(); - //handler().setEndDate(endDate); - JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); - final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); - ActionListener beginDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(beginDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(beginDatePicker.getDate()); - beginDatePicker.addActionListener(beginDateActionListener); - - JLabel endDateLabel = new JLabel(_("lima.common.enddate")); - final JXDatePicker endDatePicker = new JXDatePicker(endDate); - ActionListener endDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setEndDate(endDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); - fiscalPeriod.setEditable(false); - ActionListener fiscalPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); - if (fPeriod !=null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setEndDate(endDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + handler.refresh(); + + this.removeAll(); + this.add(beginDateLabel); + this.add(beginDatePicker); + this.add(endDateLabel); + this.add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod !=null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); - financialPeriod.setEditable(false); - ActionListener financialPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); - if (fPeriod !=null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); - break; - } - - } - + this.removeAll(); + this.add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod !=null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + this.removeAll(); + this.add(financialPeriod); + break; + } + + } + } 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -52,10 +52,10 @@ @Override public int getRowCount() { int result = 0; - if (cacheDataList != null){ - result = cacheDataList.getReportsDatas().size(); - } - return result; + if (cacheDataList != null){ + result = cacheDataList.getReportsDatas().size(); + } + return result; } @Override 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -76,7 +76,7 @@ protected BalanceTableModel model; private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); + new SimpleDateFormat("yyyy-MM-dd"); protected int port; @@ -84,14 +84,14 @@ this.view = view; reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); port = LimaServiceFactory.getInstance().getService( - HttpServerServiceMonitorable.class).getHttpPort(); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + HttpServerServiceMonitorable.class).getHttpPort(); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class).addListener(this); } public void setBeginDate(Date date){ @@ -129,69 +129,69 @@ } public void refresh(){ - - if (selectedBeginDate != null && selectedEndDate != null){ - model = view.getModelBalanceTable(); - BalanceTrial datasList = getDataList(); - model.refresh(datasList); - - /** - * update the labels credit, debit, solde on the footer - * get all entries for all accounts on the selected period - */ - - if (datasList != null){ - // set amounts credit, debit and solde - view.amountCreditLabel.setText( - String.valueOf(datasList.getAmountCredit())); - view.amountDebitLabel.setText( - String.valueOf(datasList.getAmountDebit())); - BigDecimal amountSolde = datasList.getAmountSolde(); - view.amountSoldeLabel.setText( - String.valueOf(amountSolde)); - - - if (amountSolde.doubleValue() == 0){ - view.soldeLabel.setText(_("lima.common.solde")); - } - else { - // set label solde: credit or debit - if (datasList.getSoldeDebit()) { - view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { - view.soldeLabel.setText(_("lima.common.soldecredit")); - } - } - } - } + + if (selectedBeginDate != null && selectedEndDate != null){ + model = view.getModelBalanceTable(); + BalanceTrial datasList = getDataList(); + model.refresh(datasList); + + /** + * update the labels credit, debit, solde on the footer + * get all entries for all accounts on the selected period + */ + + if (datasList != null){ + // set amounts credit, debit and solde + view.amountCreditLabel.setText( + String.valueOf(datasList.getAmountCredit())); + view.amountDebitLabel.setText( + String.valueOf(datasList.getAmountDebit())); + BigDecimal amountSolde = datasList.getAmountSolde(); + view.amountSoldeLabel.setText( + String.valueOf(amountSolde)); + + + if (amountSolde.doubleValue() == 0){ + view.soldeLabel.setText(_("lima.common.solde")); + } + else { + // set label solde: credit or debit + if (datasList.getSoldeDebit()) { + view.soldeLabel.setText(_("lima.common.soldedebit")); + } + else { + view.soldeLabel.setText(_("lima.common.soldecredit")); + } + } + } + } } public void createDocument() { - - if (selectedBeginDate != null & selectedEndDate != null){ - FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); - String address = LimaConfig.getInstance().getHostAdress(); - - try { - String url = "http://"+address+":"+port+"/?beginDate=" - +dateFormat.format(selectedBeginDate) - +"&endDate="+dateFormat.format(selectedEndDate)+"&format=" - +selectedEnum.getExtension()+"&model=" - + DocumentsEnum.BALANCE.getFileName(); - Desktop.getDesktop().browse(new URI(url)); - } catch (IOException e) { - log.error("Can't open browser", e); - } catch (URISyntaxException e) { - log.error("Can't create news URI", e); - } - } + + if (selectedBeginDate != null & selectedEndDate != null){ + FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); + String address = LimaConfig.getInstance().getHostAdress(); + + try { + String url = "http://"+address+":"+port+"/?beginDate=" + +dateFormat.format(selectedBeginDate) + +"&endDate="+dateFormat.format(selectedEndDate)+"&format=" + +selectedEnum.getExtension()+"&model=" + + DocumentsEnum.BALANCE.getFileName(); + Desktop.getDesktop().browse(new URI(url)); + } catch (IOException e) { + log.error("Can't open browser", e); + } catch (URISyntaxException e) { + log.error("Can't create news URI", e); + } + } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -59,7 +59,7 @@ * constructor */ public AccountTableCellEditor() { - super(); + super(); comboBox = new JWideComboBox(); accountComboBoxModel = new SubAccountComboBoxModel(); comboBox.setModel(accountComboBoxModel); @@ -79,7 +79,7 @@ @Override public Object getCellEditorValue() { - return comboBox.getSelectedItem(); + return comboBox.getSelectedItem(); } /** @@ -114,14 +114,14 @@ } - @Override - public void keyPressed(KeyEvent e) { - - } - - @Override - public void keyReleased(KeyEvent e) { - + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + // Vérifie si c'est la première frappe au clavier if ( keyPressed == false ) { @@ -131,19 +131,19 @@ edit.select(1, edit.getText().length()); keyPressed = true; } - - // delegate popup list menu + + // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) { - fireEditingStopped(); + fireEditingStopped(); } - } - - @Override - public void keyTyped(KeyEvent e) { - - } + } + @Override + public void keyTyped(KeyEvent e) { + + } + public static AccountTableCellEditor getInstance() { if (editor == null) { editor = new AccountTableCellEditor(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -57,7 +57,7 @@ * constructor */ public LetterTableCellEditor() { - super(); + super(); comboBox = new JWideComboBox(); comboBoxModel = new LetterComboBoxModel(); comboBox.setModel(comboBoxModel); @@ -77,7 +77,7 @@ @Override public Object getCellEditorValue() { - return comboBox.getSelectedItem(); + return comboBox.getSelectedItem(); } /** @@ -112,14 +112,14 @@ } - @Override - public void keyPressed(KeyEvent e) { - - } - - @Override - public void keyReleased(KeyEvent e) { - + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + // Vérifie si c'est la première frappe au clavier if ( keyPressed == false ) { @@ -129,19 +129,19 @@ edit.select(1, edit.getText().length()); keyPressed = true; } - - // delegate popup list menu + + // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) { - fireEditingStopped(); + fireEditingStopped(); } - } - - @Override - public void keyTyped(KeyEvent e) { - - } + } + @Override + public void keyTyped(KeyEvent e) { + + } + public static LetterTableCellEditor getInstance() { if (editor == null) { editor = new LetterTableCellEditor(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -44,10 +44,10 @@ public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + private static final Log log = + LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedAccount; @@ -57,11 +57,11 @@ public AccountComboBoxModel () { accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); accountService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache = getDataList(); } @@ -73,13 +73,13 @@ @Override public void setSelectedItem(Object anItem) { selectedAccount = anItem; - fireContentsChanged(this, -1, -1); + fireContentsChanged(this, -1, -1); } @Override public Object getElementAt(int index) { - return datasCache.get(index); + return datasCache.get(index); } @Override @@ -102,16 +102,16 @@ } public void refresh(){ - datasCache = getDataList(); - fireContentsChanged(this, 0, datasCache.size()); + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("Account") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("Account") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -35,19 +35,19 @@ public class AccountRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = new JLabel(); Account account = (Account) value; if (account != null){ - String accountLabel = account.getLabel(); - int nbChars = 30; - if (accountLabel.length()>nbChars){ - accountLabel = accountLabel.substring(0, nbChars)+"…"; - } + String accountLabel = account.getLabel(); + int nbChars = 30; + if (accountLabel.length()>nbChars){ + accountLabel = accountLabel.substring(0, nbChars)+"…"; + } label.setText(account.getAccountNumber() +" - " + accountLabel); } return label; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -49,10 +49,10 @@ */ public class EntryBookComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + private static final Log log = + LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedEntryBook; @@ -62,11 +62,11 @@ public EntryBookComboBoxModel() { entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); entryBookService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); cacheDatas = getDataList(); } @@ -109,14 +109,14 @@ public void refresh(){ - cacheDatas = getDataList(); - fireContentsChanged(this, 0, cacheDatas.size()); + cacheDatas = getDataList(); + fireContentsChanged(this, 0, cacheDatas.size()); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("EntryBook") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("EntryBook") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -35,25 +35,25 @@ public class EntryBookRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override - public Component getListCellRendererComponent(JList list, + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - // TODO Auto-generated method stub - - JLabel label = new JLabel(); - EntryBook entrybook = (EntryBook) value; - if (entrybook != null){ - label.setText(entrybook.getCode()+" - "+entrybook.getLabel()); - } - return label; + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + EntryBook entrybook = (EntryBook) value; + if (entrybook != null){ + label.setText(entrybook.getCode()+" - "+entrybook.getLabel()); + } + return label; - } + } - - + + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -51,9 +51,9 @@ */ public class FinancialPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final Log log = + private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedFinancialPeriod; @@ -66,13 +66,13 @@ public FinancialPeriodComboBoxModel() { financialPeriodService = - LimaServiceFactory.getInstance().getService( - FinancialPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialPeriodServiceMonitorable.class); financialPeriodService.addListener(this); - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class).addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache=getDataList(); } @@ -106,7 +106,7 @@ try { if (selectedFiscalPeriod != null){ result = (List<FinancialPeriod>) - selectedFiscalPeriod.getFinancialPeriod(); + selectedFiscalPeriod.getFinancialPeriod(); } else { result = financialPeriodService.getUnblockedFinancialPeriods(); @@ -121,14 +121,14 @@ } public void refresh(){ - datasCache = getDataList(); - fireContentsChanged(this, 0, datasCache.size()); + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("Period") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("Period") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -35,25 +35,25 @@ public class FinancialPeriodComboBoxRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override - public Component getListCellRendererComponent(JList list, + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - // TODO Auto-generated method stub - - JLabel label = new JLabel(); - FinancialPeriod financialPeriod = (FinancialPeriod) value; - if (financialPeriod != null){ + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + FinancialPeriod financialPeriod = (FinancialPeriod) value; + if (financialPeriod != null){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yy"); label.setText(simpleDateFormat.format(financialPeriod.getBeginDate())+" - "+simpleDateFormat.format(financialPeriod.getEndDate())); - } - return label; - } + } + return label; + } - + } \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -40,9 +40,9 @@ public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); + private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedFiscalPeriod; @@ -53,14 +53,14 @@ public FiscalPeriodComboBoxModel(){ fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache = getDataList(); } - + @Override public int getSize() { return datasCache.size(); @@ -97,14 +97,14 @@ } public void refresh(){ - datasCache = getDataList(); - fireContentsChanged(this, 0, datasCache.size()); + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FiscalPeriod") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FiscalPeriod") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -34,26 +34,26 @@ public class FiscalPeriodComboBoxRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override - public Component getListCellRendererComponent(JList list, + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - // TODO Auto-generated method stub - - JLabel label = new JLabel(); - FiscalPeriod fiscalPeriod = (FiscalPeriod) value; - if (fiscalPeriod != null){ - SimpleDateFormat simpleDateFormat = - new SimpleDateFormat("dd MMM yy"); - label.setText(simpleDateFormat.format(fiscalPeriod.getBeginDate()) - + " - " + simpleDateFormat.format(fiscalPeriod.getEndDate())); - } - return label; - } + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + FiscalPeriod fiscalPeriod = (FiscalPeriod) value; + if (fiscalPeriod != null){ + SimpleDateFormat simpleDateFormat = + new SimpleDateFormat("dd MMM yy"); + label.setText(simpleDateFormat.format(fiscalPeriod.getBeginDate()) + + " - " + simpleDateFormat.format(fiscalPeriod.getEndDate())); + } + return label; + } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -44,10 +44,10 @@ public class LetterComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + private static final Log log = + LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedAccount; @@ -56,12 +56,12 @@ protected FinancialTransactionServiceMonitorable service; public LetterComboBoxModel () { - service = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - service.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + service = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + service.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache = getDataList(); } @@ -73,13 +73,13 @@ @Override public void setSelectedItem(Object anItem) { selectedAccount = anItem; - fireContentsChanged(this, -1, -1); + fireContentsChanged(this, -1, -1); } @Override public Object getElementAt(int index) { - return datasCache.get(index); + return datasCache.get(index); } @Override @@ -102,16 +102,16 @@ } public void refresh(){ - datasCache = getDataList(); - fireContentsChanged(this, 0, datasCache.size()); + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("Letter") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("Letter") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -33,9 +33,9 @@ public class LetterRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = new JLabel(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -44,9 +44,9 @@ public class SubAccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final Log log = LogFactory.getLog(SubAccountComboBoxModel.class); + private static final Log log = LogFactory.getLog(SubAccountComboBoxModel.class); protected Object selectedAccount; @@ -56,11 +56,11 @@ public SubAccountComboBoxModel() { accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); accountService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache = getDataList(); } @@ -100,16 +100,16 @@ } public void refresh(){ - datasCache = getDataList(); - fireContentsChanged(this, 0, datasCache.size()); + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("Account") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("Account") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -62,8 +62,8 @@ */ public EntryBookTableModel() { entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); LimaServiceFactory.getInstance().getService(ImportServiceMonitorable.class).addListener(this); } @@ -75,7 +75,7 @@ result = entryBookService.getAllEntryBooks().size(); } catch (LimaException e) { if (log.isDebugEnabled()){ - log.debug("Can't get all entrybooks",e); + log.debug("Can't get all entrybooks",e); } } @@ -173,14 +173,14 @@ fireTableRowsDeleted(row, row); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - - //refresh on import datas - if (methodeName.contains("importEntryBooks") - || methodeName.contains("importAll") - || methodeName.contains("importAs")){ - fireTableDataChanged(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + + //refresh on import datas + if (methodeName.contains("importEntryBooks") + || methodeName.contains("importAll") + || methodeName.contains("importAs")){ + fireTableDataChanged(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -61,8 +61,8 @@ public EntryBookViewHandler(EntryBookView view) { this.view = view; entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); } public void addEntryBook() { @@ -154,23 +154,23 @@ } - public void importEntryBooks(){ - + public void importEntryBooks(){ + EntryBookImportForm form = - new EntryBookImportForm(); + new EntryBookImportForm(); form.setLocationRelativeTo(view); form.setVisible(true); - Object value = form.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - EntryBooksChartEnum defaultEntryBooksEnum = - (EntryBooksChartEnum) value; - ImportExport importExport = ImportExport.getInstance(view); - importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, - defaultEntryBooksEnum.getFilePath(), true); - } + Object value = form.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null){ + EntryBooksChartEnum defaultEntryBooksEnum = + (EntryBooksChartEnum) value; + ImportExport importExport = ImportExport.getInstance(view); + importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, + defaultEntryBooksEnum.getFilePath(), true); + } } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -40,75 +40,75 @@ public class EntryBookComboBox extends JComboBox implements KeyListener, ActionListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(EntryBookComboBox.class); - - protected EntryBooksReportsViewHandler handler; - - public EntryBookComboBox(EntryBooksReportsViewHandler handler) { - this.handler = handler; - EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); - EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); - setModel(entryBookComboBoxModel); - setRenderer(entryBookRenderer); - setEditable(true); - AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); - } + + protected EntryBooksReportsViewHandler handler; + + public EntryBookComboBox(EntryBooksReportsViewHandler handler) { + this.handler = handler; + EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); + EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); + setModel(entryBookComboBoxModel); + setRenderer(entryBookRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } - public void back(){ - int row = this.getSelectedIndex(); - log.debug(row); - if (row > 0){ - this.getEditor().setItem(this.getItemAt(row-1)); - handler.setEntryBook((EntryBook) this.getSelectedItem()); - } - } - - public void next(){ - int size = this.getModel().getSize(); - int row = this.getSelectedIndex(); - log.debug(row); - - if (row < size-1){ - this.getEditor().setItem(this.getItemAt(row+1)); - handler.setEntryBook((EntryBook) this.getSelectedItem()); - } - } - - @Override - public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); - } - } + public void back(){ + int row = this.getSelectedIndex(); + log.debug(row); + if (row > 0){ + this.getEditor().setItem(this.getItemAt(row-1)); + handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + } + + public void next(){ + int size = this.getModel().getSize(); + int row = this.getSelectedIndex(); + log.debug(row); + + if (row < size-1){ + this.getEditor().setItem(this.getItemAt(row+1)); + handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof EntryBook){ + handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + } - @Override - public void keyPressed(KeyEvent e) { - - } + @Override + public void keyPressed(KeyEvent e) { + + } - @Override - public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); - } - // delegate popup list menu + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof EntryBook){ + handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) { - firePopupMenuCanceled(); + firePopupMenuCanceled(); } - } + } - @Override - public void keyTyped(KeyEvent e) { - - } - + @Override + public void keyTyped(KeyEvent e) { + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -46,114 +46,114 @@ import org.jdesktop.swingx.JXDatePicker; public class EntryBooksReportsPeriodSearchPanel extends JPanel { - + private static final Log log = LogFactory.getLog(EntryBooksReportsPeriodSearchPanel.class); - - protected EntryBooksReportsViewHandler handler; - - public EntryBooksReportsPeriodSearchPanel(EntryBooksReportsViewHandler handler) { - this.handler = handler; - - //init date + + protected EntryBooksReportsViewHandler handler; + + public EntryBooksReportsPeriodSearchPanel(EntryBooksReportsViewHandler handler) { + this.handler = handler; + + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); - } - - static final long serialVersionUID = 1L; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - - switch (comboBoxPeriodEnum) { - case PERIOD: - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); - //handler().setBeginDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - Date endDate = calendarEnd.getTime(); - //handler().setEndDate(endDate); - JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); - final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); - ActionListener beginDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(beginDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(beginDatePicker.getDate()); - beginDatePicker.addActionListener(beginDateActionListener); - - JLabel endDateLabel = new JLabel(_("lima.common.enddate")); - final JXDatePicker endDatePicker = new JXDatePicker(endDate); - ActionListener endDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setEndDate(endDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); - fiscalPeriod.setEditable(false); - ActionListener fiscalPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ + + switch (comboBoxPeriodEnum) { + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setEndDate(endDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + handler.refresh(); + + this.removeAll(); + this.add(beginDateLabel); + this.add(beginDatePicker); + this.add(endDateLabel); + this.add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); - financialPeriod.setEditable(false); - ActionListener financialPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); - break; - } - - } - + this.removeAll(); + this.add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + this.removeAll(); + this.add(financialPeriod); + break; + } + + } + } 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-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -123,13 +123,13 @@ result = currentRow.getDescription(); break; case 4: - if (currentRow.getLetter() != null){ - result = currentRow.getLetter().getCode(); - } - else { - result = null; - } - break; + if (currentRow.getLetter() != null){ + result = currentRow.getLetter().getCode(); + } + else { + result = null; + } + break; case 5: result = currentRow.getDebit() ? currentRow.getAmount() : 0; break; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -82,23 +82,23 @@ protected int port; private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); + new SimpleDateFormat("yyyy-MM-dd"); protected EntryBooksReportsViewHandler(EntryBooksReportsView view) { this.view = view; reportService = LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); + ReportServiceMonitorable.class); port = LimaServiceFactory.getInstance().getService( - HttpServerServiceMonitorable.class).getHttpPort(); + HttpServerServiceMonitorable.class).getHttpPort(); documentService = - LimaServiceFactory.getInstance().getService( - DocumentServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + DocumentServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class).addListener(this); } public void setBeginDate(Date date){ @@ -123,92 +123,92 @@ try { results = reportService.generateEntryBooksReports( - selectedEntryBook, selectedBeginDate, selectedEndDate); + selectedEntryBook, selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } ErrorHelper.showErrorDialog("Can't get entries list", eee); - } + } } return results; } public void refresh(){ - - if (selectedBeginDate != null && selectedEndDate != null && selectedEntryBook != null){ - tableModel = view.getModelTable(); - - ReportsDatas datasList = getDataList(); - - tableModel.refresh(datasList); - - /** - * set text and amounts of labels credit, debit, solde - */ - - if (datasList != null){ - // set amounts credit, debit and solde - view.amountCreditLabel.setText( - String.valueOf(datasList.getAmountCredit())); - view.amountDebitLabel.setText( - String.valueOf(datasList.getAmountDebit())); - BigDecimal amountSolde = datasList.getAmountSolde(); - view.amountSoldeLabel.setText(String.valueOf(amountSolde)); - - if (amountSolde.doubleValue() == 0){ - view.soldeLabel.setText(_("lima.common.solde")); - } - else { - // set label solde: credit or debit - if (datasList.getSoldeDebit()) { - view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { - view.soldeLabel.setText(_("lima.common.soldecredit")); - } - } - } - } + + if (selectedBeginDate != null && selectedEndDate != null && selectedEntryBook != null){ + tableModel = view.getModelTable(); + + ReportsDatas datasList = getDataList(); + + tableModel.refresh(datasList); + + /** + * set text and amounts of labels credit, debit, solde + */ + + if (datasList != null){ + // set amounts credit, debit and solde + view.amountCreditLabel.setText( + String.valueOf(datasList.getAmountCredit())); + view.amountDebitLabel.setText( + String.valueOf(datasList.getAmountDebit())); + BigDecimal amountSolde = datasList.getAmountSolde(); + view.amountSoldeLabel.setText(String.valueOf(amountSolde)); + + if (amountSolde.doubleValue() == 0){ + view.soldeLabel.setText(_("lima.common.solde")); + } + else { + // set label solde: credit or debit + if (datasList.getSoldeDebit()) { + view.soldeLabel.setText(_("lima.common.soldedebit")); + } + else { + view.soldeLabel.setText(_("lima.common.soldecredit")); + } + } + } + } } public void createDocument() { - - if (selectedBeginDate != null && selectedEndDate != null){ - FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); - String address = LimaConfig.getInstance().getHostAdress(); - - try { - String url = "http://"+address+":"+port+"/?beginDate=" - +dateFormat.format(selectedBeginDate) - +"&endDate="+dateFormat.format(selectedEndDate) - +"&format="+selectedEnum.getExtension()+"&model=" - + DocumentsEnum.ENTRYBOOKS.getFileName(); - Desktop.getDesktop().browse(new URI(url)); - - String url2 = "http://"+address+":"+port+"/?beginDate=" - +dateFormat.format(selectedBeginDate) - +"&endDate="+dateFormat.format(selectedEndDate) - +"&format="+selectedEnum.getExtension()+"&model=" - + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName(); - Desktop.getDesktop().browse(new URI(url2)); - - } catch (IOException e) { - log.error("Can't open browser", e); - } catch (URISyntaxException e) { - log.error("Can't create news URI", e); - } - } + + if (selectedBeginDate != null && selectedEndDate != null){ + FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); + String address = LimaConfig.getInstance().getHostAdress(); + + try { + String url = "http://"+address+":"+port+"/?beginDate=" + +dateFormat.format(selectedBeginDate) + +"&endDate="+dateFormat.format(selectedEndDate) + +"&format="+selectedEnum.getExtension()+"&model=" + + DocumentsEnum.ENTRYBOOKS.getFileName(); + Desktop.getDesktop().browse(new URI(url)); + + String url2 = "http://"+address+":"+port+"/?beginDate=" + +dateFormat.format(selectedBeginDate) + +"&endDate="+dateFormat.format(selectedEndDate) + +"&format="+selectedEnum.getExtension()+"&model=" + + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName(); + Desktop.getDesktop().browse(new URI(url2)); + + } catch (IOException e) { + log.error("Can't open browser", e); + } catch (URISyntaxException e) { + log.error("Can't create news URI", e); + } + } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntryBook") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntryBook") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -45,9 +45,9 @@ public class FinancialPeriodTable extends JXTable { - private static final long serialVersionUID = -1960326844433064178L; + private static final long serialVersionUID = -1960326844433064178L; - private static final Log log = + private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); protected FinancialPeriodViewHandler handler; @@ -67,7 +67,7 @@ model = this.handler.getView().modelFinancialPeriodTable; financialPeriodService = LimaServiceFactory.getInstance().getService( - FinancialPeriodServiceMonitorable.class); + FinancialPeriodServiceMonitorable.class); //highlight financial financial transactions addMonthColor(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -68,11 +68,11 @@ public FinancialPeriodTableModel() { financialPeriodService = LimaServiceFactory.getInstance().getService( - FinancialPeriodServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class).addListener(this); + FinancialPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class).addListener(this); } @@ -190,11 +190,11 @@ } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll")){ - getDataList(); - fireTableDataChanged(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll")){ + getDataList(); + fireTableDataChanged(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -48,10 +48,10 @@ * By : $Author$ */ public class FinancialStatementChartTreeTableModel extends AbstractTreeTableModel { - + /** log. */ private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); - + /** Services. */ protected final FinancialStatementServiceMonitorable financialStatementService; @@ -62,10 +62,10 @@ //create root for the tree super(new FinancialStatementImpl()); // Gets factory service - financialStatementService = - LimaServiceFactory.getInstance().getService( - FinancialStatementServiceMonitorable.class); - } + financialStatementService = + LimaServiceFactory.getInstance().getService( + FinancialStatementServiceMonitorable.class); + } @Override @@ -81,17 +81,17 @@ res = _("lima.table.label"); break; case 1: - res = _("lima.table.debitcredit"); - break; + res = _("lima.table.debitcredit"); + break; case 2: - res = _("lima.table.debit"); - break; + res = _("lima.table.debit"); + break; case 3: - res = _("lima.table.credit"); - break; + res = _("lima.table.credit"); + break; case 4: - res = _("lima.table.provisiondeprecationamount"); - break; + res = _("lima.table.provisiondeprecationamount"); + break; } return res; } @@ -102,21 +102,21 @@ if (node == getRoot()) { try { result = financialStatementService. - getChildrenFinancialStatement(null).size(); + getChildrenFinancialStatement(null).size(); } catch (LimaException eee) { - log.debug("Can't count child", eee); + log.debug("Can't count child", eee); } } else { FinancialStatement parentFinancialStatementHeader = - (FinancialStatement) node; + (FinancialStatement) node; try { result = financialStatementService.getChildrenFinancialStatement( - parentFinancialStatementHeader).size(); + parentFinancialStatementHeader).size(); } catch (LimaException eee) { - log.debug("Can't count child", eee); - } - } + log.debug("Can't count child", eee); + } + } return result; } @@ -125,22 +125,22 @@ Object result = null; if (parent == getRoot()) { try { - List<FinancialStatement> financialStatements = - financialStatementService.getChildrenFinancialStatement(null); + List<FinancialStatement> financialStatements = + financialStatementService.getChildrenFinancialStatement(null); result = financialStatements.get(index); } catch (LimaException eee) { - log.debug("Can't get child", eee); + log.debug("Can't get child", eee); } } else { FinancialStatement parentFinancialStatement = - (FinancialStatement) parent; + (FinancialStatement) parent; try { - List<FinancialStatement> financialStatements = financialStatementService. - getChildrenFinancialStatement(parentFinancialStatement); + List<FinancialStatement> financialStatements = financialStatementService. + getChildrenFinancialStatement(parentFinancialStatement); result = financialStatements.get(index); } catch (LimaException eee) { - log.debug("Can't get child", eee); + log.debug("Can't get child", eee); } } return result; @@ -152,22 +152,22 @@ if (parent == getRoot()) { try { - List<FinancialStatement> financialStatements = - financialStatementService.getChildrenFinancialStatement(null); + List<FinancialStatement> financialStatements = + financialStatementService.getChildrenFinancialStatement(null); result = financialStatements.indexOf(child); } catch (LimaException eee) { - log.debug("Can't get index child", eee); + log.debug("Can't get index child", eee); } } else { FinancialStatement parentFinancialStatement = - (FinancialStatement) parent; + (FinancialStatement) parent; try { - List<FinancialStatement> financialStatements = financialStatementService. - getChildrenFinancialStatement(parentFinancialStatement); + List<FinancialStatement> financialStatements = financialStatementService. + getChildrenFinancialStatement(parentFinancialStatement); result = financialStatements.indexOf(child); } catch (LimaException eee) { - log.debug("Can't get index child", eee); + log.debug("Can't get index child", eee); } } return result; @@ -176,7 +176,7 @@ @Override public Object getValueAt(Object node, int column) { Object result = "n/a"; - FinancialStatement financialStatement = (FinancialStatement) node; + FinancialStatement financialStatement = (FinancialStatement) node; switch (column) { case 0: result = financialStatement.getLabel(); @@ -214,7 +214,7 @@ */ public void refreshTree() throws LimaException { - modelSupport.fireNewRoot(); + modelSupport.fireNewRoot(); } @@ -227,13 +227,13 @@ */ public void addFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException { // Calling account service - FinancialStatement parentFinancialStatementHeader = - (FinancialStatement) path.getLastPathComponent(); + FinancialStatement parentFinancialStatementHeader = + (FinancialStatement) path.getLastPathComponent(); if (parentFinancialStatementHeader == getRoot()) { - parentFinancialStatementHeader = null; + parentFinancialStatementHeader = null; } financialStatementService.createFinancialStatement( - parentFinancialStatementHeader, financialStatement); + parentFinancialStatementHeader, financialStatement); modelSupport.fireTreeStructureChanged(path); } @@ -262,7 +262,7 @@ public void removeFinancialStatementObject(TreePath path, FinancialStatement financialStatement) throws LimaException { // Calling account service int index = getIndexOfChild( - path.getParentPath().getLastPathComponent(), financialStatement); + path.getParentPath().getLastPathComponent(), financialStatement); financialStatementService.removeFinancialStatement(financialStatement); modelSupport.fireChildRemoved(path.getParentPath(), index, financialStatement); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -68,11 +68,11 @@ protected FinancialStatementChartViewHandler(FinancialStatementChartView view) { this.view = view; - financialStatementService = - LimaServiceFactory.getInstance().getService( - FinancialStatementServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + financialStatementService = + LimaServiceFactory.getInstance().getService( + FinancialStatementServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } /** @@ -82,12 +82,12 @@ JXTreeTable treeTable = view.getTreeTable(); FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); FinancialStatement newFinancialStatementHeader = - new FinancialStatementImpl(); + new FinancialStatementImpl(); FinancialStatementHeaderForm financialStatementHeaderForm = - new FinancialStatementHeaderForm(view); + new FinancialStatementHeaderForm(view); financialStatementHeaderForm.setFinancialStatement(newFinancialStatementHeader); // jaxx constructor don't call super() ? financialStatementHeaderForm.setLocationRelativeTo(view); @@ -108,7 +108,7 @@ // add it try { - treeTableModel.addFinancialStatement(treePath, newFinancialStatementHeader); + treeTableModel.addFinancialStatement(treePath, newFinancialStatementHeader); } catch (LimaBusinessException eee) { if (log.isErrorEnabled()) { log.error("Can't add financialStatementHeader", eee); @@ -128,14 +128,14 @@ public void addFinancialStatementMovement(){ - JXTreeTable treeTable = view.getTreeTable(); + JXTreeTable treeTable = view.getTreeTable(); FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); FinancialStatement newFinancialStatementMovement = - new FinancialStatementImpl(); + new FinancialStatementImpl(); FinancialStatementMovementForm financialStatementMovementForm = - new FinancialStatementMovementForm(view); + new FinancialStatementMovementForm(view); financialStatementMovementForm.setFinancialStatement(newFinancialStatementMovement); // jaxx constructor don't call super() ? financialStatementMovementForm.setLocationRelativeTo(view); @@ -150,8 +150,8 @@ treePath = view.treeTable.getPathForRow(selectedRow); // add it try { - treeTableModel. - addFinancialStatement(treePath, newFinancialStatementMovement); + treeTableModel. + addFinancialStatement(treePath, newFinancialStatementMovement); } catch (LimaBusinessException eee) { if (log.isErrorEnabled()) { log.error("Can't add FinancialStatementMovement", eee); @@ -173,71 +173,71 @@ * Verifiy if it's an account or a subledger */ public void updateFinancialStatement() { - - JXTreeTable treeTable = view.getTreeTable(); + + JXTreeTable treeTable = view.getTreeTable(); FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); // get selected account int selectedRow = view.treeTable.getSelectedRow(); TreePath treePath = view.treeTable.getPathForRow(selectedRow); // not null FinancialStatement financialStatement = - (FinancialStatement) treePath.getLastPathComponent(); - //update Account or update SubLedger - if (financialStatement != 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 - log.debug(financialStatement.getHeader()); - if (financialStatement.getHeader()){ - FinancialStatementHeaderForm financialStatementHeaderForm = - new FinancialStatementHeaderForm(view); - financialStatementHeaderForm.setFinancialStatement(financialStatement); - // jaxx constructor don't call super() ? - financialStatementHeaderForm.setLocationRelativeTo(view); - financialStatementHeaderForm.setVisible(true); - // null == cancel action - financialStatement = financialStatementHeaderForm.getFinancialStatement(); - } - // else is a movement - else{ - FinancialStatementMovementForm financialStatementMovementForm = - new FinancialStatementMovementForm(view); - financialStatementMovementForm.setFinancialStatement(financialStatement); - // jaxx constructor don't call super() ? - financialStatementMovementForm.setLocationRelativeTo(view); - financialStatementMovementForm.setVisible(true); - // null == cancel action - financialStatement = - financialStatementMovementForm.getFinancialStatement(); - } - //if action confirmed - if (financialStatement != null){ - // update it - try { - treeTableModel.updateFinancialStatement( - treePath, financialStatement); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add update", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - } + (FinancialStatement) treePath.getLastPathComponent(); + //update Account or update SubLedger + if (financialStatement != 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 + log.debug(financialStatement.getHeader()); + if (financialStatement.getHeader()){ + FinancialStatementHeaderForm financialStatementHeaderForm = + new FinancialStatementHeaderForm(view); + financialStatementHeaderForm.setFinancialStatement(financialStatement); + // jaxx constructor don't call super() ? + financialStatementHeaderForm.setLocationRelativeTo(view); + financialStatementHeaderForm.setVisible(true); + // null == cancel action + financialStatement = financialStatementHeaderForm.getFinancialStatement(); + } + // else is a movement + else{ + FinancialStatementMovementForm financialStatementMovementForm = + new FinancialStatementMovementForm(view); + financialStatementMovementForm.setFinancialStatement(financialStatement); + // jaxx constructor don't call super() ? + financialStatementMovementForm.setLocationRelativeTo(view); + financialStatementMovementForm.setVisible(true); + // null == cancel action + financialStatement = + financialStatementMovementForm.getFinancialStatement(); + } + //if action confirmed + if (financialStatement != null){ + // update it + try { + treeTableModel.updateFinancialStatement( + treePath, financialStatement); + } 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() { - JXTreeTable treeTable = view.getTreeTable(); + JXTreeTable treeTable = view.getTreeTable(); FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); // Any row selected int selectedRow = view.treeTable.getSelectedRow(); @@ -251,11 +251,11 @@ // update view of treetable TreePath treePath = view.treeTable.getPathForRow(selectedRow); FinancialStatement financialStatement = - (FinancialStatement) treePath.getLastPathComponent(); + (FinancialStatement) treePath.getLastPathComponent(); try{ treeTableModel.removeFinancialStatementObject( - treePath, financialStatement); + treePath, financialStatement); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't delete account", eee); @@ -267,68 +267,68 @@ } public void refresh(){ - JXTreeTable treeTable = view.getTreeTable(); - FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); - try { - treeTableModel.refreshTree(); - } catch (LimaException eee) { - if(log.isDebugEnabled()){ - log.debug("Can't refresh model", eee); - } - } - //refresh view - view.repaint(); + JXTreeTable treeTable = view.getTreeTable(); + FinancialStatementChartTreeTableModel treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + try { + treeTableModel.refreshTree(); + } catch (LimaException eee) { + if(log.isDebugEnabled()){ + log.debug("Can't refresh model", eee); + } + } + //refresh view + view.repaint(); } public void importFinancialStatementChart(){ - FinancialStatementImportForm form = - new FinancialStatementImportForm(); + FinancialStatementImportForm form = + new FinancialStatementImportForm(); form.setLocationRelativeTo(view); form.setVisible(true); Object value = form.getRadioButtons().getSelectedValue(); - // if action confirmed + // if action confirmed if (value != null){ - if (form.getDeleteFinancialStatementChart().isSelected()){ - try { - financialStatementService.removeAllFinancialStatement(); - - } catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't delete financial statement chart", eee); - } - } - } - FinancialStatementsChartEnum defaultFinancialStatementsEnum = - (FinancialStatementsChartEnum) value; - ImportExport importExport = ImportExport.getInstance(view); - importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - defaultFinancialStatementsEnum.getFilePath(), true); - } - } + if (form.getDeleteFinancialStatementChart().isSelected()){ + try { + financialStatementService.removeAllFinancialStatement(); + + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't delete financial statement chart", eee); + } + } + } + FinancialStatementsChartEnum defaultFinancialStatementsEnum = + (FinancialStatementsChartEnum) value; + ImportExport importExport = ImportExport.getInstance(view); + importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, + defaultFinancialStatementsEnum.getFilePath(), true); + } + } public void financialStatementChartCheck(){ - String result; - try { - result = financialStatementService.checkFinancialStatementChart(); - DialogHelper.showReportDialog(result, _("lima.financialstatement.check"), view); + String result; + try { + result = financialStatementService.checkFinancialStatementChart(); + DialogHelper.showReportDialog(result, _("lima.financialstatement.check"), view); - } catch (LimaException e) { - log.error("Can't check financialstatement chart",e); - } + } catch (LimaException e) { + log.error("Can't check financialstatement chart",e); + } } - @Override - public void notifyMethod(String serviceName, String methodName) { - - if (methodName.contains("FinancialStatements") - || methodName.contains("importAll") - || methodName.contains("importAs")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodName) { + + if (methodName.contains("FinancialStatements") + || methodName.contains("importAll") + || methodName.contains("importAs")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -32,7 +32,7 @@ private static final Log log = LogFactory.getLog(FinancialStatementReportTable.class); - - - + + + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -46,114 +46,114 @@ import org.jdesktop.swingx.JXDatePicker; public class FinancialStatementReportPeriodSearchPanel extends JPanel { - + private static final Log log = LogFactory.getLog(FinancialStatementReportPeriodSearchPanel.class); - - protected FinancialStatementReportTableModel model; - - public FinancialStatementReportPeriodSearchPanel(FinancialStatementReportTableModel model) { - this.model = model; - - //init date + + protected FinancialStatementReportTableModel model; + + public FinancialStatementReportPeriodSearchPanel(FinancialStatementReportTableModel model) { + this.model = model; + + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); - } - - static final long serialVersionUID = 1L; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - - switch (comboBoxPeriodEnum) { - case PERIOD: - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); - //handler().setBeginDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - Date endDate = calendarEnd.getTime(); - //handler().setEndDate(endDate); - JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); - final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); - ActionListener beginDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - model.setBeginDate(beginDatePicker.getDate()); - model.refresh(); - } - }; - model.setBeginDate(beginDatePicker.getDate()); - beginDatePicker.addActionListener(beginDateActionListener); - - JLabel endDateLabel = new JLabel(_("lima.common.enddate")); - final JXDatePicker endDatePicker = new JXDatePicker(endDate); - ActionListener endDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - model.setEndDate(endDatePicker.getDate()); - model.refresh(); - } - }; - model.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - model.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); - fiscalPeriod.setEditable(false); - ActionListener fiscalPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); - if (fPeriod != null){ - model.setBeginDate(fPeriod.getBeginDate()); - model.setEndDate(fPeriod.getEndDate()); - model.refresh(); - } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ + + switch (comboBoxPeriodEnum) { + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + model.setBeginDate(beginDatePicker.getDate()); + model.refresh(); + } + }; + model.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + model.setEndDate(endDatePicker.getDate()); + model.refresh(); + } + }; + model.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + model.refresh(); + + this.removeAll(); + this.add(beginDateLabel); + this.add(beginDatePicker); + this.add(endDateLabel); + this.add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null){ + model.setBeginDate(fPeriod.getBeginDate()); + model.setEndDate(fPeriod.getEndDate()); + model.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); - financialPeriod.setEditable(false); - ActionListener financialPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); - if (fPeriod !=null){ - model.setBeginDate(fPeriod.getBeginDate()); - model.setEndDate(fPeriod.getEndDate()); - model.refresh(); - } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); - break; - } - - } - + this.removeAll(); + this.add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod !=null){ + model.setBeginDate(fPeriod.getBeginDate()); + model.setEndDate(fPeriod.getEndDate()); + model.refresh(); + } + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + this.removeAll(); + this.add(financialPeriod); + break; + } + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -36,10 +36,10 @@ public class FinancialStatementReportTable extends JXTable { - - private static final long serialVersionUID = 154211277688304679L; + + private static final long serialVersionUID = 154211277688304679L; - protected FinancialStatementReportViewHandler handler; + protected FinancialStatementReportViewHandler handler; protected FinancialStatementReportTableModel model; @@ -49,7 +49,7 @@ * Constructor, call highlighter */ public FinancialStatementReportTable(FinancialStatementReportViewHandler handler) { - super(handler.getView().modelTable); + super(handler.getView().modelTable); this.handler = handler; model = this.handler.getView().modelTable; @@ -60,7 +60,7 @@ //Renderer for font FinancialStatementReportTableCellRenderer renderer = new FinancialStatementReportTableCellRenderer(); for (int i = 0; i < getColumnModel().getColumnCount(); i++) { - getColumnModel().getColumn(i).setCellRenderer(renderer); + getColumnModel().getColumn(i).setCellRenderer(renderer); } } @@ -68,18 +68,18 @@ * Color the background row in grey if the level is 1 */ protected void colorTitle1() { - - + + HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - Boolean result = false; - Object object = model.getElementAt(adapter.row); - if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts){ - FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; - result = financialStatementAmounts.getLevel() == 1; - } + Boolean result = false; + Object object = model.getElementAt(adapter.row); + if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts){ + FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; + result = financialStatementAmounts.getLevel() == 1; + } return result; } }; @@ -92,18 +92,18 @@ * Color the background in light grey if is a subamount */ protected void colorTitle2() { - - + + HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - Boolean result = false; - Object object = model.getElementAt(adapter.row); - if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts){ - FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; - result = financialStatementAmounts.getSubAmount(); - } + Boolean result = false; + Object object = model.getElementAt(adapter.row); + if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts){ + FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; + result = financialStatementAmounts.getSubAmount(); + } return result; } }; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -41,9 +41,9 @@ public class FinancialStatementReportTableCellRenderer extends DefaultTableCellRenderer { - private static final long serialVersionUID = 4682358397738816778L; + private static final long serialVersionUID = 4682358397738816778L; - @Override + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { @@ -53,13 +53,13 @@ // Récupère le bilan de la ligne Object object = financialStatementReportTableModel.getElementAt(row); - Component cell = super.getTableCellRendererComponent( + Component cell = super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); - + // Si le bilan est un soustotal, alors la ligne est en gras if (object instanceof FinancialStatementAmounts){ - FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; - + FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; + if (financialStatementAmounts.getLevel() == 1) { setFont(new Font("Verdana", Font.BOLD, 14)); @@ -70,9 +70,9 @@ setFont(new Font("Verdana", Font.BOLD, 12)); } if (!financialStatementAmounts.getHeader() && !financialStatementAmounts.getSubAmount()){ - if (column == 0){ - cell.setFont(new Font("Verdana", Font.ITALIC, 12)); - } + if (column == 0){ + cell.setFont(new Font("Verdana", Font.ITALIC, 12)); + } } } Modified: 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 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -83,7 +83,7 @@ protected int port; private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); + new SimpleDateFormat("yyyy-MM-dd"); /** data cache */ protected List<FinancialStatementAmounts> cacheDataList; @@ -92,27 +92,27 @@ * Constructor. */ public FinancialStatementReportTableModel() { - financialStatementService = - LimaServiceFactory.getInstance().getService( - FinancialStatementServiceMonitorable.class); - - financialStatementService.addListener(this); + financialStatementService = + LimaServiceFactory.getInstance().getService( + FinancialStatementServiceMonitorable.class); + + financialStatementService.addListener(this); port = LimaServiceFactory.getInstance().getService( - HttpServerServiceMonitorable.class).getHttpPort(); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); - documentService = LimaServiceFactory.getInstance().getService(DocumentServiceMonitorable.class); + HttpServerServiceMonitorable.class).getHttpPort(); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class).addListener(this); + documentService = LimaServiceFactory.getInstance().getService(DocumentServiceMonitorable.class); } @Override public int getRowCount() { int result = 0; - if (cacheDataList != null){ - result = cacheDataList.size(); - } - return result; + if (cacheDataList != null){ + result = cacheDataList.size(); + } + return result; } @Override @@ -151,51 +151,51 @@ Object result = cacheDataList.get(row); //get entries for the period for the current row if (result instanceof FinancialStatementAmounts) { - FinancialStatementAmounts currentRow = (FinancialStatementAmounts) result; - BigDecimal grossAmount = currentRow.getGrossAmount(); - if (grossAmount == null ){ - grossAmount = new BigDecimal(0); - } - - BigDecimal provisionDeprecationAmount = currentRow.getProvisionDeprecationAmount(); - if (provisionDeprecationAmount == null ){ - provisionDeprecationAmount = new BigDecimal(0); - } + FinancialStatementAmounts currentRow = (FinancialStatementAmounts) result; + BigDecimal grossAmount = currentRow.getGrossAmount(); + if (grossAmount == null ){ + grossAmount = new BigDecimal(0); + } + + BigDecimal provisionDeprecationAmount = currentRow.getProvisionDeprecationAmount(); + if (provisionDeprecationAmount == null ){ + provisionDeprecationAmount = new BigDecimal(0); + } switch (column) { - case 0: - result = ""; - String label = currentRow.getLabel(); - if ( label != null){ - for (int i = 0; i <= currentRow.getLevel(); i++) { - result = result+"\t"; - } - result = result+label; - } - break; + case 0: + result = ""; + String label = currentRow.getLabel(); + if ( label != null){ + for (int i = 0; i <= currentRow.getLevel(); i++) { + result = result+"\t"; + } + result = result+label; + } + break; case 1: - if (grossAmount.doubleValue() == 0){ - result = null; - } - else { + if (grossAmount.doubleValue() == 0){ + result = null; + } + else { result = grossAmount; - } + } break; case 2: - if (provisionDeprecationAmount.doubleValue() == 0){ - result = null; - } - else { + if (provisionDeprecationAmount.doubleValue() == 0){ + result = null; + } + else { result = provisionDeprecationAmount; - } + } break; case 3: - BigDecimal solde = grossAmount.subtract(provisionDeprecationAmount); - if (solde.doubleValue() == 0){ - result = null; - } - else { + BigDecimal solde = grossAmount.subtract(provisionDeprecationAmount); + if (solde.doubleValue() == 0){ + result = null; + } + else { result = solde; - } + } break; } } @@ -223,18 +223,18 @@ * @return */ public List<FinancialStatementAmounts> getDataList(){ - List<FinancialStatementAmounts> results = null; - if (selectedBeginDate != null && selectedEndDate != null){ - try { - results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate); - } - catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); - } - ErrorHelper.showErrorDialog("Can't get entries list", eee); - } - } + List<FinancialStatementAmounts> results = null; + if (selectedBeginDate != null && selectedEndDate != null){ + try { + results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate); + } + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.debug("Can't update model", eee); + } + ErrorHelper.showErrorDialog("Can't get entries list", eee); + } + } return results; } @@ -245,29 +245,29 @@ public void createDocument(FormatsEnum formatsEnum) { - - if (selectedBeginDate != null && selectedEndDate != null){ - String address = LimaConfig.getInstance().getHostAdress(); - try { - String url = "http://"+address+":"+port+"/?beginDate=" - +dateFormat.format(selectedBeginDate) - +"&endDate="+dateFormat.format(selectedEndDate) - +"&format="+formatsEnum.getExtension()+"&model=" - + DocumentsEnum.FINANCIALSTATEMENT.getFileName(); - Desktop.getDesktop().browse(new URI(url)); - } catch (IOException e) { - log.error("Can't open browser", e); - } catch (URISyntaxException e) { - log.error("Can't create news URI", e); - } - } + + if (selectedBeginDate != null && selectedEndDate != null){ + String address = LimaConfig.getInstance().getHostAdress(); + try { + String url = "http://"+address+":"+port+"/?beginDate=" + +dateFormat.format(selectedBeginDate) + +"&endDate="+dateFormat.format(selectedEndDate) + +"&format="+formatsEnum.getExtension()+"&model=" + + DocumentsEnum.FINANCIALSTATEMENT.getFileName(); + Desktop.getDesktop().browse(new URI(url)); + } catch (IOException e) { + log.error("Can't open browser", e); + } catch (URISyntaxException e) { + log.error("Can't create news URI", e); + } + } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("FinancialStatement") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("FinancialStatement") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -56,10 +56,10 @@ } public void createDocument() { - - model = view.getModelTable(); - FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); - model.createDocument(selectedEnum); + + model = view.getModelTable(); + FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); + model.createDocument(selectedEnum); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -37,53 +37,53 @@ public class FinancialPeriodComboBox extends JComboBox implements ActionListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(FinancialPeriodComboBox.class); - - protected FinancialTransactionViewHandler handler; - - public FinancialPeriodComboBox(FinancialTransactionViewHandler handler) { - this.handler = handler; + + protected FinancialTransactionViewHandler handler; + + public FinancialPeriodComboBox(FinancialTransactionViewHandler handler) { + this.handler = handler; - FinancialPeriodComboBoxModel comboBoxModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer comboBoxRenderer = new FinancialPeriodComboBoxRenderer(); + FinancialPeriodComboBoxModel comboBoxModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer comboBoxRenderer = new FinancialPeriodComboBoxRenderer(); - setModel(comboBoxModel); - setRenderer(comboBoxRenderer); - addActionListener(this); + setModel(comboBoxModel); + setRenderer(comboBoxRenderer); + addActionListener(this); - } + } - public void back(){ - int row = this.getSelectedIndex(); - log.debug(row); - if (row > 0){ - this.setSelectedItem(this.getItemAt(row-1)); - repaint(); - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); - } - } - - public void next(){ - int size = this.getModel().getSize(); - int row = this.getSelectedIndex(); - log.debug(row); - - if (row < size-1){ - this.setSelectedItem(this.getItemAt(row+1)); - repaint(); - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); - } - } - - @Override - public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof FinancialPeriod){ - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); - } - } - + public void back(){ + int row = this.getSelectedIndex(); + log.debug(row); + if (row > 0){ + this.setSelectedItem(this.getItemAt(row-1)); + repaint(); + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + + public void next(){ + int size = this.getModel().getSize(); + int row = this.getSelectedIndex(); + log.debug(row); + + if (row < size-1){ + this.setSelectedItem(this.getItemAt(row+1)); + repaint(); + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof FinancialPeriod){ + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -130,7 +130,7 @@ boolean isHighlighted = false; Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { - BigDecimal currentBalance = (BigDecimal) value; + BigDecimal currentBalance = (BigDecimal) value; if (currentBalance.doubleValue() != 0) { isHighlighted = true; } @@ -205,79 +205,79 @@ Boolean end = true; if (x_tab < max_x - 1){ - x_tab++; - } - //end of row - else { - x_tab=0; - y_tab++; - } - //skip all cell while not editable or if end of table add entry or transaction or end of table - while (!isCellEditable(y_tab, x_tab) && end ){ - //if end of row - if (x_tab == max_x-1) { - Object object = this.handler.tableModel.getElementAt(y_tab); - - //if transaction, add entry - if (object instanceof FinancialTransaction){ - FinancialTransaction financialTransaction = (FinancialTransaction) object; - if (financialTransaction.getEntry().size() == 0){ - handler.addEmptyEntry(); - this.setColumnSelectionInterval(1, 1); - } - } - //if entry - else { - //FIXME set value is doing after key pressed - // so update not terminated before get balanced - //Swing Worker stop the UI 500ms - // found best solution ? - final JXTable table = this; - final int y_t = y_tab; - final int m_t = max_y; - new SwingWorker<Void,Void>() { - @Override protected Void doInBackground() throws InterruptedException { - Thread.sleep(500); - return null; - } - @Override protected void done() { - Object object = handler.tableModel.getElementAt(y_tab-1); - FinancialTransaction financialTransaction = null; - if (object instanceof Entry){ - financialTransaction = ((Entry) object).getFinancialTransaction(); - } - else if (object instanceof FinancialTransaction){ - financialTransaction = (FinancialTransaction) object; - } - BigDecimal amountC = financialTransaction.getAmountCredit(); - BigDecimal amountD = financialTransaction.getAmountDebit(); - if (amountC == amountD){ - if (y_t == m_t-1){ - handler.addFinancialTransaction(); - table.setColumnSelectionInterval(0, 0); - } - } - else { - handler.addEmptyEntry(); - table.setColumnSelectionInterval(1, 1); - y_tab++; - // positionne la sélection sur la nouvelle ligne créée - table.setRowSelectionInterval(y_tab, y_tab); - x_tab=0; - } - } - }.execute(); - } - end = false; - } - else { - if (x_tab < max_x){ - this.setRowSelectionInterval(y_tab, y_tab); - this.setColumnSelectionInterval(x_tab, x_tab); - x_tab++; - } - } - } + x_tab++; + } + //end of row + else { + x_tab=0; + y_tab++; + } + //skip all cell while not editable or if end of table add entry or transaction or end of table + while (!isCellEditable(y_tab, x_tab) && end ){ + //if end of row + if (x_tab == max_x-1) { + Object object = this.handler.tableModel.getElementAt(y_tab); + + //if transaction, add entry + if (object instanceof FinancialTransaction){ + FinancialTransaction financialTransaction = (FinancialTransaction) object; + if (financialTransaction.getEntry().size() == 0){ + handler.addEmptyEntry(); + this.setColumnSelectionInterval(1, 1); + } + } + //if entry + else { + //FIXME set value is doing after key pressed + // so update not terminated before get balanced + //Swing Worker stop the UI 500ms + // found best solution ? + final JXTable table = this; + final int y_t = y_tab; + final int m_t = max_y; + new SwingWorker<Void,Void>() { + @Override protected Void doInBackground() throws InterruptedException { + Thread.sleep(500); + return null; + } + @Override protected void done() { + Object object = handler.tableModel.getElementAt(y_tab-1); + FinancialTransaction financialTransaction = null; + if (object instanceof Entry){ + financialTransaction = ((Entry) object).getFinancialTransaction(); + } + else if (object instanceof FinancialTransaction){ + financialTransaction = (FinancialTransaction) object; + } + BigDecimal amountC = financialTransaction.getAmountCredit(); + BigDecimal amountD = financialTransaction.getAmountDebit(); + if (amountC == amountD){ + if (y_t == m_t-1){ + handler.addFinancialTransaction(); + table.setColumnSelectionInterval(0, 0); + } + } + else { + handler.addEmptyEntry(); + table.setColumnSelectionInterval(1, 1); + y_tab++; + // positionne la sélection sur la nouvelle ligne créée + table.setRowSelectionInterval(y_tab, y_tab); + x_tab=0; + } + } + }.execute(); + } + end = false; + } + else { + if (x_tab < max_x){ + this.setRowSelectionInterval(y_tab, y_tab); + this.setColumnSelectionInterval(x_tab, x_tab); + x_tab++; + } + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -96,12 +96,12 @@ */ public FinancialTransactionTableModel() { /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } /** @@ -129,7 +129,7 @@ log.debug("Can't update model", eee); } ErrorHelper.showErrorDialog("Can't get transaction list", eee); - } + } } return results; } @@ -205,7 +205,7 @@ result = _("lima.table.description"); break; case 5: - result = _("lima.table.letter"); + result = _("lima.table.letter"); break; case 6: result = _("lima.table.debit"); @@ -241,10 +241,10 @@ result = cacheDataList.get(row); if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; - BigDecimal amountDebit = currentRow.getAmountDebit(); - BigDecimal amountCredit = currentRow.getAmountCredit(); - + FinancialTransaction currentRow = (FinancialTransaction)result; + BigDecimal amountDebit = currentRow.getAmountDebit(); + BigDecimal amountCredit = currentRow.getAmountCredit(); + switch (column) { case 0: result = currentRow.getTransactionDate(); @@ -287,7 +287,7 @@ result = null; // date break; case 1 : // entry book - result = null; + result = null; break; case 2: result = currentEntry.getVoucher(); @@ -304,13 +304,13 @@ result = currentEntry.getDescription(); break; case 5 : - if (currentEntry.getLetter() != null){ - result = currentEntry.getLetter().getCode(); - } - else { - result = null; - } - break; + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } + break; case 6: result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; break; @@ -318,7 +318,7 @@ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); break; case 8: - result = null; + result = null; break; } @@ -359,47 +359,47 @@ */ public void addFinancialTransaction() throws LimaException{ /* Calling transaction service */ - FinancialTransaction financialTransaction = new FinancialTransactionImpl(); - financialTransaction.setAmountDebit(new BigDecimal(0)); - financialTransaction.setAmountCredit(new BigDecimal(0)); - //if a period is selected - if (selectedFinancialPeriod != null){ - financialTransaction.setFinancialPeriod(selectedFinancialPeriod); - // get today - Calendar actualCalendar = Calendar.getInstance(); - // get the financial period date - Date transactionDate = selectedFinancialPeriod.getBeginDate(); - - Calendar selectedPeriodCal = Calendar.getInstance(); - selectedPeriodCal.setTime(transactionDate); - int dayMax = selectedPeriodCal.getActualMaximum(Calendar.DAY_OF_MONTH); - - int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH); - - if (toDay>dayMax){ - // change the day - transactionDate = DateUtils.setDays(transactionDate, dayMax); - } - else{ - // change the day - transactionDate = DateUtils.setDays(transactionDate, toDay); - } - + FinancialTransaction financialTransaction = new FinancialTransactionImpl(); + financialTransaction.setAmountDebit(new BigDecimal(0)); + financialTransaction.setAmountCredit(new BigDecimal(0)); + //if a period is selected + if (selectedFinancialPeriod != null){ + financialTransaction.setFinancialPeriod(selectedFinancialPeriod); + // get today + Calendar actualCalendar = Calendar.getInstance(); + // get the financial period date + Date transactionDate = selectedFinancialPeriod.getBeginDate(); + + Calendar selectedPeriodCal = Calendar.getInstance(); + selectedPeriodCal.setTime(transactionDate); + int dayMax = selectedPeriodCal.getActualMaximum(Calendar.DAY_OF_MONTH); + + int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH); + + if (toDay>dayMax){ + // change the day + transactionDate = DateUtils.setDays(transactionDate, dayMax); + } + else{ + // change the day + transactionDate = DateUtils.setDays(transactionDate, toDay); + } + - // set date to the financial transaction - financialTransaction.setTransactionDate(transactionDate); - // create it - financialTransactionService.createFinancialTransaction(financialTransaction); + // set date to the financial transaction + financialTransaction.setTransactionDate(transactionDate); + // create it + financialTransactionService.createFinancialTransaction(financialTransaction); - //on recharge la liste + //on recharge la liste cacheDataList = getDataList(); - int row = getDataList().indexOf(financialTransaction); + int row = getDataList().indexOf(financialTransaction); fireTableRowsInserted(row, row); - //fireTableDataChanged(); - } - else { - throw new LimaBusinessException("No financial period selected"); - } + //fireTableDataChanged(); + } + else { + throw new LimaBusinessException("No financial period selected"); + } } @@ -414,12 +414,12 @@ entry.setAmount(new BigDecimal(0)); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; + currentTransaction = (FinancialTransaction)currentRow; } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); + Entry currentEntry = (Entry)currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); } //create it entry.setFinancialTransaction(currentTransaction); @@ -436,15 +436,15 @@ Object currentRow = cacheDataList.get(row); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; + currentTransaction = (FinancialTransaction)currentRow; //update the financial transaction in entire financialTransactionRow = getDataList().indexOf(((FinancialTransaction) currentRow)); } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); + Entry currentEntry = (Entry)currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); //update the financial transaction in entire financialTransactionRow = getDataList().indexOf(((Entry) currentRow). @@ -469,15 +469,15 @@ if (cacheDataList != null) { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentFinancialTransaction = - (FinancialTransaction)currentRow; + FinancialTransaction currentFinancialTransaction = + (FinancialTransaction)currentRow; switch (column) { case 0: //update currentFinancialTransaction.setTransactionDate((Date)value); break; case 1 : - currentFinancialTransaction.setEntryBook((EntryBook)value); + currentFinancialTransaction.setEntryBook((EntryBook)value); break; } // notify service for modification @@ -514,7 +514,7 @@ currentEntry.setDebit(true); break; case 7: - currentEntry.setAmount((BigDecimal)value); + currentEntry.setAmount((BigDecimal)value); currentEntry.setDebit(false); break; } @@ -539,10 +539,10 @@ } public Object getElementAt(int row){ - Object result = null; - if (cacheDataList != null){ + Object result = null; + if (cacheDataList != null){ result = cacheDataList.get(row); - } + } return result; } @@ -557,24 +557,24 @@ public void removeObject(Object object, int row) throws LimaException { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = - (FinancialTransaction)currentRow; - financialTransactionService.removeFinancialTransaction(currentTransaction); + FinancialTransaction currentTransaction = + (FinancialTransaction)currentRow; + financialTransactionService.removeFinancialTransaction(currentTransaction); } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - financialTransactionService.removeEntry(currentEntry); + Entry currentEntry = (Entry)currentRow; + financialTransactionService.removeEntry(currentEntry); } //on recharge la liste cacheDataList = getDataList(); fireTableDataChanged(); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -74,9 +74,9 @@ //copy entry public void copyRow(){ - table = view.getFinancialTransactionTable(); - int indexSelectedRow = table.getSelectedRow(); - + table = view.getFinancialTransactionTable(); + int indexSelectedRow = table.getSelectedRow(); + if (indexSelectedRow != -1) { clipBoard = tableModel.getElementAt(indexSelectedRow); } @@ -84,32 +84,32 @@ //paste entry public void pasteRow(){ - table = view.getFinancialTransactionTable(); - int indexSelectedRow = table.getSelectedRow(); - + table = view.getFinancialTransactionTable(); + int indexSelectedRow = table.getSelectedRow(); + if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); - if (clipBoard instanceof Entry) { - try { - tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow); - //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow+1, indexSelectedRow+1); - //focus on second column - table.changeSelection(indexSelectedRow+1, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee){ - if (log.isErrorEnabled()) { - log.error("Can't past entry", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } + if (clipBoard instanceof Entry) { + try { + tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow); + //select the new line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow+1, indexSelectedRow+1); + //focus on second column + table.changeSelection(indexSelectedRow+1, 1, false, false); + table.requestFocusInWindow(); + } catch (LimaException eee){ + if (log.isErrorEnabled()) { + log.error("Can't past entry", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + } } - + } //add a new transaction @@ -118,7 +118,7 @@ tableModel = view.getFinancialTransactionTableModel(); try { - tableModel.addFinancialTransaction(); + tableModel.addFinancialTransaction(); //select the new line int numberRow = table.getRowCount(); ListSelectionModel selectionModel = @@ -144,23 +144,23 @@ int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { - Object selectedValue = tableModel.getElementAt(indexSelectedRow); - try { - tableModel.addEmptyEntry(selectedValue, indexSelectedRow); - //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow+1, indexSelectedRow+1); + Object selectedValue = tableModel.getElementAt(indexSelectedRow); + try { + tableModel.addEmptyEntry(selectedValue, indexSelectedRow); + //select the new line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow+1, indexSelectedRow+1); //focus on second column table.changeSelection(indexSelectedRow+1, 1, false, false); table.requestFocusInWindow(); - } catch (LimaException eee){ + } catch (LimaException eee){ if (log.isErrorEnabled()) { log.error("Can't add emptyentry", eee); } DialogHelper.showMessageDialog(eee.getMessage()); - } + } } else { if (log.isWarnEnabled()) { @@ -196,14 +196,14 @@ _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { - + try { - tableModel.removeObject(selectedValue, indexSelectedRow); + tableModel.removeObject(selectedValue, indexSelectedRow); //select the upper line ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval( - indexSelectedRow-1, indexSelectedRow-1); + indexSelectedRow-1, indexSelectedRow-1); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't remove transaction or entry", eee); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -40,63 +40,63 @@ public class AccountSearchComboBox extends JComboBox implements KeyListener, ActionListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(AccountSearchComboBox.class); - - protected FinancialTransactionSearchViewHandler handler; - - public AccountSearchComboBox(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); - AccountRenderer accountRenderer = new AccountRenderer(); - setModel(accountComboBoxModel); - setRenderer(accountRenderer); - setEditable(true); - AutoCompleteDecorator.decorate(this, AccountToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); - } + + protected FinancialTransactionSearchViewHandler handler; + + public AccountSearchComboBox(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); + AccountRenderer accountRenderer = new AccountRenderer(); + setModel(accountComboBoxModel); + setRenderer(accountRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, AccountToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } - - - @Override - public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Account){ - handler.setAccount((Account) this.getSelectedItem()); - } - } + + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Account){ + handler.setAccount((Account) this.getSelectedItem()); + } + } - @Override - public void keyPressed(KeyEvent e) { - - } + @Override + public void keyPressed(KeyEvent e) { + + } - @Override - public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Account){ - Account account = (Account) this.getSelectedItem(); - //to prevent useless call to service - if (!account.equals(handler.getAccount())){ - handler.setAccount(account); - } + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Account){ + Account account = (Account) this.getSelectedItem(); + //to prevent useless call to service + if (!account.equals(handler.getAccount())){ + handler.setAccount(account); + } - } - - // delegate popup list menu + } + + // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) { - firePopupMenuCanceled(); + firePopupMenuCanceled(); } - } + } - @Override - public void keyTyped(KeyEvent e) { - - } - + @Override + public void keyTyped(KeyEvent e) { + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -34,63 +34,63 @@ import org.chorem.lima.enums.ComboBoxAccountsEnum; public class AccountSearchPanel extends JPanel { - - protected FinancialTransactionSearchViewHandler handler; - - public AccountSearchPanel(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - } - - static final long serialVersionUID = 1L; + + protected FinancialTransactionSearchViewHandler handler; + + public AccountSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxAccountsEnum comboBoxAccountsEnum){ - - switch (comboBoxAccountsEnum) { - case ALL: - handler.setAccount(null); - handler.refresh(); - this.removeAll(); - break; - - case ACCOUNT: - final AccountSearchComboBox accountComboBox = new AccountSearchComboBox(handler); - handler.setAccount((Account) accountComboBox.getSelectedItem()); - handler.refresh(); - this.removeAll(); - this.add(accountComboBox); - break; - - case ACCOUNT_LIST: - final JTextField accountsList = new JTextField(16); - accountsList.setMinimumSize(accountsList.getPreferredSize()); - accountsList.setToolTipText(_("lima.tooltip.filter")); - KeyListener accountsListKeyListener = new KeyListener() { - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyReleased(KeyEvent e) { - String accounts = accountsList.getText(); - //to prevent useless call to service - if (!accounts.equals(handler.getAccountsList())){ - handler.setAccountsList(accounts); - } - } - - @Override - public void keyPressed(KeyEvent e) { - } - }; - accountsList.addKeyListener(accountsListKeyListener); - handler.setAccountsList(accountsList.getText()); - handler.setAccount(null); - this.removeAll(); - this.add(accountsList); - break; - } - - } - + public void refresh(ComboBoxAccountsEnum comboBoxAccountsEnum){ + + switch (comboBoxAccountsEnum) { + case ALL: + handler.setAccount(null); + handler.refresh(); + this.removeAll(); + break; + + case ACCOUNT: + final AccountSearchComboBox accountComboBox = new AccountSearchComboBox(handler); + handler.setAccount((Account) accountComboBox.getSelectedItem()); + handler.refresh(); + this.removeAll(); + this.add(accountComboBox); + break; + + case ACCOUNT_LIST: + final JTextField accountsList = new JTextField(16); + accountsList.setMinimumSize(accountsList.getPreferredSize()); + accountsList.setToolTipText(_("lima.tooltip.filter")); + KeyListener accountsListKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + String accounts = accountsList.getText(); + //to prevent useless call to service + if (!accounts.equals(handler.getAccountsList())){ + handler.setAccountsList(accounts); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + accountsList.addKeyListener(accountsListKeyListener); + handler.setAccountsList(accountsList.getText()); + handler.setAccount(null); + this.removeAll(); + this.add(accountsList); + break; + } + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -32,76 +32,76 @@ import org.chorem.lima.enums.ComboBoxOperatorsEnum; public class AmountSearchPanel extends JPanel { - - protected FinancialTransactionSearchViewHandler handler; - - public AmountSearchPanel(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - refresh(ComboBoxOperatorsEnum.EQUAL); - } - - static final long serialVersionUID = 1L; + + protected FinancialTransactionSearchViewHandler handler; + + public AmountSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + refresh(ComboBoxOperatorsEnum.EQUAL); + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxOperatorsEnum enums){ - - final JTextField amountTextField = new JTextField(16); - amountTextField.setMinimumSize(amountTextField.getPreferredSize()); - KeyListener amountKeyListener = new KeyListener() { - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyReleased(KeyEvent e) { - String amount = amountTextField.getText(); - //to prevent useless call to service - if (!amount.equals(handler.getAmount())){ - handler.setAmount(amount); - } - } - - @Override - public void keyPressed(KeyEvent e) { - } - }; - amountTextField.addKeyListener(amountKeyListener); - handler.setAmount2(""); - handler.setOperator(enums.getSymbol()); - handler.refresh(); - this.removeAll(); - this.add(amountTextField); - - switch (enums) { - case INTERVAL: - final JTextField amount2TextField = new JTextField(16); - amount2TextField.setMinimumSize(amount2TextField.getPreferredSize()); - KeyListener amount2KeyListener = new KeyListener() { - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyReleased(KeyEvent e) { - - String amount2 = amount2TextField.getText(); - //to prevent useless call to service - if (!amount2.equals(handler.getAmount2())){ - handler.setAmount2(amount2); - } - } - - @Override - public void keyPressed(KeyEvent e) { - } - }; - amount2TextField.addKeyListener(amount2KeyListener); - handler.setAmount(""); - this.add(amount2TextField); - break; - } - amountTextField.setText(handler.getAmount()); - } - + public void refresh(ComboBoxOperatorsEnum enums){ + + final JTextField amountTextField = new JTextField(16); + amountTextField.setMinimumSize(amountTextField.getPreferredSize()); + KeyListener amountKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + String amount = amountTextField.getText(); + //to prevent useless call to service + if (!amount.equals(handler.getAmount())){ + handler.setAmount(amount); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + amountTextField.addKeyListener(amountKeyListener); + handler.setAmount2(""); + handler.setOperator(enums.getSymbol()); + handler.refresh(); + this.removeAll(); + this.add(amountTextField); + + switch (enums) { + case INTERVAL: + final JTextField amount2TextField = new JTextField(16); + amount2TextField.setMinimumSize(amount2TextField.getPreferredSize()); + KeyListener amount2KeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + + String amount2 = amount2TextField.getText(); + //to prevent useless call to service + if (!amount2.equals(handler.getAmount2())){ + handler.setAmount2(amount2); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + amount2TextField.addKeyListener(amount2KeyListener); + handler.setAmount(""); + this.add(amount2TextField); + break; + } + amountTextField.setText(handler.getAmount()); + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -40,57 +40,57 @@ public class EntryBookSearchComboBox extends JComboBox implements KeyListener, ActionListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(EntryBookSearchComboBox.class); - - protected FinancialTransactionSearchViewHandler handler; - - public EntryBookSearchComboBox(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); - EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); - setModel(entryBookComboBoxModel); - setRenderer(entryBookRenderer); - setEditable(true); - AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); - } + + protected FinancialTransactionSearchViewHandler handler; + + public EntryBookSearchComboBox(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); + EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); + setModel(entryBookComboBoxModel); + setRenderer(entryBookRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } - - - @Override - public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); - } - } + + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof EntryBook){ + handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + } - @Override - public void keyPressed(KeyEvent e) { - - } + @Override + public void keyPressed(KeyEvent e) { + + } - @Override - public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); - } - // delegate popup list menu + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof EntryBook){ + handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) { - firePopupMenuCanceled(); + firePopupMenuCanceled(); } - } + } - @Override - public void keyTyped(KeyEvent e) { - - } - + @Override + public void keyTyped(KeyEvent e) { + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -29,31 +29,31 @@ import org.chorem.lima.enums.ComboBoxEntryBooksEnum; public class EntryBookSearchPanel extends JPanel { - - protected FinancialTransactionSearchViewHandler handler; - - public EntryBookSearchPanel(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - } - - static final long serialVersionUID = 1L; + + protected FinancialTransactionSearchViewHandler handler; + + public EntryBookSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxEntryBooksEnum enums){ - - switch (enums) { - case SELECT_ONE: - EntryBookSearchComboBox entryBookSearchComboBox = new EntryBookSearchComboBox(handler); - handler.setEntryBook(null); - this.removeAll(); - this.add(entryBookSearchComboBox); - break; - - case ALL: - handler.setEntryBook(null); - this.removeAll(); - break; - } - - } - + public void refresh(ComboBoxEntryBooksEnum enums){ + + switch (enums) { + case SELECT_ONE: + EntryBookSearchComboBox entryBookSearchComboBox = new EntryBookSearchComboBox(handler); + handler.setEntryBook(null); + this.removeAll(); + this.add(entryBookSearchComboBox); + break; + + case ALL: + handler.setEntryBook(null); + this.removeAll(); + break; + } + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -47,130 +47,130 @@ import org.jdesktop.swingx.JXDatePicker; public class FinancialTransactionPeriodSearchPanel extends JPanel { - + private static final Log log = LogFactory.getLog(FinancialTransactionPeriodSearchPanel.class); - - protected FinancialTransactionSearchViewHandler handler; - - public FinancialTransactionPeriodSearchPanel(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - - //init date + + protected FinancialTransactionSearchViewHandler handler; + + public FinancialTransactionPeriodSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + + //init date refresh(ComboBoxPeriodEnum.PERIOD); - } - - static final long serialVersionUID = 1L; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxPeriodEnum comboBoxPeriodEnum){ - - switch (comboBoxPeriodEnum) { - case DATE: - Calendar calendar = Calendar.getInstance(); - Date date = calendar.getTime(); - date = DateUtils.truncate(date, Calendar.DATE); - final JXDatePicker datePicker = new JXDatePicker(date); - ActionListener dateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(datePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(datePicker.getDate()); - handler.setEndDate(null); - handler.refresh(); - datePicker.addActionListener(dateActionListener); - this.removeAll(); - this.add(datePicker); - break; - - case PERIOD: - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); - //handler().setBeginDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - Date endDate = calendarEnd.getTime(); - //handler().setEndDate(endDate); - JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); - final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); - ActionListener beginDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(beginDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(beginDatePicker.getDate()); - beginDatePicker.addActionListener(beginDateActionListener); - - JLabel endDateLabel = new JLabel(_("lima.common.enddate")); - final JXDatePicker endDatePicker = new JXDatePicker(endDate); - ActionListener endDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setEndDate(endDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); - fiscalPeriod.setEditable(false); - ActionListener fiscalPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + public void refresh(ComboBoxPeriodEnum comboBoxPeriodEnum){ + + switch (comboBoxPeriodEnum) { + case DATE: + Calendar calendar = Calendar.getInstance(); + Date date = calendar.getTime(); + date = DateUtils.truncate(date, Calendar.DATE); + final JXDatePicker datePicker = new JXDatePicker(date); + ActionListener dateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(datePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(datePicker.getDate()); + handler.setEndDate(null); + handler.refresh(); + datePicker.addActionListener(dateActionListener); + this.removeAll(); + this.add(datePicker); + break; + + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setEndDate(endDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + handler.refresh(); + + this.removeAll(); + this.add(beginDateLabel); + this.add(beginDatePicker); + this.add(endDateLabel); + this.add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); - financialPeriod.setEditable(false); - ActionListener financialPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); - break; - } - - } - + this.removeAll(); + this.add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + this.removeAll(); + this.add(financialPeriod); + break; + } + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -117,7 +117,7 @@ boolean isHighlighted = false; Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { - BigDecimal currentBalance = (BigDecimal) value; + BigDecimal currentBalance = (BigDecimal) value; if (currentBalance.doubleValue() != 0) { isHighlighted = true; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -86,10 +86,10 @@ */ public FinancialTransactionSearchTableModel() { /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addListener(this); } /** @@ -102,12 +102,12 @@ List<Object> results = null; //prevent to much result if (financialTransactionSearch != null && (financialTransactionSearch.getVoucher() != null || financialTransactionSearch.getDescription() != null - || financialTransactionSearch.getLetter() != null || financialTransactionSearch.getAccountList() != null - || financialTransactionSearch.getAccount() != null || financialTransactionSearch.getEntryBook() != null - || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getOperator() != null) - || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getAmount2() != null))){ + || financialTransactionSearch.getLetter() != null || financialTransactionSearch.getAccountList() != null + || financialTransactionSearch.getAccount() != null || financialTransactionSearch.getEntryBook() != null + || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getOperator() != null) + || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getAmount2() != null))){ try { - results = financialTransactionService.searchFinancialTransaction(financialTransactionSearch); + results = financialTransactionService.searchFinancialTransaction(financialTransactionSearch); } catch (LimaException eee) { if (log.isErrorEnabled()) { @@ -115,7 +115,7 @@ } ErrorHelper.showErrorDialog("Can't get transaction list", eee); - } + } } return results; @@ -123,7 +123,7 @@ protected void refresh(FinancialTransactionSearch financialTransactionSearch) { - this.financialTransactionSearch = financialTransactionSearch; + this.financialTransactionSearch = financialTransactionSearch; cacheDataList = getDataList(financialTransactionSearch); fireTableDataChanged(); } @@ -230,10 +230,10 @@ result = cacheDataList.get(row); if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; + FinancialTransaction currentRow = (FinancialTransaction)result; BigDecimal amountDebit = currentRow.getAmountDebit(); BigDecimal amountCredit = currentRow.getAmountCredit(); - + switch (column) { case 0: result = currentRow.getTransactionDate(); @@ -276,7 +276,7 @@ result = null; // date break; case 1 : // entry book - result = null; + result = null; break; case 2: result = currentEntry.getVoucher(); @@ -299,16 +299,16 @@ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); break; case 7: - result = null; + result = null; break; case 8: - if (currentEntry.getLetter() != null){ - result = currentEntry.getLetter().getCode(); - } - else { - result = null; - } - break; + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } + break; } } @@ -351,12 +351,12 @@ entry.setAmount(new BigDecimal(0)); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; + currentTransaction = (FinancialTransaction)currentRow; } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); + Entry currentEntry = (Entry)currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); } //create it entry.setFinancialTransaction(currentTransaction); @@ -375,15 +375,15 @@ // just prevent too much result Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentFinancialTransaction = - (FinancialTransaction)currentRow; + FinancialTransaction currentFinancialTransaction = + (FinancialTransaction)currentRow; switch (column) { case 0: //update currentFinancialTransaction.setTransactionDate((Date)value); break; case 1 : - currentFinancialTransaction.setEntryBook((EntryBook)value); + currentFinancialTransaction.setEntryBook((EntryBook)value); break; } // notify service for modification @@ -417,7 +417,7 @@ currentEntry.setDebit(true); break; case 6: - currentEntry.setAmount((BigDecimal)value); + currentEntry.setAmount((BigDecimal)value); currentEntry.setDebit(false); break; case 8: @@ -434,7 +434,7 @@ } //update the financial transaction in entire financialTransactionRow = - cacheDataList.indexOf(((Entry) currentRow). + cacheDataList.indexOf(((Entry) currentRow). getFinancialTransaction()); } //on recharge la liste @@ -458,27 +458,27 @@ public void removeObject(Object object, int row) throws LimaException { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = - (FinancialTransaction)currentRow; - financialTransactionService.removeFinancialTransaction(currentTransaction); + FinancialTransaction currentTransaction = + (FinancialTransaction)currentRow; + financialTransactionService.removeFinancialTransaction(currentTransaction); } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - financialTransactionService.removeEntry(currentEntry); + Entry currentEntry = (Entry)currentRow; + financialTransactionService.removeEntry(currentEntry); } //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); fireTableDataChanged(); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if ((serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") - || methodeName.contains("importAll")) && !methodeName.contains("search")){ - //on recharge la liste - cacheDataList = getDataList(financialTransactionSearch); - fireTableDataChanged(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if ((serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") + || methodeName.contains("importAll")) && !methodeName.contains("search")){ + //on recharge la liste + cacheDataList = getDataList(financialTransactionSearch); + fireTableDataChanged(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -72,109 +72,109 @@ this.view = view; /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - - financialTransactionSearch = new FinancialTransactionSearchImpl(); - + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + + financialTransactionSearch = new FinancialTransactionSearchImpl(); + } public void setBeginDate(Date beginDate){ - financialTransactionSearch.setBeginDate(beginDate); + financialTransactionSearch.setBeginDate(beginDate); } public void setEndDate(Date endDate){ - financialTransactionSearch.setEndDate(endDate); + financialTransactionSearch.setEndDate(endDate); } public void setVoucher(String voucher){ - String result = null; - if (!voucher.equals("")){ - result = voucher; - } - financialTransactionSearch.setVoucher(result); + String result = null; + if (!voucher.equals("")){ + result = voucher; + } + financialTransactionSearch.setVoucher(result); } public void setDescription(String description){ - String result = null; - if (!description.equals("")){ - result = description; - } - financialTransactionSearch.setDescription(result); + String result = null; + if (!description.equals("")){ + result = description; + } + financialTransactionSearch.setDescription(result); } public void setLetter(Letter letter){ - financialTransactionSearch.setLetter(letter); + financialTransactionSearch.setLetter(letter); } public String getAccountsList(){ - return financialTransactionSearch.getAccountList(); + return financialTransactionSearch.getAccountList(); } public void setAccountsList(String accountsList){ - String result = null; - if (!accountsList.equals("")){ - result = accountsList; - } - financialTransactionSearch.setAccountList(result); + String result = null; + if (!accountsList.equals("")){ + result = accountsList; + } + financialTransactionSearch.setAccountList(result); } public Account getAccount(){ - return financialTransactionSearch.getAccount(); + return financialTransactionSearch.getAccount(); } public void setAccount(Account account){ - financialTransactionSearch.setAccount(account); + financialTransactionSearch.setAccount(account); } public void setEntryBook(EntryBook entryBook){ - financialTransactionSearch.setEntryBook(entryBook); + financialTransactionSearch.setEntryBook(entryBook); } public String getAmount(){ - return financialTransactionSearch.getAmount(); + return financialTransactionSearch.getAmount(); } public void setAmount(String amount){ - String result = null; - if (!amount.equals("")){ - result = amount; - } - financialTransactionSearch.setAmount(result); + String result = null; + if (!amount.equals("")){ + result = amount; + } + financialTransactionSearch.setAmount(result); } public String getAmount2(){ - return financialTransactionSearch.getAmount2(); + return financialTransactionSearch.getAmount2(); } public void setAmount2(String amount2){ - String result = null; - if (!amount2.equals("")){ - result = amount2; - } - financialTransactionSearch.setAmount2(result); + String result = null; + if (!amount2.equals("")){ + result = amount2; + } + financialTransactionSearch.setAmount2(result); } public void setAmountWayEnum(FinancialStatementWayEnum amountWayEnum){ - financialTransactionSearch.setAmountWayEnum(amountWayEnum); + financialTransactionSearch.setAmountWayEnum(amountWayEnum); } public void setOperator(String operator){ - String result = null; - if (!operator.equals("")){ - result = operator; - } - financialTransactionSearch.setOperator(result); + String result = null; + if (!operator.equals("")){ + result = operator; + } + financialTransactionSearch.setOperator(result); } public void refresh(){ tableModel = view.getFinancialTransactionSearchTableModel(); if (tableModel != null){ - tableModel.refresh(financialTransactionSearch); + tableModel.refresh(financialTransactionSearch); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -40,55 +40,55 @@ public class LetterSearchComboBox extends JComboBox implements KeyListener, ActionListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(LetterSearchComboBox.class); - - protected FinancialTransactionSearchViewHandler handler; - - public LetterSearchComboBox(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); - LetterRenderer letterRenderer = new LetterRenderer(); - setModel(letterComboBoxModel); - setRenderer(letterRenderer); - setEditable(true); - AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); - } - - @Override - public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Letter){ - handler.setLetter((Letter) this.getSelectedItem()); - } - } + + protected FinancialTransactionSearchViewHandler handler; + + public LetterSearchComboBox(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); + LetterRenderer letterRenderer = new LetterRenderer(); + setModel(letterComboBoxModel); + setRenderer(letterRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Letter){ + handler.setLetter((Letter) this.getSelectedItem()); + } + } - @Override - public void keyPressed(KeyEvent e) { - - } + @Override + public void keyPressed(KeyEvent e) { + + } - @Override - public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Letter){ - handler.setLetter((Letter) this.getSelectedItem()); - } - // delegate popup list menu + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Letter){ + handler.setLetter((Letter) this.getSelectedItem()); + } + // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) { - firePopupMenuCanceled(); + firePopupMenuCanceled(); } - } + } - @Override - public void keyTyped(KeyEvent e) { - - } - + @Override + public void keyTyped(KeyEvent e) { + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -29,32 +29,32 @@ import org.chorem.lima.enums.ComboBoxLetterEnum; public class LetterSearchPanel extends JPanel { - - protected FinancialTransactionSearchViewHandler handler; - - public LetterSearchPanel(FinancialTransactionSearchViewHandler handler) { - this.handler = handler; - } - - static final long serialVersionUID = 1L; + + protected FinancialTransactionSearchViewHandler handler; + + public LetterSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxLetterEnum comboBoxEnum){ - - switch (comboBoxEnum) { - case ALL: - handler.setLetter(null); - handler.refresh(); - this.removeAll(); - break; - - case SELECT_ONE: - LetterSearchComboBox comboBox = new LetterSearchComboBox(handler); - this.removeAll(); - this.add(comboBox); - break; - - } - - } - + public void refresh(ComboBoxLetterEnum comboBoxEnum){ + + switch (comboBoxEnum) { + case ALL: + handler.setLetter(null); + handler.refresh(); + this.removeAll(); + break; + + case SELECT_ONE: + LetterSearchComboBox comboBox = new LetterSearchComboBox(handler); + this.removeAll(); + this.add(comboBox); + break; + + } + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -122,7 +122,7 @@ boolean isHighlighted = false; Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { - BigDecimal currentBalance = (BigDecimal) value; + BigDecimal currentBalance = (BigDecimal) value; if (currentBalance.doubleValue() != 0) { isHighlighted = true; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -106,10 +106,10 @@ */ public FinancialTransactionUnbalancedTableModel() { /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addListener(this); } /** @@ -137,7 +137,7 @@ } ErrorHelper.showErrorDialog("Can't get transaction list", eee); - } + } } return results; @@ -249,10 +249,10 @@ result = cacheDataList.get(row); if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; + FinancialTransaction currentRow = (FinancialTransaction)result; BigDecimal amountDebit = currentRow.getAmountDebit(); BigDecimal amountCredit = currentRow.getAmountCredit(); - + switch (column) { case 0: result = currentRow.getTransactionDate(); @@ -295,7 +295,7 @@ result = null; // date break; case 1 : // entry book - result = null; + result = null; break; case 2: result = currentEntry.getVoucher(); @@ -318,16 +318,16 @@ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); break; case 7: - result = null; + result = null; break; case 8: - if (currentEntry.getLetter() != null){ - result = currentEntry.getLetter().getCode(); - } - else { - result = null; - } - break; + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } + break; } } @@ -370,12 +370,12 @@ entry.setAmount(new BigDecimal(0)); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; + currentTransaction = (FinancialTransaction)currentRow; } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); + Entry currentEntry = (Entry)currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); } //create it entry.setFinancialTransaction(currentTransaction); @@ -394,15 +394,15 @@ if (selectedFiscalPeriod != null) { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentFinancialTransaction = - (FinancialTransaction)currentRow; + FinancialTransaction currentFinancialTransaction = + (FinancialTransaction)currentRow; switch (column) { case 0: //update currentFinancialTransaction.setTransactionDate((Date)value); break; case 1 : - currentFinancialTransaction.setEntryBook((EntryBook)value); + currentFinancialTransaction.setEntryBook((EntryBook)value); break; } // notify service for modification @@ -436,7 +436,7 @@ currentEntry.setDebit(true); break; case 6: - currentEntry.setAmount((BigDecimal)value); + currentEntry.setAmount((BigDecimal)value); currentEntry.setDebit(false); break; case 8: @@ -453,7 +453,7 @@ } //update the financial transaction in entire financialTransactionRow = - cacheDataList.indexOf(((Entry) currentRow). + cacheDataList.indexOf(((Entry) currentRow). getFinancialTransaction()); } //on recharge la liste @@ -463,7 +463,7 @@ } public Object getElementAt(int row){ - + Object currentRow = cacheDataList.get(row); return currentRow; } @@ -479,22 +479,22 @@ public void removeObject(Object object, int row) throws LimaException { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = - (FinancialTransaction)currentRow; - financialTransactionService.removeFinancialTransaction(currentTransaction); + FinancialTransaction currentTransaction = + (FinancialTransaction)currentRow; + financialTransactionService.removeFinancialTransaction(currentTransaction); } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - financialTransactionService.removeEntry(currentEntry); + Entry currentEntry = (Entry)currentRow; + financialTransactionService.removeEntry(currentEntry); } //on recharge la liste refresh(); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -69,14 +69,14 @@ //add a new entry to the selected transaction public void addEmptyEntry(){ - table = view.getFinancialTransactionUnbalancedTable(); + table = view.getFinancialTransactionUnbalancedTable(); tableModel = view.getFinancialTransactionUnbalancedTableModel(); int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { - Object selectedValue = tableModel.getElementAt(indexSelectedRow); - try { - tableModel.addEmptyEntry(selectedValue, indexSelectedRow); + Object selectedValue = tableModel.getElementAt(indexSelectedRow); + try { + tableModel.addEmptyEntry(selectedValue, indexSelectedRow); //select the new line ListSelectionModel selectionModel = table.getSelectionModel(); @@ -84,13 +84,13 @@ //focus on second column table.changeSelection(indexSelectedRow+1, 1, false, false); table.requestFocusInWindow(); - } catch (LimaException eee){ + } catch (LimaException eee){ if (log.isErrorEnabled()) { log.error("Can't add emptyentry", eee); } DialogHelper.showMessageDialog(eee.getMessage()); - } + } } else { if (log.isWarnEnabled()) { @@ -107,7 +107,7 @@ */ public void deleteSelectedRow(){ - table = view.getFinancialTransactionUnbalancedTable(); + table = view.getFinancialTransactionUnbalancedTable(); tableModel = view.getFinancialTransactionUnbalancedTableModel(); int indexSelectedRow = table.getSelectedRow(); @@ -126,9 +126,9 @@ _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { - + try { - tableModel.removeObject(selectedValue, indexSelectedRow); + tableModel.removeObject(selectedValue, indexSelectedRow); //select the upper line ListSelectionModel selectionModel = table.getSelectionModel(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -36,9 +36,9 @@ public class FiscalPeriodTable extends JXTable { - private static final long serialVersionUID = -8462838870024505659L; + private static final long serialVersionUID = -8462838870024505659L; - protected FiscalPeriodViewHandler handler; + protected FiscalPeriodViewHandler handler; protected FiscalPeriodTableModel model; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -58,11 +58,11 @@ public FiscalPeriodTableModel() { fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } @Override @@ -194,11 +194,11 @@ fireTableDataChanged(); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - //refresh on import datas - if (methodeName.contains("importAll")){ - fireTableDataChanged(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + //refresh on import datas + if (methodeName.contains("importAll")){ + fireTableDataChanged(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -70,10 +70,10 @@ // null = cancel if (fiscalPeriod!= null) { //check if fiscalperiod have 12 months, ask a confirmation - int nbMonth = - DateUtils.getDifferenceInMonths(fiscalPeriod.getBeginDate(), - fiscalPeriod.getEndDate()); - int n = 0; + int nbMonth = + DateUtils.getDifferenceInMonths(fiscalPeriod.getBeginDate(), + fiscalPeriod.getEndDate()); + int n = 0; if(nbMonth !=12){ n = JOptionPane.showConfirmDialog(getView(), _("lima.charts.fiscalperiod.question.morethan12"), Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -45,85 +45,85 @@ import org.chorem.lima.ui.MainView; public class AccountsPane extends JEditorPane implements HyperlinkListener, ServiceListener { - - private static final long serialVersionUID = 1L; - + + private static final long serialVersionUID = 1L; + private static final Log log = LogFactory.getLog(AccountsPane.class); protected HomeView view; - - protected AccountServiceMonitorable accountService; - + + protected AccountServiceMonitorable accountService; + private static Color redBackground = new Color(0xff, 0xee, 0xee); private static Color greenBackground = new Color(0xee, 0xff, 0xee); public AccountsPane(HomeView view) { - this.view=view; - accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); - accountService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - - //init - setOpaque(true); - setContentType("text/html"); - setEditable(false); - setUI(new BasicEditorPaneUI()); - addHyperlinkListener(this); - refresh(); + this.view=view; + accountService = + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); + accountService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + + //init + setOpaque(true); + setContentType("text/html"); + setEditable(false); + setUI(new BasicEditorPaneUI()); + addHyperlinkListener(this); + refresh(); } - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (e.getDescription().equals("#accountschart")) { - MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); - ui.getHandler().showAccountView(ui); - } - } - } + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showAccountView(ui); + } + } + } - public void refresh(){ - - String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; - String htmlEnd = "</p></font>"; - - try { - - List<Account> accounts = accountService.getAllAccounts(); - if (accounts.size()>0){ - setBackground(greenBackground); - String accountsString = _("lima.home.chartaccounts.state1_2") + " " - + accounts.size() + " " + _("lima.home.chartaccounts.state2_2") - + "<br/><br/><a href='#accountschart'>" - + _("lima.home.chartaccounts.modify") + "</a>"; - //set Text - setText(htmlBegin + accountsString + htmlEnd); - } - else { - setBackground(redBackground); - String accountsString = _("lima.home.chartaccounts.nothing") - + "<br/><br/><a href='#accountschart'>" - + _("lima.home.chartaccounts.create") + "</a>"; - //set Text - setText(htmlBegin + accountsString + htmlEnd); - } - } catch (LimaException eee) { - log.debug("Can't get datas account editor pane home", eee); - } - } + public void refresh(){ + + String htmlBegin = "<font face='sans-serif' size=3>" + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + String htmlEnd = "</p></font>"; + + try { + + List<Account> accounts = accountService.getAllAccounts(); + if (accounts.size()>0){ + setBackground(greenBackground); + String accountsString = _("lima.home.chartaccounts.state1_2") + " " + + accounts.size() + " " + _("lima.home.chartaccounts.state2_2") + + "<br/><br/><a href='#accountschart'>" + + _("lima.home.chartaccounts.modify") + "</a>"; + //set Text + setText(htmlBegin + accountsString + htmlEnd); + } + else { + setBackground(redBackground); + String accountsString = _("lima.home.chartaccounts.nothing") + + "<br/><br/><a href='#accountschart'>" + + _("lima.home.chartaccounts.create") + "</a>"; + //set Text + setText(htmlBegin + accountsString + htmlEnd); + } + } catch (LimaException eee) { + log.debug("Can't get datas account editor pane home", eee); + } + } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("Account") || methodeName.contains("importAll") || methodeName.contains("importAs")){ - refresh(); - } - } - + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("Account") || methodeName.contains("importAll") || methodeName.contains("importAs")){ + refresh(); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -45,8 +45,8 @@ public class EntryBooksPane extends JEditorPane implements HyperlinkListener, ServiceListener { - private static final long serialVersionUID = 1L; - + private static final long serialVersionUID = 1L; + private static final Log log = LogFactory.getLog(EntryBooksPane.class); protected HomeView view; @@ -57,95 +57,95 @@ private static Color greenBackground = new Color(0xee, 0xff, 0xee); public EntryBooksPane(HomeView view) { - this.view=view; + this.view=view; entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); entryBookService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - - //init - setOpaque(true); - setContentType("text/html"); - setEditable(false); - setUI(new BasicEditorPaneUI()); - addHyperlinkListener(this); - refresh(); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + + //init + setOpaque(true); + setContentType("text/html"); + setEditable(false); + setUI(new BasicEditorPaneUI()); + addHyperlinkListener(this); + refresh(); } - - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { + + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (e.getDescription().equals("#entrybookschart")) { - MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); - ui.getHandler().showEntryBookView(ui); - } - } - } + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showEntryBookView(ui); + } + } + } - public void refresh(){ - - String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; - String htmlEnd = "</p></font>"; - - try { - - List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); - int ebSize = entryBooks.size(); - if (ebSize>0){ - setBackground(greenBackground); - String entryBooksString=""; - if (ebSize == 1){ - entryBooksString = _("lima.home.entrybooks.state.single") - + "<br/>" + entryBooks.get(0).getLabel() - + "<br/><br/><a href='#entrybookschart'>" - + _("lima.home.entrybooks.modify") + "</a>"; - - } - else { - entryBooksString = _("lima.home.entrybooks.state1_2.plural") - + " " + entryBooks.size() + " " - + _("lima.home.entrybooks.state2_2.plural") + "<ul>"; + public void refresh(){ + + String htmlBegin = "<font face='sans-serif' size=3>" + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + String htmlEnd = "</p></font>"; + + try { + + List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); + int ebSize = entryBooks.size(); + if (ebSize>0){ + setBackground(greenBackground); + String entryBooksString=""; + if (ebSize == 1){ + entryBooksString = _("lima.home.entrybooks.state.single") + + "<br/>" + entryBooks.get(0).getLabel() + + "<br/><br/><a href='#entrybookschart'>" + + _("lima.home.entrybooks.modify") + "</a>"; + + } + else { + entryBooksString = _("lima.home.entrybooks.state1_2.plural") + + " " + entryBooks.size() + " " + + _("lima.home.entrybooks.state2_2.plural") + "<ul>"; for (int i = 0; i < ebSize && i < 3; i++) { -// for (EntryBook entryBook : entryBooks) { +// for (EntryBook entryBook : entryBooks) { EntryBook entryBook = entryBooks.get(i); entryBooksString += "<li>"+entryBook.getCode() + - " - "+entryBook.getLabel()+"</li>"; - } + " - "+entryBook.getLabel()+"</li>"; + } if (ebSize > 3) { entryBooksString += "<li> ... </li>"; } - entryBooksString += "</ul></p><p horizontal-align:'center'>" - + "<a href='#entrybookschart'>" - + _("lima.home.entrybooks.modify") + "</a>"; - } - //set Text - setText(htmlBegin + entryBooksString + htmlEnd); - } - else { - setBackground(redBackground); - //set Text - setText(htmlBegin - + _("lima.home.entrybooks.nothing") - + "<br/><br/><a href='#entrybookschart'>" - + _("lima.home.entrybooks.create") +"</a>" + htmlEnd); - } - - } catch (LimaException eee) { - log.debug("Can't get datas account editor pane home", eee); - } - } - - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("EntryBook") || methodeName.contains("importAll") - || methodeName.contains("importAs") || methodeName.contains("importEntries")){ - refresh(); - } - } + entryBooksString += "</ul></p><p horizontal-align:'center'>" + + "<a href='#entrybookschart'>" + + _("lima.home.entrybooks.modify") + "</a>"; + } + //set Text + setText(htmlBegin + entryBooksString + htmlEnd); + } + else { + setBackground(redBackground); + //set Text + setText(htmlBegin + + _("lima.home.entrybooks.nothing") + + "<br/><br/><a href='#entrybookschart'>" + + _("lima.home.entrybooks.create") +"</a>" + htmlEnd); + } + + } catch (LimaException eee) { + log.debug("Can't get datas account editor pane home", eee); + } + } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("EntryBook") || methodeName.contains("importAll") + || methodeName.contains("importAs") || methodeName.contains("importEntries")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -47,117 +47,117 @@ public class FinancialTransactionsPane extends JEditorPane implements HyperlinkListener, ServiceListener { - private static final long serialVersionUID = 1L; - + private static final long serialVersionUID = 1L; + private static final Log log = LogFactory.getLog(FinancialTransactionsPane.class); protected HomeView view; - - protected FinancialTransactionServiceMonitorable financialTransactionService; + + protected FinancialTransactionServiceMonitorable financialTransactionService; protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + private static Color redBackground = new Color(0xff, 0xee, 0xee); private static Color greenBackground = new Color(0xee, 0xff, 0xee); public FinancialTransactionsPane(HomeView view) { - this.view = view; - + this.view = view; + financialTransactionService = - LimaServiceFactory.getInstance().getService(FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.getInstance().getService(FinancialTransactionServiceMonitorable.class); financialTransactionService.addListener(this); fiscalPeriodService = - LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - - //init - setOpaque(true); - setContentType("text/html"); - setEditable(false); - setUI(new BasicEditorPaneUI()); - addHyperlinkListener(this); - refresh(); - } - - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - - if (e.getDescription().equals("#financialtransactionunbalanced")) { - MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); - ui.getHandler().showTransactionUnbalancedView(ui); - } + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + + //init + setOpaque(true); + setContentType("text/html"); + setEditable(false); + setUI(new BasicEditorPaneUI()); + addHyperlinkListener(this); + refresh(); + } + + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + + if (e.getDescription().equals("#financialtransactionunbalanced")) { + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showTransactionUnbalancedView(ui); + } else if (e.getDescription().equals("#financialtransactionbalanced")) { - MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); - ui.getHandler().showTransactionView(ui); - } - } - } + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showTransactionView(ui); + } + } + } public void refresh(){ - - String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; - String htmlEnd = "</p></font>"; - - try { - - List<FiscalPeriod> unblockedFiscalPeriods = - fiscalPeriodService.getAllUnblockedFiscalPeriods(); - if (unblockedFiscalPeriods.size() != 0){ - List<FinancialTransaction> financialTransactionsUnbal = - financialTransactionService. - getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0)); - if (financialTransactionsUnbal.size()>0){ - setBackground(redBackground); - String transactionsString = financialTransactionsUnbal.size() - + " " + _("lima.home.transaction.unbalanced") - + "<br/><br/><a href='#financialtransactionunbalanced'>" - + _("lima.home.transaction.modifiy.unbalanced") + "</a>"; - //set Text - setText(htmlBegin + transactionsString + htmlEnd); - } - else { - List<FinancialTransaction> financialTransactionsBal = - financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0)); - - if (financialTransactionsBal.size()>0){ - setBackground(greenBackground); - String transactionsString = financialTransactionsBal.size() - + " " + _("lima.home.transaction.balanced") - + "<br/><br/><a href='#financialtransactionbalanced'>" - + _("lima.home.transaction.modifiy.balanced") + "</a>"; - //set Text - setText(htmlBegin + transactionsString + htmlEnd); - } - else { - setBackground(redBackground); - String transactionsString = _("lima.home.transaction.nothing") - + "<br/><br/><a href='#financialtransactionbalanced'>" - + _("lima.home.transaction.create") + "</a>"; - //set Text - setText(htmlBegin + transactionsString + htmlEnd); - } + + String htmlBegin = "<font face='sans-serif' size=3>" + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + String htmlEnd = "</p></font>"; + + try { + + List<FiscalPeriod> unblockedFiscalPeriods = + fiscalPeriodService.getAllUnblockedFiscalPeriods(); + if (unblockedFiscalPeriods.size() != 0){ + List<FinancialTransaction> financialTransactionsUnbal = + financialTransactionService. + getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0)); + if (financialTransactionsUnbal.size()>0){ + setBackground(redBackground); + String transactionsString = financialTransactionsUnbal.size() + + " " + _("lima.home.transaction.unbalanced") + + "<br/><br/><a href='#financialtransactionunbalanced'>" + + _("lima.home.transaction.modifiy.unbalanced") + "</a>"; + //set Text + setText(htmlBegin + transactionsString + htmlEnd); + } + else { + List<FinancialTransaction> financialTransactionsBal = + financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0)); + + if (financialTransactionsBal.size()>0){ + setBackground(greenBackground); + String transactionsString = financialTransactionsBal.size() + + " " + _("lima.home.transaction.balanced") + + "<br/><br/><a href='#financialtransactionbalanced'>" + + _("lima.home.transaction.modifiy.balanced") + "</a>"; + //set Text + setText(htmlBegin + transactionsString + htmlEnd); + } + else { + setBackground(redBackground); + String transactionsString = _("lima.home.transaction.nothing") + + "<br/><br/><a href='#financialtransactionbalanced'>" + + _("lima.home.transaction.create") + "</a>"; + //set Text + setText(htmlBegin + transactionsString + htmlEnd); + } - } - } - else { - setBackground(redBackground); - } - - } catch (LimaException eee) { - log.debug("Can't get datas account editor pane home", eee); - } - } - - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("FiscalPeriod") || methodeName.contains("FinancialTransaction") - || methodeName.contains("Entry") || methodeName.contains("importEntries") - || methodeName.contains("importAll") || methodeName.contains("importAs")){ - refresh(); - } - } + } + } + else { + setBackground(redBackground); + } + + } catch (LimaException eee) { + log.debug("Can't get datas account editor pane home", eee); + } + } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("FiscalPeriod") || methodeName.contains("FinancialTransaction") + || methodeName.contains("Entry") || methodeName.contains("importEntries") + || methodeName.contains("importAll") || methodeName.contains("importAs")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -45,95 +45,95 @@ public class FiscalPeriodsPane extends JEditorPane implements HyperlinkListener, ServiceListener { - private static final long serialVersionUID = 1L; - + private static final long serialVersionUID = 1L; + private static final Log log = LogFactory.getLog(FiscalPeriodsPane.class); protected HomeView view; - - protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + + protected FiscalPeriodServiceMonitorable fiscalPeriodService; + private static Color redBackground = new Color(0xff, 0xee, 0xee); private static Color greenBackground = new Color(0xee, 0xff, 0xee); public FiscalPeriodsPane(HomeView view) { - this.view = view; - + this.view = view; + fiscalPeriodService = - LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - - //init - setOpaque(true); - setContentType("text/html"); - setEditable(false); - setUI(new BasicEditorPaneUI()); - addHyperlinkListener(this); - refresh(); } - - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - - if (e.getDescription().equals("#fiscalperiodschart")) { - MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); - ui.getHandler().showFiscalPeriodView(ui); - } - } - } - + LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); + fiscalPeriodService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + + //init + setOpaque(true); + setContentType("text/html"); + setEditable(false); + setUI(new BasicEditorPaneUI()); + addHyperlinkListener(this); + refresh(); } + + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + + if (e.getDescription().equals("#fiscalperiodschart")) { + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showFiscalPeriodView(ui); + } + } + } + public void refresh(){ - - String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; - String htmlEnd = "</p></font>"; - - try { - - //FISCAL PERIOD - List<FiscalPeriod> fiscalPeriods = - fiscalPeriodService.getAllFiscalPeriods(); - List<FiscalPeriod> unblockedFiscalPeriods = - fiscalPeriodService.getAllUnblockedFiscalPeriods(); - if (unblockedFiscalPeriods.size()>0){ - setBackground(greenBackground); - String fiscalString = unblockedFiscalPeriods.size() + " " - + _("lima.home.fiscalperiod.opened") + "<br/>" - + (fiscalPeriods.size()-unblockedFiscalPeriods.size()) - + " " + _("lima.home.fiscalperiod.closed") - + "<br/><br/><a href='#fiscalperiodschart'>" - + _("lima.home.fiscalperiod.modify") + "</a>"; - //set Text - setText(htmlBegin + fiscalString + htmlEnd); - - - } - else { - setBackground(redBackground); - String fiscalString = _("lima.home.fiscalperiod.noopen"); - if (fiscalPeriods.size()>0){ - fiscalString += "<br/>" + fiscalPeriods.size() + " " - + _("lima.home.fiscalperiod.closed"); - } - fiscalString += "<br/><br/><a href='#fiscalperiodschart'>" - + _("lima.home.fiscalperiod.create") + "</a>"; - //set Text - setText(htmlBegin + fiscalString + htmlEnd); + + String htmlBegin = "<font face='sans-serif' size=3>" + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + String htmlEnd = "</p></font>"; + + try { + + //FISCAL PERIOD + List<FiscalPeriod> fiscalPeriods = + fiscalPeriodService.getAllFiscalPeriods(); + List<FiscalPeriod> unblockedFiscalPeriods = + fiscalPeriodService.getAllUnblockedFiscalPeriods(); + if (unblockedFiscalPeriods.size()>0){ + setBackground(greenBackground); + String fiscalString = unblockedFiscalPeriods.size() + " " + + _("lima.home.fiscalperiod.opened") + "<br/>" + + (fiscalPeriods.size()-unblockedFiscalPeriods.size()) + + " " + _("lima.home.fiscalperiod.closed") + + "<br/><br/><a href='#fiscalperiodschart'>" + + _("lima.home.fiscalperiod.modify") + "</a>"; + //set Text + setText(htmlBegin + fiscalString + htmlEnd); + + + } + else { + setBackground(redBackground); + String fiscalString = _("lima.home.fiscalperiod.noopen"); + if (fiscalPeriods.size()>0){ + fiscalString += "<br/>" + fiscalPeriods.size() + " " + + _("lima.home.fiscalperiod.closed"); + } + fiscalString += "<br/><br/><a href='#fiscalperiodschart'>" + + _("lima.home.fiscalperiod.create") + "</a>"; + //set Text + setText(htmlBegin + fiscalString + htmlEnd); - } - } catch (LimaException eee) { - log.debug("Can't get datas home", eee); - } + } + } catch (LimaException eee) { + log.debug("Can't get datas home", eee); + } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll") - || methodeName.contains("importAs")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll") + || methodeName.contains("importAs")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -36,40 +36,40 @@ public class IdentityHandler { - protected IdentityService identityService; - + protected IdentityService identityService; + private static final Log log = LogFactory.getLog(IdentityHandler.class); - - public IdentityHandler() { - identityService = - LimaServiceFactory.getInstance().getService( - IdentityServiceMonitorable.class); - } - - public Identity getIdentity(){ - Identity identity = null; - try { - identity = identityService.getIdentity(); - } catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't get Identity", eee); - } - } - if (identity == null){ - identity = new IdentityImpl(); - } - return identity; - } - - public void updateIdentity(Identity identity){ - - try { - identityService.updateIdentity(identity); - } catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't update Identity", eee); - } - } + + public IdentityHandler() { + identityService = + LimaServiceFactory.getInstance().getService( + IdentityServiceMonitorable.class); + } + + public Identity getIdentity(){ + Identity identity = null; + try { + identity = identityService.getIdentity(); + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't get Identity", eee); + } + } + if (identity == null){ + identity = new IdentityImpl(); + } + return identity; + } + + public void updateIdentity(Identity identity){ + + try { + identityService.updateIdentity(identity); + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't update Identity", eee); + } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -65,13 +65,13 @@ public class ImportExport { - private static ImportExport exchanger; - + private static ImportExport exchanger; + private static final Log log = LogFactory.getLog(AccountViewHandler.class); - protected static Component viewComponent; - - protected EncodingEnum encodingEnum; + protected static Component viewComponent; + + protected EncodingEnum encodingEnum; protected ImportServiceMonitorable importService; @@ -80,15 +80,15 @@ private ImportExportWaitView waitView; public ImportExport(Component view) { - viewComponent=view; - - //services - importService = - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class); + viewComponent=view; + + //services + importService = + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class); exportService = - LimaServiceFactory.getInstance().getService( - ExportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ExportServiceMonitorable.class); //create the wait dialog panel waitView = new ImportExportWaitView(); @@ -97,112 +97,112 @@ BusyPainter busyPainter = waitView.getBusylabel().getBusyPainter(); busyPainter.setHighlightColor(new Color(44, 61, 146).darker()); busyPainter.setBaseColor(new Color(168, 204, 241).brighter()); - } + } /** * Call the appropriate methode in business service. * * @param importExportMethode */ - public void importExport(ImportExportEnum importExportMethode, String file, Boolean verbose){ - final ImportExportEnum importExportMethodeF = importExportMethode; - encodingEnum = EncodingEnum.UTF8; - if (file.equals("")) { - file = chooseFile(importExportMethode.getImportMode(), importExportMethode); - } - //if export cancel - if (!file.equals("")) { - final EncodingEnum charset = encodingEnum; - final String filePath = file; - final Boolean verboseMode = verbose; - new SwingWorker<String,Void>() { - @Override protected String doInBackground() throws LimaException { - String datas = ""; - String result = ""; - switch (importExportMethodeF) { - case CSV_ALL_EXPORT: - datas = exportService.exportAsCSV(); - createFile(filePath, charset.getEncoding(), datas); - break; - case CSV_ACCOUNTCHARTS_EXPORT: - datas = exportService.exportAccountsChartAsCSV(); - createFile(filePath, charset.getEncoding(), datas); - break; - case CSV_ENTRYBOOKS_EXPORT: - datas = exportService.exportEntryBookChartAsCSV(); - createFile(filePath, charset.getEncoding(), datas); - break; - case CSV_FINANCIALSTATEMENTS_EXPORT: - datas = exportService.exportFinancialStatementChartAsCSV(); - createFile(filePath, charset.getEncoding(), datas); - break; - case EBP_ACCOUNTCHARTS_EXPORT: - //For windows ebp - datas = exportService.exportAccountsAsEBP(); - createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); - break; - case EBP_ENTRIES_EXPORT: - //For windows ebp - datas = exportService.exportEntriesAsEBP(); - createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); - break; - case CSV_ALL_IMPORT: - datas = extractFile(filePath, charset.getEncoding()); - result = importService.importAllAsCSV(datas); - break; - case CSV_ACCOUNTCHARTS_IMPORT: - datas = extractFile(filePath, charset.getEncoding()); - result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT); - break; - case CSV_ENTRYBOOKS_IMPORT: - datas = extractFile(filePath, charset.getEncoding()); - result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK); - break; - case CSV_FINANCIALSTATEMENTS_IMPORT: - datas = extractFile(filePath, charset.getEncoding()); - result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT); - break; - case EBP_ACCOUNTCHARTS_IMPORT: - //For windows ebp - datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); - result = importService.importAccountsChartFromEbp(datas); - break; - case EBP_ENTRIES_IMPORT: - //For windows ebp - datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); - result = importService.importEntriesFromEbp(datas); - break; - } - return result; - } - @Override protected void done() { - try { - //hidde wait dialog panel - waitView.setVisible(false); - // display result dialog - if (verboseMode){ - String result = get(); - if (!result.equals("")){ - DialogHelper.showReportDialog(result, _("lima.importexport.import"), viewComponent); - } - else { - DialogHelper.showMessageDialog(_("lima.importexport.import.terminated")); - } - } - } catch (InterruptedException eee) { - if (log.isErrorEnabled()){ - log.error("Can't get result message", eee); - } - } catch (ExecutionException eee) { - DialogHelper.showMessageDialog(eee.getCause().getMessage()); - if (log.isErrorEnabled()){ - log.error("Error on import", eee); - } - } - } - }.execute(); - waitView.setVisible(true); - } + public void importExport(ImportExportEnum importExportMethode, String file, Boolean verbose){ + final ImportExportEnum importExportMethodeF = importExportMethode; + encodingEnum = EncodingEnum.UTF8; + if (file.equals("")) { + file = chooseFile(importExportMethode.getImportMode(), importExportMethode); + } + //if export cancel + if (!file.equals("")) { + final EncodingEnum charset = encodingEnum; + final String filePath = file; + final Boolean verboseMode = verbose; + new SwingWorker<String,Void>() { + @Override protected String doInBackground() throws LimaException { + String datas = ""; + String result = ""; + switch (importExportMethodeF) { + case CSV_ALL_EXPORT: + datas = exportService.exportAsCSV(); + createFile(filePath, charset.getEncoding(), datas); + break; + case CSV_ACCOUNTCHARTS_EXPORT: + datas = exportService.exportAccountsChartAsCSV(); + createFile(filePath, charset.getEncoding(), datas); + break; + case CSV_ENTRYBOOKS_EXPORT: + datas = exportService.exportEntryBookChartAsCSV(); + createFile(filePath, charset.getEncoding(), datas); + break; + case CSV_FINANCIALSTATEMENTS_EXPORT: + datas = exportService.exportFinancialStatementChartAsCSV(); + createFile(filePath, charset.getEncoding(), datas); + break; + case EBP_ACCOUNTCHARTS_EXPORT: + //For windows ebp + datas = exportService.exportAccountsAsEBP(); + createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); + break; + case EBP_ENTRIES_EXPORT: + //For windows ebp + datas = exportService.exportEntriesAsEBP(); + createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); + break; + case CSV_ALL_IMPORT: + datas = extractFile(filePath, charset.getEncoding()); + result = importService.importAllAsCSV(datas); + break; + case CSV_ACCOUNTCHARTS_IMPORT: + datas = extractFile(filePath, charset.getEncoding()); + result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT); + break; + case CSV_ENTRYBOOKS_IMPORT: + datas = extractFile(filePath, charset.getEncoding()); + result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK); + break; + case CSV_FINANCIALSTATEMENTS_IMPORT: + datas = extractFile(filePath, charset.getEncoding()); + result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT); + break; + case EBP_ACCOUNTCHARTS_IMPORT: + //For windows ebp + datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); + result = importService.importAccountsChartFromEbp(datas); + break; + case EBP_ENTRIES_IMPORT: + //For windows ebp + datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); + result = importService.importEntriesFromEbp(datas); + break; + } + return result; + } + @Override protected void done() { + try { + //hidde wait dialog panel + waitView.setVisible(false); + // display result dialog + if (verboseMode){ + String result = get(); + if (!result.equals("")){ + DialogHelper.showReportDialog(result, _("lima.importexport.import"), viewComponent); + } + else { + DialogHelper.showMessageDialog(_("lima.importexport.import.terminated")); + } + } + } catch (InterruptedException eee) { + if (log.isErrorEnabled()){ + log.error("Can't get result message", eee); + } + } catch (ExecutionException eee) { + DialogHelper.showMessageDialog(eee.getCause().getMessage()); + if (log.isErrorEnabled()){ + log.error("Error on import", eee); + } + } + } + }.execute(); + waitView.setVisible(true); + } } @@ -213,25 +213,25 @@ * @return */ public String chooseFile(Boolean importMode, ImportExportEnum importExportMethode){ - String filePath = ""; - JFileChooser chooser = new JFileChooser(); - //Encoding option - - JComboBox comboBox = new JComboBox(EncodingEnum.descriptions()); - if (importExportMethode.getEncodingOption()){ - JPanel panel = new JPanel(); - panel.setLayout(new BorderLayout()); - panel.add(new JLabel(_("lima.importexport.choiceencoding")), BorderLayout.WEST); - panel.add(comboBox, BorderLayout.CENTER); - ((Container)chooser.getComponent(2)).add(panel, BorderLayout.SOUTH); - } - - if (importMode){ - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - } - else { - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - } + String filePath = ""; + JFileChooser chooser = new JFileChooser(); + //Encoding option + + JComboBox comboBox = new JComboBox(EncodingEnum.descriptions()); + if (importExportMethode.getEncodingOption()){ + JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(new JLabel(_("lima.importexport.choiceencoding")), BorderLayout.WEST); + panel.add(comboBox, BorderLayout.CENTER); + ((Container)chooser.getComponent(2)).add(panel, BorderLayout.SOUTH); + } + + if (importMode){ + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + } + else { + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + } if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) { filePath = chooser.getSelectedFile().getAbsolutePath(); @@ -240,7 +240,7 @@ } } - return filePath; + return filePath; } @@ -248,63 +248,63 @@ * Get csv datas in string and write file * */ - public void createFile(String filePath, String charset, String datas){ - try { - File file = new File(filePath); - BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); - out.write(datas); - out.flush(); - out.close(); - } - catch (IOException eee) { - if (log.isErrorEnabled()){ - log.error("Can't write file " + filePath, eee); - } - } - } + public void createFile(String filePath, String charset, String datas){ + try { + File file = new File(filePath); + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); + out.write(datas); + out.flush(); + out.close(); + } + catch (IOException eee) { + if (log.isErrorEnabled()){ + log.error("Can't write file " + filePath, eee); + } + } + } - /** - * Open csv file and get his datas on a string. - */ - public String extractFile(String filePath, String charset) { - StringWriter sw = new StringWriter(); - BufferedReader in = null; - try { - InputStream is = null; + /** + * Open csv file and get his datas on a string. + */ + public String extractFile(String filePath, String charset) { + StringWriter sw = new StringWriter(); + BufferedReader in = null; + try { + InputStream is = null; - // FIXME echatellier 20101129 remove this hack and modify resources reading mecanism - if (filePath != null && filePath.indexOf(".jar!") > 0) { - String resourcesPath = filePath.substring(filePath.indexOf(".jar!") + 5); - is = ImportExport.class.getResourceAsStream(resourcesPath); - } - else { - is = new FileInputStream(filePath); - } + // FIXME echatellier 20101129 remove this hack and modify resources reading mecanism + if (filePath != null && filePath.indexOf(".jar!") > 0) { + String resourcesPath = filePath.substring(filePath.indexOf(".jar!") + 5); + is = ImportExport.class.getResourceAsStream(resourcesPath); + } + else { + is = new FileInputStream(filePath); + } - in = new BufferedReader(new InputStreamReader(is, charset)); - IOUtils.copy(in, sw); - in.close(); - } - catch (IOException eee) { - if (log.isErrorEnabled()) { - log.error("Can't read file " + filePath, eee); - } - } - finally { - IOUtils.closeQuietly(in); - } + in = new BufferedReader(new InputStreamReader(is, charset)); + IOUtils.copy(in, sw); + in.close(); + } + catch (IOException eee) { + if (log.isErrorEnabled()) { + log.error("Can't read file " + filePath, eee); + } + } + finally { + IOUtils.closeQuietly(in); + } - return sw.toString(); - } - + return sw.toString(); + } + public static ImportExport getInstance(Component view) { if (exchanger == null) { - exchanger = new ImportExport(view); + exchanger = new ImportExport(view); } else { - viewComponent=view; + viewComponent=view; } return exchanger; } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -46,114 +46,114 @@ import org.jdesktop.swingx.JXDatePicker; public class LedgerPeriodSearchPanel extends JPanel { - + private static final Log log = LogFactory.getLog(LedgerPeriodSearchPanel.class); - - protected LedgerViewHandler handler; - - public LedgerPeriodSearchPanel(LedgerViewHandler handler) { - this.handler = handler; - - //init date + + protected LedgerViewHandler handler; + + public LedgerPeriodSearchPanel(LedgerViewHandler handler) { + this.handler = handler; + + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); - } - - static final long serialVersionUID = 1L; + } + + static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - - switch (comboBoxPeriodEnum) { - case PERIOD: - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); - //handler().setBeginDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - Date endDate = calendarEnd.getTime(); - //handler().setEndDate(endDate); - JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); - final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); - ActionListener beginDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(beginDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(beginDatePicker.getDate()); - beginDatePicker.addActionListener(beginDateActionListener); - - JLabel endDateLabel = new JLabel(_("lima.common.enddate")); - final JXDatePicker endDatePicker = new JXDatePicker(endDate); - ActionListener endDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setEndDate(endDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); - fiscalPeriod.setEditable(false); - ActionListener fiscalPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ + + switch (comboBoxPeriodEnum) { + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setEndDate(endDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + handler.refresh(); + + this.removeAll(); + this.add(beginDateLabel); + this.add(beginDatePicker); + this.add(endDateLabel); + this.add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); - financialPeriod.setEditable(false); - ActionListener financialPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); - break; - } - - } - + this.removeAll(); + this.add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null){ + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + this.removeAll(); + this.add(financialPeriod); + break; + } + + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -156,12 +156,12 @@ else if (result instanceof Entry) { Entry currentRow = (Entry)result; BigDecimal amountDebit = new BigDecimal(0), - amountCredit = new BigDecimal(0); + amountCredit = new BigDecimal(0); if (currentRow.getDebit()){ - amountDebit = currentRow.getAmount(); + amountDebit = currentRow.getAmount(); } else { - amountCredit = currentRow.getAmount(); + amountCredit = currentRow.getAmount(); } switch (column) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -85,7 +85,7 @@ protected BalanceTrial balanceTrialCache; private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); + new SimpleDateFormat("yyyy-MM-dd"); protected int port; @@ -95,18 +95,18 @@ this.view = view; reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); reportService.addListener(this); port = LimaServiceFactory.getInstance().getService( - HttpServerServiceMonitorable.class).getHttpPort(); + HttpServerServiceMonitorable.class).getHttpPort(); documentService = - LimaServiceFactory.getInstance().getService( - DocumentServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + DocumentServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class).addListener(this); } public void setBeginDate(Date date){ @@ -130,18 +130,18 @@ List<Object> results = new ArrayList<Object>(); try { balanceTrialCache = reportService.generateLedger(selectedBeginDate, - selectedEndDate, selectedAccounts, - view.getMovmentedFilter().isSelected()); - if (balanceTrialCache.getReportsDatas() != null){ - for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { - results.add(reportsDatas); - List<Entry> entries = (List<Entry>) reportsDatas.getListEntry(); - if (entries != null){ - Collections.sort(entries, new EntryComparator()); - results.addAll(entries); - } - } - } + selectedEndDate, selectedAccounts, + view.getMovmentedFilter().isSelected()); + if (balanceTrialCache.getReportsDatas() != null){ + for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { + results.add(reportsDatas); + List<Entry> entries = (List<Entry>) reportsDatas.getListEntry(); + if (entries != null){ + Collections.sort(entries, new EntryComparator()); + results.addAll(entries); + } + } + } } catch (LimaException eee) { if (log.isErrorEnabled()) { @@ -153,67 +153,67 @@ } public void refresh(){ - if (selectedBeginDate != null && selectedEndDate != null){ - model = view.getModelTable(); - cachedatasList = getDataList(); - model.refresh(cachedatasList); - - /** - * set text and amounts of labels credit, debit, solde - */ - - if (balanceTrialCache != null){ - // set amounts credit, debit and solde - view.amountCreditLabel.setText( - String.valueOf(balanceTrialCache.getAmountCredit())); - view.amountDebitLabel.setText( - String.valueOf(balanceTrialCache.getAmountDebit())); - BigDecimal amountSolde = balanceTrialCache.getAmountSolde(); - view.amountSoldeLabel.setText( - String.valueOf(amountSolde)); - - if (amountSolde.doubleValue() == 0){ - view.soldeLabel.setText(_("lima.common.solde")); - } - else { - // set label solde: credit or debit - if (balanceTrialCache.getSoldeDebit()) { - view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { - view.soldeLabel.setText(_("lima.common.soldecredit")); - } - } - } - } + if (selectedBeginDate != null && selectedEndDate != null){ + model = view.getModelTable(); + cachedatasList = getDataList(); + model.refresh(cachedatasList); + + /** + * set text and amounts of labels credit, debit, solde + */ + + if (balanceTrialCache != null){ + // set amounts credit, debit and solde + view.amountCreditLabel.setText( + String.valueOf(balanceTrialCache.getAmountCredit())); + view.amountDebitLabel.setText( + String.valueOf(balanceTrialCache.getAmountDebit())); + BigDecimal amountSolde = balanceTrialCache.getAmountSolde(); + view.amountSoldeLabel.setText( + String.valueOf(amountSolde)); + + if (amountSolde.doubleValue() == 0){ + view.soldeLabel.setText(_("lima.common.solde")); + } + else { + // set label solde: credit or debit + if (balanceTrialCache.getSoldeDebit()) { + view.soldeLabel.setText(_("lima.common.soldedebit")); + } + else { + view.soldeLabel.setText(_("lima.common.soldecredit")); + } + } + } + } } public void createDocument() { - - if (selectedBeginDate != null && selectedEndDate != null){ - FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); - String address = LimaConfig.getInstance().getHostAdress(); - - try { - String url = "http://"+address+":"+port+"/?beginDate=" - +dateFormat.format(selectedBeginDate) - +"&endDate="+dateFormat.format(selectedEndDate) - +"&format="+selectedEnum.getExtension()+"&model=" - + DocumentsEnum.LEDGER.getFileName(); - Desktop.getDesktop().browse(new URI(url)); - } catch (IOException e) { - log.error("Can't open browser", e); - } catch (URISyntaxException e) { - log.error("Can't create news URI", e); - } - } + + if (selectedBeginDate != null && selectedEndDate != null){ + FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); + String address = LimaConfig.getInstance().getHostAdress(); + + try { + String url = "http://"+address+":"+port+"/?beginDate=" + +dateFormat.format(selectedBeginDate) + +"&endDate="+dateFormat.format(selectedEndDate) + +"&format="+selectedEnum.getExtension()+"&model=" + + DocumentsEnum.LEDGER.getFileName(); + Desktop.getDesktop().browse(new URI(url)); + } catch (IOException e) { + log.error("Can't open browser", e); + } catch (URISyntaxException e) { + log.error("Can't create news URI", e); + } + } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ - refresh(); - } - } - + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ + refresh(); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -35,20 +35,20 @@ public class LetterComboBox extends JComboBox { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(LetterComboBox.class); - - - public LetterComboBox() { - - LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); - LetterRenderer letterRenderer = new LetterRenderer(); - setModel(letterComboBoxModel); - setRenderer(letterRenderer); - setEditable(true); - AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); - } - + + + public LetterComboBox() { + + LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); + LetterRenderer letterRenderer = new LetterRenderer(); + setModel(letterComboBoxModel); + setRenderer(letterRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -37,53 +37,53 @@ public class LetteringFinancialPeriodComboBox extends JComboBox implements ActionListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(LetteringFinancialPeriodComboBox.class); - - protected LetteringViewHandler handler; - - public LetteringFinancialPeriodComboBox(LetteringViewHandler handler) { - this.handler = handler; + + protected LetteringViewHandler handler; + + public LetteringFinancialPeriodComboBox(LetteringViewHandler handler) { + this.handler = handler; - FinancialPeriodComboBoxModel comboBoxModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer comboBoxRenderer = new FinancialPeriodComboBoxRenderer(); + FinancialPeriodComboBoxModel comboBoxModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer comboBoxRenderer = new FinancialPeriodComboBoxRenderer(); - setModel(comboBoxModel); - setRenderer(comboBoxRenderer); - addActionListener(this); + setModel(comboBoxModel); + setRenderer(comboBoxRenderer); + addActionListener(this); - } + } - public void back(){ - int row = this.getSelectedIndex(); - log.debug(row); - if (row > 0){ - this.setSelectedItem(this.getItemAt(row-1)); - repaint(); - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); - } - } - - public void next(){ - int size = this.getModel().getSize(); - int row = this.getSelectedIndex(); - log.debug(row); - - if (row < size-1){ - this.setSelectedItem(this.getItemAt(row+1)); - repaint(); - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); - } - } - - @Override - public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof FinancialPeriod){ - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); - } - } - + public void back(){ + int row = this.getSelectedIndex(); + log.debug(row); + if (row > 0){ + this.setSelectedItem(this.getItemAt(row-1)); + repaint(); + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + + public void next(){ + int size = this.getModel().getSize(); + int row = this.getSelectedIndex(); + log.debug(row); + + if (row < size-1){ + this.setSelectedItem(this.getItemAt(row+1)); + repaint(); + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof FinancialPeriod){ + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -131,7 +131,7 @@ boolean isHighlighted = false; Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { - BigDecimal currentBalance = (BigDecimal) value; + BigDecimal currentBalance = (BigDecimal) value; if (currentBalance.doubleValue() != 0) { isHighlighted = true; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -90,12 +90,12 @@ */ public LetteringTableModel() { /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } /** @@ -123,33 +123,33 @@ log.error("Can't update model", eee); } ErrorHelper.showErrorDialog("Can't get transaction list", eee); - } + } } return results; } public void setLetter(int row, Letter letter){ - try { - Object currentRow = cacheDataList.get(row); - if (currentRow instanceof Entry){ - Entry entry = (Entry) currentRow; - financialTransactionService.setEntryLetter(entry, letter); - } - } catch (LimaException eee) { - log.error("Can't set letter", eee); - } + try { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof Entry){ + Entry entry = (Entry) currentRow; + financialTransactionService.setEntryLetter(entry, letter); + } + } catch (LimaException eee) { + log.error("Can't set letter", eee); + } } public void removeLetter(int row){ - try { - Object currentRow = cacheDataList.get(row); - if (currentRow instanceof Entry){ - Entry entry = (Entry) currentRow; - financialTransactionService.removeEntryLetter(entry); - } - } catch (LimaException eee) { - log.error("Can't remove letter", eee); - } + try { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof Entry){ + Entry entry = (Entry) currentRow; + financialTransactionService.removeEntryLetter(entry); + } + } catch (LimaException eee) { + log.error("Can't remove letter", eee); + } } public void refresh(){ @@ -223,7 +223,7 @@ result = _("lima.table.description"); break; case 5: - result = _("lima.table.letter"); + result = _("lima.table.letter"); break; case 6: result = _("lima.table.debit"); @@ -259,10 +259,10 @@ result = cacheDataList.get(row); if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; - BigDecimal amountDebit = currentRow.getAmountDebit(); - BigDecimal amountCredit = currentRow.getAmountCredit(); - + FinancialTransaction currentRow = (FinancialTransaction)result; + BigDecimal amountDebit = currentRow.getAmountDebit(); + BigDecimal amountCredit = currentRow.getAmountCredit(); + switch (column) { case 0: result = currentRow.getTransactionDate(); @@ -305,7 +305,7 @@ result = null; // date break; case 1 : // entry book - result = null; + result = null; break; case 2: result = currentEntry.getVoucher(); @@ -322,12 +322,12 @@ result = currentEntry.getDescription(); break; case 5 : - if (currentEntry.getLetter() != null){ - result = currentEntry.getLetter().getCode(); - } - else { - result = null; - } + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } break; case 6: result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; @@ -336,7 +336,7 @@ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); break; case 8: - result = null; + result = null; break; } @@ -368,10 +368,10 @@ public Object getElementAt(int row){ - Object result = null; - if (cacheDataList != null){ + Object result = null; + if (cacheDataList != null){ result = cacheDataList.get(row); - } + } return result; } @@ -411,11 +411,11 @@ } } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ - refresh(); - } - } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -73,69 +73,69 @@ this.view = view; /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); } public void addLetter(){ - Letter letter = null; - Boolean valid = true; - - table = view.getTable(); - tableModel = view.getTableModel(); - - AddLetterForm addLetterForm = new AddLetterForm(); - JTextField newLetterTextField = addLetterForm.getNewLetterTextField(); + Letter letter = null; + Boolean valid = true; + + table = view.getTable(); + tableModel = view.getTableModel(); + + AddLetterForm addLetterForm = new AddLetterForm(); + JTextField newLetterTextField = addLetterForm.getNewLetterTextField(); - try { - letter = financialTransactionService.getNewLetter(); - newLetterTextField.setText(letter.getCode()); - } catch (LimaException eee) { - log.error("Can't get new letter", eee); - } - - addLetterForm.setLocationRelativeTo(view); - addLetterForm.setVisible(true); - - //false = cancel Action - if (addLetterForm.validOk){ - Object object = addLetterForm.getRadioButtons().getSelectedValue(); - if (!(Boolean) object){ - JComboBox comboBox = addLetterForm.getLetterListComboBox(); - Object selectedObject = comboBox.getSelectedItem(); - if (selectedObject instanceof Letter){ - letter = (Letter) selectedObject; - } - else { - DialogHelper.showMessageDialog(_("lima.entries.lettering.noletterselected")); - valid = false; - } - } - if (valid){ - //addLetters - int[] rows = table.getSelectedRows(); - for (int i : rows) { - tableModel.setLetter(i, letter); - } - tableModel.refresh(); - } - } + try { + letter = financialTransactionService.getNewLetter(); + newLetterTextField.setText(letter.getCode()); + } catch (LimaException eee) { + log.error("Can't get new letter", eee); + } + + addLetterForm.setLocationRelativeTo(view); + addLetterForm.setVisible(true); + + //false = cancel Action + if (addLetterForm.validOk){ + Object object = addLetterForm.getRadioButtons().getSelectedValue(); + if (!(Boolean) object){ + JComboBox comboBox = addLetterForm.getLetterListComboBox(); + Object selectedObject = comboBox.getSelectedItem(); + if (selectedObject instanceof Letter){ + letter = (Letter) selectedObject; + } + else { + DialogHelper.showMessageDialog(_("lima.entries.lettering.noletterselected")); + valid = false; + } + } + if (valid){ + //addLetters + int[] rows = table.getSelectedRows(); + for (int i : rows) { + tableModel.setLetter(i, letter); + } + tableModel.refresh(); + } + } } public void removeLetter(){ - table = view.getTable(); - tableModel = view.getTableModel(); - - //removeLetters - int[] rows = table.getSelectedRows(); - for (int i : rows) { - tableModel.removeLetter(i); - } - tableModel.refresh(); + table = view.getTable(); + tableModel = view.getTableModel(); + + //removeLetters + int[] rows = table.getSelectedRows(); + for (int i : rows) { + tableModel.removeLetter(i); + } + tableModel.refresh(); } public void refresh(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -46,133 +46,133 @@ import org.chorem.lima.ui.importexport.ImportExport; public class OpeningViewHandler { - - private static final Log log = LogFactory.getLog(OpeningViewHandler.class); - - private static Border noBorder = new EmptyBorder(0,0,0,0); + + private static final Log log = LogFactory.getLog(OpeningViewHandler.class); + + private static Border noBorder = new EmptyBorder(0,0,0,0); private static Color green = new Color(0x66, 0xcc, 0x00); - - protected int step; - protected OpeningView view; - - //Panels - private CreateAccountsPanel caPanel; - private CreateIdentityPanel idPanel; - private CreateEntryBookPanel ebPanel; - private CreateFiscalPeriodPanel fsPanel; - - public OpeningViewHandler(OpeningView view) { - this.view = view; - caPanel = new CreateAccountsPanel(); - idPanel = new CreateIdentityPanel(); - ebPanel = new CreateEntryBookPanel(); - fsPanel = new CreateFiscalPeriodPanel(); - step = 0; - } - - - public void importSave() { - ImportExport importExport = new ImportExport(view); - importExport.importExport(ImportExportEnum.CSV_ALL_IMPORT, "", true); - view.dispose(); - } - - public void next() { - ImportExport importExport = ImportExport.getInstance(view); - JPanel panel = view.getPanel(); - panel.removeAll(); - switch (step) { - case 0: - //refresh UI - view.getIdentityIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(idPanel); - panel.validate(); - view.repaint(); - step++; - break; - case 1: - IdentityHandler identityHandler = new IdentityHandler(); - identityHandler.updateIdentity(idPanel.getIdentity()); - //refresh UI - view.getIdentityIcon().setBorder(noBorder); - view.getAccountsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(caPanel); - panel.validate(); - view.repaint(); - step++; - break; - - case 2 : - Object value = caPanel.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - AccountsChartEnum defaultAccountsChartEnum = - (AccountsChartEnum) value; - //Import accounts chart - switch (defaultAccountsChartEnum) { - case IMPORTEBP: - importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; + + protected int step; + protected OpeningView view; + + //Panels + private CreateAccountsPanel caPanel; + private CreateIdentityPanel idPanel; + private CreateEntryBookPanel ebPanel; + private CreateFiscalPeriodPanel fsPanel; + + public OpeningViewHandler(OpeningView view) { + this.view = view; + caPanel = new CreateAccountsPanel(); + idPanel = new CreateIdentityPanel(); + ebPanel = new CreateEntryBookPanel(); + fsPanel = new CreateFiscalPeriodPanel(); + step = 0; + } + + + public void importSave() { + ImportExport importExport = new ImportExport(view); + importExport.importExport(ImportExportEnum.CSV_ALL_IMPORT, "", true); + view.dispose(); + } + + public void next() { + ImportExport importExport = ImportExport.getInstance(view); + JPanel panel = view.getPanel(); + panel.removeAll(); + switch (step) { + case 0: + //refresh UI + view.getIdentityIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(idPanel); + panel.validate(); + view.repaint(); + step++; + break; + case 1: + IdentityHandler identityHandler = new IdentityHandler(); + identityHandler.updateIdentity(idPanel.getIdentity()); + //refresh UI + view.getIdentityIcon().setBorder(noBorder); + view.getAccountsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(caPanel); + panel.validate(); + view.repaint(); + step++; + break; + + case 2 : + Object value = caPanel.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null){ + AccountsChartEnum defaultAccountsChartEnum = + (AccountsChartEnum) value; + //Import accounts chart + switch (defaultAccountsChartEnum) { + case IMPORTEBP: + importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; - default: - importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; - } - //Import financialstatement - switch (defaultAccountsChartEnum) { - case SHORTENED: - importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - FinancialStatementsChartEnum.SHORTENED.getFilePath(), false); - break; - case DEVELOPED: - importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - FinancialStatementsChartEnum.DEVELOPED.getFilePath(), false); - break; - default: - importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - FinancialStatementsChartEnum.BASE.getFilePath(), false); - break; - } - } - view.getAccountsIcon().setBorder(noBorder); - view.getEntrybooksIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(ebPanel); - panel.validate(); - view.repaint(); - step++; - break; - - case 3 : - if (ebPanel.getImportEntryBook().isSelected()) { - importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, - EntryBooksChartEnum.DEFAULT.getFilePath(), false); - } - view.getEntrybooksIcon().setBorder(noBorder); - view.getFiscalperiodsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(fsPanel); - panel.validate(); - view.getOk().setText(_("lima.common.fin")); - view.repaint(); - step++; - break; - case 4 : - try { - FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); - fiscalPeriod.setBeginDate(fsPanel.getBeginDatePicker().getDate()); - fiscalPeriod.setEndDate(fsPanel.getEndDatePicker().getDate()); - - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class). - createFiscalPeriod(fiscalPeriod); - - } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't create fiscal period", ex); - } - } - view.dispose(); - } - } + default: + importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; + } + //Import financialstatement + switch (defaultAccountsChartEnum) { + case SHORTENED: + importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, + FinancialStatementsChartEnum.SHORTENED.getFilePath(), false); + break; + case DEVELOPED: + importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, + FinancialStatementsChartEnum.DEVELOPED.getFilePath(), false); + break; + default: + importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, + FinancialStatementsChartEnum.BASE.getFilePath(), false); + break; + } + } + view.getAccountsIcon().setBorder(noBorder); + view.getEntrybooksIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(ebPanel); + panel.validate(); + view.repaint(); + step++; + break; + + case 3 : + if (ebPanel.getImportEntryBook().isSelected()) { + importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, + EntryBooksChartEnum.DEFAULT.getFilePath(), false); + } + view.getEntrybooksIcon().setBorder(noBorder); + view.getFiscalperiodsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(fsPanel); + panel.validate(); + view.getOk().setText(_("lima.common.fin")); + view.repaint(); + step++; + break; + case 4 : + try { + FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); + fiscalPeriod.setBeginDate(fsPanel.getBeginDatePicker().getDate()); + fiscalPeriod.setEndDate(fsPanel.getEndDatePicker().getDate()); + + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class). + createFiscalPeriod(fiscalPeriod); + + } catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't create fiscal period", ex); + } + } + view.dispose(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -29,26 +29,26 @@ import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; public class AccountToString extends ObjectToStringConverter { - + private static AccountToString converter; - - @Override - public String getPreferredStringForItem(Object item) { - String result = null; - if (item != null){ - if (item instanceof Account){ - Account account = (Account) item; - result = account.getAccountNumber()+" - "+account.getLabel(); - } - } - return result; - } + + @Override + public String getPreferredStringForItem(Object item) { + String result = null; + if (item != null){ + if (item instanceof Account){ + Account account = (Account) item; + result = account.getAccountNumber()+" - "+account.getLabel(); + } + } + return result; + } - public static AccountToString getInstance() { + public static AccountToString getInstance() { if (converter == null) { - converter = new AccountToString(); + converter = new AccountToString(); } return converter; } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -85,14 +85,14 @@ * @param type */ public static void showReportDialog (String message, String title, Component parent) { - ReportDialogView reportDialogView = new ReportDialogView(); - reportDialogView.setIconImage(Resource.getIcon("icons/lima.png").getImage()); - JTextArea textArea = reportDialogView.getTextArea(); - textArea.setText(message); - reportDialogView.setSize(600,400); - reportDialogView.setTitle(title); - reportDialogView.setLocationRelativeTo(parent); - reportDialogView.setVisible(true); + ReportDialogView reportDialogView = new ReportDialogView(); + reportDialogView.setIconImage(Resource.getIcon("icons/lima.png").getImage()); + JTextArea textArea = reportDialogView.getTextArea(); + textArea.setText(message); + reportDialogView.setSize(600,400); + reportDialogView.setTitle(title); + reportDialogView.setLocationRelativeTo(parent); + reportDialogView.setVisible(true); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -31,23 +31,23 @@ public class EntryBookToString extends ObjectToStringConverter{ private static EntryBookToString converter; - - @Override - public String getPreferredStringForItem(Object item) { - String result = null; - if (item != null){ - if (item instanceof EntryBook){ - EntryBook entryBook = (EntryBook) item; - result = entryBook.getCode()+" - "+entryBook.getLabel(); - } - } - return result; - } - - + + @Override + public String getPreferredStringForItem(Object item) { + String result = null; + if (item != null){ + if (item instanceof EntryBook){ + EntryBook entryBook = (EntryBook) item; + result = entryBook.getCode()+" - "+entryBook.getLabel(); + } + } + return result; + } + + public static EntryBookToString getInstance() { if (converter == null) { - converter = new EntryBookToString(); + converter = new EntryBookToString(); } return converter; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -133,7 +133,7 @@ for (String propertyName : propertiesNames) { // security, don't send string containing password : if (!propertyName.contains("pass")) { - message.append("\t" + propertyName + " : " + LimaMain.config.getOptions().getProperty(propertyName) + "\n"); + message.append("\t" + propertyName + " : " + LimaMain.config.getOptions().getProperty(propertyName) + "\n"); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java 2010-11-29 14:43:15 UTC (rev 3050) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java 2010-11-29 14:57:16 UTC (rev 3051) @@ -29,26 +29,26 @@ import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; public class LetterToString extends ObjectToStringConverter { - + private static LetterToString converter; - - @Override - public String getPreferredStringForItem(Object item) { - String result = null; - if (item != null){ - if (item instanceof Letter){ - Letter letter = (Letter) item; - result = letter.getCode(); - } - } - return result; - } + + @Override + public String getPreferredStringForItem(Object item) { + String result = null; + if (item != null){ + if (item instanceof Letter){ + Letter letter = (Letter) item; + result = letter.getCode(); + } + } + return result; + } - public static LetterToString getInstance() { + public static LetterToString getInstance() { if (converter == null) { - converter = new LetterToString(); + converter = new LetterToString(); } return converter; } - + }