r3609 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/utils lima-business/src/main/resources/i18n lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/accountsreports lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports lima-swing/src/main/resources lima-swing/src/main/resources/i18n
Author: mallon Date: 2012-08-16 16:31:59 +0200 (Thu, 16 Aug 2012) New Revision: 3609 Url: http://chorem.org/repositories/revision/lima/3609 Log: refs #769 Modification du jaxx, et mise en place de l affichage html des donnees filtrees, pour l edition des comptes. Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties trunk/lima-swing/src/main/resources/log4j.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -40,6 +40,9 @@ import com.lowagie.text.Table; import com.lowagie.text.html.HtmlWriter; import com.lowagie.text.pdf.PdfWriter; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.examples.fdf.SetField; import org.apache.pdfbox.pdmodel.PDDocument; import org.chorem.lima.beans.BalanceTrial; @@ -58,6 +61,7 @@ import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.business.utils.FormatsEnum; import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; import org.chorem.lima.entity.Entry; @@ -67,11 +71,13 @@ import org.chorem.lima.entity.FinancialPeriodDAO; import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.VatStatement; +import org.nuiton.topia.TopiaException; import javax.ejb.EJB; import javax.ejb.Remote; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; +import javax.swing.JOptionPane; import java.awt.*; import java.io.File; import java.io.FileInputStream; @@ -79,6 +85,7 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -91,6 +98,8 @@ @TransactionAttribute public class DocumentServiceImpl extends AbstractLimaService implements DocumentService { + protected static final Log log = LogFactory.getLog(DocumentServiceImpl.class); + @EJB private IdentityService identityService; @@ -120,8 +129,15 @@ private static final Font bolditalicFont = new Font(Font.HELVETICA, 9, Font.BOLDITALIC, Color.BLACK); + private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("dd-MM-yyyy"); + public DocumentServiceImpl() { path = LimaConfig.getInstance().getReportsDir().getAbsolutePath(); + + if (log.isDebugEnabled()) { + log.debug("Path : " + path); + } + } /** @@ -1369,4 +1385,94 @@ throw new LimaException("Can't create document", ex); } } + + @Override + public String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException { + + String accountReport = null; + + try { + + AccountDAO accountDAO = getDaoHelper().getAccountDAO(); + Account accountFormat = accountDAO.findByTopiaId(account); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMMM yyyy"); + + accountReport = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" + + "<html>\n" + + "<head>\n" + + "<title>"+_("lima.reports.accounts")+"</title>\n" + + "</head>\n" + + "<p align=\"center\">" + + "<font size=5>\n" + + _("lima.reports.accounts") + + "</font>\n" + + "</p>\n" + + "<p>"; + ReportsDatas results; + + if (beginDate != null && endDate != null && account != null) { + + accountReport += "<font size=3>\n" + + _("lima.ui.fiscalperiod.fiscalperiod") + " : " + simpleDateFormat.format(beginDate) + " - " + simpleDateFormat.format(endDate) + + "</p>\n" + + "<p>" + + _("lima.ui.financialtransaction.account") + " : " + accountFormat.getAccountNumber() + " - " + accountFormat.getLabel() + + "</font>"+ + "</p>" + + "<body>\n"; + results = reportService.generateAccountsReports(accountFormat, true, + beginDate, endDate); + List<Entry> entries = results.getListEntry(); + + accountReport += "<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n"; + accountReport += "<tr align=\"center\">\n"; + accountReport +="<td>" + _("lima.table.number") + "</td>\n"; + accountReport +="<td>" + _("lima.table.date") + "</td>\n"; + accountReport +="<td>" + _("lima.table.entrybook") + "</td>\n"; + accountReport +="<td>" + _("lima.table.voucher") + "</td>\n"; + accountReport +="<td>" + _("lima.table.description") + "</td>\n"; + accountReport +="<td>" + _("lima.table.letter") + "</td>\n"; + accountReport +="<td>" + _("lima.table.debit") + "</td>\n"; + accountReport +="<td>" + _("lima.table.credit") + "</td>\n"; + accountReport += "<tr>\n"; + for(Entry entry : entries) { + accountReport += "<tr align=\"center\">\n"; + + String accountNumber = entry.getAccount().getAccountNumber(); + accountReport += "<td>" + (StringUtils.isBlank(accountNumber)?"":accountNumber) + "</td>\n"; + String transactionDate = simpleDateFormat.format(entry.getFinancialTransaction().getTransactionDate()); + accountReport += "<td>" + (StringUtils.isBlank(transactionDate)?"":transactionDate) + "</td>\n"; + if (entry.getFinancialTransaction().getEntryBook() != null) { + String code = entry.getFinancialTransaction().getEntryBook().getCode(); + accountReport += "<td>" + (StringUtils.isBlank(code)?"":code) + "</td>\n"; + } + String voucher = entry.getVoucher(); + accountReport += "<td>" + (StringUtils.isBlank(voucher)?"":voucher) + "</td>\n"; + String description = entry.getDescription(); + accountReport += "<td>" + (StringUtils.isBlank(description)?"":description) + "</td>\n"; + String lettering = entry.getLettering(); + accountReport += "<td>" + (StringUtils.isBlank(lettering)?"":lettering) + "</td>\n"; + accountReport += "<td>" + (entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO) + "</td>\n"; + accountReport += "<td>" + (entry.getDebit() ? BigDecimal.ZERO : entry.getAmount()) + "</td>\n"; + + accountReport += "</tr>\n"; + } + accountReport += "</table>\n" + + "</body>\n"; + + } else { + JOptionPane.showMessageDialog(null, _("lima.reports.account.noaccount"), _("lima.reports.account.noaccounttitle"), JOptionPane.INFORMATION_MESSAGE); + } + + accountReport += "</html>"; + + }catch (TopiaException e) { + log.error("Can't find object", e); + } + catch (Exception e) { + throw new LimaException("Can't create document", e); + } + + return accountReport; + } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -32,6 +32,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URL; +import java.net.URLDecoder; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -46,8 +47,11 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.Charsets; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.api.DocumentService; @@ -66,6 +70,8 @@ @TransactionAttribute public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService { + protected static final Log log = LogFactory.getLog(HttpServerServiceImpl.class); + @EJB private DocumentService documentService; @@ -124,6 +130,11 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { + + if (log.isDebugEnabled()) { + log.debug("doGet"); + } + //get all params String imageParam = req.getParameter("img"); String model = req.getParameter("model"); @@ -131,6 +142,7 @@ String beginDate = req.getParameter("beginDate"); String endDate = req.getParameter("endDate"); String autocomplete = req.getParameter("autocomplete"); + String account = URLDecoder.decode(req.getParameter("account"), "UTF-8"); //if image if (imageParam != null) { @@ -145,6 +157,7 @@ //if doc pdf or html else if (model != null && format != null && beginDate != null && endDate != null) { FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format); + String accountReport = null; //create docs try { @@ -156,6 +169,18 @@ documentService.createBalanceDocuments( beginDateFormat, endDateFormat, formatsEnum); break; + case ACCOUNT: + if (log.isDebugEnabled()) { + log.debug("Account"); + } + /*AccountDAO accountDAO = new AccountDAO(); + Account accountFormat = accountDAO.findByTopiaId(account);*/ + accountReport = documentService.createAccountDocument( + beginDateFormat, endDateFormat, account); + if (log.isDebugEnabled()) { + log.debug("After creating account document"); + } + break; case ENTRYBOOKS: documentService.createEntryBooksDocuments( beginDateFormat, endDateFormat, formatsEnum); @@ -189,10 +214,18 @@ // après génération // fonctionne pour le moment, mais a modifier URL doc = new URL("file:" + path + File.separator + model + formatsEnum.getExtension()); + if (log.isDebugEnabled()) { + log.debug("file:" + path + File.separator + model + formatsEnum.getExtension()); + log.debug(accountReport); + } resp.setContentType(formatsEnum.getMimeType()); - InputStream in = doc.openStream(); +// InputStream in = doc.openStream(); OutputStream out = resp.getOutputStream(); - IOUtils.copy(in, out); + if (accountReport != null) { + IOUtils.write(accountReport, out, Charsets.UTF_8); +// out.write(accountReport.getBytes()); + } +// IOUtils.copy(in, out); } // else return home html else { Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -36,6 +36,8 @@ import javax.ejb.TransactionAttribute; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.beans.BalanceTrialImpl; import org.chorem.lima.beans.ReportsDatas; @@ -64,6 +66,8 @@ @EJB protected AccountService accountService; + protected static final Log log = LogFactory.getLog(ReportServiceImpl.class); + /** * Recursiv * List entries for a period and an account @@ -86,37 +90,29 @@ //Get allsubaccounts and thirdParts accounts List<Account> accounts = accountService.getAllSubAccounts(account); - - // is already subaccount - // TODO echatellier 20120502 c'est vraiment voulu ? - // il ne peut pas y avoir de transaction sur des comptes non feuilles ? - // a verifier, sinon, supprimer la récursion - if (accounts.size() == 0) { - reportsDatas = generateSubAccountReports(account, + + for (Account subAccount : accounts) { + reportsDatas = generateSubAccountReports(subAccount, beginDate, endDate); + debit = debit.add(reportsDatas.getAmountDebit()); + credit = credit.add(reportsDatas.getAmountCredit()); + entries.addAll(reportsDatas.getListEntry()); } - // else is folder accounts contains many subs and thirds accounts - else { - for (Account subAccount : accounts) { - ReportsDatas subReportsDatas = - generateAccountsReports(subAccount, true, beginDate, endDate); - debit = debit.add(subReportsDatas.getAmountDebit()); - credit = credit.add(subReportsDatas.getAmountCredit()); - entries.addAll(subReportsDatas.getListEntry()); - } - //solde = debit - credit - solde = solde.add(debit); - solde = solde.subtract(credit); - - if (solde.compareTo(BigDecimal.ZERO) == 1) { - reportsDatas.setSoldeDebit(true); - } - solde = solde.abs(); - reportsDatas.setAmountCredit(credit); - reportsDatas.setAmountDebit(debit); - reportsDatas.setAmountSolde(solde); - reportsDatas.setListEntry(entries); + + //solde = debit - credit + solde = solde.add(debit); + solde = solde.subtract(credit); + + if (solde.compareTo(BigDecimal.ZERO) == 1) { + reportsDatas.setSoldeDebit(true); } + solde = solde.abs(); + reportsDatas.setAmountCredit(credit); + reportsDatas.setAmountDebit(debit); + reportsDatas.setAmountSolde(solde); + + reportsDatas.setListEntry(entries); + } catch (TopiaException ex) { throw new LimaException("Can't generate report", ex); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -35,7 +35,8 @@ BALANCE(_("lima-business.document.balance"), "lima_balance"), LEDGER(_("lima-business.document.ledger"), "lima_ledger"), FINANCIALSTATEMENT(_("lima-business.document.financialstatement"), "lima_financialstatements"), - VAT(_("lima-business.document.vat"), "lima_vat"); + VAT(_("lima-business.document.vat"), "lima_vat"), + ACCOUNT(_("lima-business.document.account"), "lima_account"); private final String fileName; Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-08-16 14:31:59 UTC (rev 3609) @@ -17,6 +17,7 @@ lima-business.defaultaccountingrules.invalidaccountnumber=Invalid Account Number \: %d lima-business.defaultaccountingrules.missingelements=Can't block financialperiod / missing elements in transactions for this FinancialPeriod/EntryBook lima-business.defaultaccountingrules.missingentrybook=Can't block financialperiod / missing EntryBook in transactions +lima-business.document.account= lima-business.document.accountnumber=Account N° lima-business.document.amounts=Amounts lima-business.document.amountsperiod=Amounts %1$tB %1$tY @@ -100,4 +101,6 @@ lima.config.rulesnationality.description=Rules Nationality lima.config.scale.description=Scale lima.config.serveraddress.description=Server Address +lima.reports.account.noaccount= +lima.reports.account.noaccounttitle= lima.ui.lettering.accountRegularization= Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-08-16 14:31:59 UTC (rev 3609) @@ -17,6 +17,7 @@ lima-business.defaultaccountingrules.invalidaccountnumber=Numéro de compte invalide \: %d lima-business.defaultaccountingrules.missingelements=Impossible de bloquer la période financière / il manque des éléments dans des transactions lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY) +lima-business.document.account= lima-business.document.accountnumber=N° Compte lima-business.document.amounts=Totaux lima-business.document.amountsperiod=Totaux %1$tB %1$tY @@ -100,4 +101,6 @@ lima.config.rulesnationality.description=Règles nationales lima.config.scale.description=Précision lima.config.serveraddress.description=Addresse serveur +lima.reports.account.noaccount= +lima.reports.account.noaccounttitle= lima.ui.lettering.accountRegularization= Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -27,6 +27,7 @@ import org.chorem.lima.business.LimaException; import org.chorem.lima.business.utils.FormatsEnum; +import org.chorem.lima.entity.Account; import java.util.Date; @@ -50,4 +51,5 @@ void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format, String autocomplete) throws LimaException; + String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException; } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -75,6 +75,11 @@ List<Entry> entries = context.findAll(query, "beginDate", beginDate, "endDate", endDate, "account", account); + + if (log.isDebugEnabled()) { + log.debug("Size of entries : " + entries.size()); + } + return entries; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-08-16 14:31:59 UTC (rev 3609) @@ -23,7 +23,7 @@ #L% --> -<Table> +<Table constraints='BorderLayout.NORTH'> <import> javax.swing.ListSelectionModel @@ -42,67 +42,37 @@ } ]]> </script> - <row weightx="1" weighty="0" anchor="center"> - <cell fill='horizontal'> - <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" /> - </cell> - <cell fill='horizontal' anchor="east"> - <JLabel id="accountSelectorLabel" text="lima.common.account"/> - </cell> - <cell fill='horizontal' anchor="west"> - <AccountComboBoxModel id="accountComboboxModel" /> - <AccountComboBox id="accountComboBox" model="{accountComboboxModel}" - renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" - onItemStateChanged="handler.accountChanged(event)" /> - </cell> - <cell> - <JButton id="back" text="lima.common.buttonback" - onActionPerformed="accountComboBox.back()"/> - </cell> - <cell> - <JButton id="next" text="lima.common.buttonnext" - onActionPerformed="accountComboBox.next()"/> - </cell> - </row> <row> - <cell fill="both" weightx="1" weighty="1" columns="6"> - <JScrollPane> - <AccountsReportsTableModel id="accountsReportsTableModel"/> - <AccountsReportsTable - id="accountsReportsTable" rowHeight="24" - model="{accountsReportsTableModel}" - highlighters="{HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" - columnControlVisible="true"/> - <ListSelectionModel - javaBean="getAccountsReportsTable().getSelectionModel()"/> - </JScrollPane> + <cell columns="1"> + <IntervalPanel id="intervalPanel"/> </cell> </row> <row> - <cell fill="horizontal" weightx="1" columns="7"> - <Table> - <row fill="horizontal" weightx="1"> - <cell> - <JLabel text="lima.ui.common.amountdebit"/> - </cell> - <cell> - <JLabel id="amountDebitLabel"/> - </cell> - <cell> - <JLabel text="lima.ui.common.amountcredit"/> - </cell> - <cell> - <JLabel id="amountCreditLabel"/> - </cell> - <cell> - <JLabel id="soldeLabel" text="lima.ui.common.solde"/> - </cell> - <cell> - <JLabel id="amountSoldeLabel"/> - </cell> - </row> - </Table> + <cell columns="1"> + <Table> + <row> + <cell weightx="0.125" anchor="east"> + <JLabel id="accountSelectorLabel" text="lima.common.account"/> + </cell> + <cell weightx="0.5" anchor="east"> + <AccountComboBoxModel id="accountComboboxModel" /> + <AccountComboBox id="accountComboBox" model="{accountComboboxModel}" + renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" /> + </cell> + <cell weightx="0.125" anchor="east"> + <JButton id="back" text="lima.common.buttonback" + onActionPerformed="accountComboBox.back()"/> + </cell> + <cell weightx="0.125" anchor="east"> + <JButton id="next" text="lima.common.buttonnext" + onActionPerformed="accountComboBox.next()"/> + </cell> + <cell weightx="0.125" anchor="east"> + <JButton id="html" text="lima.common.generateHtml" + onActionPerformed="handler.createDocument()"/> + </cell> + </row> + </Table> </cell> </row> </Table> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -25,31 +25,34 @@ package org.chorem.lima.ui.accountsreports; -import static org.nuiton.i18n.I18n._; - -import java.awt.event.ItemEvent; -import java.math.BigDecimal; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; -import org.chorem.lima.beans.ReportsDatas; -import org.chorem.lima.business.ServiceListener; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.LimaConfig; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.api.FinancialPeriodService; -import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; -import org.chorem.lima.business.api.ImportService; +import org.chorem.lima.business.api.HttpServerService; import org.chorem.lima.business.api.ReportService; +import org.chorem.lima.business.utils.DocumentsEnum; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; + /** * Handler associated with accounts reports view. * By : $Author$ */ -public class AccountsReportsViewHandler implements ServiceListener { +public class AccountsReportsViewHandler { protected AccountsReportsView view; @@ -58,6 +61,8 @@ protected AccountService accountService; protected FiscalPeriodService fiscalPeriodService; protected FinancialPeriodService financialPeriodService; + private static final Log log = LogFactory.getLog(AccountsReportsViewHandler.class); + private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); protected AccountsReportsViewHandler(AccountsReportsView view) { this.view = view; @@ -66,8 +71,6 @@ accountService = LimaServiceFactory.getService(AccountService.class); fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); - LimaServiceFactory.addServiceListener(ImportService.class, this); - LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this); } /** @@ -83,69 +86,38 @@ view.getIntervalPanel().init(fiscalPeriod, financialPeriod); } - protected void accountChanged(ItemEvent event) { - if (event.getStateChange() == ItemEvent.SELECTED) { - refreshData(); - } - } + public void createDocument() { - public void intervalChanged() { - refreshData(); - } - - /** - * Refresh table data depending on item selected on combo boxes. - */ - protected void refreshData() { - Date beginDate = view.getIntervalPanel().getBeginDate(); Date endDate = view.getIntervalPanel().getEndDate(); - Account account = (Account)view.getAccountComboBox().getModel().getSelectedItem(); - + if (beginDate != null && endDate != null && account != null) { - ReportsDatas results = reportService.generateAccountsReports(account, true, - beginDate, endDate); - - AccountsReportsTableModel dataModel = view.getAccountsReportsTableModel(); - dataModel.setReportDatas(results); - - updateFooter(results); - } - - } - /** - * Update footer labels containing reports total sum fields. - * - * @param reportsDatas result to render - */ - protected void updateFooter(ReportsDatas reportsDatas) { - // set amounts credit and debit and solde - view.amountCreditLabel.setText( - reportsDatas.getAmountCredit().toString()); - view.amountDebitLabel.setText( - reportsDatas.getAmountDebit().toString()); - BigDecimal amountSolde = reportsDatas.getAmountSolde(); - view.amountSoldeLabel.setText(amountSolde.toString()); + int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort(); + String address = LimaConfig.getInstance().getHostAdress(); + try { + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(beginDate) + + "&endDate=" + dateFormat.format(endDate) + + "&account=" + URLEncoder.encode(account.getTopiaId(), "UTF-8") + + "&format=.html&model=" + + DocumentsEnum.ACCOUNT.getFileName(); - if (BigDecimal.ZERO.equals(amountSolde)) { - view.soldeLabel.setText(_("lima.common.solde")); - } else { - // set label solde: credit or debit - if (reportsDatas.getSoldeDebit()) { - view.soldeLabel.setText(_("lima.common.soldedebit")); - } else { - view.soldeLabel.setText(_("lima.common.soldecredit")); + if (log.isDebugEnabled()) { + log.debug("URL : " + url); + } + + URI uri = URI.create(url); + if (log.isDebugEnabled()) { + log.debug("URI : " + uri); + } + Desktop.getDesktop().browse(uri); + + } catch (IOException e) { + log.error("Can't open browser", e); } } } - - @Override - public void notifyMethod(String serviceName, String methodName) { - if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) { - refreshData(); - } - } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-08-16 14:31:59 UTC (rev 3609) @@ -141,7 +141,7 @@ /** * Update footer labels containing reports total sum fields. * - * @param results result to render + * @param reportsDatas result to render */ protected void updateFooter(ReportsDatas reportsDatas) { // set amounts credit and debit and solde Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-16 14:31:59 UTC (rev 3609) @@ -53,6 +53,7 @@ lima.common.entrybooks=EntryBooks lima.common.error=Error lima.common.filter=Filter +lima.common.generateHtml= lima.common.info=Information lima.common.label=Label lima.common.movmentedfilter=Accounts filtered @@ -169,6 +170,8 @@ lima.opening.accounts= lima.preferences=Preferences lima.reports=Reports +lima.reports.account.noaccount= +lima.reports.account.noaccounttitle= lima.reports.accounts=Edit account lima.reports.balance=Balance lima.reports.entrybooks=Edit entrybook Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-16 14:31:59 UTC (rev 3609) @@ -53,6 +53,7 @@ lima.common.entrybooks=Journaux lima.common.error=Erreur lima.common.filter=Filtrer +lima.common.generateHtml=HTML lima.common.info=Information lima.common.label=Libellé lima.common.movmentedfilter=Comptes mouvementés @@ -168,6 +169,8 @@ lima.opening.accounts= lima.preferences=Préférences lima.reports=Rapports +lima.reports.account.noaccount= +lima.reports.account.noaccounttitle= lima.reports.accounts=Edition compte lima.reports.balance=Balance lima.reports.entrybooks=Edition journal Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-14 14:28:26 UTC (rev 3608) +++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-16 14:31:59 UTC (rev 3609) @@ -55,4 +55,8 @@ log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionPeriodSearchPanel=DEBUG log4j.logger.org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchViewHandler=DEBUG log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodViewHandler=DEBUG -log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel=DEBUG \ No newline at end of file +log4j.logger.org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel=DEBUG +log4j.logger.org.chorem.lima.business.ejb.DocumentServiceImpl=DEBUG +log4j.logger.org.chorem.lima.business.ejb.HttpServerServiceImpl=DEBUG +log4j.logger.org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler=DEBUG +log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG \ No newline at end of file
participants (1)
-
mallon@users.chorem.org