This is an automated email from the git hooks/post-receive script. New commit to branch feature/1241-account-report in repository lima. See http://git.chorem.org/lima.git commit 887373c77477f6f7919b0c05009b679ca385de4d Author: dcosse <cosse@codelutin.com> Date: Mon Sep 7 14:27:30 2015 +0200 refs #1241 ajout possibilité de créer des rapports de balance globale ou générale (le dernier par défaut centralise les comptes 401 avec ses sous comptes idem pour 411) --- .../chorem/lima/business/api/OptionsService.java | 3 + .../business/api/report/BalanceReportService.java | 3 +- .../chorem/lima/business/LimaBusinessConfig.java | 11 ++- .../lima/business/ejb/OptionsServiceImpl.java | 6 ++ .../ejb/report/BalanceReportServiceImpl.java | 110 ++++++++++++++++++--- .../org/chorem/lima/beans/BalanceAccountImpl.java | 23 +++-- .../lima/report/service/DocumentService.java | 8 +- .../balance/BalanceSubAccountsReport.jrxml | 14 +-- .../jasperreports/balance/DocumentReport.jrxml | 81 +++++++++++++++ .../org/chorem/lima/report/action/ReportTest.java | 2 +- .../org/chorem/lima/server/HttpServerService.java | 40 +++++--- .../main/java/org/chorem/lima/LimaSwingConfig.java | 1 + 12 files changed, 248 insertions(+), 54 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java index 6598454..44ce1e2 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java @@ -24,6 +24,8 @@ package org.chorem.lima.business.api; import org.chorem.lima.business.config.LimaConfigOptionDef; import org.chorem.lima.business.utils.BigDecimalToString; +import java.util.Locale; + /** * Service de report des certaines configurations du swing dans business * <p/> @@ -57,4 +59,5 @@ public interface OptionsService extends BigDecimalToString.Config { int getLimaHttpPort(); + void setLocal(Locale newLocale); } diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceReportService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceReportService.java index 016e01c..b284fb4 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceReportService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/report/BalanceReportService.java @@ -39,10 +39,11 @@ public interface BalanceReportService { * @param from from date * @param to to date * @param selectedAccounts if null all accounts will be selected + * @Param isBalanceGeneral true if general Balance is requested * @param bigDecimalFormat format used for amount representation * @param mainAccountsJasperReport Jasper sub report for balance's main accounts representation * @param subAccountsJasperReport Jasper sub account report for balance sub account representation * @return model for balance report */ - DocumentReport getBalanceDocumentReport(Date from, Date to, String selectedAccounts, DecimalFormat bigDecimalFormat, JasperReport mainAccountsJasperReport, JasperReport subAccountsJasperReport); + DocumentReport getBalanceDocumentReport(Date from, Date to, String selectedAccounts, String isBalanceGeneral, DecimalFormat bigDecimalFormat, JasperReport mainAccountsJasperReport, JasperReport subAccountsJasperReport); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java b/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java index c7beb4f..c3ecca2 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java +++ b/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java @@ -37,6 +37,7 @@ import org.nuiton.topia.flyway.TopiaFlywayService; import org.nuiton.topia.persistence.TopiaConfigurationConstants; import java.io.File; +import java.util.Locale; import java.util.Map; import java.util.Properties; @@ -225,7 +226,14 @@ public class LimaBusinessConfig { loadAccountingRules(); } + public Locale getLocal() { + return config.getOptionAsLocale(BusinessConfigOption.LOCAL.key); + } + public void setLocal(Locale local) { + config.setOption(BusinessConfigOption.LOCAL.key, local.toString()); + saveConfig(); + } public int getScale() { return config.getOptionAsInt(BusinessConfigOption.SCALE.key); @@ -343,9 +351,10 @@ public class LimaBusinessConfig { HOST_EJB_BIND("lima.host.ejb.bind", "", "0.0.0.0", String.class, false, false), HOST_EJB_PORT("lima.host.ejb.port", n("lima.host.ejb.port.description"), "4202", Integer.class, false, false), - HOST_HTTP_ADDRESS("lima.host.http.address", n("lima.host.http.address.description"), "localhost", Integer.class, false, false), + HOST_HTTP_ADDRESS("lima.host.http.address", n("lima.host.http.address.description"), "localhost", String.class, false, false), HOST_HTTP_PORT("lima.host.http.port", n("lima.host.http.port.description"), "5462", Integer.class, false, false), + LOCAL("lima.config.local", t("lima.config.local.label"), n("lima.config.local.description"), Locale.FRANCE.toString() , Locale.class, false, false), SCALE("lima.data.bigDecimal.scale", t("lima.config.scale.label"), n("lima.config.scale.description"), "2", String.class, false, false), CURRENCY("lima.config.currency", t("lima.config.currency.label"), n("lima.config.currency.description"), "false", Boolean.class, false, false), DATE_FORMAT("lima.config.dateFormat", t("lima.config.dateFormat.label"), n("lima.config.dateFormat.description"), "DD/MM/YYYY", Boolean.class, false, false), diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java index 8cbfae8..e4fec31 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java @@ -27,6 +27,7 @@ import org.chorem.lima.business.config.LimaConfigOptionDef; import javax.ejb.Remote; import javax.ejb.Stateless; +import java.util.Locale; @Stateless @Remote(OptionsService.class) @@ -102,4 +103,9 @@ public class OptionsServiceImpl extends AbstractLimaService implements OptionsSe return LimaBusinessConfig.getInstance().getHostHttpPort(); } + @Override + public void setLocal(Locale local) { + LimaBusinessConfig.getInstance().setLocal(local); + } + } diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceReportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceReportServiceImpl.java index ff5af26..a9da2e0 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceReportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/BalanceReportServiceImpl.java @@ -76,6 +76,8 @@ public class BalanceReportServiceImpl extends AbstractLimaService implements Bal protected IdentityService identityService; protected static final Integer ACCOUNT_NUMBER_SIZE = 6; + protected static final String GROUP_401 = "401"; + protected static final String GROUP_411 = "411"; protected static final Predicate<BalanceAccount> HAS_NO_ENTRY = new Predicate<BalanceAccount>() { @@ -90,7 +92,7 @@ public class BalanceReportServiceImpl extends AbstractLimaService implements Bal }; @Override - public DocumentReport getBalanceDocumentReport(Date from, Date to, String selectedAccounts, DecimalFormat bigDecimalFormat, JasperReport mainAccountsJasperReport, JasperReport subAccountsJasperReport) { + public DocumentReport getBalanceDocumentReport(Date from, Date to, String selectedAccounts, String isBalanceGeneralSt, DecimalFormat bigDecimalFormat, JasperReport mainAccountsJasperReport, JasperReport subAccountsJasperReport) { String reportName = t("lima-business.document.balanceReport.title"); DocumentReport documentReport = CommonsDocumentReport.getDocumentReport(reportName, from, to, mainAccountsJasperReport, bigDecimalFormat, identityService); @@ -103,6 +105,15 @@ public class BalanceReportServiceImpl extends AbstractLimaService implements Bal documentReport.setColumnTotalForPeriodTitle(t("lima-business.document.columnTotalForPeriodTitle")); documentReport.setColumnVoucherTitle(t("lima-business.document.columnVoucherTitle")); + documentReport.setLastPageColumnDescription(t("lima-business.document.balance.lastPageColumnDescription")); + + boolean isBalanceGeneral = StringUtils.isBlank(isBalanceGeneralSt) || Boolean.valueOf(isBalanceGeneralSt); + + BigDecimal globalDebit = BigDecimal.ZERO; + BigDecimal globalCredit = BigDecimal.ZERO; + BigDecimal globalDebitBalance = BigDecimal.ZERO; + BigDecimal globalCreditBalance = BigDecimal.ZERO; + BalanceTrial balanceTrial = new BalanceTrialImpl(); balanceTrial.setReportsDatas(new ArrayList<ReportsDatas>()); @@ -128,30 +139,103 @@ public class BalanceReportServiceImpl extends AbstractLimaService implements Bal setDocumentReportHeaderSelectedAccounts(documentReport, accounts); HashMap<String, BalanceAccountImpl> accountsByClasses = new HashMap<>(); + + BalanceAccount sold401 = null; + BalanceAccount sold411 = null; + for (Account account : accounts) { String accountClass = String.valueOf(account.getAccountNumber().charAt(0)); - BalanceAccountImpl accountSubAccounts = accountsByClasses.get(accountClass); - if (accountSubAccounts == null) { - accountSubAccounts = new BalanceAccountImpl(); - accountSubAccounts.setFormatter(bigDecimalFormat); - accountSubAccounts.setSubReport(subAccountsJasperReport); - accountSubAccounts.setSubAccounts(new ArrayList<BalanceAccount>()); - accountsByClasses.put(accountClass, accountSubAccounts); - returnedAccounts.add(accountSubAccounts); - } + // all results for a account classes + BalanceAccountImpl accountSubAccounts = getBalanceAccountForAccountClass(bigDecimalFormat, subAccountsJasperReport, returnedAccounts, accountsByClasses, accountClass); + + // compute balance for the account classes BalanceAccount subClassAccount = computeSubAccountBalance(accountClass, account, from, to, bigDecimalFormat); + + // only add it if there are results if (subClassAccount != null) { - accountSubAccounts.addSubAccount(subClassAccount); + // we group Account 401 and 411 with there sub accounts + String accountNb = account.getAccountNumber(); + + if (isBalanceGeneral && ((accountNb.startsWith(GROUP_401)) || (accountNb.startsWith(GROUP_411)))){ + BalanceAccount balanceAccount = null; + if ((accountNb.startsWith(GROUP_401))){ + if (sold401 == null) { + sold401 = new BalanceAccountImpl(); + sold401.setLabel(t("lima-business.document.balance.globalSupplier")); + sold401.setFormatter(bigDecimalFormat); + sold401.setAccountNumber("4010000"); + accountSubAccounts.addSubAccount(sold401); + } + balanceAccount = sold401; + } else if((accountNb.startsWith(GROUP_411))) { + if (sold411 == null) { + sold411 = new BalanceAccountImpl(); + sold411.setLabel(t("lima-business.document.balance.globalClient")); + sold411.setFormatter(bigDecimalFormat); + sold411.setAccountNumber("4110000"); + accountSubAccounts.addSubAccount(sold411); + } + balanceAccount = sold411; + } + + if (balanceAccount != null) { + // add amounts to global 4 account + addInWith(accountSubAccounts, subClassAccount); + + // add amounts to 401 or 411 global amount + addInWith(balanceAccount, subClassAccount); + + // add amounts to global result + globalDebit = globalDebit.add(subClassAccount.getAmountDebit()); + globalCredit = globalCredit.add(subClassAccount.getAmountCredit()); + globalDebitBalance = globalDebitBalance.add(subClassAccount.getDebitBalance()); + globalCreditBalance = globalCreditBalance.add(subClassAccount.getCreditBalance()); + } + + } else { + accountSubAccounts.addSubAccount(subClassAccount); + + globalDebit = globalDebit.add(subClassAccount.getAmountDebit()); + globalCredit = globalCredit.add(subClassAccount.getAmountCredit()); + globalDebitBalance = globalDebitBalance.add(subClassAccount.getDebitBalance()); + globalCreditBalance = globalCreditBalance.add(subClassAccount.getCreditBalance()); + } } } } Iterables.removeIf(returnedAccounts, HAS_NO_ENTRY); documentReport.addAllMainAccounts(returnedAccounts); + + documentReport.setTotalDebit(globalDebit); + documentReport.setTotalCredit(globalCredit); + documentReport.setDebitBalance(globalDebitBalance); + documentReport.setCreditBalance(globalCreditBalance); + return documentReport; } + protected void addInWith(BalanceAccount target, BalanceAccount toBeAdded) { + target.setAmountDebit(target.getAmountDebit().add(toBeAdded.getAmountDebit())); + target.setAmountCredit(target.getAmountCredit().add(toBeAdded.getAmountCredit())); + target.setDebitBalance(target.getDebitBalance().add(toBeAdded.getDebitBalance())); + target.setCreditBalance(target.getCreditBalance().add(toBeAdded.getCreditBalance())); + } + + protected BalanceAccountImpl getBalanceAccountForAccountClass(DecimalFormat bigDecimalFormat, JasperReport subAccountsJasperReport, Collection<BalanceAccount> returnedAccounts, HashMap<String, BalanceAccountImpl> accountsByClasses, String accountClass) { + BalanceAccountImpl accountSubAccounts = accountsByClasses.get(accountClass); + if (accountSubAccounts == null) { + accountSubAccounts = new BalanceAccountImpl(); + accountSubAccounts.setFormatter(bigDecimalFormat); + accountSubAccounts.setSubReport(subAccountsJasperReport); + accountSubAccounts.setSubAccounts(new ArrayList<BalanceAccount>()); + accountsByClasses.put(accountClass, accountSubAccounts); + returnedAccounts.add(accountSubAccounts); + } + return accountSubAccounts; + } + protected void setDocumentReportHeaderSelectedAccounts(DocumentReport documentReport, List<Account> accounts) { Account fromAccount = accounts.get(0); Account toAccount = accounts.get(accounts.size()-1); @@ -196,7 +280,6 @@ public class BalanceReportServiceImpl extends AbstractLimaService implements Bal BalanceAccount balanceAccount = addSubAccountReport(mainAccountLabel, account, bigDecimalFormat, credit, debit, balance); - return balanceAccount; } @@ -216,10 +299,8 @@ public class BalanceReportServiceImpl extends AbstractLimaService implements Bal if (balance.compareTo(BigDecimal.ZERO) == 1) { balanceAccount.setDebitBalance(balance.abs()); - balanceAccount.setCreditBalance(BigDecimal.ZERO); } else { balanceAccount.setCreditBalance(balance.abs()); - balanceAccount.setDebitBalance(BigDecimal.ZERO); } balanceAccount.setAmountCredit(credit); @@ -227,4 +308,5 @@ public class BalanceReportServiceImpl extends AbstractLimaService implements Bal } return balanceAccount; } + } diff --git a/lima-callao/src/main/java/org/chorem/lima/beans/BalanceAccountImpl.java b/lima-callao/src/main/java/org/chorem/lima/beans/BalanceAccountImpl.java index de819dc..2e1bdde 100644 --- a/lima-callao/src/main/java/org/chorem/lima/beans/BalanceAccountImpl.java +++ b/lima-callao/src/main/java/org/chorem/lima/beans/BalanceAccountImpl.java @@ -29,24 +29,23 @@ public class BalanceAccountImpl extends BalanceAccount { private static final long serialVersionUID = 1L; + public BalanceAccountImpl() { + this.amountDebit = BigDecimal.ZERO; + this.amountCredit = BigDecimal.ZERO; + this.debitBalance = BigDecimal.ZERO; + this.creditBalance = BigDecimal.ZERO; + } + public void addSubAccount(BalanceAccount subAccount) { // we only add account that have values if (subAccount.getAmountDebit() != null && subAccount.getAmountCredit() != null) { getSubAccounts().add(subAccount); - BigDecimal newAmountDebit = this.amountDebit == null ? BigDecimal.ZERO : this.amountDebit; - BigDecimal newAmountCredit = this.amountCredit == null ? BigDecimal.ZERO : this.amountCredit; - BigDecimal newSoldeDebit = this.debitBalance == null ? BigDecimal.ZERO : this.debitBalance; - BigDecimal newSoldeCredit = this.creditBalance == null ? BigDecimal.ZERO : this.creditBalance; - - this.amountDebit = subAccount.getAmountDebit().add(newAmountDebit); - - this.amountCredit = subAccount.getAmountCredit().add(newAmountCredit); - - this.debitBalance = subAccount.getDebitBalance().add(newSoldeDebit); - - this.creditBalance = subAccount.getCreditBalance().add(newSoldeCredit); + this.amountDebit = this.amountDebit.add(subAccount.getAmountDebit()); + this.amountCredit = this.amountCredit.add(subAccount.getAmountCredit()); + this.debitBalance = this.debitBalance.add(subAccount.getDebitBalance()); + this.creditBalance = this.creditBalance.add(subAccount.getCreditBalance()); } // firePropertyChange(PROPERTY_SUB_ACCOUNTS, null, subAccount); diff --git a/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java b/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java index 40ef663..37206ec 100644 --- a/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java +++ b/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java @@ -472,10 +472,10 @@ public class DocumentService { //############## balance ############## - public void createBalanceDocuments(Date beginDate, Date endDate, String fromToAccount) { + public void createBalanceDocuments(Date beginDate, Date endDate, String isBalanceGeneral, String fromToAccount) { JasperReport balanceMainAccountsReport = jasperReports.getBalanceManAccountsReport(); JasperReport balanceSubAccountsReport = jasperReports.getBalanceSubAccountsReport(); - DocumentReport report = balanceReportService.getBalanceDocumentReport(beginDate, endDate, fromToAccount, + DocumentReport report = balanceReportService.getBalanceDocumentReport(beginDate, endDate, fromToAccount, isBalanceGeneral, getDecimalFormat(), balanceMainAccountsReport, balanceSubAccountsReport); jasperReports.generatePDFReport(DocumentsEnum.BALANCE, balanceFilePath, Lists.newArrayList(report)); } @@ -520,13 +520,13 @@ public class DocumentService { return inputStream; } - public GeneratedReport createReport(Date beginDate, Date endDate, String model, String account, String autocomplete) throws IOException { + public GeneratedReport createReport(Date beginDate, Date endDate, String model, String account, String isBalanceGeneral, String autocomplete) throws IOException { String stringResult = null; //create docs switch (DocumentsEnum.valueOfLink(model)) { case BALANCE: - createBalanceDocuments(beginDate, endDate, null); + createBalanceDocuments(beginDate, endDate, isBalanceGeneral, null); break; case ACCOUNT: createAccountDocument(account, beginDate, endDate); diff --git a/lima-report/src/main/resources/jasperreports/balance/BalanceSubAccountsReport.jrxml b/lima-report/src/main/resources/jasperreports/balance/BalanceSubAccountsReport.jrxml index 4f8896d..3b7611c 100644 --- a/lima-report/src/main/resources/jasperreports/balance/BalanceSubAccountsReport.jrxml +++ b/lima-report/src/main/resources/jasperreports/balance/BalanceSubAccountsReport.jrxml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0 --> -<!-- 2015-07-02T18:03:10 --> +<!-- 2015-09-07T13:45:22 --> <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="20" 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"/> @@ -11,7 +11,6 @@ <![CDATA[]]> </queryString> <field name="formatter" class="java.text.DecimalFormat"/> - <field name="accountNumber" class="java.lang.String"/> <field name="label" class="java.lang.String"/> <field name="amountDebit" class="java.math.BigDecimal"/> @@ -21,7 +20,6 @@ <field name="mainAccountLabel" class="java.lang.String"/> <field name="totalForLabel" class="java.lang.String"/> <field name="subTotalForLabel" class="java.lang.String"/> - <variable name="amountBalanceDebit" class="java.math.BigDecimal" calculation="Sum"> <variableExpression><![CDATA[$F{amountDebit}]]></variableExpression> <initialValueExpression><![CDATA[BigDecimal.ZERO]]></initialValueExpression> @@ -162,7 +160,7 @@ <font size="8" isBold="true"/> <paragraph leftIndent="80"/> </textElement> - <textFieldExpression><![CDATA[$F{subTotalForLabel} + $F{mainAccountLabel}]]></textFieldExpression> + <textFieldExpression><![CDATA[String.format($F{subTotalForLabel}, $F{mainAccountLabel})]]></textFieldExpression> </textField> <textField pattern="" isBlankWhenNull="true"> <reportElement key="" x="434" y="0" width="72" height="10" forecolor="#736343" uuid="9c59df76-21ef-428f-8266-0da4cade0a20"> @@ -172,7 +170,6 @@ <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"/> - <printWhenExpression><![CDATA[new Boolean($V{sumBalanceDebit}.compareTo(BigDecimal.ZERO) != 0)]]></printWhenExpression> </reportElement> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> @@ -208,7 +205,7 @@ <textFieldExpression><![CDATA[new Boolean($V{sumBalanceCredit}.compareTo(BigDecimal.ZERO) != 0) ? $F{formatter}.format($V{sumBalanceCredit}) : ""]]></textFieldExpression> </textField> <textField pattern="" isBlankWhenNull="true"> - <reportElement key="" x="290" y="0" width="72" height="10" forecolor="#736343" uuid="7f9a6117-e3b4-492f-ba5a-b4f913516294"> + <reportElement key="" isPrintRepeatedValues="false" x="290" y="0" width="72" height="10" forecolor="#736343" uuid="7f9a6117-e3b4-492f-ba5a-b4f913516294"> <property name="local_mesure_unitx" value="pixel"/> <property name="com.jaspersoft.studio.unit.x" value="px"/> <property name="local_mesure_unitwidth" value="pixel"/> @@ -217,7 +214,6 @@ <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"/> - <printWhenExpression><![CDATA[new Boolean($V{sumBalanceDebit}.compareTo(BigDecimal.ZERO) != 0)]]></printWhenExpression> </reportElement> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> @@ -289,7 +285,7 @@ <font size="8" isBold="true"/> <paragraph leftIndent="80"/> </textElement> - <textFieldExpression><![CDATA[$F{totalForLabel} + $F{mainAccountLabel}]]></textFieldExpression> + <textFieldExpression><![CDATA[String.format($F{totalForLabel}, $F{mainAccountLabel})]]></textFieldExpression> </textField> <textField pattern="" isBlankWhenNull="true"> <reportElement key="" x="434" y="0" width="72" height="10" forecolor="#736343" uuid="6edd1323-c09c-45f8-ac94-be4753616581"> @@ -299,7 +295,6 @@ <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"/> - <printWhenExpression><![CDATA[new Boolean($V{sumBalanceDebit}.compareTo(BigDecimal.ZERO) != 0)]]></printWhenExpression> </reportElement> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> @@ -344,7 +339,6 @@ <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"/> - <printWhenExpression><![CDATA[new Boolean($V{sumBalanceDebit}.compareTo(BigDecimal.ZERO) != 0)]]></printWhenExpression> </reportElement> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> diff --git a/lima-report/src/main/resources/jasperreports/balance/DocumentReport.jrxml b/lima-report/src/main/resources/jasperreports/balance/DocumentReport.jrxml index bc37ab4..9cb88c4 100644 --- a/lima-report/src/main/resources/jasperreports/balance/DocumentReport.jrxml +++ b/lima-report/src/main/resources/jasperreports/balance/DocumentReport.jrxml @@ -14,10 +14,22 @@ <rightPen lineWidth="0.6" lineColor="#804000"/> </box> </style> + + <style name="FooterHeader" mode="Opaque" forecolor="#D0B48E" backcolor="#FDCA97" fontName="DejaVu Sans"/> + <style name="FooterColumn" forecolor="#804000" fontName="DejaVu Sans" fontSize="8" isBold="true"> + <box> + <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> + </style> + <style name="Oblique" fontName="DejaVu Sans Mono" fontSize="8" isItalic="true"/> <queryString> <![CDATA[]]> </queryString> + <field name="formatter" class="java.text.DecimalFormat"/> <field name="subReport" class="net.sf.jasperreports.engine.JasperReport"/> <field name="mainAccounts" class="java.util.List"/> @@ -44,6 +56,14 @@ <field name="columnDebitTitle" class="java.lang.String"/> <field name="columnDescriptionTitle" class="java.lang.String"/> <field name="columnTotalForPeriodTitle" class="java.lang.String"/> + + <field name="lastPageColumnDescription" class="java.lang.String"/> + + <field name="totalDebit" class="java.math.BigDecimal"/> + <field name="totalCredit" class="java.math.BigDecimal"/> + <field name="debitBalance" class="java.math.BigDecimal"/> + <field name="creditBalance" class="java.math.BigDecimal"/> + <variable name="mainAccounts" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"> <variableExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.List)$F{mainAccounts})]]></variableExpression> </variable> @@ -260,4 +280,65 @@ </textField> </band> </pageFooter> + <lastPageFooter> + <band height="30"> + <frame> + <reportElement style="FooterHeader" stretchType="RelativeToBandHeight" x="0" y="0" width="578" height="20" isRemoveLineWhenBlank="true"/> + <textField isBlankWhenNull="true"> + <reportElement style="FooterColumn" x="0" y="0" width="434" height="20"/> + <textElement textAlignment="Left" verticalAlignment="Middle"> + <font size="12" isBold="true" isItalic="true"/> + <paragraph lineSpacingSize="0.0" leftIndent="40"/> + </textElement> + <textFieldExpression><![CDATA[$F{lastPageColumnDescription}]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="FooterColumn" x="290" y="0" width="72" height="20"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans Mono" size="8" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[new Boolean($F{totalDebit}.compareTo(BigDecimal.ZERO) != 0) ? $F{formatter}.format($F{totalDebit}) : ""]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="FooterColumn" x="362" y="0" width="72" height="20"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans Mono" size="8" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[new Boolean($F{totalCredit}.compareTo(BigDecimal.ZERO) != 0) ? $F{formatter}.format($F{totalCredit}) : ""]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="FooterColumn" x="434" y="0" width="72" height="20"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans Mono" size="8" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[new Boolean($F{debitBalance}.compareTo(BigDecimal.ZERO) != 0) ? $F{formatter}.format($F{debitBalance}) : ""]]></textFieldExpression> + </textField> + <textField isBlankWhenNull="true"> + <reportElement style="FooterColumn" x="506" y="0" width="72" height="20"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans Mono" size="8" isBold="true"/> + <paragraph lineSpacingSize="0.0" rightIndent="2"/> + </textElement> + <textFieldExpression><![CDATA[new Boolean($F{creditBalance}.compareTo(BigDecimal.ZERO) != 0) ? $F{formatter}.format($F{creditBalance}) : ""]]></textFieldExpression> + </textField> + </frame> + <textField isBlankWhenNull="false"> + <reportElement x="0" y="20" width="288" height="10"/> + <textElement textAlignment="Right"> + <paragraph lineSpacingSize="0.0"/> + </textElement> + <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report"> + <reportElement x="288" y="20" width="287" height="10"/> + <textElement textAlignment="Left"> + <paragraph lineSpacingSize="0.0"/> + </textElement> + <textFieldExpression><![CDATA[" / " + $V{PAGE_NUMBER}]]></textFieldExpression> + </textField> + </band> + </lastPageFooter> </jasperReport> diff --git a/lima-report/src/test/java/org/chorem/lima/report/action/ReportTest.java b/lima-report/src/test/java/org/chorem/lima/report/action/ReportTest.java index 5826982..a8d1f56 100644 --- a/lima-report/src/test/java/org/chorem/lima/report/action/ReportTest.java +++ b/lima-report/src/test/java/org/chorem/lima/report/action/ReportTest.java @@ -55,6 +55,6 @@ public class ReportTest { Date beginDateFormat = df.parse("01/01/2013"); Date endDateFormat = df.parse("31/12/2014"); DocumentService documentService = new DocumentService(); - documentService.createBalanceDocuments(beginDateFormat, endDateFormat, null); + documentService.createBalanceDocuments(beginDateFormat, endDateFormat, null, null); } } diff --git a/lima-server/src/main/java/org/chorem/lima/server/HttpServerService.java b/lima-server/src/main/java/org/chorem/lima/server/HttpServerService.java index 127a6b5..eaa9a13 100644 --- a/lima-server/src/main/java/org/chorem/lima/server/HttpServerService.java +++ b/lima-server/src/main/java/org/chorem/lima/server/HttpServerService.java @@ -30,6 +30,7 @@ import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaTechnicalException; +import org.chorem.lima.business.LimaBusinessConfig; import org.chorem.lima.business.LimaServiceFactory; import org.chorem.lima.business.api.OptionsService; import org.chorem.lima.entity.Account; @@ -58,6 +59,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Locale; import static org.nuiton.i18n.I18n.t; @@ -140,13 +142,13 @@ public class HttpServerService { String endDate = req.getParameter("endDate"); String account = (StringUtils.isBlank(req.getParameter("account")) ? null : URLDecoder.decode(req.getParameter("account"), "UTF-8")); String autocomplete = req.getParameter("autocomplete") == null ? "true" : req.getParameter("autocomplete"); - + String isGeneral = req.getParameter("isGeneral") == null ? "true" : req.getParameter("isGeneral"); if (imageParam != null) { // render image doImage(resp, imageParam); } else if (model != null && beginDate != null && endDate != null) { // generate and render report - doCreateReport(resp, model, beginDate, endDate, account, autocomplete); + doCreateReport(resp, model, beginDate, endDate, account, isGeneral, autocomplete); } else { // render home HTML doHomeHtml(req, resp); @@ -168,7 +170,7 @@ public class HttpServerService { } protected void doCreateReport(HttpServletResponse resp, String model, String beginDate, String endDate, - String account, String autocomplete) throws IOException { + String account, String isGeneral, String autocomplete) throws IOException { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); @@ -178,7 +180,7 @@ public class HttpServerService { Date endDateFormat = sdf.parse(endDate); GeneratedReport generatedReport = - documentService.createReport(beginDateFormat, endDateFormat, model, account, autocomplete); + documentService.createReport(beginDateFormat, endDateFormat, model, account, isGeneral, autocomplete); if (Strings.isNullOrEmpty(generatedReport.getHtmlContent())) { InputStream in = generatedReport.getPdfStream(); @@ -225,7 +227,11 @@ public class HttpServerService { beginDatePicker = DateUtils.truncate(beginDatePicker, Calendar.YEAR); - pageContent.append("<!DOCTYPE html>\n" + "<html lang=\"fr\">\n" + Locale locale = LimaBusinessConfig.getInstance().getLocal(); + + pageContent.append("<!DOCTYPE html>\n" + "<html lang=\""); + pageContent.append(locale.getLanguage()); + pageContent.append("\">\n" + "<head>\n" + "<script type=\"text/javascript\">" + " function showAccountInput(){" + @@ -239,8 +245,18 @@ public class HttpServerService { " document.getElementById('accountField').style.display = 'none';" + " }" + " }" + + " var request = document.getElementById('model');" + + " var requestValue = request == null ? '': request.value;" + + " var isDocumentBalance = requestValue === 'lima_balance'; " + + " if (document.getElementById('balanceType') != null) {" + + " if (isDocumentBalance) {" + + " document.getElementById('balanceType').style.display = 'block';" + + " } else {" + + " document.getElementById('balanceType').style.display = 'none';" + + " }" + + " }" + " }" + - " showAccountInput();" + + " showAccountInput();" + " </script>" + "<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" @@ -255,11 +271,8 @@ public class HttpServerService { .append("<input value=\"") .append(sdf.format(endDatePicker)) .append("\" type=\"date\" name=\"endDate\">\n<br/><br/>"); - //+ "Format : <select name=\"format\">"); - - pageContent.append(/*"</select>\n" - + */"Documents : <select id=\"model\" name=\"model\" onchange='showAccountInput()'>"); + pageContent.append("Documents : <select id=\"model\" name=\"model\" onchange='showAccountInput()'>"); for (DocumentsEnum documentsEnum : DocumentsEnum.values()) { pageContent.append("<option value=\"") @@ -278,10 +291,15 @@ public class HttpServerService { optionAccounts.append("</option>\n"); } - pageContent.append("</select>" + pageContent.append( "</select>" + "<div id='accountField'>Compte : <select id=\"account\" name=\"account\">" + optionAccounts.toString() + "</select></div>" + + "<div id='balanceType'>" + + " <input type=\"radio\" name=\"isGeneral\" value=\"true\" checked>Balance Générale\n" + + " <br>\n" + + " <input type=\"radio\" name=\"isGeneral\" value=\"false\">Balance Globale" + + "</div>" + "<input type=\"submit\">\n" + "</form></td>" + "<tr><td class=\"tdright\"><img src=\"?img=entries.png\"/></td></tr>\n" diff --git a/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java b/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java index 740f3ae..f1af0d0 100644 --- a/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java +++ b/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java @@ -172,6 +172,7 @@ public class LimaSwingConfig extends ApplicationConfig implements BigDecimalToSt */ public void setLocale(Locale newLocale) { setOption(Option.LOCALE.key, newLocale.toString()); + optionsService.setLocal(newLocale); saveForUser(); firePropertyChange("locale", null, newLocale); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.