r3613 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/resources/i18n lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport lima-swing/src/main/resources
Author: mallon Date: 2012-08-20 13:38:22 +0200 (Mon, 20 Aug 2012) New Revision: 3613 Url: http://chorem.org/repositories/revision/lima/3613 Log: refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition du bilan et du r?\195?\169sultat (Reste le calcul ?\195?\160 revoir.) Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.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/DocumentServiceImpl.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/HttpServerServiceImpl.java trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java trunk/lima-swing/src/main/resources/log4j.properties 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 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -188,7 +188,7 @@ //Check if the fiscal period to block is the oldest if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) { - throw new LimaBusinessException(_("lima-business.franceaccountingrules.antefiscalperiodnotblocked")); + throw new LimaBusinessException(_("lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked")); } } catch (TopiaException ex) { throw new LimaException("Can't check rule", ex); 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 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -27,18 +27,12 @@ import com.lowagie.text.BadElementException; import com.lowagie.text.Cell; -import com.lowagie.text.Chapter; -import com.lowagie.text.Document; -import com.lowagie.text.DocumentException; import com.lowagie.text.Element; import com.lowagie.text.Font; -import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.Rectangle; import com.lowagie.text.Table; -import com.lowagie.text.html.HtmlWriter; -import com.lowagie.text.pdf.PdfWriter; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -81,7 +75,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.text.SimpleDateFormat; @@ -234,229 +227,124 @@ } @Override - public void createFinancialStatementsDocuments(Date beginDate, - Date endDate, - FormatsEnum format) throws LimaException { - Document document = new Document(PageSize.A4, 8, 8, 8, 8); + public String createFinancialStatementsDocuments(Date beginDate, + Date endDate) throws LimaException { + String financialStatementReport = null; - List<FinancialStatementAmounts> financialStatementAmounts = - financialStatementService.financialStatementReport(beginDate, endDate); - - Date newDate = new Date(); - String filePath = path + File.separator + DocumentsEnum.FINANCIALSTATEMENT.getFileName(); - try { - 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; + financialStatementReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" + + "<html>\n"; + financialStatementReport += constructHeadHtml(_("lima.reports.financialstatement")); + financialStatementReport += "<body>\n"; - Identity identity = identityService.getIdentity(); + if (beginDate != null && endDate != null) { - //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)); + List<FinancialStatementAmounts> financialStatementAmounts = + financialStatementService.financialStatementReport(beginDate, endDate); + //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; } - min = i; } - } - listList.add(financialStatementAmounts.subList(min, size)); + 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, beginDate, endDate)); - //n° page - chapter.add(createNumberPage(nbpages, newDate)); - //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++; - } - } + String boldBegin = "<b>"; + String boldEnd = "</b>"; + //create pages + for (List<FinancialStatementAmounts> list : listList) { + String subTitle = list.get(0).getLabel(); + financialStatementReport += constructSubTitleHtml(boldBegin + subTitle + boldEnd, ""); + int i = 0; + int n = list.size(); + int max = n; + while (i < n) { + int j = i + max; + if (j > n) { + j = n; + } - document.close(); + financialStatementReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" + + "<tr align=\"center\">\n"; - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } - } + String columnNames [] = {_("lima-business.document.label"), _("lima-business.document.grossamount"), + _("lima-business.document.provisiondeprecationamount"), _("lima-business.document.netamount")}; + financialStatementReport += constructColumnsHtml(columnNames); - protected 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)); + String tabLabel = ""; + String bigAmountString = "0"; + String provisionDeprecationAmountString = "0"; + String soldeString = "0"; + List<FinancialStatementAmounts> subFinancialStatementAmounts = list.subList(i, j); + for (FinancialStatementAmounts financialStatementAmount : subFinancialStatementAmounts) { - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; + String label = financialStatementAmount.getLabel(); + int level = financialStatementAmount.getLevel(); + BigDecimal bigAmount = + financialStatementAmount.getGrossAmount(); + if (bigAmount == null) { + bigAmount = new BigDecimal(0); + } + BigDecimal provisionDeprecationAmount = + financialStatementAmount.getProvisionDeprecationAmount(); + if (provisionDeprecationAmount == null) { + provisionDeprecationAmount = new BigDecimal(0); + } - } + StringBuffer tab = new StringBuffer(); + for (int k = 0; k < level; k++) { + tab.append("\t"); + } - protected 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); + if (financialStatementAmount.getHeader()) { + tabLabel = boldBegin + tab + label + boldEnd; + } else { + tabLabel = tab + label; + } + if (bigAmount != BigDecimal.ZERO) { + bigAmountString = bigAmount.toString(); + } + if (provisionDeprecationAmount != BigDecimal.ZERO) { + provisionDeprecationAmountString = provisionDeprecationAmount.toString(); + } + BigDecimal solde = bigAmount; + solde = solde.subtract(provisionDeprecationAmount); + if (solde != BigDecimal.ZERO) { + soldeString = solde.toString(); + } + } - 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"); + String columnData [] = {(StringUtils.isBlank(tabLabel)?"": tabLabel), bigAmountString, + provisionDeprecationAmountString, soldeString}; + financialStatementReport += constructColumnsHtml(columnData); + i = i + max; + financialStatementReport += "</table>" + + "<p>"; } - Phrase phrase; - 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 != BigDecimal.ZERO) { - phrase = new Phrase(String.valueOf( - grossAmount), normalFont); - } else { - phrase = new Phrase(""); - } - t.addCell(phrase); - //cell 3 - if (provisionDeprecationAmount != BigDecimal.ZERO) { - 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 != BigDecimal.ZERO) { - phrase = new Phrase(solde.toString(), normalFont); - } else { - phrase = new Phrase(""); - } - t.addCell(phrase); } } + financialStatementReport += "</body>" + + "</html>"; - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); + } catch (Exception ex) { + log.error("Can't create document", ex); } - return t; + return financialStatementReport; } - //############## Ledger ############## 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 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -39,6 +39,8 @@ import javax.ejb.TransactionAttribute; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.lima.FinancialStatementWayEnum; import org.chorem.lima.beans.Amounts; import org.chorem.lima.beans.AmountsImpl; @@ -64,6 +66,8 @@ @EJB private ReportService reportService; + protected static final Log log = LogFactory.getLog(FinancialStatementServiceImpl.class); + @Override public void createFinancialStatement(FinancialStatement masterFinancialStatement, FinancialStatement financialStatement) throws LimaException { @@ -193,6 +197,7 @@ List<FinancialStatementAmounts> result = null; try { + //create list form tree result = financialStatementReport(null, selectedBeginDate, selectedEndDate, new FinancialStatementDatasImpl()).getListResult(); 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 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -164,6 +164,7 @@ String generalEntryBooksReport = null; String balanceReport = null; String ledgerReport = null; + String financialReport = null; //create docs try { @@ -194,8 +195,8 @@ } break; case FINANCIALSTATEMENT: - documentService.createFinancialStatementsDocuments( - beginDateFormat, endDateFormat, formatsEnum); + financialReport = documentService.createFinancialStatementsDocuments( + beginDateFormat, endDateFormat); break; case LEDGER: ledgerReport = documentService.createLedgerDocuments( @@ -225,7 +226,7 @@ resp.setContentType(formatsEnum.getMimeType()); OutputStream out = resp.getOutputStream(); if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null - || balanceReport != null || ledgerReport != null) { + || balanceReport != null || ledgerReport != null || financialReport != null) { String report = null; if (accountReport != null) { report = accountReport; @@ -235,8 +236,10 @@ report = generalEntryBooksReport; } else if (balanceReport != null) { report = balanceReport; + } else if (ledgerReport != null) { + report = ledgerReport; } else { - report = ledgerReport; + report = financialReport; } IOUtils.write(report, out, Charsets.UTF_8); } else { Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-20 11:38:22 UTC (rev 3613) @@ -76,6 +76,7 @@ lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=The previous financial periods for this entrybook must be blocked before this lima-business.franceaccountingrules.antefiscalperiodnotblocked=The ante fiscal period is not locked lima-business.franceaccountingrules.fiscalperiodnotempty=The fiscal period is not empty \! +lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked= lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=The new fiscal period must adjoining the last lima-business.import.accountadded=SUCCES \: Account %s - %s added\n lima-business.import.accountalreadyexist=FAILED \: Account %s already exist \n Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-20 11:38:22 UTC (rev 3613) @@ -76,6 +76,7 @@ lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=Les périodes financières précédentes pour ce journal doivent être bloquées avant lima-business.franceaccountingrules.antefiscalperiodnotblocked=La période fiscale précédente n'est pas bloquée lima-business.franceaccountingrules.fiscalperiodnotempty=La période fiscale à supprimer n'est pas vide \! +lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked=Impossible de clore la dernière période fiscale ouverte lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=La nouvelle période fiscale doit suivre la précédente lima-business.import.accountadded=Succès \: Compte %s - %s ajouté\n lima-business.import.accountalreadyexist=Échec \: Le compte %s existe déjà \n Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -38,7 +38,7 @@ public interface DocumentService { - void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; + String createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException; String createLedgerDocuments(Date beginDate, Date endDate) throws LimaException; 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 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -161,11 +161,10 @@ } //search all account start with accountnumber else { - - String query = "FROM " + Account.class.getName() + " a WHERE NOT IN (" + + String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" + "FROM " + Account.class.getName() + " b where b.accountNumber like a.accountNumber+'%')" + - " AND a.accountNumber LIKE ?"; - List<Account> accountsResult = getContext().findAll(query, s); + " AND a.accountNumber LIKE :s"; + List<Account> accountsResult = getContext().findAll(query, "s",s); if (accountsResult != null) { //if first if (first) { Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -76,10 +76,6 @@ List<Entry> entries = context.findAll(query, "beginDate", beginDate, "endDate", endDate, "account", account); - if (log.isDebugEnabled()) { - log.debug("Size of entries : " + entries.size()); - } - return entries; } 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 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -78,8 +78,6 @@ entryBookService = LimaServiceFactory.getService(EntryBookService.class); fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); - /*LimaServiceFactory.addServiceListener(ImportService.class, this); - LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);*/ } /** Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2012-08-20 11:38:22 UTC (rev 3613) @@ -41,26 +41,11 @@ <row weightx="1" weighty="0" anchor="center"> <cell fill='both'> - <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" /> + <IntervalPanel id="intervalPanel"/> </cell> <cell> - <EnumEditor id='DocumentEditor' - constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/> - </cell> - <cell> <JButton text="lima.common.ok" onActionPerformed="getHandler().createDocument()"/> </cell> </row> - <row> - <cell fill="both" weightx="1" weighty="1" columns="7"> - <JScrollPane> - <FinancialStatementReportTableModel id="financialStatementReportTableModel"/> - <FinancialStatementReportTable id="table" rowHeight="24" - constructorParams="financialStatementReportTableModel" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> - <ListSelectionModel javaBean="getTable().getSelectionModel()"/> - </JScrollPane> - </cell> - </row> </Table> \ No newline at end of file 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 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-08-20 11:38:22 UTC (rev 3613) @@ -25,7 +25,6 @@ package org.chorem.lima.ui.financialstatementreport; -import static org.nuiton.i18n.I18n._; import java.awt.Desktop; import java.io.IOException; @@ -34,22 +33,14 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; - -import javax.swing.JOptionPane; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; -import org.chorem.lima.beans.FinancialStatementAmounts; -import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialPeriodService; import org.chorem.lima.business.api.FinancialStatementService; -import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; import org.chorem.lima.business.api.HttpServerService; -import org.chorem.lima.business.api.ImportService; import org.chorem.lima.business.utils.DocumentsEnum; -import org.chorem.lima.business.utils.FormatsEnum; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; @@ -63,7 +54,7 @@ * Last update : $Date$ * By : $Author$ */ -public class FinancialStatementReportViewHandler implements ServiceListener { +public class FinancialStatementReportViewHandler { /** log. */ private static final Log log = LogFactory.getLog(FinancialStatementReportViewHandler.class); @@ -83,10 +74,6 @@ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); financialStatementService = LimaServiceFactory.getService(FinancialStatementService.class); - - LimaServiceFactory.addServiceListener(FinancialStatementService.class, this); - LimaServiceFactory.addServiceListener(ImportService.class, this); - LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this); } /** @@ -95,86 +82,31 @@ public void init() { // init data models - List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods(); + List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllBlockedFiscalPeriods(); List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods(); view.getIntervalPanel().init(fiscalPeriod, financialPeriod); } - public void intervalChanged() { - refreshData(); - } - - /** - * Refresh table data depending on item selected on combo boxes. - */ - protected void refreshData() { - - Date beginDate = view.getIntervalPanel().getBeginDate(); - Date endDate = view.getIntervalPanel().getEndDate(); - - if (beginDate != null && endDate != null) { - List<FinancialStatementAmounts> results = - financialStatementService.financialStatementReport(beginDate, endDate); - - FinancialStatementReportTableModel dataModel = view.getFinancialStatementReportTableModel(); - dataModel.setFinancialStatementAmounts(results); - } - } - public void createDocument() { Date beginDate = view.getIntervalPanel().getBeginDate(); Date endDate = view.getIntervalPanel().getEndDate(); if (beginDate != null && endDate != null) { - //looks for all blocked fiscal periods - List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); - - //tells if the fiscaPeriod as been found and is blocked - boolean error = true; - - for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) { - if (blockedFiscalPeriod.getBeginDate().equals(beginDate) - && blockedFiscalPeriod.getEndDate().equals(endDate) - && blockedFiscalPeriod.getLocked()) { - error = false; - } + String address = LimaConfig.getInstance().getHostAdress(); + int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort(); + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(beginDate) + + "&endDate=" + dateFormat.format(endDate) + + "&format=.html&model=" + + DocumentsEnum.FINANCIALSTATEMENT.getFileName(); + try { + 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); } - - //shows error message to user if the fiscalPeriod is unblocked - if (error) { - JOptionPane.showMessageDialog( - view, - "Can't create document on an open fiscal year", - _("lima.common.error"), - JOptionPane.ERROR_MESSAGE); - } else { - FormatsEnum selectedEnum = - (FormatsEnum) view.getDocumentEditor().getSelectedItem(); - - String address = LimaConfig.getInstance().getHostAdress(); - int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort(); - String url = "http://" + address + ":" + port + "/?beginDate=" - + dateFormat.format(beginDate) - + "&endDate=" + dateFormat.format(endDate) - + "&format=" + selectedEnum.getExtension() + "&model=" - + DocumentsEnum.FINANCIALSTATEMENT.getFileName(); - try { - 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 methodName) { - if (serviceName.contains("FinancialTransaction") || - methodName.contains("FinancialStatement") || methodName.contains("importAll")) { - refreshData(); - } - } } Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-17 17:24:10 UTC (rev 3612) +++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-20 11:38:22 UTC (rev 3613) @@ -60,4 +60,5 @@ log4j.logger.org.chorem.lima.business.ejb.HttpServerServiceImpl=DEBUG log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG -log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG \ No newline at end of file +log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG +log4j.logger.org.chorem.lima.business.ejb.FinancialStatementServiceImpl=DEBUG \ No newline at end of file
participants (1)
-
mallon@users.chorem.org