Author: jpepin Date: 2010-08-02 15:02:10 +0200 (Mon, 02 Aug 2010) New Revision: 2991 Url: http://chorem.org/repositories/revision/lima/2991 Log: Sortie document pdf du grand-livre termin?\195?\169. Added: trunk/lima-business/src/main/resources/i18n/ 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/pom.xml trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/pom.xml =================================================================== --- trunk/lima-business/pom.xml 2010-08-02 08:19:54 UTC (rev 2990) +++ trunk/lima-business/pom.xml 2010-08-02 13:02:10 UTC (rev 2991) @@ -59,6 +59,20 @@ <packaging>jar</packaging> <build> + <plugins> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> <pluginManagement> <plugins> <plugin> @@ -91,6 +105,8 @@ <attach>false</attach> </configuration> </plugin> + + </plugins> </pluginManagement> </build> Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-02 08:19:54 UTC (rev 2990) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-02 13:02:10 UTC (rev 2991) @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; - import javax.ejb.EJB; import javax.ejb.Stateless; import org.apache.commons.logging.Log; @@ -47,7 +46,6 @@ import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; - import com.lowagie.text.BadElementException; import com.lowagie.text.Cell; import com.lowagie.text.Chapter; @@ -61,9 +59,6 @@ import com.lowagie.text.Rectangle; import com.lowagie.text.Table; import com.lowagie.text.html.HtmlWriter; -import com.lowagie.text.pdf.PdfPCell; -import com.lowagie.text.pdf.PdfPTable; -import com.lowagie.text.pdf.PdfTable; import com.lowagie.text.pdf.PdfWriter; @Stateless @@ -136,26 +131,26 @@ titleCell.setHorizontalAlignment(Element.ALIGN_CENTER); titleCell.setRowspan(2); t.addCell(titleCell); - t.addCell(new Phrase("N° Siret", bolditalicFont)); + t.addCell(new Phrase(_("lima-business.document.businessnumber"), bolditalicFont)); t.addCell(new Phrase(identity.getBusinessNumber(), italicFont)); //line 2 - t.addCell(new Phrase("SSL", italicFont)); - t.addCell(new Phrase("NAF :", bolditalicFont)); + 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("n°TVA", bolditalicFont)); + 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("Période du", bolditalicFont)); + t.addCell(new Phrase(_("lima-business.document.period1"), bolditalicFont)); t.addCell(new Phrase(beginDate, italicFont)); //line 5 t.addCell(new Phrase(identity.getZipCode() + " " + identity.getCity(), italicFont)); t.addCell(""); - t.addCell(new Phrase("au", bolditalicFont)); + t.addCell(new Phrase(_("lima-business.document.period2"), bolditalicFont)); t.addCell(new Phrase(endDate, italicFont)); } catch (BadElementException eeBEE) { log.error("Can't create table", eeBEE); @@ -164,7 +159,7 @@ } - //############## FinancialStatements + //############## FinancialStatements ############## @Override @@ -220,8 +215,8 @@ list.subList(i, j); //create page : header + table + footer Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate)); - Table headerTable = createHeaderTableFinancialStatement(); - Table table = createFinancialStatementTable(subFinancialStatementAmounts); + Table headerTable = createFinancialStatementsHeaderTable(); + Table table = createFinancialStatementsTable(subFinancialStatementAmounts); //new page Chapter chapter = new Chapter(0); //headerPage @@ -238,8 +233,8 @@ c.setBorder(Rectangle.NO_BORDER); c.setHorizontalAlignment(Element.ALIGN_CENTER); infos.setDefaultCell(c); - infos.addCell(new Phrase("Date de tirage " + dateS + " à " + hourS, normalFont)); - infos.addCell(new Phrase("Page n° "+nbpages, normalFont)); + infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont)); + infos.addCell(new Phrase(_("lima-business.document.pagenumber")+nbpages, normalFont)); paragraphPage.add(infos); chapter.add(paragraphPage); //headerTable @@ -266,7 +261,7 @@ } } - public Table createHeaderTableFinancialStatement(){ + public Table createFinancialStatementsHeaderTable(){ Table t = null; try { t = new Table(4,1); @@ -280,10 +275,10 @@ cell.setHorizontalAlignment(Element.ALIGN_CENTER); t.setDefaultCell(cell); t.setOffset(8); - t.addCell(new Phrase(_("lima.table.label"), boldFont)); - t.addCell(new Phrase(_("lima.table.grossamount"), boldFont)); - t.addCell(new Phrase(_("lima.table.provisiondeprecationamount"), boldFont)); - t.addCell(new Phrase(_("lima.table.netamount"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.label"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.grossamount"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.provisiondeprecationamount"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.netamount"), boldFont)); } catch (BadElementException eeBEE) { log.error("Can't create table", eeBEE); @@ -292,7 +287,7 @@ } - public Table createFinancialStatementTable(List<FinancialStatementAmounts> financialStatementAmounts){ + public Table createFinancialStatementsTable(List<FinancialStatementAmounts> financialStatementAmounts){ int nbrow = financialStatementAmounts.size(); Table t = null; try { @@ -382,7 +377,9 @@ return t; } - //############## Ledger + + + //############## Ledger ############## @Override @@ -397,6 +394,8 @@ String fileDateS = filedateFormat.format(newDate); Double currentAmountDebit = 0.0; + Double currentAmountCredit = 0.0; + String accountcarry =""; PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("/ledger_lima"+fileDateS+".pdf")); @@ -407,20 +406,19 @@ Identity identity = identityService.getIdentity(); //create pages - String title = "Ledger"; + String title = _("lima-business.document.ledger"); int i=0; int n=list.size(); - int max=n; + int max = 32; while (i<n){ - int j=i+max; + int j = i+max; if (j>n){ j = n; } List <Object> subList = list.subList(i, j); //create page : header + table + footer Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate)); - Table headerTable = createHeaderTableLedger(); - PdfPTable table = createTableLedger(subList); + Table headerTable = createLedgerHeaderTable(); //new page Chapter chapter = new Chapter(0); //headerPage @@ -437,8 +435,8 @@ c.setBorder(Rectangle.NO_BORDER); c.setHorizontalAlignment(Element.ALIGN_CENTER); infos.setDefaultCell(c); - infos.addCell(new Phrase("Date de tirage " + dateS + " à " + hourS, normalFont)); - infos.addCell(new Phrase("Page n° "+nbpages, normalFont)); + infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont)); + infos.addCell(new Phrase(_("lima-business.document.pagenumber")+nbpages, normalFont)); paragraphPage.add(infos); chapter.add(paragraphPage); //headerTable @@ -448,20 +446,41 @@ //backward amounts if (n>max && nbpages>1){ Paragraph backwardParagraph = new Paragraph(); - backwardParagraph.add(""); + 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; + currentAmountDebit += entry.getDebit() ? entry.getAmount() : 0; + currentAmountCredit += entry.getDebit() ? 0 : entry.getAmount(); + } + else { + ReportsDatas reportsDatas = (ReportsDatas) object; + Account account = reportsDatas.getAccount(); + if ( account != null){ + accountcarry = account.getAccountNumber()+" "+account.getLabel()+" "; + log.debug(accountcarry); + } + } + } //forward amounts - if (n>max){ + if (n>max && i<=n-max){ Paragraph forwardParagraph = new Paragraph(); - forwardParagraph.add(""); + 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.amount"), currentAmountDebit, currentAmountCredit)); + chapter.add(finalAmountParagraph); + } //add page document.add(chapter); i=i+max; @@ -476,27 +495,27 @@ } } - public Table createHeaderTableLedger(){ + public Table createLedgerHeaderTable(){ Table t = null; try { t = new Table(7,1); float[] widths = {0.1f, 0.05f, 0.1f, 0.3f, 0.15f, 0.15f, 0.15f}; t.setWidths(widths); t.setWidth(100f); - t.setPadding(3f); + 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.table.date"), boldFont)); - t.addCell(new Phrase(_("lima.table.entrybook"), boldFont)); - t.addCell(new Phrase(_("lima.table.voucher"), boldFont)); - t.addCell(new Phrase(_("lima.table.description"), boldFont)); - t.addCell(new Phrase(_("lima.table.debit"), boldFont)); - t.addCell(new Phrase(_("lima.table.credit"), boldFont)); - t.addCell(new Phrase(_("lima.table.solde"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.date"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.entrybook"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.voucher"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.description"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.debit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.credit"), boldFont)); + t.addCell(new Phrase(_("lima-business.document.solde"), boldFont)); } catch (BadElementException eeBEE) { log.error("Can't create table", eeBEE); @@ -505,37 +524,55 @@ } - public PdfPTable createTableLedger(List<Object> subList){ + public Table createLedgerAmountTable(String account, String title, Double credit, Double debit){ + 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)); + Double solde = debit-credit; + t.addCell(new Phrase(solde.toString(), boldFont)); + } catch (BadElementException eeBEE) { + log.error("Can't create table", eeBEE); + } + return t; + + } + + public Table createLedgerTable(List<Object> subList){ int nbrow = subList.size(); - PdfPTable t = null; + Table t = null; try { //define table - t = new PdfPTable(7); - t.setWidthPercentage(100f); + 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.setHeaderRows(2); - //t.setPadding(1.5f); - //t.setBorderWidth(1); - //t.setOffset(0); + 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); - - Paragraph p = new Paragraph("test"); - PdfPCell header = new PdfPCell(p); - header.setColspan(7); - t.addCell(header); - //t.setTableFitsPage(true); - - t.setFooterRows(1); - Paragraph p2 = new Paragraph("footer"); - PdfPCell footer = new PdfPCell(p2); - footer.setColspan(7); - t.addCell(footer); - + t.setDefaultCell(cell); + for (Object object : subList) { if (object instanceof ReportsDatas) { @@ -549,7 +586,7 @@ Double amountCredit = reportsDatas.getAmountCredit(); Double amountDebit = reportsDatas.getAmountDebit(); - PdfPCell c = new PdfPCell(new Phrase(accountS, boldFont)); + Cell c = new Cell(new Phrase(accountS, boldFont)); c.setColspan(4); c.setHorizontalAlignment(Element.ALIGN_LEFT); t.addCell(c); Added: trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties (rev 0) +++ trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-02 13:02:10 UTC (rev 2991) @@ -0,0 +1,36 @@ +An\ EntryBook\ already\ exists\ with\ this\ label\ \:\ %s= +An\ account\ already\ exists\ with\ this\ number\ \:\ %s= +An\ financialStatement\ already\ exists\ with\ this\ label\ \:\ %s= +lima-business.config.configFileName.description= +lima-business.config.rulesnationality= +lima-business.document.amount=Amout +lima-business.document.businessnumber= +lima-business.document.carryback=Carry Back +lima-business.document.carryforward=reporter\u00C0 +lima-business.document.classificationcode= +lima-business.document.classificationcode\ \:= +lima-business.document.createdate1= +lima-business.document.createdate2= +lima-business.document.credit=Credit +lima-business.document.date=Date +lima-business.document.debit=Debit +lima-business.document.description=Description +lima-business.document.entrybook=EntryBook +lima-business.document.grossamount=Gross Amount +lima-business.document.label=Label +lima-business.document.ledger= +lima-business.document.netamount=Net Amount +lima-business.document.pagenumber= +lima-business.document.period1= +lima-business.document.period2= +lima-business.document.provisiondeprecationamount=Provision Deprecation Amount +lima-business.document.solde=Solde +lima-business.document.vatnumber= +lima-business.document.voucher=Voucher +lima.business.document.date=Date +lima.config.configFileName.description= +lima.config.rulesnationality= +lima.table.grossamount= +lima.table.label=Test +lima.table.netamount= +lima.table.provisiondeprecationamount= Added: trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties (rev 0) +++ trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-02 13:02:10 UTC (rev 2991) @@ -0,0 +1,28 @@ +An\ EntryBook\ already\ exists\ with\ this\ label\ \:\ %s= +An\ account\ already\ exists\ with\ this\ number\ \:\ %s= +An\ financialStatement\ already\ exists\ with\ this\ label\ \:\ %s= +lima-business.document.amount=Total +lima-business.document.businessnumber=N\u00B0 Siret +lima-business.document.carryback=Report +lima-business.document.carryforward=\u00C0 reporter +lima-business.document.classificationcode=NAF +lima-business.document.createdate1=Date de tirage +lima-business.document.createdate2=\u00E0 +lima-business.document.credit=Cr\u00E9dit +lima-business.document.date=Date +lima-business.document.debit=D\u00E9bit +lima-business.document.description=Description +lima-business.document.entrybook=Journal +lima-business.document.grossamount=Brut +lima-business.document.label=Libell\u00E9 +lima-business.document.ledger=Grand Livre +lima-business.document.netamount=Net +lima-business.document.pagenumber=N\u00B0 page +lima-business.document.period1=P\u00E9riode du +lima-business.document.period2=au +lima-business.document.provisiondeprecationamount=Amortissements et provisions +lima-business.document.solde=Solde +lima-business.document.vatnumber=N\u00B0 TVA +lima-business.document.voucher=Pi\u00E8ce comptable +lima.config.configFileName.description= +lima.config.rulesnationality= Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-02 08:19:54 UTC (rev 2990) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-02 13:02:10 UTC (rev 2991) @@ -4,7 +4,6 @@ Global\ lima\ exception= LIMA= Loading\ accounting...= -blabla= export= hello\ world= lima.about.message=\u00C0 propos de Lima