Author: mallon Date: 2012-08-22 12:06:55 +0200 (Wed, 22 Aug 2012) New Revision: 3627 Url: http://chorem.org/repositories/revision/lima/3627 Log: refs #769 Correction sur la methode d acquisition des comptes et sous-comptes entres au sein du plan BCR. 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/java/org/chorem/lima/business/ejb/ReportServiceImpl.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 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-21 14:16:49 UTC (rev 3626) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-22 10:06:55 UTC (rev 3627) @@ -25,20 +25,7 @@ package org.chorem.lima.business.ejb; -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 +68,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; @@ -137,130 +123,20 @@ } - /** - * Crée l'entete du document avec le titre, l'ientité, et les dates. - * - * @param title - * @param identity - * @param beginDate - * @param endDate - * @return - */ - protected Paragraph createHeaderPage(String title, - Identity identity, - Date beginDate, - Date 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(_("lima-business.document.period1format", 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(_("lima-business.document.period2format", endDate), italicFont)); - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - - paragraphHeaderPage.add(t); - return paragraphHeaderPage; - } - - /** - * Sous tableau. - * - * @param nbPages - * @param date - * @return - * @throws BadElementException - */ - protected Paragraph createNumberPage(int nbPages, Date date) 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.createdate", date), normalFont)); - infos.addCell(new Phrase(_("lima-business.document.pagenumber", nbPages), normalFont)); - paragraphPage.add(infos); - return paragraphPage; - } - @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 { List<FinancialStatementAmounts> financialStatementAmounts = financialStatementService.financialStatementReport(beginDate, endDate); + String financialReport = ""; - 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; + financialReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" + + "<html>\n" + + "<body>\n"; - Identity identity = identityService.getIdentity(); - //Split list by financialstatement type List<List<FinancialStatementAmounts>> listList = new ArrayList<List<FinancialStatementAmounts>>(); @@ -280,6 +156,7 @@ } } listList.add(financialStatementAmounts.subList(min, size)); + int printedType = -1; //create pages for (List<FinancialStatementAmounts> list : listList) { @@ -287,10 +164,7 @@ 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; - } + printedType ++; while (i < n) { int j = i + max; if (j > n) { @@ -298,162 +172,113 @@ } 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++; - } - } - document.close(); + financialReport += constructHeaderTitle(title, beginDate, endDate); - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } - } + String boldBegin = "<b>"; + String boldEnd = "</b>"; + financialReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" + + "<tr align=\"center\">\n"; - 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)); + if (printedType == 0) { + String[] columnHeaderTable = {boldBegin+_("lima-business.document.label")+boldEnd, boldBegin+_("lima-business.document.grossamount")+boldEnd, + boldBegin+_("lima-business.document.provisiondeprecationamount")+boldEnd, boldBegin+_("lima-business.document.netamount")+boldEnd}; + financialReport += constructColumnsHtml(columnHeaderTable, ""); + } else if (printedType == 1) { + String[] columnHeaderTable = {boldBegin+_("lima-business.document.label")+boldEnd, boldBegin+_("lima-business.document.amount")+boldEnd}; + financialReport += constructColumnsHtml(columnHeaderTable, ""); + } else { + String[] columnHeaderTable = {boldBegin+_("lima-business.document.label")+boldEnd, boldBegin+_("lima-business.document.amount")+boldEnd}; + financialReport += constructColumnsHtml(columnHeaderTable, ""); + } - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; + for (FinancialStatementAmounts financialStatementAmount : subFinancialStatementAmounts) { - } + 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); + } - 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); + String fontColor = ""; + if (financialStatementAmount.getSubAmount() && level == 1) { + fontColor = "#CCCCCC"; + } else if (financialStatementAmount.getSubAmount()) { + fontColor = "#C0C0C0"; + } else { + fontColor = "#999999"; + } + if (label == null) { + if (printedType == 0) { + String [] emptyColumn = {"","","",""}; + financialReport += constructColumnsHtml(emptyColumn, fontColor); + } else { + String [] emptyColumn = {"", ""}; + financialReport += constructColumnsHtml(emptyColumn, fontColor); + } + } else { + //cell1 + StringBuffer tab = new StringBuffer(); + for (int k = 0; k < level; k++) { + tab.append("\t"); + } + //Phrase phrase; + String tabLabel = ""; + if (financialStatementAmount.getHeader()) { + tabLabel = boldBegin + tab + label + boldEnd; + } else { + tabLabel = tab + label; + } + //cell2 + String grossAmountStr = ""; + if (grossAmount != BigDecimal.ZERO) { + grossAmountStr = grossAmount.toString(); + } - for (FinancialStatementAmounts financialStatementAmount : financialStatementAmounts) { + //cell 3 + String provisionDeprecationAmountStr = ""; + if (provisionDeprecationAmount != BigDecimal.ZERO) { + provisionDeprecationAmountStr = provisionDeprecationAmount.toString(); + } - 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); - } + //cell 4 + BigDecimal solde = grossAmount; + solde = solde.subtract(provisionDeprecationAmount); + String soldeStr = ""; + if (solde != BigDecimal.ZERO) { + soldeStr = solde.toString(); + } - 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"); + if (printedType == 0) { + String [] columns = {tabLabel, grossAmountStr, provisionDeprecationAmountStr, soldeStr}; + financialReport += constructColumnsHtml(columns, ""); + } else /*if (printedType == 1)*/ { + String [] columns = {tabLabel, soldeStr}; + financialReport += constructColumnsHtml(columns, ""); + } /*else { + String [] columns = {tabLabel, grossAmountStr, provisionDeprecationAmountStr, soldeStr}; + financialReport += constructColumnsHtml(columns, ""); + }*/ + } } - 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); + i = i + max; + financialReport += "</table>"; } } + financialReport += "</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 financialReport; } //############## Ledger ############## @@ -497,7 +322,13 @@ j = n; } - ledgerReport += "<table>" + + ledgerReport += constructHeaderTitle(_("lima-business.document.ledger"), beginDate, endDate); + + BigDecimal currentAmountDebit = new BigDecimal(0); + BigDecimal currentAmountCredit = new BigDecimal(0); + String accountcarry = ""; + + /*ledgerReport += "<table>" + "<tr> " + "<td>" + "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" + @@ -505,33 +336,30 @@ String boldItalicBegin = "<b>" + "<i>"; String boldItalicEnd = "</i>" + "</b>"; - BigDecimal currentAmountDebit = new BigDecimal(0); - BigDecimal currentAmountCredit = new BigDecimal(0); - String accountcarry = ""; Identity identity = identityService.getIdentity(); String [] columnsNameSociety = {boldItalicBegin + identity.getName()+ boldItalicEnd}; - ledgerReport += constructColumnsHtml(columnsNameSociety); + ledgerReport += constructColumnsHtml(columnsNameSociety, ""); ledgerReport += "<tr>\n"; String [] columnsDescription = {"<i>" + identity.getDescription()+ "</i>"}; - ledgerReport += constructColumnsHtml(columnsDescription); + ledgerReport += constructColumnsHtml(columnsDescription, ""); ledgerReport += "<tr>\n"; String [] columnsAdressOne = {"<i>" + identity.getAddress() + "</i>"}; - ledgerReport += constructColumnsHtml(columnsAdressOne); + ledgerReport += constructColumnsHtml(columnsAdressOne, ""); ledgerReport += "<tr>\n"; String [] columnsAdressTwo = {"<i>" + identity.getAddress2() + "</i>"}; - ledgerReport += constructColumnsHtml(columnsAdressTwo); + ledgerReport += constructColumnsHtml(columnsAdressTwo, ""); ledgerReport += "<tr>\n"; String [] columnsZipCode = {"<i>" + identity.getZipCode() + "</i>"}; - ledgerReport += constructColumnsHtml(columnsZipCode); + ledgerReport += constructColumnsHtml(columnsZipCode, ""); ledgerReport += "<tr>\n"; String [] columnsCity = {"<i>" + identity.getCity()+ "</i>"}; - ledgerReport += constructColumnsHtml(columnsCity); + ledgerReport += constructColumnsHtml(columnsCity, ""); ledgerReport += "</table>\n" + "</td>" + @@ -544,31 +372,31 @@ ledgerReport += "<tr>\n"; String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") + boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"}; - ledgerReport += constructColumnsHtml(columnsBusinessNumber); + ledgerReport += constructColumnsHtml(columnsBusinessNumber, ""); ledgerReport += "<tr>\n"; String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") + boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"}; - ledgerReport += constructColumnsHtml(columnsClassifCode); + ledgerReport += constructColumnsHtml(columnsClassifCode, ""); ledgerReport += "<tr>\n"; String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd, "<i>" + identity.getVatNumber()+ "</i>", }; - ledgerReport += constructColumnsHtml(columnsVatNumber); + 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 += constructColumnsHtml(columnsPeriodOne, ""); ledgerReport += "<tr>\n"; String [] columnsPeriodTwo = {boldItalicBegin + _("lima-business.document.period2") + boldItalicEnd, "<i>" + _("lima-business.document.period2format", endDate)+ "</i>"}; - ledgerReport += constructColumnsHtml(columnsPeriodTwo); + ledgerReport += constructColumnsHtml(columnsPeriodTwo, ""); ledgerReport += "</table>" + "</td>" + - "</table>"; + "</table>";*/ List<Object> subList = list.subList(i, j); @@ -578,7 +406,7 @@ 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); + ledgerReport += constructColumnsHtml(columnsCarryBack, ""); } ledgerReport += "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" + @@ -586,7 +414,7 @@ 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); + ledgerReport += constructColumnsHtml(columnsNames, ""); for (Object object : subList) { if (object instanceof ReportsDatas) { @@ -604,7 +432,7 @@ String [] columnsTable = {boldBegin + accountS + boldEnd, boldBegin + amountDebit.toString() + boldEnd, boldBegin + amountCredit.toString() + boldEnd, boldBegin + amountDebit.subtract(amountCredit).toString() + boldEnd}; - ledgerReport += constructColumnsHtml(columnsTable); + ledgerReport += constructColumnsHtml(columnsTable, ""); } else { Entry entry = (Entry) object; @@ -629,12 +457,12 @@ 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); + 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 += constructColumnsHtml(columnsTable, ""); ledgerReport += "</table>" + "</td></tr>"; } @@ -662,14 +490,14 @@ 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); + 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); + ledgerReport += constructColumnsHtml(columnsTable, ""); } i = i + max; } @@ -751,7 +579,7 @@ _("lima-business.document.debit"), _("lima-business.document.credit")}; - entryBookReport += constructColumnsHtml(columnNames); + entryBookReport += constructColumnsHtml(columnNames, ""); for (Entry entry : entries) { String numaccount = null; @@ -764,10 +592,10 @@ (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO).toString(), (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()).toString()}; - entryBookReport += constructColumnsHtml(columnData); + entryBookReport += constructColumnsHtml(columnData, ""); } String [] columnDataTotal = {"", "", "", _("lima-business.document.amounts"), debit.toString(), credit.toString()}; - entryBookReport += constructColumnsHtml(columnDataTotal); + entryBookReport += constructColumnsHtml(columnDataTotal, ""); entryBookReport += "</table></p>\n"; } } @@ -816,8 +644,10 @@ } List<ReportsDatas> subList = list.subList(i, j); - balanceReport += "<body>\n" + - "<table>" + + balanceReport += "<body>\n"; + balanceReport += constructHeaderTitle(_("lima-business.document.balance"), beginDate, endDate); + + /*balanceReport += "<table>" + "<tr> " + "<td>" + "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" + @@ -827,27 +657,27 @@ String boldItalicEnd = "</i>" + "</b>"; String [] columnsNameSociety = {boldItalicBegin + identity.getName()+ boldItalicEnd}; - balanceReport += constructColumnsHtml(columnsNameSociety); + balanceReport += constructColumnsHtml(columnsNameSociety, ""); balanceReport += "<tr>\n"; String [] columnsDescription = {"<i>" + identity.getDescription()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsDescription); + balanceReport += constructColumnsHtml(columnsDescription, ""); balanceReport += "<tr>\n"; String [] columnsAdressOne = {"<i>" + identity.getAddress() + "</i>"}; - balanceReport += constructColumnsHtml(columnsAdressOne); + balanceReport += constructColumnsHtml(columnsAdressOne, ""); balanceReport += "<tr>\n"; String [] columnsAdressTwo = {"<i>" + identity.getAddress2() + "</i>"}; - balanceReport += constructColumnsHtml(columnsAdressTwo); + balanceReport += constructColumnsHtml(columnsAdressTwo, ""); balanceReport += "<tr>\n"; String [] columnsZipCode = {"<i>" + identity.getZipCode() + "</i>"}; - balanceReport += constructColumnsHtml(columnsZipCode); + balanceReport += constructColumnsHtml(columnsZipCode, ""); balanceReport += "<tr>\n"; String [] columnsCity = {"<i>" + identity.getCity()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsCity); + balanceReport += constructColumnsHtml(columnsCity, ""); balanceReport += "</table>\n" + "</td>" + @@ -860,38 +690,39 @@ balanceReport += "<tr>\n"; String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") + boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsBusinessNumber); + balanceReport += constructColumnsHtml(columnsBusinessNumber, ""); balanceReport += "<tr>\n"; String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") + boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"}; - balanceReport += constructColumnsHtml(columnsClassifCode); + balanceReport += constructColumnsHtml(columnsClassifCode, ""); balanceReport += "<tr>\n"; String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd, "<i>" + identity.getVatNumber()+ "</i>", }; - balanceReport += constructColumnsHtml(columnsVatNumber); + balanceReport += constructColumnsHtml(columnsVatNumber, ""); balanceReport += "<tr>\n"; String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>" + _("lima-business.document.period1format", beginDate)+ "</i>"}; - balanceReport += constructColumnsHtml(columnsPeriodOne); + balanceReport += constructColumnsHtml(columnsPeriodOne, ""); balanceReport += "<tr>\n"; String [] columnsPeriodTwo = {boldItalicBegin + _("lima-business.document.period2") + boldItalicEnd, "<i>" + _("lima-business.document.period2format", endDate)+ "</i>"}; - balanceReport += constructColumnsHtml(columnsPeriodTwo); + balanceReport += constructColumnsHtml(columnsPeriodTwo, ""); balanceReport += "</table>" + "</td>" + - "</table>" + - "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" + + "</table>"*/ + + balanceReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" + "<tr align=\"center\">\n"; String [] columnsNames = {_("lima-business.document.accountnumber"), _("lima-business.document.description"), _("lima-business.document.movementdebit"), _("lima-business.document.movementcredit"), _("lima-business.document.soldedebit"), _("lima-business.document.soldecredit")}; - balanceReport += constructColumnsHtml(columnsNames); + balanceReport += constructColumnsHtml(columnsNames, ""); if (n > max) { String boldBegin = "<b>"; @@ -899,7 +730,7 @@ String [] columnsBalanceAmount = {"", boldBegin + _("lima-business.document.carryback") + boldEnd, boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, boldBegin + currentSoldeDebit.toString() + boldEnd,boldBegin + currentSoldeCredit.toString() + boldEnd}; - balanceReport += constructColumnsHtml(columnsBalanceAmount); + balanceReport += constructColumnsHtml(columnsBalanceAmount, ""); balanceReport += "</table>\n"; } @@ -910,7 +741,7 @@ String [] columnsBalanceAmount = {reportsDatas.getAccount().getAccountNumber(), reportsDatas.getAccount().getLabel(), reportsDatas.getAmountDebit().toString(), reportsDatas.getAmountCredit().toString(), soldeDebit, soldeCredit}; - balanceReport += constructColumnsHtml(columnsBalanceAmount); + balanceReport += constructColumnsHtml(columnsBalanceAmount, ""); } for (ReportsDatas reportsDatas : subList) { @@ -929,7 +760,7 @@ String [] columnsBalanceAmount = {"", boldBegin + _("lima-business.document.carryforward") + boldEnd, boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, boldBegin + currentSoldeDebit.toString() + boldEnd,boldBegin + currentSoldeCredit.toString() + boldEnd}; - balanceReport += constructColumnsHtml(columnsBalanceAmount); + balanceReport += constructColumnsHtml(columnsBalanceAmount, ""); balanceReport += "</table>\n"; } @@ -940,7 +771,7 @@ String [] columnsBalanceAmount = {"", boldBegin + _("lima-business.document.amounts") + boldEnd, boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, boldBegin + currentSoldeDebit.toString() + boldEnd,boldBegin + currentSoldeCredit.toString() + boldEnd}; - balanceReport += constructColumnsHtml(columnsBalanceAmount); + balanceReport += constructColumnsHtml(columnsBalanceAmount, ""); balanceReport += "</table>\n"; } i = i + max; @@ -1055,7 +886,7 @@ _("lima-business.document.date"), _("lima-business.document.debit"), _("lima-business.document.credit")}; - entryBookReport += constructColumnsHtml(columnNames); + entryBookReport += constructColumnsHtml(columnNames, ""); String entryBookCode = ""; for (GeneralEntryBooksDatas generalEntryBooksDataInList : list) { @@ -1075,7 +906,7 @@ _("lima-business.document.monthformat", generalEntryBooksDataInList.getPeriod()), generalEntryBooksDataInList.getDebit().toString(), generalEntryBooksDataInList.getCredit().toString()}; - entryBookReport += constructColumnsHtml(columnData); + entryBookReport += constructColumnsHtml(columnData, ""); } else { String amount; if (generalEntryBooksDataInList.getAmount()) { @@ -1086,7 +917,7 @@ String[] columnDataTotal = {"", "", "<b>"+ (StringUtils.isBlank(amount)?"":amount) + "</b>", generalEntryBooksDataInList.getDebit().toString(), generalEntryBooksDataInList.getCredit().toString()}; - entryBookReport += constructColumnsHtml(columnDataTotal); + entryBookReport += constructColumnsHtml(columnDataTotal, ""); } } } @@ -1200,7 +1031,7 @@ "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" + "<tr align=\"center\">\n"; - accountReport += constructColumnsHtml(columnNames); + accountReport += constructColumnsHtml(columnNames, ""); for(Entry entry : entries) { @@ -1221,7 +1052,7 @@ (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO).toString(), (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()).toString()}; - accountReport += constructColumnsHtml(columnData); + accountReport += constructColumnsHtml(columnData, ""); } accountReport += "</table>\n" + @@ -1270,16 +1101,92 @@ return subTitle; } - protected String constructColumnsHtml(String[] columnsNames) { + protected String constructColumnsHtml(String[] columnsNames, String fontColor) { String columns = ""; for (String name : columnsNames) { - columns += "<td>" + name + "</td>\n"; + columns += "<td style=\"background-color:"+fontColor+";\">" + name + "</td>\n"; } columns += "<tr>\n"; + return columns; } + protected String constructHeaderTitle(String title, Date beginDate, Date endDate) { + String headerTitle = ""; + Identity identity = identityService.getIdentity(); + + headerTitle += "<table>" + + "<tr> " + + "<td>" + + "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" + + "<tr>\n"; + + String boldItalicBegin = "<b>" + "<i>"; + String boldItalicEnd = "</i>" + "</b>"; + + String [] columnsNameSociety = {boldItalicBegin + identity.getName()+ boldItalicEnd}; + headerTitle += constructColumnsHtml(columnsNameSociety, ""); + + headerTitle += "<tr>\n"; + String [] columnsDescription = {"<i>" + identity.getDescription()+ "</i>"}; + headerTitle += constructColumnsHtml(columnsDescription, ""); + + headerTitle += "<tr>\n"; + String [] columnsAdressOne = {"<i>" + identity.getAddress() + "</i>"}; + headerTitle += constructColumnsHtml(columnsAdressOne, ""); + headerTitle += "<tr>\n"; + String [] columnsAdressTwo = {"<i>" + identity.getAddress2() + "</i>"}; + headerTitle += constructColumnsHtml(columnsAdressTwo, ""); + + headerTitle += "<tr>\n"; + String [] columnsZipCode = {"<i>" + identity.getZipCode() + "</i>"}; + headerTitle += constructColumnsHtml(columnsZipCode, ""); + + headerTitle += "<tr>\n"; + String [] columnsCity = {"<i>" + identity.getCity()+ "</i>"}; + headerTitle += constructColumnsHtml(columnsCity, ""); + + headerTitle += "</table>\n" + + "</td>" + + "<td valign=\"middle\" align=\"center\" style=\"width:100%\">" + + "<p style=\"font-size:30px;\">" + title + "</p>" + + "</td>" + + "<td>" + + "<table align=\"right\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n"; + + headerTitle += "<tr>\n"; + String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") + + boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"}; + headerTitle += constructColumnsHtml(columnsBusinessNumber, ""); + + headerTitle += "<tr>\n"; + String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") + + boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"}; + headerTitle += constructColumnsHtml(columnsClassifCode, ""); + + headerTitle += "<tr>\n"; + String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd, + "<i>" + identity.getVatNumber()+ "</i>", }; + headerTitle += constructColumnsHtml(columnsVatNumber, ""); + + headerTitle += "<tr>\n"; + String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>" + + _("lima-business.document.period1format", beginDate)+ "</i>"}; + headerTitle += constructColumnsHtml(columnsPeriodOne, ""); + + headerTitle += "<tr>\n"; + String [] columnsPeriodTwo = {boldItalicBegin + _("lima-business.document.period2") + boldItalicEnd, "<i>" + + _("lima-business.document.period2format", endDate)+ "</i>"}; + headerTitle += constructColumnsHtml(columnsPeriodTwo, ""); + + headerTitle += "</table>" + + "</td>" + + "</table>"; + + return headerTitle; + } + } 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-21 14:16:49 UTC (rev 3626) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-22 10:06:55 UTC (rev 3627) @@ -164,7 +164,7 @@ String generalEntryBooksReport = null; String balanceReport = null; String ledgerReport = null; - //String financialReport = null; + String financialReport = null; //create docs try { @@ -195,8 +195,8 @@ } break; case FINANCIALSTATEMENT: - documentService.createFinancialStatementsDocuments( - beginDateFormat, endDateFormat, formatsEnum); + financialReport = documentService.createFinancialStatementsDocuments( + beginDateFormat, endDateFormat); break; case LEDGER: ledgerReport = documentService.createLedgerDocuments( @@ -226,7 +226,7 @@ resp.setContentType(formatsEnum.getMimeType()); OutputStream out = resp.getOutputStream(); if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null - || balanceReport != null || ledgerReport != null /*|| financialReport != null*/) { + || balanceReport != null || ledgerReport != null || financialReport != null) { String report = null; if (accountReport != null) { report = accountReport; @@ -238,9 +238,9 @@ report = balanceReport; } else if (ledgerReport != null) { report = ledgerReport; - } /*else { + } else { report = financialReport; - }*/ + } IOUtils.write(report, out, Charsets.UTF_8); } else { InputStream in = doc.openStream(); 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 2012-08-21 14:16:49 UTC (rev 3626) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-08-22 10:06:55 UTC (rev 3627) @@ -87,7 +87,13 @@ BigDecimal debit = new BigDecimal(0); BigDecimal solde = new BigDecimal(0); List<Entry> entries = new ArrayList<Entry>(); - + + reportsDatas = generateSubAccountReports(account, + beginDate, endDate); + debit = debit.add(reportsDatas.getAmountDebit()); + credit = credit.add(reportsDatas.getAmountCredit()); + entries.addAll(reportsDatas.getListEntry()); + //Get allsubaccounts and thirdParts accounts List<Account> accounts = accountService.getAllSubAccounts(account); 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-21 14:16:49 UTC (rev 3626) +++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-22 10:06:55 UTC (rev 3627) @@ -21,6 +21,7 @@ lima-business.document.accountnumber=Account N° lima-business.document.adress= lima-business.document.adresssuite= +lima-business.document.amount= lima-business.document.amounts=Amounts lima-business.document.amountsperiod=Amounts %1$tB %1$tY lima-business.document.balance=Balance 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-21 14:16:49 UTC (rev 3626) +++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-22 10:06:55 UTC (rev 3627) @@ -21,12 +21,14 @@ lima-business.document.accountnumber=N° Compte lima-business.document.adress=Adresse lima-business.document.adresssuite=Adresse - suite +lima-business.document.amount=Total lima-business.document.amounts=Totaux lima-business.document.amountsperiod=Totaux %1$tB %1$tY lima-business.document.balance=Balance lima-business.document.businessnumber=N° Siret lima-business.document.carryback=Report lima-business.document.carryforward=À reporter +lima-business.document.charge=Charge lima-business.document.city=Ville lima-business.document.classificationcode=NAF lima-business.document.createdate=Date de tirage %1$te/%1$tm/%1$tY à %1$tH\:%1$tM @@ -54,10 +56,9 @@ lima-business.document.period1format=%1$te/%1$tm/%1$tY lima-business.document.period2=au lima-business.document.period2format=%1$te/%1$tm/%1$tY +lima-business.document.product=Produit lima-business.document.provisiondeprecationamount=Amortissements et provisions lima-business.document.society=Nom -lima-business.document.product=Produit -lima-business.document.charge=Charge lima-business.document.solde=Solde lima-business.document.soldecredit=Solde Créditeur lima-business.document.soldedebit=Solde Débiteur 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-21 14:16:49 UTC (rev 3626) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-22 10:06:55 UTC (rev 3627) @@ -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;