This is an automated email from the git hooks/post-receive script. New commit to branch feature/newReportBuilder in repository lima. See http://git.chorem.org/lima.git commit b39b384480ec0586e2b73449fd95d1c19789d0e2 Author: dcosse <japbiw74> Date: Tue Nov 18 18:31:24 2014 +0100 refs #769 Ajout génération rappor Journal Général Provisoire --- .../chorem/lima/business/api/DocumentService.java | 53 ----- ...eportService.java => BalanceReportService.java} | 6 +- .../api/report/GeneralEntryBookReportService.java | 21 ++ ...viceImpl.java => BalanceReportServiceImpl.java} | 22 +- .../report/GeneralEntryBookReportServiceImpl.java | 183 +++++++++++++++ lima-callao/src/main/xmi/accounting-model.zargo | Bin 48316 -> 51731 bytes .../main/jasperreports/balance/BalanceReport.jrxml | 15 +- .../EntryBookMainReport.jrxml} | 237 +++++++++++-------- .../generalEntryBook/EntryBookPeriodReport.jrxml | 137 +++++++++++ .../GeneralEntryBookEntryReport.jrxml | 81 +++++++ .../chorem/lima/web/action/DocumentService.java | 259 +++------------------ ...alanceReportBuilder.java => ReportBuilder.java} | 40 ++-- .../chorem/lima/web/service/HttpServerService.java | 21 +- .../org/chorem/lima/web/action/ReportTest.java | 2 +- 14 files changed, 643 insertions(+), 434 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java deleted file mode 100644 index f090da5..0000000 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * #%L - * Lima :: business API - * %% - * 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.business.api; - -import org.chorem.lima.beans.BalanceReport; - -import java.util.Date; - -/** - * Interface to create pdf and html docs - * - * @author john - */ - -public interface DocumentService { - - String createFinancialStatementsDocuments(Date beginDate, Date endDate); - - String createLedgerDocuments(Date beginDate, Date endDate); - - String createBalanceDocuments(Date beginDate, Date endDate); - - String createEntryBooksDocuments(Date beginDate, Date endDate); - - String createGeneralEntryBooksDocuments(Date beginDate, Date endDate); - - void createVatDocuments(Date beginDate, Date endDate, String autocomplete); - - String createAccountDocument(Date beginDate, Date endDate, String account); - - BalanceReport buildGeneralEntryBooksDocuments(Date beginDate, - Date endDate); -} diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceBeanReportService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceReportService.java similarity index 85% rename from lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceBeanReportService.java rename to lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceReportService.java index 401f69b..3967f57 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceBeanReportService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceReportService.java @@ -22,14 +22,14 @@ package org.chorem.lima.business.api.report; * #L% */ -import org.chorem.lima.beans.BalanceReport; +import org.chorem.lima.beans.DocumentReport; import java.util.Date; /** * Created by davidcosse on 06/11/14. */ -public interface BalanceBeanReportService { +public interface BalanceReportService { /** * Generate the necessary beans to make balance report. @@ -39,5 +39,5 @@ public interface BalanceBeanReportService { * @param selectedAccounts if null all accounts will be selected * @return the balance beans */ - BalanceReport generateBalanceReportDocument(Date from, Date to, String selectedAccounts); + DocumentReport getBalanceDocumentReport(Date from, Date to, String selectedAccounts, String Currency); } diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/report/GeneralEntryBookReportService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/report/GeneralEntryBookReportService.java new file mode 100644 index 0000000..553b6d1 --- /dev/null +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/report/GeneralEntryBookReportService.java @@ -0,0 +1,21 @@ +package org.chorem.lima.business.api.report; + +import org.chorem.lima.beans.DocumentReport; + +import java.util.Date; + +/** + * Created by davidcosse on 17/11/14. + */ +public interface GeneralEntryBookReportService { + + /** + * Generate the necessary beans to make general entry book report. + * + * @param from from date + * @param to to date + * @param currency the currency used + * @return the entryBook beans + */ + DocumentReport getEntryBookDocumentReport(Date from, Date to, String currency); +} diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceBeanReportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceReportServiceImpl.java similarity index 93% rename from lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceBeanReportServiceImpl.java rename to lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceReportServiceImpl.java index 47af558..6a2ea1d 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceBeanReportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceReportServiceImpl.java @@ -25,17 +25,17 @@ package org.chorem.lima.business.ejb.report; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; -import org.chorem.lima.beans.BalanceReport; +import org.chorem.lima.beans.DocumentReport; import org.chorem.lima.beans.BalanceReportAccount; import org.chorem.lima.beans.BalanceReportAccountImpl; -import org.chorem.lima.beans.BalanceReportImpl; +import org.chorem.lima.beans.DocumentReportImpl; import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.beans.BalanceTrialImpl; import org.chorem.lima.beans.ReportsDatas; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.api.FinancialPeriodService; import org.chorem.lima.business.api.IdentityService; -import org.chorem.lima.business.api.report.BalanceBeanReportService; +import org.chorem.lima.business.api.report.BalanceReportService; import org.chorem.lima.business.ejb.AbstractLimaService; import org.chorem.lima.business.utils.AccountComparator; import org.chorem.lima.entity.Account; @@ -60,9 +60,9 @@ import java.util.List; * Created by davidcosse on 04/11/14. */ @Stateless -@Remote(BalanceBeanReportService.class) +@Remote(BalanceReportService.class) @TransactionAttribute -public class BalanceBeanReportServiceImpl extends AbstractLimaService implements BalanceBeanReportService { +public class BalanceReportServiceImpl extends AbstractLimaService implements BalanceReportService { @EJB protected FinancialPeriodService financialPeriodService; @@ -77,6 +77,7 @@ public class BalanceBeanReportServiceImpl extends AbstractLimaService implements protected static String ROOT_PATH = new File("").getAbsolutePath(); protected static String BALANCE_REPORT_ACCOUNT_REPORT_PATH = ROOT_PATH + "/lima-web/src/main/jasperreports/balance/BalanceReportAccountReport.jrxml"; protected static String BALANCE_SUB_ACCOUNTS_REPORT_PATH = ROOT_PATH + "/lima-web/src/main/jasperreports/balance/BalanceSubAccountsReport.jrxml"; + protected static final String TITLE = "BALANCE"; protected static final Predicate<BalanceReportAccount> HAS_NO_ENTRY = new Predicate<BalanceReportAccount>() { @@ -91,20 +92,18 @@ public class BalanceBeanReportServiceImpl extends AbstractLimaService implements }; @Override - public BalanceReport generateBalanceReportDocument(Date from, Date to, String selectedAccounts) { - BalanceReport result = new BalanceReportImpl(); + public DocumentReport getBalanceDocumentReport(Date from, Date to, String selectedAccounts, String currency) { + DocumentReport result = new DocumentReportImpl(); Identity identity = identityService.getIdentity(); result.setCompanyName(StringUtils.isNotBlank(identity.getName()) ? identity.getName() : ""); - // TODO DCossé 06/11/14 - String currency = "€"; - // general info about balance report + result.setTitle(TITLE); result.setCurrency(currency); result.setFromDate(from); result.setToDate(to); - result.setBalanceReportAccountPath(BALANCE_REPORT_ACCOUNT_REPORT_PATH); + result.setSubReportPath(BALANCE_REPORT_ACCOUNT_REPORT_PATH); BalanceTrial balanceTrial = new BalanceTrialImpl(); @@ -206,7 +205,6 @@ public class BalanceBeanReportServiceImpl extends AbstractLimaService implements } else { balanceReportAccount.setSoldeCredit(solde.compareTo(BigDecimal.ZERO) == 0 ? "" : String.valueOf(solde.abs())); balanceReportAccount.setSoldeDebit(""); - } balanceReportAccount.setAmountCredit(credit.compareTo(BigDecimal.ZERO) == 0 ? "" : String.valueOf(credit)); diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/GeneralEntryBookReportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/GeneralEntryBookReportServiceImpl.java new file mode 100644 index 0000000..f70f5c7 --- /dev/null +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/GeneralEntryBookReportServiceImpl.java @@ -0,0 +1,183 @@ +package org.chorem.lima.business.ejb.report; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.LimaTechnicalException; +import org.chorem.lima.beans.DocumentReport; +import org.chorem.lima.beans.DocumentReportImpl; +import org.chorem.lima.beans.EntryBookPeriodReport; +import org.chorem.lima.beans.EntryBookPeriodReportImpl; +import org.chorem.lima.beans.GeneralEntryBookEntry; +import org.chorem.lima.beans.GeneralEntryBookEntryImpl; +import org.chorem.lima.business.api.ClosedPeriodicEntryBookService; +import org.chorem.lima.business.api.EntryService; +import org.chorem.lima.business.api.FinancialPeriodService; +import org.chorem.lima.business.api.IdentityService; +import org.chorem.lima.business.api.report.GeneralEntryBookReportService; +import org.chorem.lima.business.ejb.AbstractLimaService; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.Identity; + +import javax.ejb.EJB; +import javax.ejb.Remote; +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import java.io.File; +import java.math.BigDecimal; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +/** + * Created by davidcosse on 17/11/14. + */ +@Stateless +@Remote(GeneralEntryBookReportService.class) +@TransactionAttribute +public class GeneralEntryBookReportServiceImpl extends AbstractLimaService implements GeneralEntryBookReportService { + + protected static final Log log = LogFactory.getLog(GeneralEntryBookReportServiceImpl.class); + + protected static final Predicate<GeneralEntryBookEntry> HAS_NO_ENTRY = new Predicate<GeneralEntryBookEntry>() { + + @Override + public boolean apply(GeneralEntryBookEntry generalEntryBookEntry) { + boolean result = StringUtils.isBlank(generalEntryBookEntry.getDebit()) && + StringUtils.isBlank(generalEntryBookEntry.getCredit()); + return result; + } + }; + + @EJB + protected FinancialPeriodService financialPeriodService; + + @EJB + protected ClosedPeriodicEntryBookService closedPeriodicEntryBookService; + + @EJB + protected EntryService entryService; + + @EJB + protected IdentityService identityService; + + protected static String ROOT_PATH = new File("").getAbsolutePath(); + protected static String ENTRY_BOOK_PERIOD_REPORT_PATH = ROOT_PATH + "/lima-web/src/main/jasperreports/generalEntryBook/EntryBookPeriodReport.jrxml"; + protected static String GENERAL_ENTRY_BOOK_ENTRY_REPORT_PATH = ROOT_PATH + "/lima-web/src/main/jasperreports/generalEntryBook/GeneralEntryBookEntryReport.jrxml"; + protected static final String TITLE = "Journal Général Provisoire"; + + @Override + public DocumentReport getEntryBookDocumentReport(Date beginDate, Date endDate, String currency) { + DocumentReport result = new DocumentReportImpl(); + try { + + if (beginDate != null && endDate != null) { + Identity identity = identityService.getIdentity(); + result.setCompanyName(StringUtils.isNotBlank(identity.getName()) ? identity.getName() : ""); + + // general infos about balance report + result.setTitle(TITLE); + result.setCurrency(currency); + result.setFromDate(beginDate); + result.setToDate(endDate); + result.setSubReportPath(ENTRY_BOOK_PERIOD_REPORT_PATH); + + List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(beginDate, endDate); + + BigDecimal amountDebit = BigDecimal.ZERO; + BigDecimal amountCredit = BigDecimal.ZERO; + + // for each FinancialPeriod an EntryBookPeriodReport is created + for (FinancialPeriod financialPeriod : financialPeriods) { + + List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = + closedPeriodicEntryBookService.getAllByDates( + financialPeriod.getBeginDate(), financialPeriod.getEndDate()); + + BigDecimal subAmountDebit = BigDecimal.ZERO; + BigDecimal subAmountCredit = BigDecimal.ZERO; + + // for all ClosedPeriodicEntryBook with same code we create an GeneralEntryBookEntry + Map<String, GeneralEntryBookEntry> generalEntryBookEntryByEntryBookCode = Maps.newHashMap(); + BigDecimal entryBookDebit = BigDecimal.ZERO; + BigDecimal entryBookCredit = BigDecimal.ZERO; + for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) { + + String entryBookCode = closedPeriodicEntryBook.getEntryBook().getCode(); + GeneralEntryBookEntry generalEntryBookEntry = generalEntryBookEntryByEntryBookCode.get(entryBookCode); + if (generalEntryBookEntry == null) { + generalEntryBookEntry = new GeneralEntryBookEntryImpl(); + generalEntryBookEntry.setCode(closedPeriodicEntryBook.getEntryBook().getCode()); + generalEntryBookEntry.setLibelle(closedPeriodicEntryBook.getEntryBook().getLabel()); + generalEntryBookEntryByEntryBookCode.put(entryBookCode, generalEntryBookEntry); + + // init debit and credit + entryBookDebit = BigDecimal.ZERO; + entryBookCredit = BigDecimal.ZERO; + + if (log.isDebugEnabled()) { + log.debug("Entrybook code added : " + closedPeriodicEntryBook.getEntryBook().getCode()); + } + + } + + List<Object[]> results = entryService.findDebitCreditOfTransaction(closedPeriodicEntryBook); + + 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(1)[1]; + } + } + entryBookDebit = entryBookDebit.add(debit); + entryBookCredit = entryBookCredit.add(credit); + + subAmountDebit= subAmountDebit.add(entryBookDebit); + subAmountCredit = subAmountCredit.add(entryBookCredit); + generalEntryBookEntry.setDebit(entryBookDebit.compareTo(BigDecimal.ZERO) == 0 ? "" : entryBookDebit.toPlainString()); + generalEntryBookEntry.setCredit(entryBookCredit.compareTo(BigDecimal.ZERO) == 0 ? "" : entryBookCredit.toPlainString()); + + } + Collection<GeneralEntryBookEntry> generalEntryBookEntries = generalEntryBookEntryByEntryBookCode.values(); + Iterables.removeIf(generalEntryBookEntries, HAS_NO_ENTRY); + + if (subAmountCredit.compareTo(BigDecimal.ZERO) != 0 && subAmountDebit.compareTo(BigDecimal.ZERO) != 0) { + EntryBookPeriodReport entryBookPeriodReport = new EntryBookPeriodReportImpl(); + entryBookPeriodReport.setPeriode(financialPeriod.getBeginDate()); + entryBookPeriodReport.setSubReportPath(GENERAL_ENTRY_BOOK_ENTRY_REPORT_PATH); + entryBookPeriodReport.setSoldeDebit(subAmountDebit.compareTo(BigDecimal.ZERO) == 0 ? "" : subAmountDebit.toPlainString()); + entryBookPeriodReport.setSoldeCredit(subAmountCredit.compareTo(BigDecimal.ZERO) == 0 ? "" : subAmountCredit.toPlainString()); + entryBookPeriodReport.setGeneralEntryBookEntry(Lists.newArrayList(generalEntryBookEntries)); + result.addEntryBookPeriodReport(entryBookPeriodReport); + + amountCredit = amountCredit.add(subAmountCredit); + amountDebit = amountDebit.add(subAmountDebit); + } + + } + + result.setSoldeDebit(amountDebit.compareTo(BigDecimal.ZERO) == 0 ? "" : amountDebit.toPlainString()); + result.setSoldeCredit(amountCredit.compareTo(BigDecimal.ZERO) == 0 ? "" : amountCredit.toPlainString()); + } + } catch (Exception ex) { + log.error("Can't create document", ex); + throw new LimaTechnicalException("Can't create document", ex); + } + return result; + } +} diff --git a/lima-callao/src/main/xmi/accounting-model.zargo b/lima-callao/src/main/xmi/accounting-model.zargo index a308d61..b019fe8 100644 Binary files a/lima-callao/src/main/xmi/accounting-model.zargo and b/lima-callao/src/main/xmi/accounting-model.zargo differ diff --git a/lima-web/src/main/jasperreports/balance/BalanceReport.jrxml b/lima-web/src/main/jasperreports/balance/BalanceReport.jrxml index b114e8e..0332994 100644 --- a/lima-web/src/main/jasperreports/balance/BalanceReport.jrxml +++ b/lima-web/src/main/jasperreports/balance/BalanceReport.jrxml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1 --> -<!-- 2014-11-17T15:00:12 --> +<!-- 2014-11-18T10:06:48 --> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="BalanceReport" pageWidth="595" pageHeight="842" whenNoDataType="BlankPage" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" isSummaryNewPage="true" isSummaryWithPageHeaderAndFooter="true" isFloa [...] <property name="com.jaspersoft.studio.unit." value="pixel"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> @@ -17,8 +17,9 @@ <field name="fromAccount" class="java.lang.String"/> <field name="toAccount" class="java.lang.String"/> <field name="accounts" class="java.util.List"/> - <field name="balanceReportAccountPath" class="java.lang.String"/> + <field name="subReportPath" class="java.lang.String"/> <field name="companyName" class="java.lang.String"/> + <field name="title" class="java.lang.String"/> <variable name="accounts" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"> <variableExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.List)$F{accounts})]]></variableExpression> </variable> @@ -36,13 +37,13 @@ <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> </box> - <staticText> - <reportElement style="Default" x="0" y="0" width="578" height="20" forecolor="#736343" uuid="e7bf1b4c-d748-4c99-b9e2-838903711b48"/> + <textField isBlankWhenNull="true"> + <reportElement style="Default" x="0" y="0" width="578" height="20" forecolor="#736343" uuid="9ee9d5f1-6e74-4526-83a4-3b386f2733a8"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14" isBold="true"/> </textElement> - <text><![CDATA[Balance]]></text> - </staticText> + <textFieldExpression><![CDATA[$F{title}]]></textFieldExpression> + </textField> <textField pattern="dd/MM/yyyy HH:mm" isBlankWhenNull="true"> <reportElement style="Default" x="444" y="0" width="134" height="20" forecolor="#736343" uuid="a60d5d40-69ac-4c50-a33a-67c26cce05f3"/> <textElement textAlignment="Right" verticalAlignment="Middle"> @@ -246,7 +247,7 @@ <subreport isUsingCache="false" runToBottom="false"> <reportElement key="subreport-5" positionType="Float" mode="Transparent" x="0" y="0" width="578" height="20" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="d7fbefd9-03b1-4eaf-b7c6-fb46c737190a"/> <dataSourceExpression><![CDATA[$V{accounts}]]></dataSourceExpression> - <subreportExpression><![CDATA[JasperCompileManager.compileReport($F{balanceReportAccountPath})]]></subreportExpression> + <subreportExpression><![CDATA[JasperCompileManager.compileReport($F{subReportPath})]]></subreportExpression> </subreport> </band> </detail> diff --git a/lima-web/src/main/jasperreports/balance/BalanceReport.jrxml b/lima-web/src/main/jasperreports/generalEntryBook/EntryBookMainReport.jrxml similarity index 60% copy from lima-web/src/main/jasperreports/balance/BalanceReport.jrxml copy to lima-web/src/main/jasperreports/generalEntryBook/EntryBookMainReport.jrxml index b114e8e..75a2866 100644 --- a/lima-web/src/main/jasperreports/balance/BalanceReport.jrxml +++ b/lima-web/src/main/jasperreports/generalEntryBook/EntryBookMainReport.jrxml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1 --> -<!-- 2014-11-17T15:00:12 --> +<!-- 2014-11-18T18:27:11 --> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="BalanceReport" pageWidth="595" pageHeight="842" whenNoDataType="BlankPage" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" isSummaryNewPage="true" isSummaryWithPageHeaderAndFooter="true" isFloa [...] <property name="com.jaspersoft.studio.unit." value="pixel"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> @@ -14,15 +14,16 @@ <field name="fromDate" class="java.util.Date"/> <field name="toDate" class="java.util.Date"/> <field name="currency" class="java.lang.String"/> - <field name="fromAccount" class="java.lang.String"/> - <field name="toAccount" class="java.lang.String"/> - <field name="accounts" class="java.util.List"/> - <field name="balanceReportAccountPath" class="java.lang.String"/> + <field name="entryBookPeriodReport" class="java.util.List"/> + <field name="subReportPath" class="java.lang.String"/> <field name="companyName" class="java.lang.String"/> - <variable name="accounts" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"> - <variableExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.List)$F{accounts})]]></variableExpression> + <field name="title" class="java.lang.String"/> + <field name="soldeDebit" class="java.lang.String"/> + <field name="soldeCredit" class="java.lang.String"/> + <variable name="entryBookPeriodReport" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"> + <variableExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.List)$F{entryBookPeriodReport})]]></variableExpression> </variable> - <group name="accounts"/> + <group name="entryBookPeriodReport"/> <background> <band splitType="Stretch"/> </background> @@ -31,25 +32,25 @@ <frame> <reportElement style="Default" mode="Opaque" x="0" y="1" width="578" height="40" forecolor="#D0B48E" backcolor="#F2EBDF" uuid="1aba49d4-0acc-4925-8731-13c1cc1a90f4"/> <box> - <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> + <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> </box> - <staticText> - <reportElement style="Default" x="0" y="0" width="578" height="20" forecolor="#736343" uuid="e7bf1b4c-d748-4c99-b9e2-838903711b48"/> + <textField isBlankWhenNull="true"> + <reportElement style="Default" x="0" y="0" width="578" height="20" forecolor="#736343" uuid="9ee9d5f1-6e74-4526-83a4-3b386f2733a8"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14" isBold="true"/> </textElement> - <text><![CDATA[Balance]]></text> - </staticText> + <textFieldExpression><![CDATA[$F{title}]]></textFieldExpression> + </textField> <textField pattern="dd/MM/yyyy HH:mm" isBlankWhenNull="true"> <reportElement style="Default" x="444" y="0" width="134" height="20" forecolor="#736343" uuid="a60d5d40-69ac-4c50-a33a-67c26cce05f3"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font size="8" isBold="false"/> <paragraph rightIndent="5"/> </textElement> - <textFieldExpression><![CDATA["Edition du: " + new SimpleDateFormat("MM/dd/yyyy").format(new java.util.Date())]]></textFieldExpression> + <textFieldExpression><![CDATA["Edition du: " + new SimpleDateFormat("dd/MM/yyyy à HH:mm").format(new java.util.Date())]]></textFieldExpression> </textField> <textField pattern="dd/MM/yyyy" isBlankWhenNull="true"> <reportElement style="Default" x="210" y="20" width="80" height="20" forecolor="#736343" uuid="37d0a47c-0197-4f09-8358-823b39a2a42a"> @@ -90,17 +91,6 @@ <pageHeader> <band height="25" splitType="Stretch"> <textField isBlankWhenNull="true"> - <reportElement style="Oblique" x="0" y="9" width="444" height="16" uuid="9db3917c-44e3-46d2-b95a-6463e5eff328"> - <property name="local_mesure_unitheight" value="pixel"/> - <property name="local_mesure_unitwidth" value="pixel"/> - <property name="com.jaspersoft.studio.unit.width" value="px"/> - </reportElement> - <textElement textAlignment="Left" verticalAlignment="Middle"> - <font size="8" isItalic="true"/> - </textElement> - <textFieldExpression><![CDATA["Comptes: " + $F{fromAccount}]]></textFieldExpression> - </textField> - <textField isBlankWhenNull="true"> <reportElement style="Oblique" x="444" y="9" width="134" height="16" forecolor="#000000" uuid="abcb18cb-7d0e-4eb8-a9f5-aca4baffa9ae"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> @@ -115,29 +105,29 @@ <columnHeader> <band height="20"> <frame> - <reportElement style="Column header" mode="Opaque" x="0" y="0" width="578" height="20" uuid="6c2c2b44-eebf-41d3-8b56-47d4a20a4b24"> + <reportElement style="Column header" mode="Opaque" x="0" y="0" width="578" height="20" backcolor="#FDCA97" uuid="6c2c2b44-eebf-41d3-8b56-47d4a20a4b24"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/> </reportElement> <box> - <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> + <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> </box> <staticText> - <reportElement x="0" y="0" width="40" height="20" uuid="63da28a1-a793-4bf5-81d4-6a4d6fc1e4df"> + <reportElement x="0" y="0" width="40" height="20" forecolor="#804000" uuid="63da28a1-a793-4bf5-81d4-6a4d6fc1e4df"> <property name="local_mesure_unitwidth" value="pixel"/> </reportElement> <box> <rightPen lineWidth="0.6"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <font size="8" isBold="true"/> </textElement> - <text><![CDATA[Compte]]></text> + <text><![CDATA[Journal]]></text> </staticText> <staticText> - <reportElement x="40" y="0" width="250" height="20" uuid="da44668c-4f62-4f75-abaf-cb941b73bfcb"> + <reportElement x="40" y="0" width="394" height="20" forecolor="#804000" uuid="da44668c-4f62-4f75-abaf-cb941b73bfcb"> <property name="local_mesure_unitheight" value="pixel"/> </reportElement> <box> @@ -147,128 +137,183 @@ <rightPen lineWidth="0.6"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <font size="8" isBold="true"/> </textElement> <text><![CDATA[Intitulé]]></text> </staticText> <staticText> - <reportElement x="290" y="0" width="144" height="10" uuid="caadc464-ad77-4b53-b5cb-11e29c0a18ce"> + <reportElement x="434" y="0" width="144" height="10" forecolor="#804000" uuid="1bc6ab8b-d490-46a2-9a10-8f4c4f219889"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <box> - <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> + <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <font size="8" isBold="true"/> </textElement> <text><![CDATA[Total Période]]></text> </staticText> <staticText> - <reportElement x="290" y="10" width="72" height="10" uuid="e6928f86-fe5c-4c14-996c-19728e6abf44"> + <reportElement x="434" y="10" width="72" height="10" forecolor="#804000" uuid="b6ea8597-d637-47d1-9a39-7c99101594e9"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <box> - <rightPen lineWidth="0.6"/> + <topPen lineWidth="0.6" lineColor="#804000"/> + <leftPen lineWidth="0.6" lineColor="#804000"/> + <bottomPen lineWidth="0.6" lineColor="#804000"/> + <rightPen lineWidth="0.6" lineColor="#804000"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <font size="8" isBold="true"/> </textElement> <text><![CDATA[Débit]]></text> </staticText> <staticText> - <reportElement x="362" y="10" width="72" height="10" uuid="13dd0f7b-3331-4ca4-8ef8-5468fb65fc3e"> + <reportElement x="506" y="10" width="72" height="10" forecolor="#804000" uuid="c4f9f592-7052-4b66-abc2-f04cc5f3972c"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <box> - <rightPen lineWidth="0.6"/> + <topPen lineColor="#804000"/> + <leftPen lineColor="#804000"/> + <bottomPen lineColor="#804000"/> + <rightPen lineWidth="0.6" lineColor="#804000"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <font size="8" isBold="true"/> </textElement> <text><![CDATA[Crédit]]></text> </staticText> - <staticText> - <reportElement x="434" y="0" width="144" height="10" uuid="1bc6ab8b-d490-46a2-9a10-8f4c4f219889"> + </frame> + </band> + </columnHeader> + <detail> + <band height="20" splitType="Stretch"> + <subreport isUsingCache="false" runToBottom="false"> + <reportElement key="subreport-5" positionType="Float" mode="Transparent" x="0" y="0" width="578" height="20" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="d7fbefd9-03b1-4eaf-b7c6-fb46c737190a"/> + <dataSourceExpression><![CDATA[$V{entryBookPeriodReport}]]></dataSourceExpression> + <subreportExpression><![CDATA[JasperCompileManager.compileReport($F{subReportPath})]]></subreportExpression> + </subreport> + </band> + </detail> + <pageFooter> + <band height="10" splitType="Stretch"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/> + <textField isBlankWhenNull="false"> + <reportElement x="0" y="0" width="288" height="10" uuid="7efdc24b-643b-4927-89e5-30edca53124f"/> + <textElement textAlignment="Right"> + <paragraph lineSpacingSize="0.0"/> + </textElement> + <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report"> + <reportElement x="288" y="0" width="287" height="10" uuid="78cfa3db-28e7-420e-b2e4-441f37387159"/> + <textElement textAlignment="Left"> + <paragraph lineSpacingSize="0.0"/> + </textElement> + <textFieldExpression><![CDATA[" / " + $V{PAGE_NUMBER}]]></textFieldExpression> + </textField> + </band> + </pageFooter> + <lastPageFooter> + <band height="30"> + <frame> + <reportElement style="Default" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="578" height="20" forecolor="#D0B48E" backcolor="#F2EBDF" uuid="07f5ee06-0c59-46c6-b23e-052974f98f2f"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + <property name="local_mesure_unity" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="px"/> + </reportElement> + <box> + <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + </box> + <textField isBlankWhenNull="true"> + <reportElement x="0" y="0" width="434" height="20" forecolor="#736343" uuid="9e826238-b4eb-45d6-a470-859288447fad"> + <property name="local_mesure_unity" value="pixel"/> + <property name="local_mesure_unitx" value="pixel"/> + <property name="com.jaspersoft.studio.unit.x" value="px"/> + <property name="local_mesure_unitwidth" value="pixel"/> + <property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <box> - <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> - <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#000000"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> - <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <textElement textAlignment="Left" verticalAlignment="Middle"> + <font size="12" isBold="true" isItalic="true"/> + <paragraph lineSpacingSize="0.0" leftIndent="40"/> </textElement> - <text><![CDATA[Solde Période]]></text> - </staticText> - <staticText> - <reportElement x="434" y="10" width="72" height="10" uuid="b6ea8597-d637-47d1-9a39-7c99101594e9"> + <textFieldExpression><![CDATA["Total du Journal Général"]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="Default" x="434" y="0" width="72" height="20" forecolor="#736343" uuid="bfddf750-3e4a-459a-8f09-7f617d0112e8"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <box> - <topPen lineWidth="0.6"/> - <leftPen lineWidth="0.6"/> - <bottomPen lineWidth="0.6"/> - <rightPen lineWidth="0.6"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> - <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="Courier 10 Pitch" size="12" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> </textElement> - <text><![CDATA[Débit]]></text> - </staticText> - <staticText> - <reportElement x="506" y="10" width="72" height="10" uuid="c4f9f592-7052-4b66-abc2-f04cc5f3972c"> + <textFieldExpression><![CDATA[$F{soldeDebit}]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="Default" x="506" y="0" width="72" height="20" forecolor="#736343" uuid="eb9dc63a-0873-43de-91a5-6d54d0748b3d"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <box> - <rightPen lineWidth="0.6"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> - <textElement textAlignment="Center" verticalAlignment="Middle"> - <font size="8"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="Courier 10 Pitch" size="12" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> </textElement> - <text><![CDATA[Crédit]]></text> - </staticText> + <textFieldExpression><![CDATA[$F{soldeCredit}]]></textFieldExpression> + </textField> </frame> - </band> - </columnHeader> - <detail> - <band height="20" splitType="Stretch"> - <subreport isUsingCache="false" runToBottom="false"> - <reportElement key="subreport-5" positionType="Float" mode="Transparent" x="0" y="0" width="578" height="20" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="d7fbefd9-03b1-4eaf-b7c6-fb46c737190a"/> - <dataSourceExpression><![CDATA[$V{accounts}]]></dataSourceExpression> - <subreportExpression><![CDATA[JasperCompileManager.compileReport($F{balanceReportAccountPath})]]></subreportExpression> - </subreport> - </band> - </detail> - <pageFooter> - <band height="10" splitType="Stretch"> - <property name="local_mesure_unitheight" value="pixel"/> - <property name="com.jaspersoft.studio.unit.height" value="px"/> - <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/> <textField isBlankWhenNull="false"> - <reportElement x="0" y="0" width="288" height="10" uuid="7efdc24b-643b-4927-89e5-30edca53124f"/> + <reportElement x="0" y="20" width="288" height="10" uuid="87361454-c898-41a6-8d56-2cd13115ba14"> + <property name="local_mesure_unity" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="px"/> + </reportElement> <textElement textAlignment="Right"> <paragraph lineSpacingSize="0.0"/> </textElement> <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> <textField evaluationTime="Report"> - <reportElement x="288" y="0" width="287" height="10" uuid="78cfa3db-28e7-420e-b2e4-441f37387159"/> + <reportElement x="288" y="20" width="287" height="10" uuid="3528c1ce-80bd-4714-948d-493b0bba736a"> + <property name="local_mesure_unity" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="px"/> + </reportElement> <textElement textAlignment="Left"> <paragraph lineSpacingSize="0.0"/> </textElement> <textFieldExpression><![CDATA[" / " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> </band> - </pageFooter> + </lastPageFooter> </jasperReport> diff --git a/lima-web/src/main/jasperreports/generalEntryBook/EntryBookPeriodReport.jrxml b/lima-web/src/main/jasperreports/generalEntryBook/EntryBookPeriodReport.jrxml new file mode 100644 index 0000000..87a3984 --- /dev/null +++ b/lima-web/src/main/jasperreports/generalEntryBook/EntryBookPeriodReport.jrxml @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1 --> +<!-- 2014-11-18T18:07:35 --> +<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="BalanceClassesReport" pageWidth="578" pageHeight="21" whenNoDataType="BlankPage" columnWidth="578" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Empty" isIgnorePagination="true" uuid="75ff [...] + <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> + <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/> + <property name="com.jaspersoft.studio.unit." value="pixel"/> + <style name="Default" isDefault="true" fontName="Arial"/> + <style name="Default oblique" fontName="Monospaced"/> + <queryString> + <![CDATA[]]> + </queryString> + <field name="soldeDebit" class="java.lang.String"/> + <field name="soldeCredit" class="java.lang.String"/> + <field name="generalEntryBookEntry" class="java.util.List"/> + <field name="subReportPath" class="java.lang.String"/> + <field name="periode" class="java.util.Date"/> + <variable name="generalEntryBookEntry" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"> + <variableExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.List)$F{generalEntryBookEntry})]]></variableExpression> + </variable> + <detail> + <band height="10"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + <frame> + <reportElement style="Default" mode="Opaque" x="0" y="0" width="578" height="10" forecolor="#FEEEDE" backcolor="#FEEEDE" uuid="b362ba5e-b960-4aff-8c28-d8288ee352a1"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + <property name="local_mesure_unity" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="px"/> + </reportElement> + <box> + <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + </box> + <textField isBlankWhenNull="true"> + <reportElement x="0" y="0" width="578" height="10" forecolor="#736343" uuid="1472eda4-3df8-47ae-aba7-0aae2d2bedae"> + <property name="local_mesure_unity" value="pixel"/> + <property name="local_mesure_unitx" value="pixel"/> + <property name="com.jaspersoft.studio.unit.x" value="px"/> + </reportElement> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle"> + <font size="8" isBold="true" isItalic="true"/> + <paragraph lineSpacingSize="0.0" leftIndent="40"/> + </textElement> + <textFieldExpression><![CDATA["Mois de " + new SimpleDateFormat("MMMM yyyy").format($F{periode})]]></textFieldExpression> + </textField> + </frame> + </band> + <band height="10" splitType="Stretch"> + <subreport isUsingCache="false" runToBottom="false"> + <reportElement key="subreport-5" positionType="Float" mode="Transparent" x="0" y="0" width="578" height="10" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="d7fbefd9-03b1-4eaf-b7c6-fb46c737190a"/> + <dataSourceExpression><![CDATA[$V{generalEntryBookEntry}]]></dataSourceExpression> + <subreportExpression><![CDATA[JasperCompileManager.compileReport($F{subReportPath})]]></subreportExpression> + </subreport> + </band> + <band height="10" splitType="Stretch"> + <frame> + <reportElement style="Default" mode="Opaque" x="0" y="0" width="578" height="10" forecolor="#FFFFFF" backcolor="#FFFFFF" uuid="571d1774-22c4-4ab4-901b-7470c74f0405"> + <property name="local_mesure_unitheight" value="pixel"/> + <property name="com.jaspersoft.studio.unit.height" value="px"/> + <property name="local_mesure_unity" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="px"/> + </reportElement> + <box> + <topPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <bottomPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#FDCA97"/> + </box> + <textField isBlankWhenNull="true"> + <reportElement x="0" y="0" width="434" height="10" forecolor="#736343" uuid="dc68030b-597d-47b5-8be9-eecfdde17f5e"> + <property name="local_mesure_unity" value="pixel"/> + <property name="local_mesure_unitx" value="pixel"/> + <property name="com.jaspersoft.studio.unit.x" value="px"/> + <property name="local_mesure_unitwidth" value="pixel"/> + <property name="com.jaspersoft.studio.unit.width" value="px"/> + </reportElement> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle"> + <font size="8" isBold="true" isItalic="true"/> + <paragraph lineSpacingSize="0.0" leftIndent="40"/> + </textElement> + <textFieldExpression><![CDATA["Sous-total " + new SimpleDateFormat("MMMM yyyy").format($F{periode})]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="Default" x="434" y="0" width="72" height="10" forecolor="#736343" uuid="53ba669a-6626-4e70-bbf0-fb243908a20e"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="Courier 10 Pitch" size="8" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[$F{soldeDebit}]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="Default" x="506" y="0" width="72" height="10" forecolor="#736343" uuid="edb8a8c1-ac7a-44cb-9de6-b231b00f966f"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="Courier 10 Pitch" size="8" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[$F{soldeCredit}]]></textFieldExpression> + </textField> + </frame> + </band> + </detail> + <columnFooter> + <band height="1"> + <line> + <reportElement style="Default" x="0" y="0" width="578" height="1" forecolor="#FDCA97" uuid="ca761e3c-0dba-448f-a60d-afc241c74411"/> + </line> + </band> + </columnFooter> +</jasperReport> diff --git a/lima-web/src/main/jasperreports/generalEntryBook/GeneralEntryBookEntryReport.jrxml b/lima-web/src/main/jasperreports/generalEntryBook/GeneralEntryBookEntryReport.jrxml new file mode 100644 index 0000000..7c84179 --- /dev/null +++ b/lima-web/src/main/jasperreports/generalEntryBook/GeneralEntryBookEntryReport.jrxml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1 --> +<!-- 2014-11-18T18:24:29 --> +<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="BalanceClassesReport" pageWidth="578" pageHeight="21" columnWidth="578" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="75ff86c6-c370-4f0b-a2d3-e17324a465bb"> + <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> + <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/> + <property name="com.jaspersoft.studio.unit." value="pixel"/> + <style name="Default" isDefault="true" fontName="Arial"/> + <style name="Default oblique" fontName="Monospaced"/> + <queryString> + <![CDATA[]]> + </queryString> + <field name="code" class="java.lang.String"/> + <field name="libelle" class="java.lang.String"/> + <field name="debit" class="java.lang.String"/> + <field name="credit" class="java.lang.String"/> + <detail> + <band height="10" splitType="Stretch"> + <textField isBlankWhenNull="true"> + <reportElement x="0" y="0" width="40" height="10" uuid="c5f32333-c77a-45f8-9bec-c8d61e15d85a"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle"> + <font size="8"/> + <paragraph leftIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[$F{code}]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement x="40" y="0" width="394" height="10" uuid="0bcc6e5d-b2ee-474f-8e66-475933d55a16"> + <property name="local_mesure_unity" value="pixel"/> + <property name="local_mesure_unitwidth" value="pixel"/> + <property name="com.jaspersoft.studio.unit.width" value="px"/> + </reportElement> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle"> + <font size="8"/> + <paragraph leftIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[$F{libelle}]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement x="434" y="0" width="72" height="10" uuid="53ba669a-6626-4e70-bbf0-fb243908a20e"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="Courier 10 Pitch" size="8"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[$F{debit}]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement x="506" y="0" width="72" height="10" uuid="edb8a8c1-ac7a-44cb-9de6-b231b00f966f"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.6" lineStyle="Solid" lineColor="#804000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="Courier 10 Pitch" size="8"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[$F{credit}]]></textFieldExpression> + </textField> + </band> + </detail> +</jasperReport> diff --git a/lima-web/src/main/java/org/chorem/lima/web/action/DocumentService.java b/lima-web/src/main/java/org/chorem/lima/web/action/DocumentService.java index 4adf465..c4786a4 100644 --- a/lima-web/src/main/java/org/chorem/lima/web/action/DocumentService.java +++ b/lima-web/src/main/java/org/chorem/lima/web/action/DocumentService.java @@ -30,11 +30,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.examples.fdf.SetField; import org.apache.pdfbox.pdmodel.PDDocument; import org.chorem.lima.LimaTechnicalException; -import org.chorem.lima.beans.BalanceReport; import org.chorem.lima.beans.BalanceTrial; +import org.chorem.lima.beans.DocumentReport; import org.chorem.lima.beans.FinancialStatementAmounts; -import org.chorem.lima.beans.GeneralEntryBooksDatas; -import org.chorem.lima.beans.GeneralEntryBooksDatasImpl; import org.chorem.lima.beans.ReportsDatas; import org.chorem.lima.business.LimaServiceConfig; import org.chorem.lima.business.api.AccountService; @@ -45,17 +43,17 @@ import org.chorem.lima.business.api.FinancialStatementService; import org.chorem.lima.business.api.IdentityService; import org.chorem.lima.business.api.ReportService; import org.chorem.lima.business.api.VatStatementService; -import org.chorem.lima.business.api.report.BalanceBeanReportService; +import org.chorem.lima.business.api.report.BalanceReportService; +import org.chorem.lima.business.api.report.GeneralEntryBookReportService; import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.VatStatement; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.web.action.balance.BalanceReportBuilder; +import org.chorem.lima.web.action.balance.ReportBuilder; import org.chorem.lima.web.utils.DocumentsEnum; import javax.swing.*; @@ -85,7 +83,9 @@ public class DocumentService { private VatStatementService vatStatementService; - protected BalanceBeanReportService balanceBeanReportService; + protected BalanceReportService balanceReportService; + + protected GeneralEntryBookReportService generalEntryBookReportService; protected ClosedPeriodicEntryBookService closedPeriodicEntryBookService; @@ -93,26 +93,29 @@ public class DocumentService { protected EntryService entryService; - protected String path; + protected String path = LimaServiceConfig.getInstance().getReportsDir().getAbsolutePath(); - protected BalanceReportBuilder balanceReportBuilder; + protected ReportBuilder reportBuilder; protected AccountService accountService; + protected final String BALANCE_FILE_PATH = path + File.separator + DocumentsEnum.BALANCE.getFileName() + ".pdf"; + protected final String GENERAL_ENTRY_BOOK_REPORT_PDF_FILE_PATH = path + File.separator + DocumentsEnum.GENERAL_ENTRY_BOOK.getFileName() + ".pdf"; public DocumentService() { - path = LimaServiceConfig.getInstance().getReportsDir().getAbsolutePath(); identityService = LimaServiceFactory.getService(IdentityService.class); financialStatementService = LimaServiceFactory.getService(FinancialStatementService.class); reportService = LimaServiceFactory.getService(ReportService.class); vatStatementService = LimaServiceFactory.getService(VatStatementService.class); - balanceBeanReportService = LimaServiceFactory.getService(BalanceBeanReportService.class); closedPeriodicEntryBookService = LimaServiceFactory.getService(ClosedPeriodicEntryBookService.class); financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); entryService = LimaServiceFactory.getService(EntryService.class); accountService = LimaServiceFactory.getService(AccountService.class); - balanceReportBuilder = new BalanceReportBuilder(); + balanceReportService = LimaServiceFactory.getService(BalanceReportService.class); + generalEntryBookReportService = LimaServiceFactory.getService(GeneralEntryBookReportService.class); + + reportBuilder = new ReportBuilder(); if (log.isDebugEnabled()) { log.debug("Path : " + path); @@ -481,221 +484,7 @@ public class DocumentService { return entryBookReport; } - //############## balance ############## - - public String createBalanceDocuments(Date beginDate, - Date endDate) { - - BalanceTrial balanceTrial = - reportService.generateBalanceTrial(beginDate, endDate, null, false, true); - - List<ReportsDatas> list = (List<ReportsDatas>) balanceTrial.getReportsDatas(); - - String balanceReport = constructHtmlHeader(t("lima-business.document.balance")); - - if (beginDate != null && endDate != null) { - try{ - BigDecimal currentAmountDebit = BigDecimal.ZERO; - BigDecimal currentAmountCredit = BigDecimal.ZERO; - BigDecimal currentSoldeDebit = BigDecimal.ZERO; - BigDecimal currentSoldeCredit = BigDecimal.ZERO; - - //create pages - int i = 0; - int n = list.size(); - - boolean even = true; - while (i < n) { - - balanceReport += constructHeaderTitle(t("lima-business.document.balance"), beginDate, endDate); - - balanceReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n"; - - String [] columnsNames = {t("lima-business.document.accountnumber"), t("lima-business.document.description"), - t("lima-business.document.movementdebit"), t("lima-business.document.movementcredit"), - t("lima-business.document.soldedebit"), t("lima-business.document.soldecredit")}; - balanceReport += constructTableHeader(columnsNames); - balanceReport += "\t\t<tbody>\n"; - - for (ReportsDatas reportsDatas : list) { - String soldeDebit = String.valueOf(reportsDatas.isSoldeDebit() ? reportsDatas.getAmountSolde() : 0); - String soldeCredit = String.valueOf(reportsDatas.isSoldeDebit() ? 0 : reportsDatas.getAmountSolde()); - - String [] columnsBalanceAmount = {reportsDatas.getAccount().getAccountNumber(), reportsDatas.getAccount().getLabel(), - reportsDatas.getAmountDebit().toString(), reportsDatas.getAmountCredit().toString(), - soldeDebit, soldeCredit}; - balanceReport += constructTableLine(columnsBalanceAmount, even); - even = !even; - - currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit()); - currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit()); - if (reportsDatas.isSoldeDebit()) { - currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde()); - } else { - currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde()); - } - } - - i = i + n; - } - //final amounts - String boldBegin = "<b>"; - String boldEnd = "</b>"; - String [] columnsBalanceAmount = {"", boldBegin + t("lima-business.document.amounts") + boldEnd, - boldBegin + currentAmountDebit.toString() + boldEnd, boldBegin + currentAmountCredit.toString() + boldEnd, - boldBegin + currentSoldeDebit.toString() + boldEnd,boldBegin + currentSoldeCredit.toString() + boldEnd}; - balanceReport += constructTableLine(columnsBalanceAmount, even); - balanceReport += "</tbody></table>\n"; - - - balanceReport += "</body>\n</html>"; - } catch (Exception ex) { - throw new LimaTechnicalException("Can't create document", ex); - } - } - - return balanceReport; - } - - //############## General EntryBook ############# - public String createGeneralEntryBooksDocuments(Date beginDate, - Date endDate) { - - String entryBookReport; - try { - entryBookReport = constructHtmlHeader(t("lima-business.document.entrybook")); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMMM yyyy"); - - if (beginDate != null && endDate != null) { - String subTitle = t("lima-business.document.period1") + - simpleDateFormat.format(beginDate) + " " + - t("lima-business.document.period2") + - simpleDateFormat.format(endDate); - entryBookReport += constructSubTitleHtml(subTitle); - - List<FinancialPeriod> financialPeriods = - financialPeriodService.getFinancialPeriods(beginDate, endDate); - - List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>(); - BigDecimal amountDebit = BigDecimal.ZERO; - BigDecimal amountCredit = BigDecimal.ZERO; - for (FinancialPeriod financialPeriod : financialPeriods) { - List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = - closedPeriodicEntryBookService.getAllByDates( - financialPeriod.getBeginDate(), financialPeriod.getEndDate()); - - BigDecimal subAmountDebit = BigDecimal.ZERO; - BigDecimal subAmountCredit = BigDecimal.ZERO; - for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) { - - BigDecimal debit = BigDecimal.ZERO; - BigDecimal credit = BigDecimal.ZERO; - - List<Object[]> results = entryService.findDebitCreditOfTransaction(closedPeriodicEntryBook); - - 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]; - } - } - 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.setSubAmount(true); - generalEntryBooksDatas.setCredit(subAmountCredit); - generalEntryBooksDatas.setDebit(subAmountDebit); - generalEntryBooksDatas.setPeriod(financialPeriod.getBeginDate()); - 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 += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n"; - - String[] columnNames = {t("lima-business.document.entrybook"), t("lima-business.document.label"), - t("lima-business.document.date"), t("lima-business.document.debit"), - t("lima-business.document.credit")}; - - entryBookReport += constructTableHeader(columnNames); - entryBookReport += "\t\t<tbody>\n"; - String entryBookCode = ""; - boolean even = true; - for (GeneralEntryBooksDatas generalEntryBooksDataInList : list) { - if (!generalEntryBooksDataInList.getDebit().equals(BigDecimal.ZERO) && !generalEntryBooksDataInList.getCredit().equals(BigDecimal.ZERO)) { - if (!generalEntryBooksDataInList.isAmount() && !generalEntryBooksDataInList.isSubAmount()) { - String code; - String description; - if (!entryBookCode.equals(generalEntryBooksDataInList.getCode())) { - entryBookCode = generalEntryBooksDataInList.getCode(); - code = entryBookCode; - description = Strings.isNullOrEmpty(generalEntryBooksDataInList.getDescription()) ? "" : generalEntryBooksDataInList.getDescription(); - } else { - code = ""; - description = ""; - } - String[] columnData = {code, description, - t("lima-business.document.monthformat", generalEntryBooksDataInList.getPeriod()), - generalEntryBooksDataInList.getDebit().toString(), - generalEntryBooksDataInList.getCredit().toString()}; - entryBookReport += constructTableLine(columnData, even); - even = !even; - } else { - String amount; - if (generalEntryBooksDataInList.isAmount()) { - amount = t("lima-business.document.amounts"); - } else { - amount = t("lima-business.document.amountsperiod", generalEntryBooksDataInList.getPeriod()); - } - String[] columnDataTotal = {"", "", (StringUtils.isBlank(amount)?"":amount), - generalEntryBooksDataInList.getDebit().toString(), - generalEntryBooksDataInList.getCredit().toString()}; - entryBookReport += constructTableLine(columnDataTotal, even); - even = !even; - entryBookCode = ""; - } - } - } - entryBookReport += "\t\t</tbody>\n" + - "\t</table>\n" + - "</body>\n</html>"; - } - } catch (Exception ex) { - throw new LimaTechnicalException("Can't create document", ex); - } - return entryBookReport; - } //############## VAT ############## public void createVatDocuments(Date beginDate, @@ -971,14 +760,20 @@ public class DocumentService { return headerTitle; } - public BalanceReport buildGeneralEntryBooksDocuments(Date beginDate, Date endDate, String fromToAccount) { - String filePath = path + File.separator - + DocumentsEnum.BALANCE.getFileName() + ".pdf"; + //############## balance ############## + + public DocumentReport createBalanceDocuments(Date beginDate, Date endDate, String fromToAccount, String currency) { - BalanceReport result = balanceBeanReportService.generateBalanceReportDocument(beginDate, endDate, fromToAccount); - balanceReportBuilder.generateBalanceReport(filePath, Lists.newArrayList(result)); - return result; + DocumentReport report = balanceReportService.getBalanceDocumentReport(beginDate, endDate, fromToAccount, currency); + reportBuilder.generatePDFReport(org.chorem.lima.business.utils.DocumentsEnum.BALANCE, BALANCE_FILE_PATH, Lists.newArrayList(report)); + return report; } + //############## General EntryBook ############# + public DocumentReport createGeneralEntryBooksDocuments(Date beginDate, Date endDate, String currency) { + DocumentReport report = generalEntryBookReportService.getEntryBookDocumentReport(beginDate, endDate, currency); + reportBuilder.generatePDFReport(org.chorem.lima.business.utils.DocumentsEnum.GENERAL_ENTRYBOOK, GENERAL_ENTRY_BOOK_REPORT_PDF_FILE_PATH, Lists.newArrayList(report)); + return report; + } } diff --git a/lima-web/src/main/java/org/chorem/lima/web/action/balance/BalanceReportBuilder.java b/lima-web/src/main/java/org/chorem/lima/web/action/balance/ReportBuilder.java similarity index 57% rename from lima-web/src/main/java/org/chorem/lima/web/action/balance/BalanceReportBuilder.java rename to lima-web/src/main/java/org/chorem/lima/web/action/balance/ReportBuilder.java index 41db852..53bc62a 100644 --- a/lima-web/src/main/java/org/chorem/lima/web/action/balance/BalanceReportBuilder.java +++ b/lima-web/src/main/java/org/chorem/lima/web/action/balance/ReportBuilder.java @@ -22,6 +22,7 @@ package org.chorem.lima.web.action.balance; * #L% */ +import com.google.common.collect.Maps; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperExportManager; @@ -32,46 +33,53 @@ import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaTechnicalException; -import org.chorem.lima.beans.BalanceReport; +import org.chorem.lima.beans.DocumentReport; +import org.chorem.lima.business.utils.DocumentsEnum; import java.io.File; import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Created by davidcosse on 02/10/14. */ -public class BalanceReportBuilder { +public class ReportBuilder { - private static final Log log = LogFactory.getLog(BalanceReportBuilder.class); + private static final Log log = LogFactory.getLog(ReportBuilder.class); - protected JasperReport accountReport; protected JasperReport balanceReport; + protected JasperReport generalEntryBookReport; + protected Map<DocumentsEnum, JasperReport> reportsByDocumentType; - // TODO DCossé 02/10/14 remove it as soon as maven jasper plugin works - public BalanceReportBuilder() { + public ReportBuilder() { try { // compile phase String rootPath = new File("").getAbsolutePath(); // TODO DCossé 06/11/14 find it from properties - accountReport = JasperCompileManager.compileReport(rootPath + "/lima-web/src/main/jasperreports/accounts/AccountReport.jrxml"); balanceReport= JasperCompileManager.compileReport(rootPath + "/lima-web/src/main/jasperreports/balance/BalanceReport.jrxml"); + generalEntryBookReport = JasperCompileManager.compileReport(rootPath + "/lima-web/src/main/jasperreports/generalEntryBook/EntryBookMainReport.jrxml"); + + reportsByDocumentType = Maps.newHashMap(); + reportsByDocumentType.put(DocumentsEnum.BALANCE, balanceReport); + reportsByDocumentType.put(DocumentsEnum.GENERAL_ENTRYBOOK, generalEntryBookReport); } catch (JRException e) { throw new LimaTechnicalException(e); } } - - public void generateBalanceReport(String path, List<BalanceReport> reports) { + public void generatePDFReport(DocumentsEnum reportType, String path, List<DocumentReport> reports) { try { - // fill up report - JasperPrint jasperPrint = JasperFillManager.fillReport(balanceReport, new HashMap(), new JRBeanCollectionDataSource(reports)); - - // eport to PDF - JasperExportManager.exportReportToPdfFile(jasperPrint, path); - if (log.isInfoEnabled()) { - log.info("Rapport généré:"+path); + JasperReport report = reportsByDocumentType.get(reportType); + if (report != null) { + JasperPrint jasperPrint = JasperFillManager.fillReport(report, new HashMap(), new JRBeanCollectionDataSource(reports)); + JasperExportManager.exportReportToPdfFile(jasperPrint, path); + if (log.isInfoEnabled()) { + log.info("Rapport généré:"+path); + } + } else { + throw new LimaTechnicalException("JasperReport not found for " + reportType); } } catch (JRException e) { diff --git a/lima-web/src/main/java/org/chorem/lima/web/service/HttpServerService.java b/lima-web/src/main/java/org/chorem/lima/web/service/HttpServerService.java index 17159eb..eb509a8 100644 --- a/lima-web/src/main/java/org/chorem/lima/web/service/HttpServerService.java +++ b/lima-web/src/main/java/org/chorem/lima/web/service/HttpServerService.java @@ -28,7 +28,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.beans.BalanceReport; import org.chorem.lima.business.LimaServiceConfig; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.utils.DocumentsEnum; @@ -36,7 +35,7 @@ import org.chorem.lima.business.utils.FormatsEnum; import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.web.action.DocumentService; -import org.chorem.lima.web.action.balance.BalanceReportBuilder; +import org.chorem.lima.web.action.balance.ReportBuilder; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; @@ -78,7 +77,7 @@ public class HttpServerService { private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd"); - protected BalanceReportBuilder balanceReportBuilder = new BalanceReportBuilder(); + protected ReportBuilder reportBuilder = new ReportBuilder(); public HttpServerService() { path = LimaServiceConfig.getInstance().getReportsDir().getAbsolutePath(); @@ -155,8 +154,6 @@ public class HttpServerService { //FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format); String accountReport = null; String entryBooksReport = null; - String generalEntryBooksReport = null; - BalanceReport balanceReport = null; String ledgerReport = null; String financialReport = null; @@ -167,7 +164,8 @@ public class HttpServerService { switch (DocumentsEnum.valueOfLink(model)) { case BALANCE: - documentService.buildGeneralEntryBooksDocuments(beginDateFormat, endDateFormat, null); + // TODO DCossé 18/11/14 get currency from config + documentService.createBalanceDocuments(beginDateFormat, endDateFormat, null, "€"); break; case ACCOUNT: accountReport = documentService.createAccountDocument( @@ -181,11 +179,8 @@ public class HttpServerService { } break; case GENERAL_ENTRYBOOK: - generalEntryBooksReport = documentService.createGeneralEntryBooksDocuments( - beginDateFormat, endDateFormat); - if (log.isDebugEnabled()) { - log.debug("GeneralEntryBooksReport :" + generalEntryBooksReport); - } + // TODO DCossé 18/11/14 get currency from config + documentService.createGeneralEntryBooksDocuments(beginDateFormat, endDateFormat, "€"); break; case FINANCIALSTATEMENT: financialReport = documentService.createFinancialStatementsDocuments( @@ -208,7 +203,7 @@ public class HttpServerService { log.error("Can't parse date", eeePE); } - if ( (accountReport != null || entryBooksReport != null || generalEntryBooksReport != null + if ( (accountReport != null || entryBooksReport != null || ledgerReport != null || financialReport != null)) { String report; resp.setContentType(".html"); @@ -217,8 +212,6 @@ public class HttpServerService { report = accountReport; } else if (entryBooksReport != null) { report = entryBooksReport; - } else if (generalEntryBooksReport != null) { - report = generalEntryBooksReport; } else if (ledgerReport != null) { report = ledgerReport; } else { diff --git a/lima-web/src/test/java/org/chorem/lima/web/action/ReportTest.java b/lima-web/src/test/java/org/chorem/lima/web/action/ReportTest.java index dbd1039..f636c90 100644 --- a/lima-web/src/test/java/org/chorem/lima/web/action/ReportTest.java +++ b/lima-web/src/test/java/org/chorem/lima/web/action/ReportTest.java @@ -54,6 +54,6 @@ public class ReportTest { Date beginDateFormat = df.parse("01/01/2013"); Date endDateFormat = df.parse("31/12/2014"); DocumentService documentService = new DocumentService(); - documentService.buildGeneralEntryBooksDocuments(beginDateFormat, endDateFormat, null); + documentService.createBalanceDocuments(beginDateFormat, endDateFormat, null, "€"); } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.