Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
August 2012
- 5 participants
- 86 discussions
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
by mallon@users.chorem.org 17 Aug '12
by mallon@users.chorem.org 17 Aug '12
17 Aug '12
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();
}
- }
+ }*/
}
1
0
r3611 - 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 lima-swing/src/main/java/org/chorem/lima/ui/balance
by mallon@users.chorem.org 17 Aug '12
by mallon@users.chorem.org 17 Aug '12
17 Aug '12
Author: mallon
Date: 2012-08-17 16:41:36 +0200 (Fri, 17 Aug 2012)
New Revision: 3611
Url: http://chorem.org/repositories/revision/lima/3611
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition de la balance.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
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_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.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 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -816,7 +816,7 @@
entryBookReport += "</table></p>\n";
}
}
- entryBookReport += "</body>\n";
+ entryBookReport += "</body>\n</html>";
}
} catch (Exception ex) {
throw new LimaException("Can't create document", ex);
@@ -828,213 +828,177 @@
//############## Balance ##############
@Override
- public void createBalanceDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+ public String createBalanceDocuments(Date beginDate,
+ Date endDate) throws LimaException {
BalanceTrial balanceTrial =
reportService.generateBalanceTrial(beginDate, endDate, null, false, true);
List<ReportsDatas> list = (List<ReportsDatas>) balanceTrial.getReportsDatas();
- try {
- Date newDate = new Date();
+ String balanceReport = "";
+ balanceReport += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
- BigDecimal currentAmountDebit = new BigDecimal(0);
- BigDecimal currentAmountCredit = new BigDecimal(0);
- BigDecimal currentSoldeDebit = new BigDecimal(0);
- BigDecimal currentSoldeCredit = new BigDecimal(0);
+ if (beginDate != null && endDate != null) {
+ try{
+ BigDecimal currentAmountDebit = new BigDecimal(0);
+ BigDecimal currentAmountCredit = new BigDecimal(0);
+ BigDecimal currentSoldeDebit = new BigDecimal(0);
+ BigDecimal currentSoldeCredit = new BigDecimal(0);
- String filePath = path + File.separator + DocumentsEnum.BALANCE.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();
+ Identity identity = identityService.getIdentity();
- //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 = 26;
- }
- while (i < n) {
- int j = i + max;
- if (j > n) {
- j = n;
- }
- List<ReportsDatas> subList = list.subList(i, j);
- //create page : header + table + footer
- Table headerTable = createBalanceHeaderTable();
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(DocumentsEnum.BALANCE.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(createBalanceAmountTable(
- _("lima-business.document.carryback"),
- currentAmountDebit, currentAmountCredit,
- currentSoldeDebit, currentSoldeCredit));
- chapter.add(backwardParagraph);
- }
- //table
- Paragraph paragraphTable = new Paragraph();
- Table table = createBalanceTable(subList);
- paragraphTable.add(table);
- chapter.add(paragraphTable);
- for (ReportsDatas reportsDatas : subList) {
- currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit());
- currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit());
- if (reportsDatas.getSoldeDebit()) {
- currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde());
- } else {
- currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde());
+ //create pages
+ int i = 0;
+ int n = list.size();
+ int max = n;
+
+ while (i < n) {
+ int j = i + max;
+ if (j > n) {
+ j = n;
}
- }
- //forward amounts
- if (n > max && i <= n - max) {
- Paragraph forwardParagraph = new Paragraph();
- forwardParagraph.add(createBalanceAmountTable(
- _("lima-business.document.carryforward"),
- currentAmountDebit, currentAmountCredit,
- currentSoldeDebit, currentSoldeCredit));
- chapter.add(forwardParagraph);
- }
- //final amounts
- if (i >= n - max) {
- Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createBalanceAmountTable(
- _("lima-business.document.amounts"),
- currentAmountDebit, currentAmountCredit,
- currentSoldeDebit, currentSoldeCredit));
- chapter.add(finalAmountParagraph);
- }
- //add page
- document.add(chapter);
- i = i + max;
- nbpages++;
- }
- document.close();
+ List<ReportsDatas> subList = list.subList(i, j);
- } catch (FileNotFoundException eeFNFE) {
- log.error("Can't create pdf file", eeFNFE);
- } catch (DocumentException eeDE) {
- log.error("Can't create document", eeDE);
- }
- }
+ balanceReport += "<body>\n" +
+ "<table>" +
+ "<tr> " +
+ "<td>" +
+ "<table align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"font-size:13px;\" >\n" +
+ "<tr>\n";
- public Table createBalanceHeaderTable() {
- Table t = null;
- try {
- t = new Table(6, 1);
- float[] widths = {0.07f, 0.33f, 0.15f, 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.accountnumber"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.description"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.movementdebit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.movementcredit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.soldedebit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.soldecredit"), boldFont));
+ String boldItalicBegin = "<b>" + "<i>";
+ String boldItalicEnd = "</i>" + "</b>";
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
+ String [] columnsNameSociety = {boldItalicBegin + _("lima-business.document.society") +
+ boldItalicEnd, "<i>" + identity.getName()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsNameSociety);
- }
+ balanceReport += "<tr>\n";
+ String [] columnsBusinessNumber = {boldItalicBegin + _("lima-business.document.businessnumber") +
+ boldItalicEnd, "<i>" + identity.getBusinessNumber()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsBusinessNumber);
- public Table createBalanceTable(List<ReportsDatas> subList) {
- int nbrow = subList.size();
- Table t = null;
- try {
- //define table
- t = new Table(6, nbrow);
- t.setWidth(100f);
- float[] widths = {0.07f, 0.33f, 0.15f, 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);
+ balanceReport += "<tr>\n";
+ String [] columnsDescription = {boldItalicBegin + _("lima-business.document.description") + boldItalicEnd,
+ "<i>" + identity.getDescription()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsDescription);
- for (ReportsDatas reportsDatas : subList) {
+ balanceReport += "<tr>\n";
+ String [] columnsClassifCode = {boldItalicBegin + _("lima-business.document.classificationcode") +
+ boldItalicEnd, "<i>" + identity.getClassificationCode()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsClassifCode);
- String soldeDebit = String.valueOf(reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0);
- String soldeCredit = String.valueOf(reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde());
+ balanceReport += "<tr>\n";
+ String [] columnsVatNumber = {boldItalicBegin + _("lima-business.document.vatnumber") + boldItalicEnd,
+ "<i>" + identity.getVatNumber()+ "</i>", };
+ balanceReport += constructColumnsHtml(columnsVatNumber);
- t.addCell(new Phrase(reportsDatas.getAccount().getAccountNumber(), normalFont));
- t.addCell(new Phrase(reportsDatas.getAccount().getLabel(), normalFont));
- t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountDebit()), normalFont));
- t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountCredit()), normalFont));
- t.addCell(new Phrase(soldeDebit, normalFont));
- t.addCell(new Phrase(soldeCredit, normalFont));
- }
- } catch (DocumentException eeDE) {
- log.error("Can't create table", eeDE);
+ balanceReport += "<tr>\n";
+ String [] columnsAdressOne = {boldItalicBegin + _("lima-business.document.adress") + boldItalicEnd,
+ "<i>" + identity.getAddress() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsAdressOne);
- }
- return t;
- }
+ balanceReport += "<tr>\n";
+ String [] columnsAdressTwo = {boldItalicBegin + _("lima-business.document.adresssuite") + boldItalicEnd,
+ "<i>" + identity.getAddress2() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsAdressTwo);
- public Table createBalanceAmountTable(String title,
- BigDecimal amountDebit,
- BigDecimal amountCredit,
- BigDecimal soldeDebit,
- BigDecimal soldeCredit) {
- 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);
+ balanceReport += "<tr>\n";
+ String [] columnsZipCode = {boldItalicBegin + _("lima-business.document.zipcode") + boldItalicEnd,
+ "<i>" + identity.getZipCode() + "</i>"};
+ balanceReport += constructColumnsHtml(columnsZipCode);
- t.addCell(new Phrase(title, boldFont));
- t.addCell(new Phrase(amountDebit.toString(), boldFont));
- t.addCell(new Phrase(amountCredit.toString(), boldFont));
- t.addCell(new Phrase(soldeDebit.toString(), boldFont));
- t.addCell(new Phrase(soldeCredit.toString(), boldFont));
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
+ balanceReport += "<tr>\n";
+ String [] columnsCity = {boldItalicBegin + _("lima-business.document.city") + boldItalicEnd,
+ "<i>" + identity.getCity()+ "</i>"};
+ balanceReport += constructColumnsHtml(columnsCity);
+
+ balanceReport += "<tr>\n";
+ String [] columnsPeriodOne = {boldItalicBegin + _("lima-business.document.period1") + boldItalicEnd, "<i>"
+ + _("lima-business.document.period1format", beginDate)+ "</i>"};
+ 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 += "</table>\n" +
+ "</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";
+
+ 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);
+
+ if (n > max) {
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+ 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 += "</table>\n";
+ }
+
+ for (ReportsDatas reportsDatas : subList) {
+ String soldeDebit = String.valueOf(reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0);
+ String soldeCredit = String.valueOf(reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde());
+
+ String [] columnsBalanceAmount = {reportsDatas.getAccount().getAccountNumber(), reportsDatas.getAccount().getLabel(),
+ reportsDatas.getAmountDebit().toString(), reportsDatas.getAmountCredit().toString(),
+ soldeDebit, soldeCredit};
+ balanceReport += constructColumnsHtml(columnsBalanceAmount);
+ }
+
+ for (ReportsDatas reportsDatas : subList) {
+ currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit());
+ currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit());
+ if (reportsDatas.getSoldeDebit()) {
+ currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde());
+ } else {
+ currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde());
+ }
+ }
+
+ if (n > max && i <= n - max) {
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+ 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 += "</table>\n";
+ }
+
+ //final amounts
+ if (i >= n - max) {
+ String boldBegin = "<b>";
+ String boldEnd = "</b>";
+ 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 += "</table>\n";
+ }
+ i = i + max;
+ }
+ balanceReport += "</body>\n</html>";
+ } catch (Exception ex) {
+ log.error("Can't create document", ex);
+ }
}
- return t;
+
+ return balanceReport;
}
//############## General EntryBook ##############
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 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -162,6 +162,7 @@
String accountReport = null;
String entryBooksReport = null;
String generalEntryBooksReport = null;
+ String balanceReport = null;
//create docs
try {
@@ -170,8 +171,8 @@
switch (DocumentsEnum.valueOfLink(model)) {
case BALANCE:
- documentService.createBalanceDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
+ balanceReport = documentService.createBalanceDocuments(
+ beginDateFormat, endDateFormat);
break;
case ACCOUNT:
accountReport = documentService.createAccountDocument(
@@ -222,14 +223,17 @@
}
resp.setContentType(formatsEnum.getMimeType());
OutputStream out = resp.getOutputStream();
- if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null) {
+ if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null
+ || balanceReport != null) {
String report = null;
if (accountReport != null) {
report = accountReport;
} else if (entryBooksReport != null) {
report = entryBooksReport;
+ } else if (generalEntryBooksReport != null) {
+ report = generalEntryBooksReport;
} else {
- report = generalEntryBooksReport;
+ report = balanceReport;
}
IOUtils.write(report, out, Charsets.UTF_8);
} else {
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-17 14:41:36 UTC (rev 3611)
@@ -19,12 +19,15 @@
lima-business.defaultaccountingrules.missingentrybook=Can't block financialperiod / missing EntryBook in transactions
lima-business.document.account=
lima-business.document.accountnumber=Account N°
+lima-business.document.adress=
+lima-business.document.adresssuite=
lima-business.document.amounts=Amounts
lima-business.document.amountsperiod=Amounts %1$tB %1$tY
lima-business.document.balance=Balance
lima-business.document.businessnumber=Business N°
lima-business.document.carryback=Carry Back
lima-business.document.carryforward=reporterÀ
+lima-business.document.city=
lima-business.document.classificationcode=Classification Code
lima-business.document.createdate=Editing Date %1$tm/%1$te/%1$tY at %1$tH\:%1$tM
lima-business.document.credit=Credit
@@ -52,12 +55,14 @@
lima-business.document.period2=to
lima-business.document.period2format=%1$tm/%1$te/%1$tY
lima-business.document.provisiondeprecationamount=Provision Deprecation Amount
+lima-business.document.society=
lima-business.document.solde=Solde
lima-business.document.soldecredit=Credit solde
lima-business.document.soldedebit=Debit solde
lima-business.document.vat=VAT form
lima-business.document.vatnumber=VAT N°
lima-business.document.voucher=Voucher
+lima-business.document.zipcode=
lima-business.entrybook.entrybookalreadyexist=An EntryBook already exists with this label \: %s
lima-business.financialstatement.check.nothing=Not found \: %s - %s \n
lima-business.financialstatement.check.warn=Warning this function is just an help.\n Many accounts must no calculate on Financial statement.\n Some account marked not found is normally.\n\n
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 14:41:36 UTC (rev 3611)
@@ -19,12 +19,15 @@
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.accountnumber=N° Compte
+lima-business.document.adress=Adresse
+lima-business.document.adresssuite=Adresse - suite
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.city=Ville
lima-business.document.classificationcode=NAF
lima-business.document.createdate=Date de tirage %1$te/%1$tm/%1$tY à %1$tH\:%1$tM
lima-business.document.credit=Crédit
@@ -52,12 +55,14 @@
lima-business.document.period2=au
lima-business.document.period2format=%1$te/%1$tm/%1$tY
lima-business.document.provisiondeprecationamount=Amortissements et provisions
+lima-business.document.society=Nom
lima-business.document.solde=Solde
lima-business.document.soldecredit=Solde Créditeur
lima-business.document.soldedebit=Solde Débiteur
lima-business.document.vat=Déclaration de TVA
lima-business.document.vatnumber=N° TVA
lima-business.document.voucher=Pièce comptable
+lima-business.document.zipcode=Code postal
lima-business.entrybook.entrybookalreadyexist=Un journal existe déjà avec ce libellé \: %s
lima-business.financialstatement.check.nothing=Introuvable \: %s - %s \n
lima-business.financialstatement.check.warn=Attention cette fonctionnalité n'est qu'une aide utilisateur.\n Certains comptes ne doivent pas être présent au bilan et compte de résultat.\n Il est donc normal que des comptes sont marqués comme introuvable.\n\n
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -42,7 +42,7 @@
void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
- void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ String createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
String createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -38,7 +38,7 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.accountsreports.AccountsReportsView;
-import org.chorem.lima.ui.balance.BalanceView;
+import org.chorem.lima.ui.balance.BalanceReportsView;
import org.chorem.lima.ui.entrybook.EntryBookView;
import org.chorem.lima.ui.entrybooksreports.EntryBooksReportsView;
import org.chorem.lima.ui.financialperiod.FinancialPeriodView;
@@ -451,7 +451,7 @@
public void showBalanceView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- BalanceView balanceView = new BalanceView(mainView);
+ BalanceReportsView balanceView = new BalanceReportsView(mainView);
showTab(mainView, _("lima.reports.balance"), balanceView);
swingSession.add(balanceView);
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx (from rev 3587, trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx 2012-08-17 14:41:36 UTC (rev 3611)
@@ -0,0 +1,56 @@
+<!--
+ #%L
+ Lima Swing
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<Table>
+
+ <import>
+ javax.swing.ListSelectionModel
+ javax.swing.text.Document
+ org.jdesktop.swingx.decorator.HighlighterFactory
+ org.chorem.lima.business.utils.FormatsEnum
+ org.chorem.lima.enums.ComboBoxDatesEnum
+ org.chorem.lima.ui.common.IntervalPanel
+ </import>
+
+ <BalanceReportsViewHandler id="handler" constructorParams="this"/>
+
+ <script>
+ <![CDATA[
+ void $afterCompleteSetup() {
+ handler.init();
+ }
+
+ ]]>
+ </script>
+ <row>
+ <cell columns="1">
+ <IntervalPanel id="intervalPanel"/>
+ </cell>
+ <cell>
+ <JButton text="lima.common.ok"
+ onActionPerformed="getHandler().createDocument()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java (from rev 3587, trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -0,0 +1,110 @@
+/*
+ * #%L
+ * Lima Swing
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.ui.balance;
+
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.api.FiscalPeriodService;
+import org.chorem.lima.business.api.HttpServerService;
+import org.chorem.lima.business.api.ReportService;
+import org.chorem.lima.business.utils.DocumentsEnum;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Handler associated with accounts reports view.
+ * By : $Author$
+ */
+public class BalanceReportsViewHandler {
+
+ protected BalanceReportsView view;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(BalanceReportsViewHandler.class);
+
+ /** Services. */
+ protected ReportService reportService;
+ protected HttpServerService httpServerServiceMonitorable;
+ protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
+
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+
+ protected BalanceReportsViewHandler(BalanceReportsView view) {
+ this.view = view;
+
+ reportService = LimaServiceFactory.getService(ReportService.class);
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
+ }
+
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllBlockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
+ }
+
+ public void createDocument() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ if (beginDate != null & endDate != null) {
+ 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=.html&model="
+ + DocumentsEnum.BALANCE.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);
+ }
+ }
+ }
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceReportsViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2012-08-17 14:41:36 UTC (rev 3611)
@@ -1,113 +0,0 @@
-<!--
- #%L
- Lima Swing
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-
-<Table>
-
- <import>
- javax.swing.ListSelectionModel
- javax.swing.text.Document
- org.jdesktop.swingx.decorator.HighlighterFactory
- org.chorem.lima.business.utils.FormatsEnum
- org.chorem.lima.enums.ComboBoxDatesEnum
- org.chorem.lima.ui.common.IntervalPanel
- </import>
-
- <BalanceViewHandler id="handler" constructorParams="this"/>
-
- <script>
- <![CDATA[
- void $afterCompleteSetup() {
- handler.init();
- }
-
- ]]>
- </script>
- <row weightx="1" weighty="0" anchor="center">
- <cell fill='both'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
- </cell>
- <cell anchor="east">
- <JLabel text="lima.common.filter"/>
- </cell>
- <cell anchor="west">
- <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter"
- minimumSize='{balanceFilter.getPreferredSize()}'/>
- <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='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>
- <BalanceTableModel id="balanceTableModel" />
- <BalanceTable id="balanceTable"
- rowHeight="24"
- model="{balanceTableModel}"
- highlighters="{HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- columnControlVisible="true"/>
- </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 text="lima.common.solde"/>
- </cell>
- <cell>
- <JLabel id="amountSoldeLabel"/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-08-17 11:03:36 UTC (rev 3610)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-08-17 14:41:36 UTC (rev 3611)
@@ -1,216 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.balance;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.Desktop;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.JOptionPane;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaConfig;
-import org.chorem.lima.beans.BalanceTrial;
-import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.business.api.FinancialPeriodService;
-import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.api.FiscalPeriodService;
-import org.chorem.lima.business.api.HttpServerService;
-import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.api.ReportService;
-import org.chorem.lima.business.utils.DocumentsEnum;
-import org.chorem.lima.business.utils.FormatsEnum;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.service.LimaServiceFactory;
-
-/**
- * Handler associated with accounts reports view.
- * By : $Author$
- */
-public class BalanceViewHandler implements ServiceListener {
-
- protected BalanceView view;
-
- /** log. */
- private static final Log log = LogFactory.getLog(BalanceViewHandler.class);
-
- /** Services. */
- protected ReportService reportService;
- protected HttpServerService httpServerServiceMonitorable;
- protected FiscalPeriodService fiscalPeriodService;
- protected FinancialPeriodService financialPeriodService;
-
- private static SimpleDateFormat dateFormat =
- new SimpleDateFormat("yyyy-MM-dd");
-
- protected BalanceViewHandler(BalanceView view) {
- this.view = view;
-
- reportService = LimaServiceFactory.getService(ReportService.class);
- fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
- financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
- }
-
- /**
- * Init data models and displayed objects.
- */
- public void init() {
-
- // init data models
- List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
- 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.generateBalanceTrial(beginDate,
- endDate, account, false, view.getMovmentedFilter().isSelected());
-
- BalanceTableModel dataModel = view.getBalanceTableModel();
- dataModel.setBalanceTrial(balanceTrial);
-
- 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) {
-
- //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;
- }
- }
-
- //shows error message to user if the fiscalPeriod is unblocked
- if (error) {
- JOptionPane.showMessageDialog(
- view,
- _("lima.balance.documentcreationfiscalerror"),
- _("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.BALANCE.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
- public void notifyMethod(String serviceName, String methodName) {
- if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) {
- refreshData();
- }
- }
-}
1
0
17 Aug '12
Author: mallon
Date: 2012-08-17 13:03:36 +0200 (Fri, 17 Aug 2012)
New Revision: 3610
Url: http://chorem.org/repositories/revision/lima/3610
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition des journaux et du journal general.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
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_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
trunk/lima-swing/src/main/resources/log4j.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-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -28,7 +28,6 @@
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
-import com.lowagie.text.DocWriter;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
@@ -129,8 +128,6 @@
private static final Font bolditalicFont =
new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK);
- private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("dd-MM-yyyy");
-
public DocumentServiceImpl() {
path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
@@ -730,160 +727,102 @@
}
@Override
- public void createEntryBooksDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
-
+ public String createEntryBooksDocuments(Date beginDate,
+ Date endDate) throws LimaException {
+ String entryBookReport;
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMMM yyyy");
try {
- Date newDate = new Date();
+ entryBookReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
- String filePath = path + File.separator + DocumentsEnum.ENTRYBOOKS.getFileName();
- FileOutputStream fileOut = new FileOutputStream(filePath + format.getExtension());
- DocWriter writer = null;
- switch (format) {
- case HTML:
- writer = HtmlWriter.getInstance(document, fileOut);
- break;
- case PDF:
- writer = PdfWriter.getInstance(document, fileOut);
- break;
- }
- document.open();
- int nbpages = 1;
+ String titre = _("lima-business.document.entrybooks");
+ entryBookReport += constructHeadHtml(titre);
- Identity identity = identityService.getIdentity();
+ if (beginDate != null && endDate != null) {
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- getDaoHelper().getClosedPeriodicEntryBookDAO();
- EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- //Split list by financialstatement type
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
- closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- // TODO echatellier 20120509, was not about only
- // balanced transaction here, normal ?
- List<Entry> entries = entryDAO.findAllEntryByDateForEntryBook(closedPeriodicEntryBook.getEntryBook(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
- closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
+ //Split list by financialstatement type
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
+ closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
- List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
- closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- BigDecimal debit = BigDecimal.ZERO;
- BigDecimal credit = BigDecimal.ZERO;
- int nbAmount = results.size();
- if (nbAmount == 2) {
- debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
- }
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
- debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
- }
- }
+ entryBookReport += "<body>\n";
+ String journal = "";
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- //create pages
- String title = _("lima-business.document.entrybooktitle",
- closedPeriodicEntryBook.getEntryBook().getLabel(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+ // TODO echatellier 20120509, was not about only
+ // balanced transaction here, normal ?
+ List<Entry> entries = entryDAO.findAllEntryByDateForEntryBook(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- //create page
- Table table = createEntryBooksTable(entries, debit, credit);
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(title, identity,
- beginDate, endDate));
- //n° page
- chapter.add(createNumberPage(nbpages, newDate));
- //table
- Paragraph paragraphTable = new Paragraph();
- paragraphTable.add(table);
- chapter.add(paragraphTable);
- //add page
- document.add(chapter);
+ if (entries.size() > 0) {
+ List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
+ BigDecimal debit = BigDecimal.ZERO;
+ BigDecimal credit = BigDecimal.ZERO;
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
+ }
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
+ debit = (BigDecimal) results.get(0)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
+ }
+ }
- nbpages++;
- }
+ String subTitleSecPart = _("lima-business.document.date") + " : " +
+ simpleDateFormat.format(closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+ if (!journal.equals(closedPeriodicEntryBook.getEntryBook().getLabel())) {
+ entryBookReport += constructSubTitleHtml(_("lima-business.document.entrybook")
+ + " : " + closedPeriodicEntryBook.getEntryBook().getLabel(),
+ subTitleSecPart);
+ journal = closedPeriodicEntryBook.getEntryBook().getLabel();
+ } else {
+ entryBookReport += constructSubTitleHtml("", subTitleSecPart);
+ }
- document.close();
- writer.close();
- } catch (Exception ex) {
- throw new LimaException("Can't create document", ex);
- }
- }
-
- protected Table createEntryBooksTable(List<Entry> entries, BigDecimal debit, BigDecimal credit) {
- int nbrow = entries.size();
- Table t = null;
- try {
- //define table
- t = new Table(6, nbrow + 1);
- t.setWidth(100f);
- float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setPadding(1.5f);
- t.setBorderWidth(1);
- t.setOffset(0);
-
- Cell cell1 = new Cell(_("lima-business.document.date"));
- cell1.setHeader(true);
- t.addCell(cell1);
- Cell cell2 = new Cell(_("lima-business.document.accountnumber"));
- cell2.setHeader(true);
- t.addCell(cell2);
- Cell cell3 = new Cell(_("lima-business.document.voucher"));
- cell3.setHeader(true);
- t.addCell(cell3);
- Cell cell4 = new Cell(_("lima-business.document.description"));
- cell4.setHeader(true);
- t.addCell(cell4);
- Cell cell5 = new Cell(_("lima-business.document.debit"));
- cell5.setHeader(true);
- t.addCell(cell5);
- Cell cell6 = new Cell(_("lima-business.document.credit"));
- cell6.setHeader(true);
- t.addCell(cell6);
- t.endHeaders();
+ entryBookReport += "<p><table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
- //define default cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.LEFT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
+ String [] columnNames = {_("lima-business.document.date"), _("lima-business.document.accountnumber"),
+ _("lima-business.document.voucher"), _("lima-business.document.description"),
+ _("lima-business.document.debit"),
+ _("lima-business.document.credit")};
- for (Entry entry : entries) {
- t.addCell(new Phrase(_("lima-business.document.dateformat",
- entry.getFinancialTransaction().getTransactionDate()), normalFont));
- String account = "";
- if (entry.getAccount() != null) {
- account = entry.getAccount().getAccountNumber();
+ entryBookReport += constructColumnsHtml(columnNames);
+
+ for (Entry entry : entries) {
+ String numaccount = null;
+ if (entry.getAccount() != null) {
+ numaccount = entry.getAccount().getAccountNumber();
+ }
+ String [] columnData = {_("lima-business.document.dateformat", entry.getFinancialTransaction().getTransactionDate()),
+ (StringUtils.isBlank(numaccount)?"":numaccount), (StringUtils.isBlank(entry.getVoucher())?"":entry.getVoucher()),
+ (StringUtils.isBlank(entry.getDescription())?"":entry.getDescription()),
+ (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO).toString(),
+ (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()).toString()};
+
+ entryBookReport += constructColumnsHtml(columnData);
+ }
+ String [] columnDataTotal = {"", "", "", _("lima-business.document.amounts"), debit.toString(), credit.toString()};
+ entryBookReport += constructColumnsHtml(columnDataTotal);
+ entryBookReport += "</table></p>\n";
+ }
}
- t.addCell(new Phrase(account, normalFont));
- t.addCell(new Phrase(entry.getVoucher(), normalFont));
- t.addCell(new Phrase(entry.getDescription(), normalFont));
- t.addCell(new Phrase(String.valueOf(
- entry.getDebit() ? entry.getAmount() : 0), normalFont));
- t.addCell(new Phrase(String.valueOf(
- !entry.getDebit() ? entry.getAmount() : 0), normalFont));
+ entryBookReport += "</body>\n";
}
-
- // total
- Cell cellTotal = new Cell(new Phrase(_("lima-business.document.amounts"), boldFont));
- cellTotal.setColspan(4);
- cellTotal.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.addCell(cellTotal);
- t.addCell(new Phrase(debit.toString(), boldFont));
- t.addCell(new Phrase(credit.toString(), boldFont));
-
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
+ } catch (Exception ex) {
+ throw new LimaException("Can't create document", ex);
}
- return t;
+
+ return entryBookReport;
}
//############## Balance ##############
@@ -1102,221 +1041,143 @@
@Override
- public void createGeneralEntryBooksDocuments(Date beginDate,
- Date endDate,
- FormatsEnum format) throws LimaException {
+ public String createGeneralEntryBooksDocuments(Date beginDate,
+ Date endDate) throws LimaException {
- Document document = new Document(PageSize.A4, 8, 8, 8, 8);
-
+ String entryBookReport;
try {
+ entryBookReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
- Date newDate = new Date();
+ String titre = _("lima-business.document.entrybook");
+ entryBookReport += constructHeadHtml(titre);
- String filePath = path + File.separator + DocumentsEnum.GENERAL_ENTRYBOOK.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;
+ if (beginDate != null && endDate != null) {
- Identity identity = identityService.getIdentity();
+ FinancialPeriodDAO financialPeriodDAO =
+ getDaoHelper().getFinancialPeriodDAO();
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- FinancialPeriodDAO financialPeriodDAO =
- getDaoHelper().getFinancialPeriodDAO();
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- getDaoHelper().getClosedPeriodicEntryBookDAO();
- EntryDAO entryDAO = getDaoHelper().getEntryDAO();
+ List<FinancialPeriod> financialPeriods =
+ financialPeriodDAO.findByDates(beginDate, endDate);
- List<FinancialPeriod> financialPeriods =
- financialPeriodDAO.findByDates(beginDate, endDate);
+ List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>();
+ BigDecimal amountDebit = new BigDecimal(0);
+ BigDecimal amountCredit = new BigDecimal(0);
+ for (FinancialPeriod financialPeriod : financialPeriods) {
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
+ closedPeriodicEntryBookDAO.findAllByDates(
+ financialPeriod.getBeginDate(), financialPeriod.getEndDate());
- List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>();
- BigDecimal amountDebit = new BigDecimal(0);
- BigDecimal amountCredit = new BigDecimal(0);
- for (FinancialPeriod financialPeriod : financialPeriods) {
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
- closedPeriodicEntryBookDAO.findAllByDates(
- financialPeriod.getBeginDate(), financialPeriod.getEndDate());
+ BigDecimal subAmountDebit = new BigDecimal(0);
+ BigDecimal subAmountCredit = new BigDecimal(0);
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- BigDecimal subAmountDebit = new BigDecimal(0);
- BigDecimal subAmountCredit = new BigDecimal(0);
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
+ BigDecimal debit = BigDecimal.ZERO;
+ BigDecimal credit = BigDecimal.ZERO;
- BigDecimal debit = BigDecimal.ZERO;
- BigDecimal credit = BigDecimal.ZERO;
+ List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
- closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
-
- int nbAmount = results.size();
- if (nbAmount == 2) {
- debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
- }
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
}
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
+ debit = (BigDecimal) results.get(0)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
+ }
+ }
+ GeneralEntryBooksDatas generalEntryBooksDatas =
+ new GeneralEntryBooksDatasImpl();
+ generalEntryBooksDatas.setCode(
+ closedPeriodicEntryBook.getEntryBook().getCode());
+ generalEntryBooksDatas.setDescription(
+ closedPeriodicEntryBook.getEntryBook().getLabel());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entrybook code added : " + closedPeriodicEntryBook.getEntryBook().getCode());
+ log.debug("Entrybook desc. added : " + closedPeriodicEntryBook.getEntryBook().getLabel());
+ }
+
+ generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
+ generalEntryBooksDatas.setCredit(credit);
+ generalEntryBooksDatas.setDebit(debit);
+ list.add(generalEntryBooksDatas);
+ subAmountCredit = subAmountCredit.add(credit);
+ subAmountDebit = subAmountDebit.add(debit);
}
GeneralEntryBooksDatas generalEntryBooksDatas =
new GeneralEntryBooksDatasImpl();
- generalEntryBooksDatas.setCode(
- closedPeriodicEntryBook.getEntryBook().getCode());
- generalEntryBooksDatas.setDescription(
- closedPeriodicEntryBook.getEntryBook().getLabel());
+ generalEntryBooksDatas.setSubAmount(true);
+ generalEntryBooksDatas.setCredit(subAmountCredit);
+ generalEntryBooksDatas.setDebit(subAmountDebit);
generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
- generalEntryBooksDatas.setCredit(credit);
- generalEntryBooksDatas.setDebit(debit);
list.add(generalEntryBooksDatas);
- subAmountCredit = subAmountCredit.add(credit);
- subAmountDebit = subAmountDebit.add(debit);
+ amountCredit = amountCredit.add(subAmountCredit);
+ amountDebit = amountDebit.add(subAmountDebit);
}
GeneralEntryBooksDatas generalEntryBooksDatas =
new GeneralEntryBooksDatasImpl();
- generalEntryBooksDatas.setSubAmount(true);
- generalEntryBooksDatas.setCredit(subAmountCredit);
- generalEntryBooksDatas.setDebit(subAmountDebit);
- generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate());
+ generalEntryBooksDatas.setAmount(true);
+ generalEntryBooksDatas.setCredit(amountCredit);
+ generalEntryBooksDatas.setDebit(amountDebit);
list.add(generalEntryBooksDatas);
- amountCredit = amountCredit.add(subAmountCredit);
- amountDebit = amountDebit.add(subAmountDebit);
- }
- GeneralEntryBooksDatas generalEntryBooksDatas =
- new GeneralEntryBooksDatasImpl();
- generalEntryBooksDatas.setAmount(true);
- generalEntryBooksDatas.setCredit(amountCredit);
- generalEntryBooksDatas.setDebit(amountDebit);
- list.add(generalEntryBooksDatas);
+ entryBookReport += "<body>\n" +
+ "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
- //create pages
- Table headerTable = createGeneralEntryBooksHeaderTable();
- Table table = createGeneralEntryBooksTable(list);
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(
- DocumentsEnum.GENERAL_ENTRYBOOK.getDescription(),
- 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);
- nbpages++;
+ String[] columnNames = {_("lima-business.document.entrybook"), _("lima-business.document.label"),
+ _("lima-business.document.date"), _("lima-business.document.debit"),
+ _("lima-business.document.credit")};
- document.close();
+ entryBookReport += constructColumnsHtml(columnNames);
+ String entryBookCode = "";
- } catch (Exception ex) {
- throw new LimaException("Can't generate document", ex);
- }
- }
-
- protected Table createGeneralEntryBooksHeaderTable() {
- Table t = null;
- try {
- t = new Table(5, 1);
- float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f};
- 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.entrybook"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.label"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.date"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.debit"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.credit"), boldFont));
-
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
-
- }
-
- protected Table createGeneralEntryBooksTable(List<GeneralEntryBooksDatas> list) {
- int nbrow = list.size();
- Table t = null;
- try {
- //define table
- t = new Table(5, nbrow);
- t.setWidth(100f);
- float[] widths = {0.1f, 0.45f, 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);
-
- for (GeneralEntryBooksDatas generalEntryBooksDatas : list) {
- if (!generalEntryBooksDatas.getAmount() && !generalEntryBooksDatas.getSubAmount()) {
- t.addCell(new Phrase(
- generalEntryBooksDatas.getCode(), normalFont));
- t.addCell(new Phrase(
- generalEntryBooksDatas.getDescription(), normalFont));
- t.addCell(new Phrase(_("lima-business.document.monthformat", generalEntryBooksDatas.getPeriod()), normalFont));
- t.addCell(new Phrase(
- String.valueOf(generalEntryBooksDatas.getDebit()),
- normalFont));
- t.addCell(new Phrase(
- String.valueOf(generalEntryBooksDatas.getCredit()),
- normalFont));
- } else {
- Phrase phrase;
- if (generalEntryBooksDatas.getAmount()) {
- phrase = new Phrase(_("lima-business.document.amounts"),
- boldFont);
- } else {
- phrase = new Phrase(_("lima-business.document.amountsperiod", generalEntryBooksDatas.getPeriod()),
- boldFont);
+ for (GeneralEntryBooksDatas generalEntryBooksDataInList : list) {
+ if (!generalEntryBooksDataInList.getDebit().equals(BigDecimal.ZERO) && !generalEntryBooksDataInList.getCredit().equals(BigDecimal.ZERO)) {
+ if (!generalEntryBooksDataInList.getAmount() && !generalEntryBooksDataInList.getSubAmount()) {
+ String code;
+ String description;
+ if (!entryBookCode.equals(generalEntryBooksDataInList.getCode())) {
+ entryBookCode = generalEntryBooksDataInList.getCode();
+ code = entryBookCode;
+ description = generalEntryBooksDataInList.getDescription();
+ } else {
+ code = "";
+ description = "";
+ }
+ String[] columnData = {code, description,
+ _("lima-business.document.monthformat", generalEntryBooksDataInList.getPeriod()),
+ generalEntryBooksDataInList.getDebit().toString(),
+ generalEntryBooksDataInList.getCredit().toString()};
+ entryBookReport += constructColumnsHtml(columnData);
+ } else {
+ String amount;
+ if (generalEntryBooksDataInList.getAmount()) {
+ amount = _("lima-business.document.amounts");
+ } else {
+ amount = _("lima-business.document.amountsperiod", generalEntryBooksDataInList.getPeriod());
+ }
+ String[] columnDataTotal = {"", "", "<b>"+ (StringUtils.isBlank(amount)?"":amount) + "</b>",
+ generalEntryBooksDataInList.getDebit().toString(),
+ generalEntryBooksDataInList.getCredit().toString()};
+ entryBookReport += constructColumnsHtml(columnDataTotal);
+ }
}
- Cell cell2 = new Cell(phrase);
- cell2.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
- cell2.setColspan(3);
- t.addCell(cell2);
- cell2 = new Cell(new Phrase(
- String.valueOf(generalEntryBooksDatas.getDebit()),
- boldFont));
- cell2.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
- t.addCell(cell2);
- cell2 = new Cell(new Phrase(
- String.valueOf(generalEntryBooksDatas.getCredit()),
- boldFont));
- cell2.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
- t.addCell(cell2);
}
}
-
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
+ } catch (Exception ex) {
+ throw new LimaException("Can't generate document", ex);
}
- return t;
+ return entryBookReport;
}
//############## VAT ##############
@@ -1397,66 +1258,55 @@
Account accountFormat = accountDAO.findByTopiaId(account);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMMM yyyy");
- accountReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
- "<html>\n" +
- "<head>\n" +
- "<title>"+_("lima.reports.accounts")+"</title>\n" +
- "</head>\n" +
- "<p align=\"center\">" +
- "<font size=5>\n" +
- _("lima.reports.accounts") +
- "</font>\n" +
- "</p>\n" +
- "<p>";
+ accountReport += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n";
+ String title = _("lima.reports.accounts");
+ accountReport = constructHeadHtml(title);
+
ReportsDatas results;
if (beginDate != null && endDate != null && account != null) {
- accountReport += "<font size=3>\n" +
- _("lima.ui.fiscalperiod.fiscalperiod") + " : " + simpleDateFormat.format(beginDate) + " - " + simpleDateFormat.format(endDate) +
- "</p>\n" +
- "<p>" +
- _("lima.ui.financialtransaction.account") + " : " + accountFormat.getAccountNumber() + " - " + accountFormat.getLabel() +
- "</font>"+
- "</p>" +
- "<body>\n";
+ String subTitleFirstpart = _("lima.ui.fiscalperiod.fiscalperiod") + " : " + simpleDateFormat.format(beginDate) + " - " + simpleDateFormat.format(endDate);
+ String subTitleSecPart = _("lima.ui.financialtransaction.account") + " : " + accountFormat.getAccountNumber() + " - " + accountFormat.getLabel();
+ accountReport += constructSubTitleHtml(subTitleFirstpart, subTitleSecPart);
+
results = reportService.generateAccountsReports(accountFormat, true,
beginDate, endDate);
List<Entry> entries = results.getListEntry();
- accountReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n";
- accountReport += "<tr align=\"center\">\n";
- accountReport +="<td>" + _("lima.table.number") + "</td>\n";
- accountReport +="<td>" + _("lima.table.date") + "</td>\n";
- accountReport +="<td>" + _("lima.table.entrybook") + "</td>\n";
- accountReport +="<td>" + _("lima.table.voucher") + "</td>\n";
- accountReport +="<td>" + _("lima.table.description") + "</td>\n";
- accountReport +="<td>" + _("lima.table.letter") + "</td>\n";
- accountReport +="<td>" + _("lima.table.debit") + "</td>\n";
- accountReport +="<td>" + _("lima.table.credit") + "</td>\n";
- accountReport += "<tr>\n";
+ String[] columnNames = {_("lima.table.number"), _("lima.table.date"), _("lima.table.entrybook"),
+ _("lima.table.voucher"), _("lima.table.decription"), _("lima.table.letter"),
+ _("lima.table.debit"), _("lima.table.credit")};
+
+ accountReport += "<body>\n" +
+ "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n" +
+ "<tr align=\"center\">\n";
+
+ accountReport += constructColumnsHtml(columnNames);
+
for(Entry entry : entries) {
- accountReport += "<tr align=\"center\">\n";
String accountNumber = entry.getAccount().getAccountNumber();
- accountReport += "<td>" + (StringUtils.isBlank(accountNumber)?"":accountNumber) + "</td>\n";
String transactionDate = simpleDateFormat.format(entry.getFinancialTransaction().getTransactionDate());
- accountReport += "<td>" + (StringUtils.isBlank(transactionDate)?"":transactionDate) + "</td>\n";
+ String code = "";
if (entry.getFinancialTransaction().getEntryBook() != null) {
- String code = entry.getFinancialTransaction().getEntryBook().getCode();
- accountReport += "<td>" + (StringUtils.isBlank(code)?"":code) + "</td>\n";
+ code = entry.getFinancialTransaction().getEntryBook().getCode();
}
String voucher = entry.getVoucher();
- accountReport += "<td>" + (StringUtils.isBlank(voucher)?"":voucher) + "</td>\n";
String description = entry.getDescription();
- accountReport += "<td>" + (StringUtils.isBlank(description)?"":description) + "</td>\n";
String lettering = entry.getLettering();
- accountReport += "<td>" + (StringUtils.isBlank(lettering)?"":lettering) + "</td>\n";
- accountReport += "<td>" + (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO) + "</td>\n";
- accountReport += "<td>" + (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()) + "</td>\n";
- accountReport += "</tr>\n";
+
+ String[] columnData = {(StringUtils.isBlank(accountNumber)?"":accountNumber), (StringUtils.isBlank(transactionDate)?"":transactionDate),
+ (StringUtils.isBlank(code)?"":code), (StringUtils.isBlank(voucher)?"":voucher),
+ (StringUtils.isBlank(description)?"":description), (StringUtils.isBlank(lettering)?"":lettering),
+ (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO).toString(),
+ (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()).toString()};
+
+ accountReport += constructColumnsHtml(columnData);
}
+
accountReport += "</table>\n" +
"</body>\n";
@@ -1475,4 +1325,44 @@
return accountReport;
}
+
+ protected String constructHeadHtml(String title) {
+ String head =
+ "<head>\n" +
+ "<title>"+title+"</title>\n" +
+ "</head>\n" +
+ "<p align=\"center\">" +
+ "<font size=5>\n" +
+ title +
+ "</font>\n" +
+ "</p>\n" +
+ "<p>";
+
+ return head;
+ }
+
+ protected String constructSubTitleHtml(String subTitleFirstpart, String subTitleSecPart) {
+ String subTitle = "<font size=3>\n" +
+ subTitleFirstpart +
+ "</p>\n" +
+ "<p>" +
+ subTitleSecPart +
+ "</font>"+
+ "</p>";
+
+ return subTitle;
+ }
+
+ protected String constructColumnsHtml(String[] columnsNames) {
+
+ String columns = "";
+
+ for (String name : columnsNames) {
+ columns += "<td>" + name + "</td>\n";
+ }
+ columns += "<tr>\n";
+
+ return columns;
+ }
+
}
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-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -49,6 +49,7 @@
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -142,7 +143,8 @@
String beginDate = req.getParameter("beginDate");
String endDate = req.getParameter("endDate");
String autocomplete = req.getParameter("autocomplete");
- String account = URLDecoder.decode(req.getParameter("account"), "UTF-8");
+ String account = (StringUtils.isBlank(req.getParameter("account"))?null:URLDecoder.decode(req.getParameter("account"), "UTF-8"));
+ String entryBook = (StringUtils.isBlank(req.getParameter("entryBook"))?null:URLDecoder.decode(req.getParameter("entryBook"), "UTF-8"));
//if image
if (imageParam != null) {
@@ -158,6 +160,8 @@
else if (model != null && format != null && beginDate != null && endDate != null) {
FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format);
String accountReport = null;
+ String entryBooksReport = null;
+ String generalEntryBooksReport = null;
//create docs
try {
@@ -170,29 +174,27 @@
beginDateFormat, endDateFormat, formatsEnum);
break;
case ACCOUNT:
- if (log.isDebugEnabled()) {
- log.debug("Account");
- }
- /*AccountDAO accountDAO = new AccountDAO();
- Account accountFormat = accountDAO.findByTopiaId(account);*/
accountReport = documentService.createAccountDocument(
beginDateFormat, endDateFormat, account);
+ break;
+ case ENTRYBOOKS:
+ entryBooksReport = documentService.createEntryBooksDocuments(
+ beginDateFormat, endDateFormat);
if (log.isDebugEnabled()) {
- log.debug("After creating account document");
+ log.debug("EntryBookReport :" + entryBooksReport);
}
break;
- case ENTRYBOOKS:
- documentService.createEntryBooksDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
+ case GENERAL_ENTRYBOOK:
+ generalEntryBooksReport = documentService.createGeneralEntryBooksDocuments(
+ beginDateFormat, endDateFormat);
+ if (log.isDebugEnabled()) {
+ log.debug("GeneralEntryBooksReport :" + generalEntryBooksReport);
+ }
break;
case FINANCIALSTATEMENT:
documentService.createFinancialStatementsDocuments(
beginDateFormat, endDateFormat, formatsEnum);
break;
- case GENERAL_ENTRYBOOK:
- documentService.createGeneralEntryBooksDocuments(
- beginDateFormat, endDateFormat, formatsEnum);
- break;
case LEDGER:
documentService.createLedgerDocuments(
beginDateFormat, endDateFormat, formatsEnum);
@@ -219,16 +221,29 @@
log.debug(accountReport);
}
resp.setContentType(formatsEnum.getMimeType());
-// InputStream in = doc.openStream();
OutputStream out = resp.getOutputStream();
- if (accountReport != null) {
- IOUtils.write(accountReport, out, Charsets.UTF_8);
-// out.write(accountReport.getBytes());
+ if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null) {
+ String report = null;
+ if (accountReport != null) {
+ report = accountReport;
+ } else if (entryBooksReport != null) {
+ report = entryBooksReport;
+ } else {
+ report = generalEntryBooksReport;
+ }
+ IOUtils.write(report, out, Charsets.UTF_8);
+ } else {
+ InputStream in = doc.openStream();
+ IOUtils.copy(in, out);
}
-// IOUtils.copy(in, out);
}
// else return home html
else {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Home html");
+ }
+
resp.setContentType(FormatsEnum.HTML.getMimeType());
StringBuilder pageContent = new StringBuilder();
String serverAdress = "http://";
@@ -251,30 +266,30 @@
DateUtils.truncate(beginDatePicker, Calendar.YEAR);
pageContent.append("<!DOCTYPE html>\n"
- + "<html lang=\"fr\">\n"
- + "<head>\n"
- + "<title>LIMA Documents Report</title>\n"
- + "<style type=\"text/css\">"
- + "body { font: 14px sans-serif; }"
- + "h1 { font: 20px sans-serif; text-align: center; }"
- + "table.padding td {padding-right:20px;}"
- + ".tdright {text-align: right;}"
- + "</style>"
- + "</head>\n"
- + "<body>\n"
- + "<table class=\"padding\">\n"
- + "<tr><td><img src=\"?img=puzzle_icon_mini.png\"/></td>\n"
- + "<td><h1>LIMA Documents Report</h1></td></tr>\n"
- + "<tr><td class=\"tdright\"><img src=\"?img=identity.png\"/></td>\n"
- + "<td rowspan=3><form method=GET action="
- + serverAdress + ">\n"
- + _("lima-business.document.date.begin")
- + "<input value=\"" + DATEFORMAT.format(beginDatePicker)
- + "\" type=\"date\" name=\"beginDate\">\n"
- + _("lima-business.document.date.end")
- + "<input value=\"" + DATEFORMAT.format(endDatePicker)
- + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"
- + "Format : <select name=\"format\">");
+ + "<html lang=\"fr\">\n"
+ + "<head>\n"
+ + "<title>LIMA Documents Report</title>\n"
+ + "<style type=\"text/css\">"
+ + "body { font: 14px sans-serif; }"
+ + "h1 { font: 20px sans-serif; text-align: center; }"
+ + "table.padding td {padding-right:20px;}"
+ + ".tdright {text-align: right;}"
+ + "</style>"
+ + "</head>\n"
+ + "<body>\n"
+ + "<table class=\"padding\">\n"
+ + "<tr><td><img src=\"?img=puzzle_icon_mini.png\"/></td>\n"
+ + "<td><h1>LIMA Documents Report</h1></td></tr>\n"
+ + "<tr><td class=\"tdright\"><img src=\"?img=identity.png\"/></td>\n"
+ + "<td rowspan=3><form method=GET action="
+ + serverAdress + ">\n"
+ + _("lima-business.document.date.begin")
+ + "<input value=\"" + DATEFORMAT.format(beginDatePicker)
+ + "\" type=\"date\" name=\"beginDate\">\n"
+ + _("lima-business.document.date.end")
+ + "<input value=\"" + DATEFORMAT.format(endDatePicker)
+ + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"
+ + "Format : <select name=\"format\">");
for (FormatsEnum formatsEnum : FormatsEnum.values()) {
pageContent.append("<option value=\""
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-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -35,6 +35,7 @@
lima-business.document.debit=Debit
lima-business.document.description=Description
lima-business.document.entrybook=EntryBook
+lima-business.document.entrybooks=
lima-business.document.entrybooktitle=%s\n%2$tB %2$tY
lima-business.document.financialstatement=FinancialStatement
lima-business.document.generalentrybook=General EntryBook
@@ -103,4 +104,15 @@
lima.config.serveraddress.description=Server Address
lima.reports.account.noaccount=
lima.reports.account.noaccounttitle=
+lima.reports.accounts=
+lima.table.credit=
+lima.table.date=
+lima.table.debit=
+lima.table.decription=
+lima.table.entrybook=
+lima.table.letter=
+lima.table.number=
+lima.table.voucher=
+lima.ui.financialtransaction.account=
+lima.ui.fiscalperiod.fiscalperiod=
lima.ui.lettering.accountRegularization=
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-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -35,6 +35,7 @@
lima-business.document.debit=Débit
lima-business.document.description=Description
lima-business.document.entrybook=Journal
+lima-business.document.entrybooks=Journaux
lima-business.document.entrybooktitle=%s\n%2$tB %2$tY
lima-business.document.financialstatement=Bilan et compte de résultat
lima-business.document.generalentrybook=Journal Général
@@ -103,4 +104,15 @@
lima.config.serveraddress.description=Addresse serveur
lima.reports.account.noaccount=
lima.reports.account.noaccounttitle=
+lima.reports.accounts=
+lima.table.credit=
+lima.table.date=
+lima.table.debit=
+lima.table.decription=
+lima.table.entrybook=
+lima.table.letter=
+lima.table.number=
+lima.table.voucher=
+lima.ui.financialtransaction.account=
+lima.ui.fiscalperiod.fiscalperiod=
lima.ui.lettering.accountRegularization=
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-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -27,7 +27,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.FormatsEnum;
-import org.chorem.lima.entity.Account;
import java.util.Date;
@@ -43,12 +42,12 @@
void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
- void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
-
void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
- void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ String createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+
void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format, String autocomplete) throws LimaException;
String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -492,6 +492,10 @@
String address = LimaConfig.getInstance().getHostAdress();
String url = "http://" + address + ":" + port + "/";
+ if (log.isDebugEnabled()) {
+ log.debug("URL : " + url);
+ }
+
SwingUtil.openLink(url);
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,97 +0,0 @@
-/*
- * #%L
- * Lima :: Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package org.chorem.lima.ui.accountsreports;
-
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.math.BigDecimal;
-
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-import org.jdesktop.swingx.JXTable;
-
-public class AccountsReportsTable extends JXTable
- implements KeyListener, MouseListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 6093850347322834480L;
-
- public AccountsReportsTable() {
-
- addKeyListener(this);
- addMouseListener(this);
-
- //Get new BigDecimal renderer
- setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
-
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void keyTyped(KeyEvent e) {
- }
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!isEditing()) {
- clearSelection();
- }
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,196 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.accountsreports;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-
-import javax.swing.table.AbstractTableModel;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Entry book table model.
- * By : $Author$
- */
-public class AccountsReportsTableModel extends AbstractTableModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 1L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
-
- /** data cache */
- protected ReportsDatas reportDatas;
-
- @Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (reportDatas != null) {
- if (reportDatas.getListEntry() != null) {
- result = reportDatas.getListEntry().size();
- }
- }
-
- return result;
- }
-
- @Override
- public int getColumnCount() {
- return 8;
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Account.class;
- break;
- case 1:
- result = Date.class;
- break;
- case 2:
- result = Entry.class;
- break;
- case 3:
- result = String.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = String.class;
- break;
- case 6:
- result = BigDecimal.class;
- break;
- case 7:
- result = BigDecimal.class;
- break;
- }
-
- return result;
- }
-
-
- @Override
- public String getColumnName(int column) {
- String res = "n/a";
- switch (column) {
- case 0:
- res = _("lima.table.account"); //Account Number
- break;
- case 1:
- res = _("lima.table.date"); //Date
- break;
- case 2:
- res = _("lima.table.entrybook"); //EntryBook
- break;
- case 3:
- res = _("lima.table.voucher"); // Voucher
- break;
- case 4:
- res = _("lima.table.description"); //Description
- break;
- case 5:
- res = _("lima.table.letter"); //Letter
- break;
- case 6:
- res = _("lima.table.debit"); //Debit
- break;
- case 7:
- res = _("lima.table.credit"); //Credit
- break;
- }
- return res;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
- if (reportDatas != null) {
- Entry currentRow = reportDatas.getListEntry().get(row);
- // FIXME echatellier 20120515, move it to renderer
- SimpleDateFormat simpleDateFormat
- = new SimpleDateFormat("dd MMMMM yyyy");
-
- switch (column) {
- case 0:
- result = currentRow.getAccount().getAccountNumber();
- break;
- case 1:
- result = simpleDateFormat.
- format(currentRow.getFinancialTransaction().getTransactionDate());
- break;
- case 2:
- if (currentRow.getFinancialTransaction().getEntryBook() != null) {
- result = currentRow.getFinancialTransaction().getEntryBook().getCode();
- } else {
- result = null;
- }
- break;
- case 3:
- result = currentRow.getVoucher();
- break;
- case 4:
- result = currentRow.getDescription();
- break;
- case 5:
- result = currentRow.getLettering();
- break;
- case 6:
- result = currentRow.getDebit() ? currentRow.getAmount() : BigDecimal.ZERO;
- break;
- case 7:
- result = currentRow.getDebit() ? BigDecimal.ZERO : currentRow.getAmount();
- break;
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No Account selected skip table model update");
- }
- }
-
- return result;
- }
-
- public void setReportDatas(ReportsDatas reportDatas) {
- this.reportDatas = reportDatas;
- fireTableDataChanged();
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-08-17 11:03:36 UTC (rev 3610)
@@ -23,7 +23,7 @@
#L%
-->
-<Table>
+<Table constraints='BorderLayout.NORTH'>
<import>
javax.swing.ListSelectionModel
org.chorem.lima.ui.common.IntervalPanel
@@ -37,71 +37,30 @@
}
]]></script>
- <row weightx="1" weighty="0" anchor="center">
- <cell fill='both'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
- </cell>
- <cell anchor="east">
- <JLabel id="entryBookSelectorLabel" text="lima.common.entrybook"/>
- </cell>
- <cell anchor="west">
- <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookModel" />
- <EntryBookComboBox id="entryBookCombo" model="{entryBookModel}"
- renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}"
- onItemStateChanged="handler.entryBookChanged(event)"/>
- </cell>
- <cell>
- <JButton id="back" text="lima.common.buttonback"
- onActionPerformed="entryBookCombo.back()"/>
- </cell>
- <cell>
- <JButton id="next" text="lima.common.buttonnext"
- onActionPerformed="entryBookCombo.next()"/>
- </cell>
- <cell>
- <EnumEditor id='DocumentEditor'
- constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/>
- </cell>
- <cell>
- <JButton text="lima.common.ok"
- onActionPerformed="getHandler().createDocument()"/>
- </cell>
- </row>
<row>
- <cell fill="both" weightx="1" weighty="1" columns="7">
- <JScrollPane>
- <EntryBooksReportsTableModel id="entryBookReportsTableModel" />
- <EntryBooksReportsTable id="reportTable" sortable="false" rowHeight="24"
- constructorParams="entryBookReportsTableModel"
- model="{entryBookReportsTableModel}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- </JScrollPane>
- </cell>
+ <cell columns="3">
+ <Table>
+ <row>
+ <cell anchor="center">
+ <JLabel text="lima-business.document.entrybooks"/>
+ </cell>
+ <cell anchor="center">
+ <JLabel text=" - "/>
+ </cell>
+ <cell anchor="center">
+ <JLabel text="lima-business.document.generalentrybook"/>
+ </cell>
+ </row>
+ </Table>
+ </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 columns="2">
+ <IntervalPanel id="intervalPanel"/>
</cell>
+ <cell columns="1">
+ <JButton text="lima.common.ok"
+ onActionPerformed="getHandler().createDocument()"/>
+ </cell>
</row>
-</Table>
\ No newline at end of file
+</Table>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-17 11:03:36 UTC (rev 3610)
@@ -25,36 +25,24 @@
package org.chorem.lima.ui.entrybooksreports;
-import static org.nuiton.i18n.I18n._;
-
import java.awt.Desktop;
-import java.awt.event.ItemEvent;
import java.io.IOException;
-import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-import javax.swing.JOptionPane;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.DocumentService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
-import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
-import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.business.utils.DocumentsEnum;
-import org.chorem.lima.business.utils.FormatsEnum;
-import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -64,7 +52,7 @@
*
* By : $Author$
*/
-public class EntryBooksReportsViewHandler implements ServiceListener {
+public class EntryBooksReportsViewHandler{
/** log. */
private static final Log log = LogFactory.getLog(EntryBooksReportsViewHandler.class);
@@ -90,81 +78,19 @@
entryBookService = LimaServiceFactory.getService(EntryBookService.class);
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
+ /*LimaServiceFactory.addServiceListener(ImportService.class, this);
+ LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);*/
}
/**
* Init data models and displayed objects.
*/
public void init() {
-
- // init data models
- List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
- view.getEntryBookModel().setObjects(entryBooks);
- List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
- view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
+ view.getIntervalPanel().init(blockedFiscalPeriods, financialPeriod);
}
-
- public void intervalChanged() {
- refreshData();
- }
- protected void entryBookChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
-
- /**
- * Refresh table data depending on item selected on combo boxes.
- */
- protected void refreshData() {
-
- Date beginDate = view.getIntervalPanel().getBeginDate();
- Date endDate = view.getIntervalPanel().getEndDate();
-
- EntryBook entryBook = (EntryBook)view.getEntryBookCombo().getModel().getSelectedItem();
-
- if (beginDate != null && endDate != null && entryBook != null) {
- ReportsDatas results = reportService.generateEntryBooksReports(entryBook,
- beginDate, endDate);
-
- EntryBooksReportsTableModel dataModel = view.getEntryBookReportsTableModel();
- dataModel.setReportDatas(results);
-
- updateFooter(results);
- }
- }
-
- /**
- * Update footer labels containing reports total sum fields.
- *
- * @param reportsDatas result to render
- */
- protected void updateFooter(ReportsDatas reportsDatas) {
- // set amounts credit and debit and solde
- view.amountCreditLabel.setText(
- reportsDatas.getAmountCredit().toString());
- view.amountDebitLabel.setText(
- reportsDatas.getAmountDebit().toString());
- BigDecimal amountSolde = reportsDatas.getAmountSolde();
- view.amountSoldeLabel.setText(amountSolde.toString());
-
-
- if (BigDecimal.ZERO.equals(amountSolde)) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (reportsDatas.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
- }
- }
- }
-
public void createDocument() {
Date beginDate = view.getIntervalPanel().getBeginDate();
@@ -172,61 +98,29 @@
if (beginDate != null && endDate != null) {
- //looks for all blocked fiscal periods
- List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String address = LimaConfig.getInstance().getHostAdress();
- //tells if the fiscaPeriod as been found and is blocked
- boolean error = true;
+ try {
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&format=.html&model="
+ + DocumentsEnum.ENTRYBOOKS.getFileName();
+ Desktop.getDesktop().browse(new URI(url));
- for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
- && blockedFiscalPeriod.getEndDate().equals(endDate)
- && blockedFiscalPeriod.getLocked()) {
- error = false;
- }
- }
+ String url2 = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&format=.html&model="
+ + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
+ Desktop.getDesktop().browse(new URI(url2));
- //shows error message to user if the fiscalPeriod is unblocked
- if (error) {
- JOptionPane.showMessageDialog(
- view,
- _("lima.entrybooksreports.documentcreationfiscalerror"),
- _("lima.entrybooksreports.documentcreationfiscaltitle"),
- JOptionPane.ERROR_MESSAGE);
- } else {
-
- int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
- FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
- String address = LimaConfig.getInstance().getHostAdress();
-
- try {
- String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(beginDate)
- + "&endDate=" + dateFormat.format(endDate)
- + "&format=" + selectedEnum.getExtension() + "&model="
- + DocumentsEnum.ENTRYBOOKS.getFileName();
- Desktop.getDesktop().browse(new URI(url));
-
- String url2 = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(beginDate)
- + "&endDate=" + dateFormat.format(endDate)
- + "&format=" + selectedEnum.getExtension() + "&model="
- + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
- Desktop.getDesktop().browse(new URI(url2));
-
- } catch (IOException e) {
- log.error("Can't open browser", e);
- } catch (URISyntaxException e) {
- log.error("Can't create news URI", e);
- }
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
}
}
}
-
- @Override
- public void notifyMethod(String serviceName, String methodName) {
- if (serviceName.contains("FinancialTransaction") || methodName.contains("importEntryBook") || methodName.contains("importAll")) {
- refreshData();
- }
- }
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,4 +1,7 @@
=
+-=
+lima-business.document.entrybooks=
+lima-business.document.generalentrybook=
lima.accountsreports.listerror=Can't get entries list
lima.action.commandline.help=Show help in console
lima.action.fullscreen=Full screen
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 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -1,4 +1,7 @@
=
+-=
+lima-business.document.entrybooks=
+lima-business.document.generalentrybook=
lima.accountsreports.listerror=Erreur lors de la récupération des données de la liste
lima.action.commandline.help=Afficher l'aide en console
lima.action.fullscreen=Plein Ecran
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-16 14:31:59 UTC (rev 3609)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-17 11:03:36 UTC (rev 3610)
@@ -59,4 +59,5 @@
log4j.logger.org.chorem.lima.business.ejb.DocumentServiceImpl=DEBUG
log4j.logger.org.chorem.lima.business.ejb.HttpServerServiceImpl=DEBUG
log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG
-log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG
\ No newline at end of file
1
0
Author: mallon
Date: 2012-08-16 16:31:59 +0200 (Thu, 16 Aug 2012)
New Revision: 3609
Url: http://chorem.org/repositories/revision/lima/3609
Log:
refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition des comptes.
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/java/org/chorem/lima/business/utils/DocumentsEnum.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
trunk/lima-swing/src/main/resources/log4j.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-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -40,6 +40,9 @@
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;
import org.apache.pdfbox.examples.fdf.SetField;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.chorem.lima.beans.BalanceTrial;
@@ -58,6 +61,7 @@
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.Entry;
@@ -67,11 +71,13 @@
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.VatStatement;
+import org.nuiton.topia.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import javax.swing.JOptionPane;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
@@ -79,6 +85,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -91,6 +98,8 @@
@TransactionAttribute
public class DocumentServiceImpl extends AbstractLimaService implements DocumentService {
+ protected static final Log log = LogFactory.getLog(DocumentServiceImpl.class);
+
@EJB
private IdentityService identityService;
@@ -120,8 +129,15 @@
private static final Font bolditalicFont =
new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK);
+ private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("dd-MM-yyyy");
+
public DocumentServiceImpl() {
path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Path : " + path);
+ }
+
}
/**
@@ -1369,4 +1385,94 @@
throw new LimaException("Can't create document", ex);
}
}
+
+ @Override
+ public String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException {
+
+ String accountReport = null;
+
+ try {
+
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
+ Account accountFormat = accountDAO.findByTopiaId(account);
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMMM yyyy");
+
+ accountReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n" +
+ "<head>\n" +
+ "<title>"+_("lima.reports.accounts")+"</title>\n" +
+ "</head>\n" +
+ "<p align=\"center\">" +
+ "<font size=5>\n" +
+ _("lima.reports.accounts") +
+ "</font>\n" +
+ "</p>\n" +
+ "<p>";
+ ReportsDatas results;
+
+ if (beginDate != null && endDate != null && account != null) {
+
+ accountReport += "<font size=3>\n" +
+ _("lima.ui.fiscalperiod.fiscalperiod") + " : " + simpleDateFormat.format(beginDate) + " - " + simpleDateFormat.format(endDate) +
+ "</p>\n" +
+ "<p>" +
+ _("lima.ui.financialtransaction.account") + " : " + accountFormat.getAccountNumber() + " - " + accountFormat.getLabel() +
+ "</font>"+
+ "</p>" +
+ "<body>\n";
+ results = reportService.generateAccountsReports(accountFormat, true,
+ beginDate, endDate);
+ List<Entry> entries = results.getListEntry();
+
+ accountReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n";
+ accountReport += "<tr align=\"center\">\n";
+ accountReport +="<td>" + _("lima.table.number") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.date") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.entrybook") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.voucher") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.description") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.letter") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.debit") + "</td>\n";
+ accountReport +="<td>" + _("lima.table.credit") + "</td>\n";
+ accountReport += "<tr>\n";
+ for(Entry entry : entries) {
+ accountReport += "<tr align=\"center\">\n";
+
+ String accountNumber = entry.getAccount().getAccountNumber();
+ accountReport += "<td>" + (StringUtils.isBlank(accountNumber)?"":accountNumber) + "</td>\n";
+ String transactionDate = simpleDateFormat.format(entry.getFinancialTransaction().getTransactionDate());
+ accountReport += "<td>" + (StringUtils.isBlank(transactionDate)?"":transactionDate) + "</td>\n";
+ if (entry.getFinancialTransaction().getEntryBook() != null) {
+ String code = entry.getFinancialTransaction().getEntryBook().getCode();
+ accountReport += "<td>" + (StringUtils.isBlank(code)?"":code) + "</td>\n";
+ }
+ String voucher = entry.getVoucher();
+ accountReport += "<td>" + (StringUtils.isBlank(voucher)?"":voucher) + "</td>\n";
+ String description = entry.getDescription();
+ accountReport += "<td>" + (StringUtils.isBlank(description)?"":description) + "</td>\n";
+ String lettering = entry.getLettering();
+ accountReport += "<td>" + (StringUtils.isBlank(lettering)?"":lettering) + "</td>\n";
+ accountReport += "<td>" + (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO) + "</td>\n";
+ accountReport += "<td>" + (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()) + "</td>\n";
+
+ accountReport += "</tr>\n";
+ }
+ accountReport += "</table>\n" +
+ "</body>\n";
+
+ } else {
+ JOptionPane.showMessageDialog(null, _("lima.reports.account.noaccount"), _("lima.reports.account.noaccounttitle"), JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ accountReport += "</html>";
+
+ }catch (TopiaException e) {
+ log.error("Can't find object", e);
+ }
+ catch (Exception e) {
+ throw new LimaException("Can't create document", e);
+ }
+
+ return accountReport;
+ }
}
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-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -32,6 +32,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
+import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -46,8 +47,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.DocumentService;
@@ -66,6 +70,8 @@
@TransactionAttribute
public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService {
+ protected static final Log log = LogFactory.getLog(HttpServerServiceImpl.class);
+
@EJB
private DocumentService documentService;
@@ -124,6 +130,11 @@
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
+
+ if (log.isDebugEnabled()) {
+ log.debug("doGet");
+ }
+
//get all params
String imageParam = req.getParameter("img");
String model = req.getParameter("model");
@@ -131,6 +142,7 @@
String beginDate = req.getParameter("beginDate");
String endDate = req.getParameter("endDate");
String autocomplete = req.getParameter("autocomplete");
+ String account = URLDecoder.decode(req.getParameter("account"), "UTF-8");
//if image
if (imageParam != null) {
@@ -145,6 +157,7 @@
//if doc pdf or html
else if (model != null && format != null && beginDate != null && endDate != null) {
FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format);
+ String accountReport = null;
//create docs
try {
@@ -156,6 +169,18 @@
documentService.createBalanceDocuments(
beginDateFormat, endDateFormat, formatsEnum);
break;
+ case ACCOUNT:
+ if (log.isDebugEnabled()) {
+ log.debug("Account");
+ }
+ /*AccountDAO accountDAO = new AccountDAO();
+ Account accountFormat = accountDAO.findByTopiaId(account);*/
+ accountReport = documentService.createAccountDocument(
+ beginDateFormat, endDateFormat, account);
+ if (log.isDebugEnabled()) {
+ log.debug("After creating account document");
+ }
+ break;
case ENTRYBOOKS:
documentService.createEntryBooksDocuments(
beginDateFormat, endDateFormat, formatsEnum);
@@ -189,10 +214,18 @@
// après génération
// fonctionne pour le moment, mais a modifier
URL doc = new URL("file:" + path + File.separator + model + formatsEnum.getExtension());
+ if (log.isDebugEnabled()) {
+ log.debug("file:" + path + File.separator + model + formatsEnum.getExtension());
+ log.debug(accountReport);
+ }
resp.setContentType(formatsEnum.getMimeType());
- InputStream in = doc.openStream();
+// InputStream in = doc.openStream();
OutputStream out = resp.getOutputStream();
- IOUtils.copy(in, out);
+ if (accountReport != null) {
+ IOUtils.write(accountReport, out, Charsets.UTF_8);
+// out.write(accountReport.getBytes());
+ }
+// IOUtils.copy(in, out);
}
// else return home html
else {
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-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -36,6 +36,8 @@
import javax.ejb.TransactionAttribute;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.BalanceTrialImpl;
import org.chorem.lima.beans.ReportsDatas;
@@ -64,6 +66,8 @@
@EJB
protected AccountService accountService;
+ protected static final Log log = LogFactory.getLog(ReportServiceImpl.class);
+
/**
* Recursiv
* List entries for a period and an account
@@ -86,37 +90,29 @@
//Get allsubaccounts and thirdParts accounts
List<Account> accounts = accountService.getAllSubAccounts(account);
-
- // is already subaccount
- // TODO echatellier 20120502 c'est vraiment voulu ?
- // il ne peut pas y avoir de transaction sur des comptes non feuilles ?
- // a verifier, sinon, supprimer la récursion
- if (accounts.size() == 0) {
- reportsDatas = generateSubAccountReports(account,
+
+ for (Account subAccount : accounts) {
+ reportsDatas = generateSubAccountReports(subAccount,
beginDate, endDate);
+ debit = debit.add(reportsDatas.getAmountDebit());
+ credit = credit.add(reportsDatas.getAmountCredit());
+ entries.addAll(reportsDatas.getListEntry());
}
- // else is folder accounts contains many subs and thirds accounts
- else {
- for (Account subAccount : accounts) {
- ReportsDatas subReportsDatas =
- generateAccountsReports(subAccount, true, beginDate, endDate);
- debit = debit.add(subReportsDatas.getAmountDebit());
- credit = credit.add(subReportsDatas.getAmountCredit());
- entries.addAll(subReportsDatas.getListEntry());
- }
- //solde = debit - credit
- solde = solde.add(debit);
- solde = solde.subtract(credit);
-
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
- }
- solde = solde.abs();
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
- reportsDatas.setListEntry(entries);
+
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
}
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
+ reportsDatas.setListEntry(entries);
+
} catch (TopiaException ex) {
throw new LimaException("Can't generate report", ex);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -35,7 +35,8 @@
BALANCE(_("lima-business.document.balance"), "lima_balance"),
LEDGER(_("lima-business.document.ledger"), "lima_ledger"),
FINANCIALSTATEMENT(_("lima-business.document.financialstatement"), "lima_financialstatements"),
- VAT(_("lima-business.document.vat"), "lima_vat");
+ VAT(_("lima-business.document.vat"), "lima_vat"),
+ ACCOUNT(_("lima-business.document.account"), "lima_account");
private final String fileName;
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-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -17,6 +17,7 @@
lima-business.defaultaccountingrules.invalidaccountnumber=Invalid Account Number \: %d
lima-business.defaultaccountingrules.missingelements=Can't block financialperiod / missing elements in transactions for this FinancialPeriod/EntryBook
lima-business.defaultaccountingrules.missingentrybook=Can't block financialperiod / missing EntryBook in transactions
+lima-business.document.account=
lima-business.document.accountnumber=Account N°
lima-business.document.amounts=Amounts
lima-business.document.amountsperiod=Amounts %1$tB %1$tY
@@ -100,4 +101,6 @@
lima.config.rulesnationality.description=Rules Nationality
lima.config.scale.description=Scale
lima.config.serveraddress.description=Server Address
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.ui.lettering.accountRegularization=
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-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -17,6 +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.accountnumber=N° Compte
lima-business.document.amounts=Totaux
lima-business.document.amountsperiod=Totaux %1$tB %1$tY
@@ -100,4 +101,6 @@
lima.config.rulesnationality.description=Règles nationales
lima.config.scale.description=Précision
lima.config.serveraddress.description=Addresse serveur
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.ui.lettering.accountRegularization=
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-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -27,6 +27,7 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.FormatsEnum;
+import org.chorem.lima.entity.Account;
import java.util.Date;
@@ -50,4 +51,5 @@
void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format, String autocomplete) throws LimaException;
+ String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException;
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -75,6 +75,11 @@
List<Entry> entries = context.findAll(query, "beginDate", beginDate,
"endDate", endDate, "account", account);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Size of entries : " + entries.size());
+ }
+
return entries;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-08-16 14:31:59 UTC (rev 3609)
@@ -23,7 +23,7 @@
#L%
-->
-<Table>
+<Table constraints='BorderLayout.NORTH'>
<import>
javax.swing.ListSelectionModel
@@ -42,67 +42,37 @@
}
]]>
</script>
- <row weightx="1" weighty="0" anchor="center">
- <cell fill='horizontal'>
- <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
- </cell>
- <cell fill='horizontal' anchor="east">
- <JLabel id="accountSelectorLabel" text="lima.common.account"/>
- </cell>
- <cell fill='horizontal' anchor="west">
- <AccountComboBoxModel id="accountComboboxModel" />
- <AccountComboBox id="accountComboBox" model="{accountComboboxModel}"
- renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
- onItemStateChanged="handler.accountChanged(event)" />
- </cell>
- <cell>
- <JButton id="back" text="lima.common.buttonback"
- onActionPerformed="accountComboBox.back()"/>
- </cell>
- <cell>
- <JButton id="next" text="lima.common.buttonnext"
- onActionPerformed="accountComboBox.next()"/>
- </cell>
- </row>
<row>
- <cell fill="both" weightx="1" weighty="1" columns="6">
- <JScrollPane>
- <AccountsReportsTableModel id="accountsReportsTableModel"/>
- <AccountsReportsTable
- id="accountsReportsTable" rowHeight="24"
- model="{accountsReportsTableModel}"
- highlighters="{HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- columnControlVisible="true"/>
- <ListSelectionModel
- javaBean="getAccountsReportsTable().getSelectionModel()"/>
- </JScrollPane>
+ <cell columns="1">
+ <IntervalPanel id="intervalPanel"/>
</cell>
</row>
<row>
- <cell fill="horizontal" weightx="1" columns="7">
- <Table>
- <row fill="horizontal" weightx="1">
- <cell>
- <JLabel text="lima.ui.common.amountdebit"/>
- </cell>
- <cell>
- <JLabel id="amountDebitLabel"/>
- </cell>
- <cell>
- <JLabel text="lima.ui.common.amountcredit"/>
- </cell>
- <cell>
- <JLabel id="amountCreditLabel"/>
- </cell>
- <cell>
- <JLabel id="soldeLabel" text="lima.ui.common.solde"/>
- </cell>
- <cell>
- <JLabel id="amountSoldeLabel"/>
- </cell>
- </row>
- </Table>
+ <cell columns="1">
+ <Table>
+ <row>
+ <cell weightx="0.125" anchor="east">
+ <JLabel id="accountSelectorLabel" text="lima.common.account"/>
+ </cell>
+ <cell weightx="0.5" anchor="east">
+ <AccountComboBoxModel id="accountComboboxModel" />
+ <AccountComboBox id="accountComboBox" model="{accountComboboxModel}"
+ renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" />
+ </cell>
+ <cell weightx="0.125" anchor="east">
+ <JButton id="back" text="lima.common.buttonback"
+ onActionPerformed="accountComboBox.back()"/>
+ </cell>
+ <cell weightx="0.125" anchor="east">
+ <JButton id="next" text="lima.common.buttonnext"
+ onActionPerformed="accountComboBox.next()"/>
+ </cell>
+ <cell weightx="0.125" anchor="east">
+ <JButton id="html" text="lima.common.generateHtml"
+ onActionPerformed="handler.createDocument()"/>
+ </cell>
+ </row>
+ </Table>
</cell>
</row>
</Table>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -25,31 +25,34 @@
package org.chorem.lima.ui.accountsreports;
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.event.ItemEvent;
-import java.math.BigDecimal;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.business.ServiceListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.FinancialPeriodService;
-import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
-import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.api.HttpServerService;
import org.chorem.lima.business.api.ReportService;
+import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+
/**
* Handler associated with accounts reports view.
* By : $Author$
*/
-public class AccountsReportsViewHandler implements ServiceListener {
+public class AccountsReportsViewHandler {
protected AccountsReportsView view;
@@ -58,6 +61,8 @@
protected AccountService accountService;
protected FiscalPeriodService fiscalPeriodService;
protected FinancialPeriodService financialPeriodService;
+ private static final Log log = LogFactory.getLog(AccountsReportsViewHandler.class);
+ private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
protected AccountsReportsViewHandler(AccountsReportsView view) {
this.view = view;
@@ -66,8 +71,6 @@
accountService = LimaServiceFactory.getService(AccountService.class);
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
/**
@@ -83,69 +86,38 @@
view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- protected void accountChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
+ public void createDocument() {
- public void intervalChanged() {
- refreshData();
- }
-
- /**
- * Refresh table data depending on item selected on combo boxes.
- */
- protected void refreshData() {
-
Date beginDate = view.getIntervalPanel().getBeginDate();
Date endDate = view.getIntervalPanel().getEndDate();
-
Account account = (Account)view.getAccountComboBox().getModel().getSelectedItem();
-
+
if (beginDate != null && endDate != null && account != null) {
- ReportsDatas results = reportService.generateAccountsReports(account, true,
- beginDate, endDate);
-
- AccountsReportsTableModel dataModel = view.getAccountsReportsTableModel();
- dataModel.setReportDatas(results);
-
- updateFooter(results);
- }
-
- }
- /**
- * Update footer labels containing reports total sum fields.
- *
- * @param reportsDatas result to render
- */
- protected void updateFooter(ReportsDatas reportsDatas) {
- // set amounts credit and debit and solde
- view.amountCreditLabel.setText(
- reportsDatas.getAmountCredit().toString());
- view.amountDebitLabel.setText(
- reportsDatas.getAmountDebit().toString());
- BigDecimal amountSolde = reportsDatas.getAmountSolde();
- view.amountSoldeLabel.setText(amountSolde.toString());
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String address = LimaConfig.getInstance().getHostAdress();
+ try {
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&account=" + URLEncoder.encode(account.getTopiaId(), "UTF-8")
+ + "&format=.html&model="
+ + DocumentsEnum.ACCOUNT.getFileName();
- if (BigDecimal.ZERO.equals(amountSolde)) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (reportsDatas.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
+ if (log.isDebugEnabled()) {
+ log.debug("URL : " + url);
+ }
+
+ URI uri = URI.create(url);
+ if (log.isDebugEnabled()) {
+ log.debug("URI : " + uri);
+ }
+ Desktop.getDesktop().browse(uri);
+
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
}
}
}
-
- @Override
- public void notifyMethod(String serviceName, String methodName) {
- if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) {
- refreshData();
- }
- }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609)
@@ -141,7 +141,7 @@
/**
* Update footer labels containing reports total sum fields.
*
- * @param results result to render
+ * @param reportsDatas result to render
*/
protected void updateFooter(ReportsDatas reportsDatas) {
// set amounts credit and debit and solde
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -53,6 +53,7 @@
lima.common.entrybooks=EntryBooks
lima.common.error=Error
lima.common.filter=Filter
+lima.common.generateHtml=
lima.common.info=Information
lima.common.label=Label
lima.common.movmentedfilter=Accounts filtered
@@ -169,6 +170,8 @@
lima.opening.accounts=
lima.preferences=Preferences
lima.reports=Reports
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.reports.accounts=Edit account
lima.reports.balance=Balance
lima.reports.entrybooks=Edit entrybook
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 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -53,6 +53,7 @@
lima.common.entrybooks=Journaux
lima.common.error=Erreur
lima.common.filter=Filtrer
+lima.common.generateHtml=HTML
lima.common.info=Information
lima.common.label=Libellé
lima.common.movmentedfilter=Comptes mouvementés
@@ -168,6 +169,8 @@
lima.opening.accounts=
lima.preferences=Préférences
lima.reports=Rapports
+lima.reports.account.noaccount=
+lima.reports.account.noaccounttitle=
lima.reports.accounts=Edition compte
lima.reports.balance=Balance
lima.reports.entrybooks=Edition journal
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-14 14:28:26 UTC (rev 3608)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-16 14:31:59 UTC (rev 3609)
@@ -55,4 +55,8 @@
log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionPeriodSearchPanel=DEBUG
log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchViewHandler=DEBUG
log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodViewHandler=DEBUG
-log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.DocumentServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.HttpServerServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
\ No newline at end of file
1
0
r3608 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod lima-swing/src/main/resources/i18n
by mallon@users.chorem.org 14 Aug '12
by mallon@users.chorem.org 14 Aug '12
14 Aug '12
Author: mallon
Date: 2012-08-14 16:28:26 +0200 (Tue, 14 Aug 2012)
New Revision: 3608
Url: http://chorem.org/repositories/revision/lima/3608
Log:
refs #768 Correction sur les libelles et les clefs d'internationalisation lors de l ajout d un journal.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-08-14 13:54:14 UTC (rev 3607)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-08-14 14:28:26 UTC (rev 3608)
@@ -302,6 +302,12 @@
}
}
+ //if entrybook isn't found
+ //then create it
+ if (!found) {
+ entryBook = entryBookService.createEntryBook(entryBook);
+ }
+
//Sets accounts, check if they exist, if not create them
//-> 8 COMPTES SPECIAUX
// -> 89 BILAN
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2012-08-14 13:54:14 UTC (rev 3607)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2012-08-14 14:28:26 UTC (rev 3608)
@@ -104,7 +104,7 @@
<cell anchor="west">
<JRadioButton
id="newEntryBook"
- text="lima.home.entrybooks.create"
+ text="lima.ui.fiscalperiod.entrybooks.create"
selected="false"
buttonGroup="EntryBookGroup"
onActionPerformed="performNew()"/>
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-14 13:54:14 UTC (rev 3607)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-14 14:28:26 UTC (rev 3608)
@@ -276,6 +276,7 @@
lima.ui.fiscalperiod.closure=
lima.ui.fiscalperiod.delete.confirmation=
lima.ui.fiscalperiod.delete.title=
+lima.ui.fiscalperiod.entrybooks.create=
lima.ui.fiscalperiod.fiscalperiod=
lima.ui.fiscalperiod.open=
lima.ui.home.account=
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 2012-08-14 13:54:14 UTC (rev 3607)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-14 14:28:26 UTC (rev 3608)
@@ -134,7 +134,6 @@
lima.financialstatement.subamount=Calculer un sous-total
lima.financialstatementreport.listerror=Erreur lors de la récupération des données de la liste
lima.fiscalperiod.unbalancedtransactions=La période fiscale contient des transactions non équilibrées
-lima.home.entrybooks.create=
lima.identity=Identité
lima.identity.address=Adresse
lima.identity.address2=Adresse (suite)
@@ -276,6 +275,7 @@
lima.ui.fiscalperiod.closure=Cloture
lima.ui.fiscalperiod.delete.confirmation=Ètes vous sûre de vouloir supprimer cette période ? Cette action est irréversible \!
lima.ui.fiscalperiod.delete.title=Suppression de l'exercice
+lima.ui.fiscalperiod.entrybooks.create=Création d'un nouveau journal
lima.ui.fiscalperiod.fiscalperiod=Exercice
lima.ui.fiscalperiod.open=Ouvert
lima.ui.home.account=Plan comptable
1
0
r3607 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod
by mallon@users.chorem.org 14 Aug '12
by mallon@users.chorem.org 14 Aug '12
14 Aug '12
Author: mallon
Date: 2012-08-14 15:54:14 +0200 (Tue, 14 Aug 2012)
New Revision: 3607
Url: http://chorem.org/repositories/revision/lima/3607
Log:
refs #768 Correction sur la methode permettant le report a nouveau et la cloture de la periode fiscal selectionnee - Reste a voir de maniere plus precise les regles concernant le report a nouveau
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-08-14 13:05:05 UTC (rev 3606)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-08-14 13:54:14 UTC (rev 3607)
@@ -302,19 +302,6 @@
}
}
- //if entrybook isn't found
- //then create it
- if (!found) {
- entryBookService.createEntryBook(entryBook);
- entryBooksList = entryBookService.getAllEntryBooks();
- for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode())) {
- entryBook = entry;
- found = true;
- }
- }
- }
-
//Sets accounts, check if they exist, if not create them
//-> 8 COMPTES SPECIAUX
// -> 89 BILAN
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-08-14 13:05:05 UTC (rev 3606)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-08-14 13:54:14 UTC (rev 3607)
@@ -229,7 +229,6 @@
_("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
- //ask user for the entrybook to use for retained earnings
if (answerRetainedEarnings == JOptionPane.YES_OPTION) {
retainedEarnings = true;
1
0
14 Aug '12
Author: mallon
Date: 2012-08-14 15:05:05 +0200 (Tue, 14 Aug 2012)
New Revision: 3606
Url: http://chorem.org/repositories/revision/lima/3606
Log:
refs #768 Correction sur la methode permettant le report a nouveau et la cloture de la periode fiscal selectionnee
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-08-14 07:58:24 UTC (rev 3605)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-08-14 13:05:05 UTC (rev 3606)
@@ -187,7 +187,7 @@
fiscalPeriodDAO.getLastUnlockedFiscalPeriod();
//Check if the fiscal period to block is the oldest
- if (!oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
+ if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
throw new LimaBusinessException(_("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
}
} catch (TopiaException ex) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-08-14 07:58:24 UTC (rev 3605)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-08-14 13:05:05 UTC (rev 3606)
@@ -220,7 +220,7 @@
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- FiscalPeriod result = null;
+ FiscalPeriod result;
try {
if (fiscalPeriod.getLocked()) {
@@ -252,97 +252,113 @@
}
@Override
- public void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear,
- EntryBook entryBook) throws LimaException {
-
- // re-attach entities to current session
- FiscalPeriod localFiscalPeriod = null;
- try {
- FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
- localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId());
- } catch (TopiaException ex) {
- throw new LimaException("Can't find fiscal period", ex);
+ public boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) throws LimaException{
+ boolean found = false;
+ List<FinancialTransaction> financialTransactionsList =
+ financialTransactionService.getAllFinancialTransactions(
+ fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate());
+ //check if they are at least one transaction to be report
+ if (!financialTransactionsList.isEmpty()) {
+ int i = 0;
+ while (i < financialTransactionsList.size() && !found) {
+ Collection<Entry> entryList = financialTransactionsList.get(i).getEntry();
+ for (Entry entry : entryList) {
+ if (entry.getAccount() != null) {
+ if (Integer.valueOf(entry.getAccount().getAccountNumber().substring(0, 1)) < 6
+ && !entry.getAmount().equals(BigDecimal.ZERO)) {
+ found = true;
+ }
+ }
+ }
+ i++;
+ }
}
+ return found;
+ }
- //sets dates
- // - endRetainedEarnings: last day of the closing year
- // - beginRetainedEarnings: first open day of the following year
- // Date endRetainedEarnings = fiscalPeriod.getBeginDate();
- // Date beginRetainedEarnings = null;
+ @Override
+ public FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
+ boolean retainedEarnings) throws LimaException {
- //Sets entryBook
- //search for the entryBook to use using param
- boolean found = false;
- List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
- for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode())) {
- entryBook = entry;
- found = true;
+ if (entryBook != null && retainedEarnings) {
+
+ // re-attach entities to current session
+ FiscalPeriod localFiscalPeriod;
+ try {
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
+ localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId());
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't find fiscal period", ex);
}
- }
- //if entrybook isn't found
- //then create it
- if (!found) {
- entryBookService.createEntryBook(entryBook);
- entryBooksList = entryBookService.getAllEntryBooks();
+ //Sets entryBook
+ //search for the entryBook to use using param
+ boolean found = false;
+ List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
for (EntryBook entry : entryBooksList) {
if (!found && entry.getCode().equals(entryBook.getCode())) {
entryBook = entry;
found = true;
}
}
- }
- //Sets accounts, check if they exist, if not create them
- //-> 8 COMPTES SPECIAUX
- // -> 89 BILAN
- // -> 890 Bilan d'ouverture
- // -> 891 Bilan de cloture
+ //if entrybook isn't found
+ //then create it
+ if (!found) {
+ entryBookService.createEntryBook(entryBook);
+ entryBooksList = entryBookService.getAllEntryBooks();
+ for (EntryBook entry : entryBooksList) {
+ if (!found && entry.getCode().equals(entryBook.getCode())) {
+ entryBook = entry;
+ found = true;
+ }
+ }
+ }
- //89 BILAN
- Account accountMaster = accountService.getAccountByNumber("89");
- if (accountMaster == null) {
- accountMaster = new AccountImpl();
- accountMaster.setAccountNumber("89");
- accountMaster.setLabel("BILAN");
- accountMaster = accountService.createAccount(accountMaster);
- }
+ //Sets accounts, check if they exist, if not create them
+ //-> 8 COMPTES SPECIAUX
+ // -> 89 BILAN
+ // -> 890 Bilan d'ouverture
+ // -> 891 Bilan de cloture
- //890 Bilan d'ouverture
- Account beginRetainedAccount = accountService.getAccountByNumber("890");
- if (beginRetainedAccount == null) {
- beginRetainedAccount = new AccountImpl();
- beginRetainedAccount.setAccountNumber("890");
- beginRetainedAccount.setLabel("Bilan d'ouverture");
- beginRetainedAccount = accountService.createAccount(beginRetainedAccount);
- }
+ //89 BILAN
+ Account accountMaster = accountService.getAccountByNumber("89");
+ if (accountMaster == null) {
+ accountMaster = new AccountImpl();
+ accountMaster.setAccountNumber("89");
+ accountMaster.setLabel("BILAN");
+ accountService.createAccount(accountMaster);
+ }
- //891 Bilan de cloture
- Account endRetainedAccount = accountService.getAccountByNumber("891");
- if (endRetainedAccount == null) {
- endRetainedAccount = new AccountImpl();
- endRetainedAccount.setAccountNumber("891");
- endRetainedAccount.setLabel("Bilan de clôture");
- endRetainedAccount = accountService.createAccount(endRetainedAccount);
- }
+ //890 Bilan d'ouverture
+ Account beginRetainedAccount = accountService.getAccountByNumber("890");
+ if (beginRetainedAccount == null) {
+ beginRetainedAccount = new AccountImpl();
+ beginRetainedAccount.setAccountNumber("890");
+ beginRetainedAccount.setLabel("Bilan d'ouverture");
+ accountService.createAccount(beginRetainedAccount);
+ }
- //look for the last financial period from the previous fiscal year
- //check if the last financial period isn't blocked
- Collection<FinancialPeriod> fperiod = localFiscalPeriod.getFinancialPeriod();
- Iterator<FinancialPeriod> itr = fperiod.iterator();
- FinancialPeriod lastFPeriod = null;
- while (itr.hasNext()) {
- lastFPeriod = itr.next();
- }
+ //891 Bilan de cloture
+ Account endRetainedAccount = accountService.getAccountByNumber("891");
+ if (endRetainedAccount == null) {
+ endRetainedAccount = new AccountImpl();
+ endRetainedAccount.setAccountNumber("891");
+ endRetainedAccount.setLabel("Bilan de clôture");
+ endRetainedAccount = accountService.createAccount(endRetainedAccount);
+ }
- if (lastFPeriod.getLocked()) {
- throw new LimaBusinessException(_("lima-business.fiscalperiod.previousfiscalperiodalreadyblocked"));
- }
+ //look for the last financial period from the previous fiscal year
+ //check if the last financial period isn't blocked
+ Collection<FinancialPeriod> fperiod = localFiscalPeriod.getFinancialPeriod();
+ Iterator<FinancialPeriod> itr = fperiod.iterator();
+ FinancialPeriod lastFPeriod = null;
+ while (itr.hasNext()) {
+ lastFPeriod = itr.next();
+ }
- FinancialPeriod beginfinancialPeriod = null;
- //settings to be done only if a new year exists
- if (newyear) {
+ FinancialPeriod beginfinancialPeriod = null;
+
//look for the first financial period on the new fiscal year which is unlocked
found = false;
List<ClosedPeriodicEntryBook> resultsArray =
@@ -352,6 +368,7 @@
Collections.sort(closedPeriodicEntryBook, new FinancialPeriodComparator());
resultsArray.addAll(closedPeriodicEntryBook);
for (ClosedPeriodicEntryBook cPeriodicEntryBook : resultsArray) {
+
//check for - unlocked financial period
// - date after the closing fiscal year
// - unlocked entrybook
@@ -368,83 +385,89 @@
if (!found) {
throw new LimaBusinessException(_("lima-business.fiscalperiod.newfinancialperioderror"));
}
- }
- //holds entries of all closing transactions
- FinancialTransaction endfinancialTransaction = new FinancialTransactionImpl();
- if (lastFPeriod != null) {
- //Sets the endfinancialTransaction
- endfinancialTransaction.setEntryBook(entryBook);
- endfinancialTransaction.setTransactionDate(localFiscalPeriod.getEndDate());
- endfinancialTransaction = financialTransactionService.createFinancialTransaction(endfinancialTransaction);
- }
+ //holds entries of all closing transactions
+ FinancialTransaction endfinancialTransaction = new FinancialTransactionImpl();
+ if (lastFPeriod != null) {
+ //Sets the endfinancialTransaction
+ endfinancialTransaction.setEntryBook(entryBook);
+ endfinancialTransaction.setTransactionDate(localFiscalPeriod.getEndDate());
+ endfinancialTransaction = financialTransactionService.createFinancialTransaction(endfinancialTransaction);
+ }
- //holds entries of all opening transactions
- FinancialTransaction beginfinancialTransaction = new FinancialTransactionImpl();
- if (newyear) {
+ //holds entries of all opening transactions
+ FinancialTransaction beginfinancialTransaction = new FinancialTransactionImpl();
if (found) {
//Sets the endfinancialTransaction
beginfinancialTransaction.setEntryBook(entryBook);
beginfinancialTransaction.setTransactionDate(beginfinancialPeriod.getBeginDate());
beginfinancialTransaction = financialTransactionService.createFinancialTransaction(beginfinancialTransaction);
}
- }
- //Sets date for description, e.g: Report à nouveau (DATE)
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(fiscalPeriod.getEndDate());
+ //Sets date for description, e.g: Report à nouveau (DATE)
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(fiscalPeriod.getEndDate());
- //Sets entries
- BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(),
- localFiscalPeriod.getEndDate(), null, false, false);
+ //Sets entries
+ BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(),
+ localFiscalPeriod.getEndDate(), null, false, false);
- List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
+ List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
- for (ReportsDatas report : reportsDatasList) {
- //Account class from 1 to 5 and only non zero amount
- if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6
- && !report.getAmountSolde().equals(BigDecimal.ZERO)) {
- //close accounts by removing amounts from all class 1 to 5 accounts
- Entry beginEntry = new EntryImpl();
- beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
- beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(endfinancialTransaction);
- beginEntry.setAccount(report.getAccount());
- beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(!report.getSoldeDebit());
- financialTransactionService.createEntry(beginEntry);
- //save amounts inside account number 891
- beginEntry = new EntryImpl();
- beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
- beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(endfinancialTransaction);
- beginEntry.setAccount(endRetainedAccount);
- beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(report.getSoldeDebit());
- financialTransactionService.createEntry(beginEntry);
- //open new year accounts if new year exists and a date has been found for the transaction
- if (newyear && found) {
- //give back amounts from class 1 to 5 accounts
- beginEntry = new EntryImpl();
+ for (ReportsDatas report : reportsDatasList) {
+
+ //Account class from 1 to 5 and only non zero amount
+ if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6
+ && !report.getAmountSolde().equals(BigDecimal.ZERO)) {
+
+ //close accounts by removing amounts from all class 1 to 5 accounts
+ Entry beginEntry = new EntryImpl();
beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(beginfinancialTransaction);
+ beginEntry.setFinancialTransaction(endfinancialTransaction);
beginEntry.setAccount(report.getAccount());
beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(report.getSoldeDebit());
+ beginEntry.setDebit(!report.getSoldeDebit());
financialTransactionService.createEntry(beginEntry);
- //close account by removing amount from account number 890
+
+ //save amounts inside account number 891
beginEntry = new EntryImpl();
beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(beginfinancialTransaction);
+ beginEntry.setFinancialTransaction(endfinancialTransaction);
beginEntry.setAccount(endRetainedAccount);
beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(!report.getSoldeDebit());
+ beginEntry.setDebit(report.getSoldeDebit());
financialTransactionService.createEntry(beginEntry);
+
+ //open new year accounts if new year exists and a date has been found for the transaction
+ if (found) {
+ //give back amounts from class 1 to 5 accounts
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(beginfinancialTransaction);
+ beginEntry.setAccount(report.getAccount());
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(report.getSoldeDebit());
+ financialTransactionService.createEntry(beginEntry);
+ //close account by removing amount from account number 890
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(beginfinancialTransaction);
+ beginEntry.setAccount(endRetainedAccount);
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(!report.getSoldeDebit());
+ financialTransactionService.createEntry(beginEntry);
+ }
}
}
}
+
+ /*block the antepenultimate fiscalPeriod */
+ FiscalPeriod fiscalPeriodBlocked = blockFiscalPeriod(fiscalPeriod);
+ return fiscalPeriodBlocked;
}
/**
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-08-14 07:58:24 UTC (rev 3605)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-08-14 13:05:05 UTC (rev 3606)
@@ -56,7 +56,21 @@
void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
- void addRetainedEarnings(FiscalPeriod fiscalPeriod,
- boolean newyear,
- EntryBook entryBook) throws LimaException;
+ /**
+ * Eventually add retained earnings on last unclosed fiscal period,
+ * and in any case, block fiscal period
+ * @param fiscalPeriod fiscal period selected, and to block
+ * @param entryBook entry book where entries will be save in new fiscal period
+ * @param retainedEarnings to know if user want retained earnings
+ * @return fiscal period blocked
+ * */
+ FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
+ boolean retainedEarnings) throws LimaException;
+
+ /**
+ * Test if we have retained earnings on a fiscal period
+ * @param fiscalPeriod
+ * @return true if retained earnings are possible
+ * */
+ boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) throws LimaException;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-08-14 07:58:24 UTC (rev 3605)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-08-14 13:05:05 UTC (rev 3606)
@@ -32,6 +32,8 @@
import javax.swing.table.AbstractTableModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FiscalPeriod;
@@ -49,6 +51,8 @@
/** serialVersionUID. */
private static final long serialVersionUID = 77027335135838258L;
+ private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class);
+
protected List<FiscalPeriod> fiscalPeriods;
public void setFiscalPeriods(List<FiscalPeriod> fiscalPeriods) {
@@ -147,7 +151,12 @@
public void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
int row = fiscalPeriods.indexOf(fiscalPeriod);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Selected row : " + row);
+ }
+
fiscalPeriods.set(row, fiscalPeriod);
- fireTableRowsInserted(row, row);
+ fireTableRowsUpdated(row, row);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-08-14 07:58:24 UTC (rev 3605)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-08-14 13:05:05 UTC (rev 3606)
@@ -27,11 +27,7 @@
import static org.nuiton.i18n.I18n._;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.math.BigDecimal;
import java.util.Calendar;
-import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -46,7 +42,6 @@
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
-import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
import org.chorem.lima.entity.FinancialTransaction;
@@ -194,106 +189,72 @@
}
/**
- * Block selected fiscal period after user confirmation.
+ * Block selected fiscal period,
+ * and make new fiscal period and retained earnings
+ * after user confirmations
*/
public void blockFiscalPeriod() {
JXTable fiscalPeriodeTable = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) view.getFiscalPeriodTableModel();
+ FiscalPeriodTableModel model = view.getFiscalPeriodTableModel();
int selectedRow = fiscalPeriodeTable.getSelectedRow();
FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
//check if the user want to block the fiscal year
- int response = JOptionPane.showConfirmDialog(view,
+ int answerBlock = JOptionPane.showConfirmDialog(view,
_("lima.ui.fiscalperiod.block.confirmation"),
_("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
- if (response == JOptionPane.YES_OPTION) {
- // FIXME report a nouveau et bloquage en une seule opération
- // transactionnelle
- selectedFiscalPeriod = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod);
- model.updateFiscalPeriod(selectedFiscalPeriod);
+ if (answerBlock == JOptionPane.YES_OPTION) {
+ boolean retainedEarnings = false;
+ EntryBook entryBook = null;
- //use to tell if the user wants to create a new fiscal year
- boolean newyear = false;
- //check if two fiscal periods are open
- if (model.getRowCount() - 1 != selectedRow) {
- newyear = true; //two are open
- } else {
- //check if the user wants to create a new fiscal year
- response = JOptionPane.showConfirmDialog(view,
- _("lima.ui.fiscalperiod.block.newyear"),
- _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- // create a new fiscal year
- if (response == JOptionPane.YES_OPTION) {
- addFiscalPeriod();
- newyear = true;
- }
- }
+ //check if the user wants to create a new fiscal year
+ int answerCreate = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.block.newyear"),
+ _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
- addRetainedEarnings(selectedFiscalPeriod, newyear);
- view.getModel().setBlockEnabled(false);
- view.getModel().setDeleteEnabled(false);
- }
- }
+ // create a new fiscal year
+ if (answerCreate == JOptionPane.YES_OPTION) {
+ addFiscalPeriod();
- /**
- * Report à nouveau.
- *
- * @deprecated a déplacer en partie en metier
- * @param selectedFiscalPeriod
- * @param newyear
- */
- @Deprecated
- public void addRetainedEarnings(FiscalPeriod selectedFiscalPeriod, boolean newyear) {
+ //report if they are at least one transaction to be report
+ if (fiscalPeriodService.isRetainedEarnings(selectedFiscalPeriod)) {
- boolean found = false;
- List<FinancialTransaction> financialTransactionsList =
- financialTransactionService.getAllFinancialTransactions(
- selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
- //check if they are at least one transaction to be report
- if (!financialTransactionsList.isEmpty()) {
- int i = 0;
- while (i < financialTransactionsList.size() && !found) {
- Collection<Entry> entryList = financialTransactionsList.get(i).getEntry();
- for (Entry entry : entryList) {
- if (Integer.valueOf(entry.getAccount().getAccountNumber().substring(0, 1)) < 6
- && !entry.getAmount().equals(BigDecimal.ZERO)) {
- found = true;
+ //check if the user wants to report datas
+ int answerRetainedEarnings = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.block.addretainedearnings"),
+ _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ //ask user for the entrybook to use for retained earnings
+ if (answerRetainedEarnings == JOptionPane.YES_OPTION) {
+ retainedEarnings = true;
+
+ //Sets EntryBook
+ EntryBook newEntryBook = new EntryBookImpl();
+ RetainedEarningsEntryBookForm entryBookForm =
+ new RetainedEarningsEntryBookForm(view);
+ entryBookForm.setEntryBook(newEntryBook);
+
+ // jaxx constructor don't call super() ?
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
+ entryBook = entryBookForm.getEntryBook();
}
}
- i++;
}
+
+ FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, retainedEarnings);
+ model.updateFiscalPeriod(fiscalPeriodBlocked);
+
+ view.getModel().setBlockEnabled(false);
+ view.getModel().setDeleteEnabled(false);
}
- //report if they are at least one transaction to be report
- if (found) {
- //check if the user wants to report datas
- int response = JOptionPane.showConfirmDialog(view,
- _("lima.ui.fiscalperiod.block.addretainedearnings"),
- _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- //ask user for the entrybook to use for retained earnings
- if (response == JOptionPane.YES_OPTION) {
- //Sets EntryBook
- EntryBook newEntryBook = new EntryBookImpl();
- RetainedEarningsEntryBookForm entryBookForm =
- new RetainedEarningsEntryBookForm(view);
- entryBookForm.setEntryBook(newEntryBook);
- // jaxx constructor don't call super() ?
- entryBookForm.setLocationRelativeTo(view);
- entryBookForm.setVisible(true);
- // null == cancel action
- EntryBook entryBook = entryBookForm.getEntryBook();
- if (entryBook != null) {
- fiscalPeriodService.addRetainedEarnings(
- selectedFiscalPeriod, newyear, entryBook);
- }
- }
- }
}
-
+
@Override
public void notifyMethod(String serviceName, String methodeName) {
//refresh on import datas
@@ -340,12 +301,7 @@
enableBlock = true;
//only an empty and open fiscal period may be deleted
- if (financialTransactionList.size() <= 0){
- enableDelete = true;
-
- }else{
- enableDelete = false;
- }
+ enableDelete = financialTransactionList.size() <= 0;
}
}
view.getModel().setBlockEnabled(enableBlock);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-08-14 07:58:24 UTC (rev 3605)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-08-14 13:05:05 UTC (rev 3606)
@@ -237,19 +237,6 @@
getEntryAt(rowEntry).setLettering(letters);
fireTableRowsUpdated(rowEntry, rowEntry);
}
-// fireTableDataChanged();
}
- /**Copy parametrised entry, without amount*/
- /*public Entry copyEntryWithoutAmount(Entry entryToCopy) {
- Entry copiedEntry = new EntryImpl();
-
- copiedEntry.setAccount(entryToCopy.getAccount());
- copiedEntry.setDescription(entryToCopy.getDescription());
- copiedEntry.setDetail(entryToCopy.getDetail());
- copiedEntry.setFinancialTransaction(entryToCopy.getFinancialTransaction());
- copiedEntry.setVoucher(entryToCopy.getVoucher());
-
- return copiedEntry;
- }*/
}
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-14 07:58:24 UTC (rev 3605)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-14 13:05:05 UTC (rev 3606)
@@ -54,4 +54,5 @@
log4j.logger.org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel=DEBUG
log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionPeriodSearchPanel=DEBUG
log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchViewHandler=DEBUG
-log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodViewHandler=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodViewHandler=DEBUG
+log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel=DEBUG
\ No newline at end of file
1
0
14 Aug '12
Author: echatellier
Date: 2012-08-14 09:58:24 +0200 (Tue, 14 Aug 2012)
New Revision: 3605
Url: http://chorem.org/repositories/revision/lima/3605
Log:
Fix uncaught exception not displayed to user.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
Added: trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java 2012-08-14 07:58:24 UTC (rev 3605)
@@ -0,0 +1,81 @@
+/*
+ * #%L
+ * Lima Swing
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * Lima global exception handler.
+ *
+ * Catch all application uncaught and display it in a custom JoptionPane
+ * or JXErrorPane.
+ *
+ * See http://stackoverflow.com/a/4448569/1165234 for details.
+ *
+ * @author echatellier
+ * @since 0.6
+ */
+public class LimaExceptionHandler implements Thread.UncaughtExceptionHandler {
+
+ private static final Log log = LogFactory.getLog(LimaExceptionHandler.class);
+
+ @Override
+ public void uncaughtException(Thread t, Throwable ex) {
+ handleException(t.getName(), ex);
+ }
+
+ public void handle(Throwable thrown) {
+ // for EDT exceptions
+ handleException(Thread.currentThread().getName(), thrown);
+ }
+
+ protected void handleException(String tname, Throwable ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Global application exception", ex);
+ }
+
+ Throwable cause = ex;
+ while (ex != null && !(cause instanceof LimaBusinessException)) {
+ cause = cause.getCause();
+ }
+
+ if (cause instanceof LimaBusinessException) {
+ JOptionPane.showMessageDialog(null, cause.getMessage(),
+ _("lima.ui.common.error"), JOptionPane.ERROR_MESSAGE);
+ } else {
+ ErrorHelper errorHelper = new ErrorHelper(LimaConfig.getInstance());
+ errorHelper.showErrorDialog(null, ex.getMessage(), ex);
+ }
+ }
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2012-08-13 15:03:37 UTC (rev 3604)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2012-08-14 07:58:24 UTC (rev 3605)
@@ -30,21 +30,18 @@
import java.util.Arrays;
import java.util.Date;
-import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.HttpServerService;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
import org.chorem.lima.ui.MainViewHandler;
import org.chorem.lima.ui.opening.OpeningView;
-import org.chorem.lima.util.ErrorHelper;
/**
* Lima GUI main class.
@@ -52,7 +49,7 @@
* @author ore
* @version $Revision$
*/
-public class LimaMain implements Thread.UncaughtExceptionHandler {
+public class LimaMain {
/** Log. */
private static final Log log = LogFactory.getLog(LimaMain.class);
@@ -85,32 +82,15 @@
// display main ui
if (config.isLaunchui()) {
+
// override default exception management (after config init)
- Thread.setDefaultUncaughtExceptionHandler(new LimaMain());
+ Thread.setDefaultUncaughtExceptionHandler(new LimaExceptionHandler());
+ System.setProperty("sun.awt.exception.handler", LimaExceptionHandler.class.getName());
launch(context);
}
}
- public void uncaughtException(Thread t, Throwable ex) {
- if (log.isErrorEnabled()) {
- log.error("Global application exception", ex);
- }
-
- Throwable cause = ex;
- while (ex != null && !(cause instanceof LimaBusinessException)) {
- cause = cause.getCause();
- }
-
- if (cause instanceof LimaBusinessException) {
- JOptionPane.showMessageDialog(null, cause.getMessage(),
- _("lima.ui.common.error"), JOptionPane.ERROR_MESSAGE);
- } else {
- ErrorHelper errorHelper = new ErrorHelper(config);
- errorHelper.showErrorDialog(null, ex.getMessage(), ex);
- }
- }
-
/**
* initialisation de l'application :
* <p/>
1
0
r3604 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch
by mallon@users.chorem.org 13 Aug '12
by mallon@users.chorem.org 13 Aug '12
13 Aug '12
Author: mallon
Date: 2012-08-13 17:03:37 +0200 (Mon, 13 Aug 2012)
New Revision: 3604
Url: http://chorem.org/repositories/revision/lima/3604
Log:
refs #755 Correction sur le listener du filtre 'Date'
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2012-08-13 14:42:17 UTC (rev 3603)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2012-08-13 15:03:37 UTC (rev 3604)
@@ -40,14 +40,8 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Calendar;
@@ -76,16 +70,18 @@
Date date = calendar.getTime();
date = DateUtils.truncate(date, Calendar.DATE);
final JXDatePicker datePicker = new JXDatePicker(date);
- ActionListener dateActionListener = new ActionListener() {
+ PropertyChangeListener datePCListener = new PropertyChangeListener() {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void propertyChange(PropertyChangeEvent evt) {
handler.setBeginDate(datePicker.getDate());
+ handler.setEndDate(datePicker.getDate());
handler.refresh();
}
};
handler.setBeginDate(datePicker.getDate());
+ handler.setEndDate(datePicker.getDate());
handler.refresh();
- datePicker.addActionListener(dateActionListener);
+ datePicker.addPropertyChangeListener(datePCListener);
removeAll();
add(datePicker);
break;
1
0
r3603 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/combobox lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch
by mallon@users.chorem.org 13 Aug '12
by mallon@users.chorem.org 13 Aug '12
13 Aug '12
Author: mallon
Date: 2012-08-13 16:42:17 +0200 (Mon, 13 Aug 2012)
New Revision: 3603
Url: http://chorem.org/repositories/revision/lima/3603
Log:
fixes #761 Correction permettant d afficher une liste deroulante avec toutes les lettres utilisees pour les entrees.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-13 12:58:13 UTC (rev 3602)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -194,6 +194,21 @@
}
@Override
+ public List<String> getAllLetters() throws LimaException {
+ List<String> letters;
+ try {
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
+
+ letters = new ArrayList<String>(entryDAO.findLetters());
+
+ } catch (Exception ex) {
+ throw new LimaException("Can't get all letters", ex);
+ }
+
+ return letters;
+ }
+
+ @Override
public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException{
Entry newSameAccountEntry = null;
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-08-13 12:58:13 UTC (rev 3602)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -76,8 +76,17 @@
void removeEntry(Entry entry) throws LimaException;
+ /** Find the last letter used
+ * and increment them
+ * @return a string representing the last letter
+ * */
String getNextLetters() throws LimaException;
+ /** Find all the letters used
+ * @return a list of string containing all the letters
+ * */
+ List<String> getAllLetters() throws LimaException;
+
/**
* From to selected entries, create one with same account and
* difference between the amounts, and another one with
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-13 12:58:13 UTC (rev 3602)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -129,6 +129,11 @@
" order by E.lettering desc";
List<String> result = new ArrayList<String>(context.findAll(query));
+
+ if (log.isDebugEnabled()) {
+ log.debug("Size of result : " + result.size());
+ }
+
return result;
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-08-13 12:58:13 UTC (rev 3602)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -327,7 +327,10 @@
if (lettering != null) {
query += " AND E.lettering = :lettering";
args.add("lettering");
- args.add("%" + lettering + "%");
+ args.add(lettering);
+ if (log.isDebugEnabled()) {
+ log.debug("Lettering filter : -" + lettering + "-");
+ }
}
// accounts
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2012-08-13 12:58:13 UTC (rev 3602)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -97,7 +97,7 @@
result = entryBookService.getAllEntryBooks();
} catch (LimaException eee) {
if (log.isDebugEnabled()) {
- log.debug("Can't get list accounts", eee);
+ log.debug("Can't get list entry books", eee);
}
}
return result;
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -0,0 +1,91 @@
+package org.chorem.lima.ui.combobox;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.api.AccountService;
+import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import java.util.List;
+
+/**
+ * Date: 13/08/12
+ *
+ * @author mallon <mallon(a)codelutin.com>
+ * @since 0.6-alpha-2
+ */
+public class LetterComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log =
+ LogFactory.getLog(AccountComboBoxModel.class);
+
+ protected Object selectedAccount;
+
+ protected List<String> datasCache;
+
+ protected FinancialTransactionService financialTransactionService;
+
+ public LetterComboBoxModel() {
+ financialTransactionService =
+ LimaServiceFactory.getService(FinancialTransactionService.class);
+ LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
+ datasCache = getDataList();
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return selectedAccount;
+ }
+
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedAccount = anItem;
+ fireContentsChanged(this, -1, -1);
+ }
+
+
+ @Override
+ public Object getElementAt(int index) {
+ return datasCache.get(index);
+ }
+
+ @Override
+ public int getSize() {
+ return datasCache.size();
+ }
+
+ public List<String> getDataList() {
+ List<String> result = null;
+ try {
+ result = financialTransactionService.getAllLetters();
+ } catch (LimaException eee) {
+ if (log.isDebugEnabled()) {
+ log.debug("Can't get list letters", eee);
+ }
+ }
+ return result;
+
+ }
+
+ public void refresh() {
+ datasCache = getDataList();
+ fireContentsChanged(this, 0, datasCache.size());
+ }
+
+ @Override
+ public void notifyMethod(String serviceName, String methodeName) {
+ if (methodeName.contains("Letter") ||
+ methodeName.contains("importAll")) {
+ refresh();
+ }
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2012-08-13 12:58:13 UTC (rev 3602)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -43,7 +43,6 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
/**
* Handler associated with financial transaction view.
@@ -120,6 +119,10 @@
financialTransactionSearch.setLettering(lettering);
}
+ public String getLetter() {
+ return financialTransactionSearch.getLettering();
+ }
+
public String getAccountsList() {
return financialTransactionSearch.getAccountList();
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -0,0 +1,68 @@
+package org.chorem.lima.ui.financialtransactionsearch;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.ui.combobox.LetterComboBoxModel;
+
+import javax.swing.JComboBox;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+/**
+ * Date: 13/08/12
+ *
+ * @author mallon <mallon(a)codelutin.com>
+ * @since 0.6-alpha-2
+ */
+public class LetterSearchComboBox extends JComboBox implements KeyListener {
+
+ private static final long serialVersionUID = 1L;
+
+ protected FinancialTransactionSearchViewHandler handler;
+
+ public LetterSearchComboBox(FinancialTransactionSearchViewHandler handler) {
+ this.handler = handler;
+ LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel();
+ setModel(letterComboBoxModel);
+ setEditable(true);
+ getEditor().getEditorComponent().addKeyListener(this);
+ addActionListener(this);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object object = getSelectedItem();
+ if (object instanceof String) {
+ handler.setLetter((String) getSelectedItem());
+ }
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ Object object = getSelectedItem();
+ if (object instanceof String) {
+ String letter = (String) getSelectedItem();
+ //to prevent useless call to service
+ if (!letter.equals(handler.getLetter())) {
+ handler.setLetter(letter);
+ }
+
+ }
+
+ // delegate popup list menu
+ if (e.getKeyChar() == KeyEvent.VK_ENTER) {
+ firePopupMenuCanceled();
+ }
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2012-08-13 12:58:13 UTC (rev 3602)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2012-08-13 14:42:17 UTC (rev 3603)
@@ -50,9 +50,9 @@
break;
case SELECT_ONE:
- /*LetterSearchComboBox comboBox = new LetterSearchComboBox(handler);
+ LetterSearchComboBox comboBox = new LetterSearchComboBox(handler);
removeAll();
- add(comboBox);*/
+ add(comboBox);
break;
}
1
0