r3612 - in trunk: 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-swing/src/main/java/org/chorem/lima/ui/ledger
Author: mallon Date: 2012-08-17 19:24:10 +0200 (Fri, 17 Aug 2012) New Revision: 3612 Url: http://chorem.org/repositories/revision/lima/3612 Log: refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition du grand livre. 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/ejb/DocumentServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 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 14:41:36 UTC (rev 3611) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-17 17:24:10 UTC (rev 3612) @@ -461,271 +461,227 @@ @Override - public void createLedgerDocuments(Date beginDate, - Date endDate, - FormatsEnum format) throws LimaException { - Document document = new Document(PageSize.A4, 8, 8, 8, 8); + public String createLedgerDocuments(Date beginDate, + Date endDate) throws LimaException { + List<Object> list = new ArrayList<Object>(); - try { + String ledgerReport = ""; + ledgerReport += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" + + "<html>\n"; - 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); + if (beginDate != null && endDate != null) { + try { + ledgerReport += "<body>\n"; + String boldBegin = "<b>"; + String boldEnd = "</b>"; + + BalanceTrial balanceTrial = reportService.generateLedger(beginDate, endDate, null, true); + if (balanceTrial.getReportsDatas() != null) { + for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) { + list.add(reportsDatas); + List<Entry> entries = reportsDatas.getListEntry(); + if (entries != null) { + Collections.sort(entries, new EntryComparator()); + list.addAll(entries); + } } } - } - Date newDate = new Date(); + //create pages + int i = 0; + int n = list.size(); + int max = n; - BigDecimal currentAmountDebit = new BigDecimal(0); - BigDecimal currentAmountCredit = new BigDecimal(0); - String accountcarry = ""; + while (i < n) { + int j = i + max; + if (j > n) { + j = n; + } - 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(); + ledgerReport += "<table>" + + "<tr> " + + "<td>" + + "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" + + "<tr>\n"; - //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, - beginDate, endDate)); - //n° page - chapter.add(createNumberPage(nbpages, newDate)); - //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(); + String boldItalicBegin = "<b>" + "<i>"; + String boldItalicEnd = "</i>" + "</b>"; + BigDecimal currentAmountDebit = new BigDecimal(0); + BigDecimal currentAmountCredit = new BigDecimal(0); + String accountcarry = ""; + Identity identity = identityService.getIdentity(); - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } - } + String [] columnsNameSociety = {boldItalicBegin + identity.getName()+ boldItalicEnd}; + ledgerReport += constructColumnsHtml(columnsNameSociety); - protected 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)); + ledgerReport += "<tr>\n"; + String [] columnsDescription = {"<i>" + identity.getDescription()+ "</i>"}; + ledgerReport += constructColumnsHtml(columnsDescription); - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; + ledgerReport += "<tr>\n"; + String [] columnsAdressOne = {"<i>" + identity.getAddress() + "</i>"}; + ledgerReport += constructColumnsHtml(columnsAdressOne); - } + ledgerReport += "<tr>\n"; + String [] columnsAdressTwo = {"<i>" + identity.getAddress2() + "</i>"}; + ledgerReport += constructColumnsHtml(columnsAdressTwo); - protected 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); + ledgerReport += "<tr>\n"; + String [] columnsZipCode = {"<i>" + identity.getZipCode() + "</i>"}; + ledgerReport += constructColumnsHtml(columnsZipCode); - for (Object object : subList) { - if (object instanceof ReportsDatas) { + ledgerReport += "<tr>\n"; + String [] columnsCity = {"<i>" + identity.getCity()+ "</i>"}; + ledgerReport += constructColumnsHtml(columnsCity); - ReportsDatas reportsDatas = (ReportsDatas) object; + ledgerReport += "</table>\n" + + "</td>" + + "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" + + "<p style=\"font-size:30px;\">" + _("lima-business.document.ledger") + "</p>" + + "</td>" + + "<td>" + + "<table align=\"right\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n"; - String accountS = ""; - Account account = reportsDatas.getAccount(); - if (account != null) { - accountS = account.getAccountNumber() + "\t" + account.getLabel(); - } - BigDecimal amountCredit = reportsDatas.getAmountCredit(); - BigDecimal amountDebit = reportsDatas.getAmountDebit(); + ledgerReport += "<tr>\n"; + String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") + + boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"}; + ledgerReport += constructColumnsHtml(columnsBusinessNumber); - 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; + ledgerReport += "<tr>\n"; + String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") + + boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"}; + ledgerReport += constructColumnsHtml(columnsClassifCode); - String entryBookCode = ""; - EntryBook entryBook = entry.getFinancialTransaction().getEntryBook(); - if (entryBook != null) { - entryBookCode = entryBook.getCode(); + ledgerReport += "<tr>\n"; + String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd, + "<i>" + identity.getVatNumber()+ "</i>", }; + ledgerReport += constructColumnsHtml(columnsVatNumber); + + ledgerReport += "<tr>\n"; + String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>" + + _("lima-business.document.period1format", beginDate)+ "</i>"}; + ledgerReport += constructColumnsHtml(columnsPeriodOne); + + ledgerReport += "<tr>\n"; + String [] columnsPeriodTwo = {boldItalicBegin + _("lima-business.document.period2") + boldItalicEnd, "<i>" + + _("lima-business.document.period2format", endDate)+ "</i>"}; + ledgerReport += constructColumnsHtml(columnsPeriodTwo); + + ledgerReport += "</table>" + + "</td>" + + "</table>"; + + List<Object> subList = list.subList(i, j); + + + //backward amounts + if (n > max ) { + String [] columnsCarryBack = {boldBegin + accountcarry + boldEnd, boldBegin + _("lima-business.document.carryback") + boldEnd, + boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, + boldBegin + currentAmountDebit.subtract(currentAmountCredit).toString() + boldEnd}; + ledgerReport += constructColumnsHtml(columnsCarryBack); } - BigDecimal amountDebit = new BigDecimal(0), - amountCredit = new BigDecimal(0); - if (entry.getDebit()) { - amountDebit = entry.getAmount(); - } else { - amountCredit = entry.getAmount(); - } - t.addCell(new Phrase(_("lima-business.document.dateformat", - 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)); + ledgerReport += "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" + + "<tr>\n"; + String [] columnsNames = {boldBegin + _("lima-business.document.account")+ boldEnd, boldBegin + _("lima-business.document.debit") + boldEnd, + boldBegin + _("lima-business.document.credit") + boldEnd, boldBegin + _("lima-business.document.solde") + boldEnd}; + ledgerReport += constructColumnsHtml(columnsNames); + + 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(); + + String [] columnsTable = {boldBegin + accountS + boldEnd, + boldBegin + amountDebit.toString() + boldEnd, boldBegin + amountCredit.toString() + boldEnd, + boldBegin + amountDebit.subtract(amountCredit).toString() + boldEnd}; + ledgerReport += constructColumnsHtml(columnsTable); + + } 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(); + } + + ledgerReport +="<tr><td>"; + ledgerReport += "<table align=\"right\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" + + "<tr>\n"; + String [] columnsEntry = {boldBegin + _("lima-business.document.date")+ boldEnd, + boldBegin + _("lima-business.document.entrybook") + boldEnd, boldBegin + _("lima-business.document.voucher") + boldEnd, + boldBegin + _("lima-business.document.description") + boldEnd, boldBegin + _("lima-business.document.debit") + boldEnd, + boldBegin + _("lima-business.document.credit") + boldEnd, boldBegin + _("lima-business.document.solde") + boldEnd}; + ledgerReport += constructColumnsHtml(columnsEntry); + + String [] columnsTable = {_("lima-business.document.dateformat",entry.getFinancialTransaction().getTransactionDate()), + entryBookCode, entry.getVoucher(), entry.getDescription(), + amountDebit.toString(), amountCredit.toString(), amountDebit.subtract(amountCredit).toString()}; + ledgerReport += constructColumnsHtml(columnsTable); + ledgerReport += "</table>" + + "</td></tr>"; + } + } + + for (Object objectList : subList) { + if (objectList instanceof Entry) { + Entry entry = (Entry) objectList; + if (entry.getDebit()) { + currentAmountDebit = currentAmountDebit.add(entry.getAmount()); + } else { + currentAmountCredit = currentAmountCredit.add(entry.getAmount()); + } + } else { + ReportsDatas reportsDatas = (ReportsDatas) objectList; + Account account = reportsDatas.getAccount(); + if (account != null) { + accountcarry = account.getAccountNumber() + + " " + account.getLabel() + " "; + } + } + } + //forward amounts + if (n > max && i <= n - max) { + String [] columnsTable = {"", boldBegin + _("lima-business.document.carryforward") + boldEnd, + boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, + boldBegin + currentAmountDebit.subtract(currentAmountCredit).toString() + boldEnd}; + ledgerReport += constructColumnsHtml(columnsTable); + } + //final amounts + if (i >= n - max) { + String [] columnsTable = { boldBegin + _("lima-business.document.amounts") + boldEnd, + boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, + boldBegin + currentAmountDebit.subtract(currentAmountCredit).toString() + boldEnd}; + ledgerReport += constructColumnsHtml(columnsTable); + } + i = i + max; } + ledgerReport += "</table></body>\n</html>"; + }catch (Exception ex) { + log.error("Can't create document", ex); } - } catch (DocumentException eeDE) { - log.error("Can't create table", eeDE); - } - return t; + return ledgerReport; } - protected 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; - } - @Override public String createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException { @@ -871,49 +827,51 @@ String boldItalicBegin = "<b>" + "<i>"; String boldItalicEnd = "</i>" + "</b>"; - String [] columnsNameSociety = {boldItalicBegin + _("lima-business.document.society") + - boldItalicEnd, "<i>" + identity.getName()+ "</i>"}; + String [] columnsNameSociety = {boldItalicBegin + identity.getName()+ boldItalicEnd}; balanceReport += constructColumnsHtml(columnsNameSociety); balanceReport += "<tr>\n"; - String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") + - boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsBusinessNumber); + String [] columnsDescription = {"<i>" + identity.getDescription()+ "</i>"}; + balanceReport += constructColumnsHtml(columnsDescription); balanceReport += "<tr>\n"; - String [] columnsDescription = {boldItalicBegin + _("lima-business.document.description") + boldItalicEnd, - "<i>" + identity.getDescription()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsDescription); + String [] columnsAdressOne = {"<i>" + identity.getAddress() + "</i>"}; + balanceReport += constructColumnsHtml(columnsAdressOne); balanceReport += "<tr>\n"; - String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") + - boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsClassifCode); + String [] columnsAdressTwo = {"<i>" + identity.getAddress2() + "</i>"}; + balanceReport += constructColumnsHtml(columnsAdressTwo); balanceReport += "<tr>\n"; - String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd, - "<i>" + identity.getVatNumber()+ "</i>", }; - balanceReport += constructColumnsHtml(columnsVatNumber); + String [] columnsZipCode = {"<i>" + identity.getZipCode() + "</i>"}; + balanceReport += constructColumnsHtml(columnsZipCode); balanceReport += "<tr>\n"; - String [] columnsAdressOne = {boldItalicBegin + _("lima-business.document.adress") + boldItalicEnd, - "<i>" + identity.getAddress() + "</i>"}; - balanceReport += constructColumnsHtml(columnsAdressOne); + String [] columnsCity = {"<i>" + identity.getCity()+ "</i>"}; + balanceReport += constructColumnsHtml(columnsCity); + balanceReport += "</table>\n" + + "</td>" + + "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" + + "<p style=\"font-size:30px;\">" + _("lima-business.document.balance") + "</p>" + + "</td>" + + "<td>" + + "<table align=\"right\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n"; + balanceReport += "<tr>\n"; - String [] columnsAdressTwo = {boldItalicBegin + _("lima-business.document.adresssuite") + boldItalicEnd, - "<i>" + identity.getAddress2() + "</i>"}; - balanceReport += constructColumnsHtml(columnsAdressTwo); + String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") + + boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"}; + balanceReport += constructColumnsHtml(columnsBusinessNumber); balanceReport += "<tr>\n"; - String [] columnsZipCode = {boldItalicBegin + _("lima-business.document.zipcode") + boldItalicEnd, - "<i>" + identity.getZipCode() + "</i>"}; - balanceReport += constructColumnsHtml(columnsZipCode); + String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") + + boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"}; + balanceReport += constructColumnsHtml(columnsClassifCode); balanceReport += "<tr>\n"; - String [] columnsCity = {boldItalicBegin + _("lima-business.document.city") + boldItalicEnd, - "<i>" + identity.getCity()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsCity); + String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd, + "<i>" + identity.getVatNumber()+ "</i>", }; + balanceReport += constructColumnsHtml(columnsVatNumber); balanceReport += "<tr>\n"; String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>" @@ -925,12 +883,8 @@ + _("lima-business.document.period2format", endDate)+ "</i>"}; balanceReport += constructColumnsHtml(columnsPeriodTwo); - balanceReport += "</table>\n" + + balanceReport += "</table>" + "</td>" + - "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" + - "<p style=\"font-size:30px;\">" + _("lima-business.document.balance") + "</p>" + - "</td>" + - "<tr>" + "</table>" + "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" + "<tr align=\"center\">\n"; 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 14:41:36 UTC (rev 3611) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-17 17:24:10 UTC (rev 3612) @@ -163,6 +163,7 @@ String entryBooksReport = null; String generalEntryBooksReport = null; String balanceReport = null; + String ledgerReport = null; //create docs try { @@ -197,8 +198,8 @@ beginDateFormat, endDateFormat, formatsEnum); break; case LEDGER: - documentService.createLedgerDocuments( - beginDateFormat, endDateFormat, formatsEnum); + ledgerReport = documentService.createLedgerDocuments( + beginDateFormat, endDateFormat); break; case VAT: documentService.createVatDocuments( @@ -224,7 +225,7 @@ resp.setContentType(formatsEnum.getMimeType()); OutputStream out = resp.getOutputStream(); if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null - || balanceReport != null) { + || balanceReport != null || ledgerReport != null) { String report = null; if (accountReport != null) { report = accountReport; @@ -232,8 +233,10 @@ report = entryBooksReport; } else if (generalEntryBooksReport != null) { report = generalEntryBooksReport; + } else if (balanceReport != null) { + report = balanceReport; } else { - report = balanceReport; + report = ledgerReport; } IOUtils.write(report, out, Charsets.UTF_8); } else { 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 14:41:36 UTC (rev 3611) +++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 17:24:10 UTC (rev 3612) @@ -17,7 +17,7 @@ lima-business.defaultaccountingrules.invalidaccountnumber=Numéro de compte invalide \: %d lima-business.defaultaccountingrules.missingelements=Impossible de bloquer la période financière / il manque des éléments dans des transactions lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY) -lima-business.document.account= +lima-business.document.account=Compte lima-business.document.accountnumber=N° Compte lima-business.document.adress=Adresse lima-business.document.adresssuite=Adresse - suite 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 14:41:36 UTC (rev 3611) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 17:24:10 UTC (rev 3612) @@ -40,7 +40,7 @@ void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; - void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; + String createLedgerDocuments(Date beginDate, Date endDate) throws LimaException; String createBalanceDocuments(Date beginDate, Date endDate) throws LimaException; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2012-08-17 14:41:36 UTC (rev 3611) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2012-08-17 17:24:10 UTC (rev 3612) @@ -40,67 +40,13 @@ ]]> </script> - <row weightx="1" weighty="0" anchor="center"> + <row> <cell fill='both'> - <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" /> + <IntervalPanel id="intervalPanel"/> </cell> - <cell anchor="east"> - <JLabel text="lima.common.filter"/> - </cell> - <cell anchor="west"> - <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter" - minimumSize='{balanceFilter.getPreferredSize()}'/> - <javax.swing.text.Document javaBean="balanceFilter.getDocument()" - onInsertUpdate='handler.accountFilterChanged()' - onRemoveUpdate='handler.accountFilterChanged()'/> - </cell> - <cell anchor="center"> - <JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter' - selected='false' - onActionPerformed="getHandler().movmentedFilterChanged()"/> - </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="8"> - <JScrollPane> - <org.chorem.lima.ui.ledger.LedgerTableModel id="ledgerTableModel"/> - <org.chorem.lima.ui.ledger.LedgerTable sortable="false" rowHeight="24" model="{ledgerTableModel}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill="horizontal" weightx="1" columns="7"> - <Table> - <row fill="horizontal" weightx="1"> - <cell> - <JLabel text="lima.common.amountdebit"/> - </cell> - <cell> - <JLabel id="amountDebitLabel"/> - </cell> - <cell> - <JLabel text="lima.common.amountcredit"/> - </cell> - <cell> - <JLabel id="amountCreditLabel"/> - </cell> - <cell> - <JLabel id="soldeLabel" text="lima.common.solde"/> - </cell> - <cell> - <JLabel id="amountSoldeLabel"/> - </cell> - </row> - </Table> - </cell> - </row> </Table> \ No newline at end of file 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 2012-08-17 14:41:36 UTC (rev 3611) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-08-17 17:24:10 UTC (rev 3612) @@ -64,7 +64,7 @@ * Handler associated with accounts reports view. * By : $Author$ */ -public class LedgerViewHandler implements ServiceListener { +public class LedgerViewHandler /*implements ServiceListener*/ { protected LedgerView view; @@ -84,13 +84,8 @@ protected LedgerViewHandler(LedgerView view) { this.view = view; - reportService = - LimaServiceFactory.getService(ReportService.class); - LimaServiceFactory.addServiceListener(ReportService.class, this); fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); - LimaServiceFactory.addServiceListener(ImportService.class, this); - LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this); } /** @@ -104,133 +99,37 @@ view.getIntervalPanel().init(fiscalPeriod, financialPeriod); } - public void intervalChanged() { - refreshData(); - } - - public void accountFilterChanged() { - refreshData(); - } - - public void movmentedFilterChanged() { - refreshData(); - } - - /** - * Refresh table data depending on item selected on combo boxes. - */ - protected void refreshData() { - - Date beginDate = view.getIntervalPanel().getBeginDate(); - Date endDate = view.getIntervalPanel().getEndDate(); - - String account = view.getBalanceFilter().getText().trim(); - - if (beginDate != null && endDate != null) { - BalanceTrial balanceTrial = reportService.generateLedger(beginDate, - endDate, account, view.getMovmentedFilter().isSelected()); - - LedgerTableModel dataModel = view.getLedgerTableModel(); - - List<Object> results = new ArrayList<Object>(); - for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) { - results.add(reportsDatas); - List<Entry> entries = reportsDatas.getListEntry(); - if (entries != null) { - Collections.sort(entries, new EntryComparator()); - results.addAll(entries); - } - } - dataModel.setObjects(results); - - updateFooter(balanceTrial); - } - } - - /** - * Update footer labels containing reports total sum fields. - * - * @param balanceTrial result to render - */ - protected void updateFooter(BalanceTrial balanceTrial) { - // set amounts credit and debit and solde - view.amountCreditLabel.setText( - balanceTrial.getAmountCredit().toString()); - view.amountDebitLabel.setText( - balanceTrial.getAmountDebit().toString()); - BigDecimal amountSolde = balanceTrial.getAmountSolde(); - view.amountSoldeLabel.setText(amountSolde.toString()); - - - if (BigDecimal.ZERO.equals(amountSolde)) { - view.amountSoldeLabel.setText(_("lima.common.solde")); - } else { - // set label solde: credit or debit - if (balanceTrial.getSoldeDebit()) { - view.amountSoldeLabel.setText(_("lima.common.soldedebit")); - } else { - view.amountSoldeLabel.setText(_("lima.common.soldecredit")); - } - } - } - public void createDocument() { Date beginDate = view.getIntervalPanel().getBeginDate(); Date endDate = view.getIntervalPanel().getEndDate(); if (beginDate != null && endDate != null) { + String address = LimaConfig.getInstance().getHostAdress(); - //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; - } + try { + int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort(); + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(beginDate) + + "&endDate=" + dateFormat.format(endDate) + + "&format=.html&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); } - - //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(); - - try { - 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.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 + /* @Override public void notifyMethod(String serviceName, String methodName) { if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) { refreshData(); } - } + }*/ }
participants (1)
-
mallon@users.chorem.org