From mallon@users.chorem.org Fri Aug 17 19:24:10 2012 From: mallon@users.chorem.org To: lima-commits@list.chorem.org Subject: [Lima-commits] 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 Date: Fri, 17 Aug 2012 19:24:10 +0200 Message-ID: <20120817172410.4CE6E158BC@nuiton.codelutin.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1671824003847557741==" --===============1671824003847557741== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 donn= ees filtrees, pour l edition du grand livre. Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/Documen= tService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentSer= viceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerS= erviceImpl.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/Docu= mentServiceImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentSe= rviceImpl.java 2012-08-17 14:41:36 UTC (rev 3611) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentSe= rviceImpl.java 2012-08-17 17:24:10 UTC (rev 3612) @@ -461,271 +461,227 @@ =20 =20 @Override - public void createLedgerDocuments(Date beginDate, - Date endDate, - FormatsEnum format) throws LimaExcepti= on { - Document document =3D new Document(PageSize.A4, 8, 8, 8, 8); + public String createLedgerDocuments(Date beginDate, + Date endDate) throws LimaException { + List list =3D new ArrayList(); - try { + String ledgerReport =3D ""; + ledgerReport +=3D "\n" + + "\n"; =20 - BalanceTrial balanceTrial =3D reportService.generateLedger(begin= Date, endDate, null, true); - if (balanceTrial.getReportsDatas() !=3D null) { - for (ReportsDatas reportsDatas : balanceTrial.getReportsData= s()) { - list.add(reportsDatas); - List entries =3D (List) reportsDatas.getLi= stEntry(); - if (entries !=3D null) { - Collections.sort(entries, new EntryComparator()); - list.addAll(entries); + if (beginDate !=3D null && endDate !=3D null) { + try { + ledgerReport +=3D "\n"; + String boldBegin =3D ""; + String boldEnd =3D ""; + + BalanceTrial balanceTrial =3D reportService.generateLedger(b= eginDate, endDate, null, true); + if (balanceTrial.getReportsDatas() !=3D null) { + for (ReportsDatas reportsDatas : balanceTrial.getReports= Datas()) { + list.add(reportsDatas); + List entries =3D reportsDatas.getListEntry(); + if (entries !=3D null) { + Collections.sort(entries, new EntryComparator()); + list.addAll(entries); + } } } - } =20 - Date newDate =3D new Date(); + //create pages + int i =3D 0; + int n =3D list.size(); + int max =3D n; =20 - BigDecimal currentAmountDebit =3D new BigDecimal(0); - BigDecimal currentAmountCredit =3D new BigDecimal(0); - String accountcarry =3D ""; + while (i < n) { + int j =3D i + max; + if (j > n) { + j =3D n; + } =20 - String filePath =3D path + File.separator + DocumentsEnum.LEDGER= .getFileName(); - FileOutputStream fileOut =3D new FileOutputStream(filePath + for= mat.getExtension()); - switch (format) { - case HTML: - HtmlWriter htmlWriter =3D HtmlWriter.getInstance(documen= t, fileOut); - break; - case PDF: - PdfWriter pdfWriter =3D PdfWriter.getInstance(document, = fileOut); - break; - } - document.open(); - int nbpages =3D 1; - Identity identity =3D identityService.getIdentity(); + ledgerReport +=3D "" + + " " + + "" + + "" + + "" + + "
" + + "\n" + + "\n"; =20 - //create pages - int i =3D 0; - int n =3D list.size(); - int max =3D n; - // alloc nb rows max for pdf documents on one page - if (format =3D=3D FormatsEnum.PDF) { - max =3D 32; - } - while (i < n) { - int j =3D i + max; - if (j > n) { - j =3D n; - } - List subList =3D list.subList(i, j); - //create page : header + table + footer - Table headerTable =3D createLedgerHeaderTable(); - //new page - Chapter chapter =3D new Chapter(0); - //headerPage - chapter.add(createHeaderPage(DocumentsEnum.LEDGER.getDescrip= tion(), identity, - beginDate, endDate)); - //n=C2=B0 page - chapter.add(createNumberPage(nbpages, newDate)); - //headerTable - Paragraph paragraphHeaderTable =3D new Paragraph(); - paragraphHeaderTable.add(headerTable); - chapter.add(paragraphHeaderTable); - //backward amounts - if (n > max && nbpages > 1) { - Paragraph backwardParagraph =3D new Paragraph(); - backwardParagraph.add(createLedgerAmountTable( - accountcarry, _("lima-business.document.carrybac= k"), - currentAmountDebit, currentAmountCredit)); - chapter.add(backwardParagraph); - } - //table - Paragraph paragraphTable =3D new Paragraph(); - Table table =3D createLedgerTable(subList); - paragraphTable.add(table); - chapter.add(paragraphTable); - for (Object object : subList) { - if (object instanceof Entry) { - Entry entry =3D (Entry) object; - if (entry.getDebit()) { - currentAmountDebit =3D currentAmountDebit.add(en= try.getAmount()); - } else { - currentAmountCredit =3D currentAmountCredit.add(= entry.getAmount()); - } - } else { - ReportsDatas reportsDatas =3D (ReportsDatas) object; - Account account =3D reportsDatas.getAccount(); - if (account !=3D null) { - accountcarry =3D account.getAccountNumber() - + " " + account.getLabel() + " = "; - } - } - } - //forward amounts - if (n > max && i <=3D n - max) { - Paragraph forwardParagraph =3D new Paragraph(); - forwardParagraph.add(createLedgerAmountTable("", - _("lima-bus= iness.document.carryforward"), - currentAmou= ntDebit, currentAmountCredit)); - chapter.add(forwardParagraph); - } - //final amounts - if (i >=3D n - max) { - Paragraph finalAmountParagraph =3D new Paragraph(); - finalAmountParagraph.add(createLedgerAmountTable("", - _("lima= -business.document.amounts"), - current= AmountDebit, currentAmountCredit)); - chapter.add(finalAmountParagraph); - } - //add page - document.add(chapter); - i =3D i + max; - nbpages++; - } - document.close(); + String boldItalicBegin =3D "" + ""; + String boldItalicEnd =3D "" + ""; + BigDecimal currentAmountDebit =3D new BigDecimal(0); + BigDecimal currentAmountCredit =3D new BigDecimal(0); + String accountcarry =3D ""; + Identity identity =3D identityService.getIdentity(); =20 - } catch (FileNotFoundException eeFNFE) { - log.error("Can't create pdf file", eeFNFE); - } catch (DocumentException eeDE) { - log.error("Can't create document", eeDE); - } - } + String [] columnsNameSociety =3D {boldItalicBegin + iden= tity.getName()+ boldItalicEnd}; + ledgerReport +=3D constructColumnsHtml(columnsNameSociet= y); =20 - protected Table createLedgerHeaderTable() { - Table t =3D null; - try { - t =3D new Table(7, 1); - float[] widths =3D {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 =3D 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"), bold= Font)); - t.addCell(new Phrase(_("lima-business.document.voucher"), boldFo= nt)); - t.addCell(new Phrase(_("lima-business.document.description"), bo= ldFont)); - t.addCell(new Phrase(_("lima-business.document.debit"), boldFont= )); - t.addCell(new Phrase(_("lima-business.document.credit"), boldFon= t)); - t.addCell(new Phrase(_("lima-business.document.solde"), boldFont= )); + ledgerReport +=3D "\n"; + String [] columnsDescription =3D {"" + identity.getDe= scription()+ ""}; + ledgerReport +=3D constructColumnsHtml(columnsDescriptio= n); =20 - } catch (BadElementException eeBEE) { - log.error("Can't create table", eeBEE); - } - return t; + ledgerReport +=3D "\n"; + String [] columnsAdressOne =3D {"" + identity.getAddr= ess() + ""}; + ledgerReport +=3D constructColumnsHtml(columnsAdressOne); =20 - } + ledgerReport +=3D "\n"; + String [] columnsAdressTwo =3D {"" + identity.getAddr= ess2() + ""}; + ledgerReport +=3D constructColumnsHtml(columnsAdressTwo); =20 - protected Table createLedgerTable(List subList) { - int nbrow =3D subList.size(); - Table t =3D null; - try { - //define table - t =3D new Table(7, nbrow); - t.setWidth(100f); - float[] widths =3D {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 =3D new Cell(); - cell.setBorder(Rectangle.LEFT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); + ledgerReport +=3D "\n"; + String [] columnsZipCode =3D {"" + identity.getZipCod= e() + ""}; + ledgerReport +=3D constructColumnsHtml(columnsZipCode); =20 - for (Object object : subList) { - if (object instanceof ReportsDatas) { + ledgerReport +=3D "\n"; + String [] columnsCity =3D {"" + identity.getCity()+ "= "}; + ledgerReport +=3D constructColumnsHtml(columnsCity); =20 - ReportsDatas reportsDatas =3D (ReportsDatas) object; + ledgerReport +=3D "
\n" + + "
" + + "

" + _("lima-busi= ness.document.ledger") + "

" + + "
" + + "\n"; =20 - String accountS =3D ""; - Account account =3D reportsDatas.getAccount(); - if (account !=3D null) { - accountS =3D account.getAccountNumber() + "\t" + acc= ount.getLabel(); - } - BigDecimal amountCredit =3D reportsDatas.getAmountCredit= (); - BigDecimal amountDebit =3D reportsDatas.getAmountDebit(); + ledgerReport +=3D "\n"; + String [] columnsBusinessNumber =3D {boldItalicBegin + _= ("lima-business.document.businessnumber") + + boldItalicEnd, "" + identity.getBusinessNumbe= r()+ ""}; + ledgerReport +=3D constructColumnsHtml(columnsBusinessNu= mber); =20 - Cell c =3D new Cell(new Phrase(accountS, boldFont)); - c.setColspan(4); - c.setHorizontalAlignment(Element.ALIGN_LEFT); - t.addCell(c); - t.addCell(new Phrase(String.valueOf(amountDebit), boldFo= nt)); - t.addCell(new Phrase(String.valueOf(amountCredit), boldF= ont)); - BigDecimal solde =3D amountDebit; - solde =3D solde.subtract(amountCredit); - t.addCell(new Phrase(String.valueOf(solde), boldFont)); - } else { - Entry entry =3D (Entry) object; + ledgerReport +=3D "\n"; + String [] columnsClassifCode =3D {boldItalicBegin + _("l= ima-business.document.classificationcode") + + boldItalicEnd, "" + identity.getClassificatio= nCode()+ ""}; + ledgerReport +=3D constructColumnsHtml(columnsClassifCod= e); =20 - String entryBookCode =3D ""; - EntryBook entryBook =3D entry.getFinancialTransaction().= getEntryBook(); - if (entryBook !=3D null) { - entryBookCode =3D entryBook.getCode(); + ledgerReport +=3D "\n"; + String [] columnsVatNumber =3D {boldItalicBegin + _("lim= a-business.document.vatnumber") + boldItalicEnd, + "" + identity.getVatNumber()+ "", }; + ledgerReport +=3D constructColumnsHtml(columnsVatNumber); + + ledgerReport +=3D "\n"; + String [] columnsPeriodOne =3D {boldItalicBegin + _("lim= a-business.document.period1") + boldItalicEnd, "" + + _("lima-business.document.period1format", begi= nDate)+ ""}; + ledgerReport +=3D constructColumnsHtml(columnsPeriodOne); + + ledgerReport +=3D "\n"; + String [] columnsPeriodTwo =3D {boldItalicBegin + _("lim= a-business.document.period2") + boldItalicEnd, "" + + _("lima-business.document.period2format", endD= ate)+ ""}; + ledgerReport +=3D constructColumnsHtml(columnsPeriodTwo); + + ledgerReport +=3D "
" + + "
"; + + List subList =3D list.subList(i, j); + + + //backward amounts + if (n > max ) { + String [] columnsCarryBack =3D {boldBegin + accountc= arry + boldEnd, boldBegin + _("lima-business.document.carryback") + boldEnd, + boldBegin + currentAmountDebit.toString() + = boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, + boldBegin + currentAmountDebit.subtract(curr= entAmountCredit).toString() + boldEnd}; + ledgerReport +=3D constructColumnsHtml(columnsCarryB= ack); } - BigDecimal amountDebit =3D new BigDecimal(0), - amountCredit =3D new BigDecimal(0); - if (entry.getDebit()) { - amountDebit =3D entry.getAmount(); - } else { - amountCredit =3D entry.getAmount(); - } =20 - t.addCell(new Phrase(_("lima-business.document.dateforma= t", - entry.getFinancialTransaction().getTransactionDa= te()), 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 =3D amountDebit.subtract(amountCredit); - t.addCell(new Phrase(solde.toString(), - normalFont)); + ledgerReport +=3D "\n" + + "\n"; =20 + String [] columnsNames =3D {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 +=3D constructColumnsHtml(columnsNames); + + for (Object object : subList) { + if (object instanceof ReportsDatas) { + + ReportsDatas reportsDatas =3D (ReportsDatas) obj= ect; + + String accountS =3D ""; + Account account =3D reportsDatas.getAccount(); + if (account !=3D null) { + accountS =3D account.getAccountNumber() + "\= t" + account.getLabel(); + } + BigDecimal amountCredit =3D reportsDatas.getAmou= ntCredit(); + BigDecimal amountDebit =3D reportsDatas.getAmoun= tDebit(); + + String [] columnsTable =3D {boldBegin + accountS= + boldEnd, + boldBegin + amountDebit.toString() + bol= dEnd, boldBegin + amountCredit.toString() + boldEnd, + boldBegin + amountDebit.subtract(amountC= redit).toString() + boldEnd}; + ledgerReport +=3D constructColumnsHtml(columnsTa= ble); + + } else { + Entry entry =3D (Entry) object; + + String entryBookCode =3D ""; + EntryBook entryBook =3D entry.getFinancialTransa= ction().getEntryBook(); + if (entryBook !=3D null) { + entryBookCode =3D entryBook.getCode(); + } + BigDecimal amountDebit =3D new BigDecimal(0), + amountCredit =3D new BigDecimal(0); + if (entry.getDebit()) { + amountDebit =3D entry.getAmount(); + } else { + amountCredit =3D entry.getAmount(); + } + + ledgerReport +=3D""; + } + } + + for (Object objectList : subList) { + if (objectList instanceof Entry) { + Entry entry =3D (Entry) objectList; + if (entry.getDebit()) { + currentAmountDebit =3D currentAmountDebi= t.add(entry.getAmount()); + } else { + currentAmountCredit =3D currentAmountCre= dit.add(entry.getAmount()); + } + } else { + ReportsDatas reportsDatas =3D (ReportsDatas)= objectList; + Account account =3D reportsDatas.getAccount(= ); + if (account !=3D null) { + accountcarry =3D account.getAccountNumbe= r() + + " " + account.getLabel= () + " "; + } + } + } + //forward amounts + if (n > max && i <=3D n - max) { + String [] columnsTable =3D {"", boldBegin + _("l= ima-business.document.carryforward") + boldEnd, + boldBegin + currentAmountDebit.toString(= ) + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, + boldBegin + currentAmountDebit.subtract(= currentAmountCredit).toString() + boldEnd}; + ledgerReport +=3D constructColumnsHtml(columnsTa= ble); + } + //final amounts + if (i >=3D n - max) { + String [] columnsTable =3D { boldBegin + _("lima= -business.document.amounts") + boldEnd, + boldBegin + currentAmountDebit.toString(= ) + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, + boldBegin + currentAmountDebit.subtract(= currentAmountCredit).toString() + boldEnd}; + ledgerReport +=3D constructColumnsHtml(columnsTa= ble); + } + i =3D i + max; } + ledgerReport +=3D "
"; + ledgerReport +=3D "\n" + + "\n"; + String [] columnsEntry =3D {boldBegin + _("lima-= business.document.date")+ boldEnd, + boldBegin + _("lima-business.document.en= trybook") + boldEnd, boldBegin + _("lima-business.document.voucher") + boldEn= d, + boldBegin + _("lima-business.document.de= scription") + boldEnd, boldBegin + _("lima-business.document.debit") + boldEn= d, + boldBegin + _("lima-business.document.cr= edit") + boldEnd, boldBegin + _("lima-business.document.solde") + boldEnd}; + ledgerReport +=3D constructColumnsHtml(columnsEn= try); + + String [] columnsTable =3D {_("lima-business.doc= ument.dateformat",entry.getFinancialTransaction().getTransactionDate()), + entryBookCode, entry.getVoucher(), entry= .getDescription(), + amountDebit.toString(), amountCredit.toS= tring(), amountDebit.subtract(amountCredit).toString()}; + ledgerReport +=3D constructColumnsHtml(columnsTa= ble); + ledgerReport +=3D "
" + + "
\n"; + }catch (Exception ex) { + log.error("Can't create document", ex); } - } catch (DocumentException eeDE) { - log.error("Can't create table", eeDE); - } - return t; + return ledgerReport; } =20 - protected Table createLedgerAmountTable(String account, - String title, - BigDecimal debit, - BigDecimal credit) { - Table t =3D null; - try { - t =3D new Table(5, 1); - float[] widths =3D {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 =3D new Cell(); - cell.setBorder(Rectangle.RIGHT); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - t.setDefaultCell(cell); - Cell accountCell =3D 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 =3D 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 =3D "" + ""; String boldItalicEnd =3D "" + ""; =20 - String [] columnsNameSociety =3D {boldItalicBegin + _("l= ima-business.document.society") + - boldItalicEnd, "" + identity.getName()+ "= "}; + String [] columnsNameSociety =3D {boldItalicBegin + iden= tity.getName()+ boldItalicEnd}; balanceReport +=3D constructColumnsHtml(columnsNameSocie= ty); =20 balanceReport +=3D "\n"; - String [] columnsBusinessNumber =3D {boldItalicBegin + _= ("lima-business.document.businessnumber") + - boldItalicEnd, "" + identity.getBusinessNumbe= r()+ ""}; - balanceReport +=3D constructColumnsHtml(columnsBusinessN= umber); + String [] columnsDescription =3D {"" + identity.getDe= scription()+ ""}; + balanceReport +=3D constructColumnsHtml(columnsDescripti= on); =20 balanceReport +=3D "\n"; - String [] columnsDescription =3D {boldItalicBegin + _("l= ima-business.document.description") + boldItalicEnd, - "" + identity.getDescription()+ ""}; - balanceReport +=3D constructColumnsHtml(columnsDescripti= on); + String [] columnsAdressOne =3D {"" + identity.getAddr= ess() + ""}; + balanceReport +=3D constructColumnsHtml(columnsAdressOne= ); =20 balanceReport +=3D "\n"; - String [] columnsClassifCode =3D {boldItalicBegin + _("l= ima-business.document.classificationcode") + - boldItalicEnd, "" + identity.getClassificatio= nCode()+ ""}; - balanceReport +=3D constructColumnsHtml(columnsClassifCo= de); + String [] columnsAdressTwo =3D {"" + identity.getAddr= ess2() + ""}; + balanceReport +=3D constructColumnsHtml(columnsAdressTwo= ); =20 balanceReport +=3D "\n"; - String [] columnsVatNumber =3D {boldItalicBegin + _("lim= a-business.document.vatnumber") + boldItalicEnd, - "" + identity.getVatNumber()+ "", }; - balanceReport +=3D constructColumnsHtml(columnsVatNumber= ); + String [] columnsZipCode =3D {"" + identity.getZipCod= e() + ""}; + balanceReport +=3D constructColumnsHtml(columnsZipCode); =20 balanceReport +=3D "\n"; - String [] columnsAdressOne =3D {boldItalicBegin + _("lim= a-business.document.adress") + boldItalicEnd, - "" + identity.getAddress() + ""}; - balanceReport +=3D constructColumnsHtml(columnsAdressOne= ); + String [] columnsCity =3D {"" + identity.getCity()+ "= "}; + balanceReport +=3D constructColumnsHtml(columnsCity); =20 + balanceReport +=3D "\n" + + "" + + "" + + "

" + _("lima-= business.document.balance") + "

" + + "" + + "" + + "\n"; + balanceReport +=3D "\n"; - String [] columnsAdressTwo =3D {boldItalicBegin + _("lim= a-business.document.adresssuite") + boldItalicEnd, - "" + identity.getAddress2() + ""}; - balanceReport +=3D constructColumnsHtml(columnsAdressTwo= ); + String [] columnsBusinessNumber =3D {boldItalicBegin + _= ("lima-business.document.businessnumber") + + boldItalicEnd, "" + identity.getBusinessNumbe= r()+ ""}; + balanceReport +=3D constructColumnsHtml(columnsBusinessN= umber); =20 balanceReport +=3D "\n"; - String [] columnsZipCode =3D {boldItalicBegin + _("lima-= business.document.zipcode") + boldItalicEnd, - "" + identity.getZipCode() + ""}; - balanceReport +=3D constructColumnsHtml(columnsZipCode); + String [] columnsClassifCode =3D {boldItalicBegin + _("l= ima-business.document.classificationcode") + + boldItalicEnd, "" + identity.getClassificatio= nCode()+ ""}; + balanceReport +=3D constructColumnsHtml(columnsClassifCo= de); =20 balanceReport +=3D "\n"; - String [] columnsCity =3D {boldItalicBegin + _("lima-bus= iness.document.city") + boldItalicEnd, - "" + identity.getCity()+ ""}; - balanceReport +=3D constructColumnsHtml(columnsCity); + String [] columnsVatNumber =3D {boldItalicBegin + _("lim= a-business.document.vatnumber") + boldItalicEnd, + "" + identity.getVatNumber()+ "", }; + balanceReport +=3D constructColumnsHtml(columnsVatNumber= ); =20 balanceReport +=3D "\n"; String [] columnsPeriodOne =3D {boldItalicBegin + _("lim= a-business.document.period1") + boldItalicEnd, "" @@ -925,12 +883,8 @@ + _("lima-business.document.period2format", endD= ate)+ ""}; balanceReport +=3D constructColumnsHtml(columnsPeriodTwo= ); =20 - balanceReport +=3D "
\n" + + balanceReport +=3D "" + "" + - "" + - "

" + _("lima-busi= ness.document.balance") + "

" + - "" + - "" + "" + "\n" + "\n"; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/Http= ServerServiceImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServer= ServiceImpl.java 2012-08-17 14:41:36 UTC (rev 3611) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServer= ServiceImpl.java 2012-08-17 17:24:10 UTC (rev 3612) @@ -163,6 +163,7 @@ String entryBooksReport =3D null; String generalEntryBooksReport =3D null; String balanceReport =3D null; + String ledgerReport =3D null; =20 //create docs try { @@ -197,8 +198,8 @@ beginDateFormat, endDateFormat, form= atsEnum); break; case LEDGER: - documentService.createLedgerDocuments( - beginDateFormat, endDateFormat, form= atsEnum); + ledgerReport =3D documentService.createLedge= rDocuments( + beginDateFormat, endDateFormat); break; case VAT: documentService.createVatDocuments( @@ -224,7 +225,7 @@ resp.setContentType(formatsEnum.getMimeType()); OutputStream out =3D resp.getOutputStream(); if (accountReport !=3D null || entryBooksReport !=3D nul= l || generalEntryBooksReport !=3D null - || balanceReport !=3D null) { + || balanceReport !=3D null || ledgerReport !=3D null= ) { String report =3D null; if (accountReport !=3D null) { report =3D accountReport; @@ -232,8 +233,10 @@ report =3D entryBooksReport; } else if (generalEntryBooksReport !=3D null) { report =3D generalEntryBooksReport; + } else if (balanceReport !=3D null) { + report =3D balanceReport; } else { - report =3D balanceReport; + report =3D ledgerReport; } IOUtils.write(report, out, Charsets.UTF_8); } else { Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.pro= perties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.propertie= s 2012-08-17 14:41:36 UTC (rev 3611) +++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.propertie= s 2012-08-17 17:24:10 UTC (rev 3612) @@ -17,7 +17,7 @@ lima-business.defaultaccountingrules.invalidaccountnumber=3DNum=C3=A9ro de c= ompte invalide \: %d lima-business.defaultaccountingrules.missingelements=3DImpossible de bloquer= la p=C3=A9riode financi=C3=A8re / il manque des =C3=A9l=C3=A9ments dans des = transactions lima-business.defaultaccountingrules.missingentrybook=3DImpossible de bloque= r la p=C3=A9riode financi=C3=A8re / il manque un journal dans une transaction= (%1$te/%1$tm/%1$tY) -lima-business.document.account=3D +lima-business.document.account=3DCompte lima-business.document.accountnumber=3DN=C2=B0 Compte lima-business.document.adress=3DAdresse lima-business.document.adresssuite=3DAdresse - suite Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/= DocumentService.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/Docume= ntService.java 2012-08-17 14:41:36 UTC (rev 3611) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/Docume= ntService.java 2012-08-17 17:24:10 UTC (rev 3612) @@ -40,7 +40,7 @@ =20 void createFinancialStatementsDocuments(Date beginDate, Date endDate, Fo= rmatsEnum format) throws LimaException; =20 - void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum for= mat) throws LimaException; + String createLedgerDocuments(Date beginDate, Date endDate) throws LimaEx= ception; =20 String createBalanceDocuments(Date beginDate, Date endDate) throws LimaE= xception; =20 Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView= .jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 @@ ]]> =20 - + - + - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView= Handler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandle= r.java 2012-08-17 14:41:36 UTC (rev 3611) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandle= r.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*/ { =20 protected LedgerView view; =20 @@ -84,13 +84,8 @@ protected LedgerViewHandler(LedgerView view) { this.view =3D view; =20 - reportService =3D - LimaServiceFactory.getService(ReportService.class); - LimaServiceFactory.addServiceListener(ReportService.class, this); fiscalPeriodService =3D LimaServiceFactory.getService(FiscalPeriodSe= rvice.class); financialPeriodService =3D LimaServiceFactory.getService(FinancialPe= riodService.class); - LimaServiceFactory.addServiceListener(ImportService.class, this); - LimaServiceFactory.addServiceListener(FinancialTransactionService.cl= ass, this); } =20 /** @@ -104,133 +99,37 @@ view.getIntervalPanel().init(fiscalPeriod, financialPeriod); } =20 - public void intervalChanged() { - refreshData(); - } - - public void accountFilterChanged() { - refreshData(); - } - =20 - public void movmentedFilterChanged() { - refreshData(); - } - - /** - * Refresh table data depending on item selected on combo boxes. - */ - protected void refreshData() { - =20 - Date beginDate =3D view.getIntervalPanel().getBeginDate(); - Date endDate =3D view.getIntervalPanel().getEndDate(); - - String account =3D view.getBalanceFilter().getText().trim(); - =20 - if (beginDate !=3D null && endDate !=3D null) { - BalanceTrial balanceTrial =3D reportService.generateLedger(begin= Date, - endDate, account, view.getMovmentedFilter().isSelected()= ); - =20 - LedgerTableModel dataModel =3D view.getLedgerTableModel(); - =20 - List results =3D new ArrayList(); - for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas())= { - results.add(reportsDatas); - List entries =3D reportsDatas.getListEntry(); - if (entries !=3D null) { - Collections.sort(entries, new EntryComparator()); - results.addAll(entries); - } - } - dataModel.setObjects(results); - =20 - updateFooter(balanceTrial); - } - } - - /** - * Update footer labels containing reports total sum fields. - *=20 - * @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 =3D 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")); - } - } - } - =20 public void createDocument() { =20 Date beginDate =3D view.getIntervalPanel().getBeginDate(); Date endDate =3D view.getIntervalPanel().getEndDate(); =20 if (beginDate !=3D null && endDate !=3D null) { + String address =3D LimaConfig.getInstance().getHostAdress(); =20 - //looks for all blocked fiscal periods - List blockedFiscalPeriods =3D fiscalPeriodService.= getAllBlockedFiscalPeriods(); - - //tells if the fiscaPeriod as been found and is blocked - boolean error =3D true; - - for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) { - if (blockedFiscalPeriod.getBeginDate().equals(beginDate) - && blockedFiscalPeriod.getEndDate().equals(endDate) - && blockedFiscalPeriod.getLocked()) { - error =3D false; - } + try { + int port =3D LimaServiceFactory.getService(HttpServerService= .class).getHttpPort(); + String url =3D "http://" + address + ":" + port + "/?beginDa= te=3D" + + dateFormat.format(beginDate) + + "&endDate=3D" + dateFormat.format(endDate) + + "&format=3D.html&model=3D" + + 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 =3D (FormatsEnum) view.getDocumentE= ditor().getSelectedItem(); - String address =3D LimaConfig.getInstance().getHostAdress(); - - try { - int port =3D LimaServiceFactory.getService(HttpServerSer= vice.class).getHttpPort(); - String url =3D "http://" + address + ":" + port + "/?beg= inDate=3D" - + dateFormat.format(beginDate) - + "&endDate=3D" + dateFormat.format(endDate) - + "&format=3D" + selectedEnum.getExtension(= ) + "&model=3D" - + 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); - } - } } } =20 - @Override + /* @Override public void notifyMethod(String serviceName, String methodName) { if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) { refreshData(); } - } + }*/ =20 } --===============1671824003847557741==--