Author: mallon Date: 2012-08-22 17:11:37 +0200 (Wed, 22 Aug 2012) New Revision: 3630 Url: http://chorem.org/repositories/revision/lima/3630 Log: refs #769 Correction sur le menu 'Documents' et l affichage de la liste deroulante des formats. 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-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.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-22 11:33:49 UTC (rev 3629) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-22 15:11:37 UTC (rev 3630) @@ -872,11 +872,10 @@ @Override public void createVatDocuments(Date beginDate, Date endDate, - FormatsEnum format, String autocomplete) throws LimaException { String filePath = path + File.separator - + DocumentsEnum.VAT.getFileName() + format.getExtension(); + + DocumentsEnum.VAT.getFileName() + ".pdf"; String path = LimaConfig.getInstance().getReportsDir().getAbsolutePath(); @@ -909,22 +908,24 @@ // load the document doc = PDDocument.load(reportsStream); - if (autocomplete.equals("true")) { + if (autocomplete != null) { + if (autocomplete.equals("true")) { - SetField fields = new SetField(); + SetField fields = new SetField(); - //search for all VAT Statements from the report - List<VatStatement> vatStatementsList = vatStatementService.getAllVatStatements(); - for (VatStatement vatStatement : vatStatementsList) { - //search for amount to display - BigDecimal amount = vatStatementService.vatStatementAmounts(vatStatement, beginDate, endDate).getAmount(); - //display amount only if it is a child and has a BoxName - if (vatStatement.getBoxName() != null && !vatStatement.isHeader()) { - fields.setField(doc, vatStatement.getBoxName(), amount.toString()); + //search for all VAT Statements from the report + List<VatStatement> vatStatementsList = vatStatementService.getAllVatStatements(); + for (VatStatement vatStatement : vatStatementsList) { + //search for amount to display + BigDecimal amount = vatStatementService.vatStatementAmounts(vatStatement, beginDate, endDate).getAmount(); + //display amount only if it is a child and has a BoxName + if (vatStatement.getBoxName() != null && !vatStatement.isHeader()) { + fields.setField(doc, vatStatement.getBoxName(), amount.toString()); + } } } + } - } // save the updated document to the new file and close doc.save(filePath); doc.close(); 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-22 11:33:49 UTC (rev 3629) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-22 15:11:37 UTC (rev 3630) @@ -156,9 +156,8 @@ IOUtils.copy(in, out); } } - //if doc pdf or html - else if (model != null && format != null && beginDate != null && endDate != null) { - FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format); + else if (model != null /*&& format != null*/ && beginDate != null && endDate != null) { + //FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format); String accountReport = null; String entryBooksReport = null; String generalEntryBooksReport = null; @@ -204,7 +203,7 @@ break; case VAT: documentService.createVatDocuments( - beginDateFormat, endDateFormat, formatsEnum, + beginDateFormat, endDateFormat, autocomplete); break; } @@ -214,20 +213,11 @@ log.error("Can't parse date", eeePE); } - // FIXME echatellier 20120606 on connait le fichier - // ou sera généré le rapport, et on peut donc le relire - // 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()); - OutputStream out = resp.getOutputStream(); - if (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null - || balanceReport != null || ledgerReport != null || financialReport != null) { - String report = null; + if ( (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null + || balanceReport != null || ledgerReport != null || financialReport != null)) { + String report; + resp.setContentType(".html"); + OutputStream out = resp.getOutputStream(); if (accountReport != null) { report = accountReport; } else if (entryBooksReport != null) { @@ -243,6 +233,12 @@ } IOUtils.write(report, out, Charsets.UTF_8); } else { + URL doc = new URL("file:" + path + File.separator + model + ".pdf"); + if (log.isDebugEnabled()) { + log.debug("file:" + path + File.separator + model + ".pdf"); + } + resp.setContentType(".pdf"); + OutputStream out = resp.getOutputStream(); InputStream in = doc.openStream(); IOUtils.copy(in, out); } @@ -298,17 +294,18 @@ + "\" 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\">"); + + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"); + //+ "Format : <select name=\"format\">"); - for (FormatsEnum formatsEnum : FormatsEnum.values()) { + /*TODO : voir pour générer des pdf avec éventuellement iReport*/ + /*for (FormatsEnum formatsEnum : FormatsEnum.values()) { pageContent.append("<option value=\"" + formatsEnum.getExtension() + "\">" + formatsEnum.getDescription() + "</option>\n"); - } + }*/ - pageContent.append("</select>\n" - + "Documents : <select name=\"model\">"); + pageContent.append(/*"</select>\n" + + */"Documents : <select name=\"model\">"); for (DocumentsEnum documentsEnum : DocumentsEnum.values()) { pageContent.append("<option value=\"" @@ -316,12 +313,11 @@ + documentsEnum.getDescription() + "</option>\n"); } - pageContent.append("</select>\n" + pageContent.append("</select><input type=\"submit\">\n" + + "</form></td>" + "<tr><td class=\"tdright\"><img src=\"?img=entries.png\"/></td></tr>\n" + "<tr><td class=\"tdright\"><img src=\"?img=accounts.png\"/></td></tr>\n" + "<tr><td class=\"tdright\"><img src=\"?img=entrybooks.png\"/></td>\n" - + "<td class=\"tdright\"><input type=\"submit\"></td></tr>" - + "</form>\n" + "<tr><td class=\"tdright\"><img src=\"?img=fiscalperiods.png\"/></td></tr>\n" + "</table>\n" + "</body>\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-22 11:33:49 UTC (rev 3629) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-22 15:11:37 UTC (rev 3630) @@ -48,7 +48,7 @@ String createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException; - void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format, String autocomplete) throws LimaException; + void createVatDocuments(Date beginDate, Date endDate, 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/financialtransaction/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-08-22 11:33:49 UTC (rev 3629) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-08-22 15:11:37 UTC (rev 3630) @@ -51,6 +51,8 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.ParsePosition; import java.util.Date; /** @@ -122,12 +124,18 @@ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { boolean isHighlighted = false; + Object valueDebit = adapter.getValueAt(adapter.row, 4); + Object valueCredit = adapter.getValueAt(adapter.row, 5); Object value = adapter.getValueAt(adapter.row, 6); if (value instanceof BigDecimal) { BigDecimal currentBalance = (BigDecimal) value; - // can compare two BigDecimals with different scales - // e.g: 3.1 == 3.10 - if (currentBalance.compareTo(BigDecimal.ZERO) != 0) { + DecimalFormat decimalFormat = new DecimalFormat(); + Double currentBalanceDouble = decimalFormat.parse(currentBalance.toString(), new ParsePosition(0)).doubleValue(); + Double debitDouble = decimalFormat.parse(valueDebit.toString(), new ParsePosition(0)).doubleValue(); + Double creditDouble = decimalFormat.parse(valueCredit.toString(), new ParsePosition(0)).doubleValue(); + + if (!currentBalanceDouble.toString().equals("0.0") || (valueDebit.equals(BigDecimal.ZERO) || debitDouble.toString().equals("0.0")) + && (valueCredit.equals(BigDecimal.ZERO) || creditDouble.toString().equals("0.0"))) { isHighlighted = true; } } @@ -147,9 +155,13 @@ Object valueDebit = adapter.getValueAt(adapter.row, 4); Object valueCredit = adapter.getValueAt(adapter.row, 5); + boolean isEntry = !(adapter.getValueAt(adapter.row, 0) instanceof Date); - return (valueDebit.equals(BigDecimal.ZERO) || valueDebit.toString().equals("0.00")) - && (valueCredit.equals(BigDecimal.ZERO) || valueCredit.toString().equals("0.00")); + DecimalFormat decimalFormat = new DecimalFormat(); + Double debitDouble = decimalFormat.parse(valueDebit.toString(), new ParsePosition(0)).doubleValue(); + Double creditDouble = decimalFormat.parse(valueCredit.toString(), new ParsePosition(0)).doubleValue(); + return (isEntry && (valueDebit.equals(BigDecimal.ZERO) || debitDouble.toString().equals("0.0")) + && (valueCredit.equals(BigDecimal.ZERO) || creditDouble.toString().equals("0.0"))); } };