Author: dcosse Date: 2014-05-06 17:41:32 +0200 (Tue, 06 May 2014) New Revision: 3782 Url: http://forge.chorem.org/projects/lima/repository/revisions/3782 Log: fixes #1020 corrige le fonctionnement du filtre Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java trunk/lima-callao/src/main/xmi/accounting.properties trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-05-06 09:22:03 UTC (rev 3781) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-05-06 15:41:32 UTC (rev 3782) @@ -50,6 +50,7 @@ import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.exceptions.COSVisitorException; @@ -266,9 +267,9 @@ entry.setAmount(debit); } entry.setAccount(account); - entry.setDescription(entryEBP.getLibelle()); - entry.setVoucher(entryEBP.getPiece()); - entry.setLettering(entryEBP.getLettre()); + entry.setDescription(StringUtils.trimToNull(entryEBP.getLibelle())); + entry.setVoucher(StringUtils.trimToNull(entryEBP.getPiece())); + entry.setLettering(StringUtils.trimToNull(entryEBP.getLettre())); // Association of the entry with the financialTransaction // Each financialTransaction is associated with an entryBook @@ -419,8 +420,8 @@ String[] line = csvReader.readNext(); while (line != null) { EntryBook entryBook = new EntryBookImpl(); - entryBook.setCode(line[0]); - entryBook.setLabel(line[2]); + entryBook.setCode(StringUtils.trimToNull(line[0])); + entryBook.setLabel(StringUtils.trimToNull(line[2])); entryBookService.createEntryBook(entryBook); result.append(t("lima-business.import.accountadded", entryBook.getCode(), entryBook.getLabel())); count++; @@ -800,8 +801,8 @@ StringBuilder result = new StringBuilder(); EntryBook entryBook = new EntryBookImpl(); - entryBook.setCode(nextLine[1]); - entryBook.setLabel(nextLine[2]); + entryBook.setCode(StringUtils.trimToNull(nextLine[1])); + entryBook.setLabel(StringUtils.trimToNull(nextLine[2])); // if exist, skip if (entryBookService.getEntryBookByCode(entryBook.getCode()) != null) { @@ -858,12 +859,12 @@ Map<String, List<FinancialStatementImport>> financialStatements) throws LimaException, TopiaException { StringBuilder result = new StringBuilder(); - String label = nextLine[1]; + String label = StringUtils.trimToNull(nextLine[1]); String header = nextLine[2]; - String accounts = nextLine[3]; - String debitAccounts = nextLine[4]; - String creditAccounts = nextLine[5]; - String provisionDeprecationAccounts = nextLine[6]; + String accounts = StringUtils.trimToNull(nextLine[3]); + String debitAccounts = StringUtils.trimToNull(nextLine[4]); + String creditAccounts = StringUtils.trimToNull(nextLine[5]); + String provisionDeprecationAccounts = StringUtils.trimToNull(nextLine[6]); String subAmount = nextLine[7]; String headerAmount = nextLine[8]; String masterFinancialStatement = nextLine[9]; @@ -918,9 +919,9 @@ StringBuilder result = new StringBuilder(); String boxName = nextLine[1]; - String label = nextLine[2]; + String label = StringUtils.trimToNull(nextLine[2]); String header = nextLine[3]; - String accounts = nextLine[4]; + String accounts = StringUtils.trimToNull(nextLine[4]); String masterVatStatement = nextLine[5]; // if exist, skip @@ -982,13 +983,13 @@ int num = new Integer(nextLine[1]); EntryImport entryImport = new EntryImportImpl(); - entryImport.setDescription(nextLine[2]); + entryImport.setDescription(StringUtils.trimToNull(nextLine[2])); entryImport.setAmount(nextLine[3]); entryImport.setDebit(nextLine[4]); - entryImport.setLettering(nextLine[5]); - entryImport.setDetail(nextLine[6]); - entryImport.setVoucher(nextLine[7]); - entryImport.setPosition(nextLine[8]); + entryImport.setLettering(StringUtils.trimToNull(nextLine[5])); + entryImport.setDetail(StringUtils.trimToNull(nextLine[6])); + entryImport.setVoucher(StringUtils.trimToNull(nextLine[7])); + entryImport.setPosition(StringUtils.trimToNull(nextLine[8])); entryImport.setAccount(nextLine[9]); if (entries.containsKey(num)) { @@ -1231,15 +1232,13 @@ Entry entry = new EntryImpl(); Account account = accountService.getAccountByNumber(entryImport.getAccount()); entry.setAccount(account); - entry.setDescription(entryImport.getDescription()); + entry.setDescription(StringUtils.trimToNull(entryImport.getDescription())); entry.setAmount(new BigDecimal(entryImport.getAmount())); entry.setDebit(Boolean.parseBoolean(entryImport.getDebit())); - - entry.setLettering(entryImport.getLettering()); - - entry.setDetail(entryImport.getDetail()); - entry.setVoucher(entryImport.getVoucher()); - entry.setPosition(entryImport.getPosition()); + entry.setLettering(StringUtils.trimToNull(entryImport.getLettering())); + entry.setDetail(StringUtils.trimToNull(entryImport.getDetail())); + entry.setVoucher(StringUtils.trimToNull(entryImport.getVoucher())); + entry.setPosition(StringUtils.trimToNull(entryImport.getPosition())); entryService.createEntry(entry); financialTransaction.addEntry(entry); } 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 2014-05-06 09:22:03 UTC (rev 3781) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2014-05-06 15:41:32 UTC (rev 3782) @@ -193,20 +193,20 @@ public List<Entry> findAllEntryByAccountAndLettering(LetteringFilter filter) throws TopiaException { List<Entry> entries; - String query = "Select E from " + Entry.class.getName() + " E, " + FinancialTransaction.class.getName() + " F" + - " where E.financialTransaction = F" + - " and E.account.accountNumber like :account "; + String query = "Select E from " + Entry.class.getName() + " E " + + " where E.account.accountNumber like :account "; if (!filter.getDisplayLettered() && filter.getDisplayUnlettred()){ - query += " and E.lettering is null"; + query += " and (E.lettering is null or E.lettering = '') "; } else if (filter.getDisplayLettered() && !filter.getDisplayUnlettred()){ - query += " and E.lettering is not null"; + query += " and (E.lettering is not null or E.lettering !='') "; } query += " and E.financialTransaction.transactionDate between :beginDate and :endDate " + - " order by F.transactionDate, F." + FinancialTransaction.TOPIA_CREATE_DATE; + " order by E.financialTransaction.transactionDate, E.financialTransaction." + FinancialTransaction.TOPIA_CREATE_DATE; + log.info("Query:" + query); entries = context.findAll(query, "account", filter.getAccount().getAccountNumber() + "%", "beginDate", filter.getDateStart(), "endDate", filter.getDateEnd()); return entries; } Modified: trunk/lima-callao/src/main/xmi/accounting.properties =================================================================== --- trunk/lima-callao/src/main/xmi/accounting.properties 2014-05-06 09:22:03 UTC (rev 3781) +++ trunk/lima-callao/src/main/xmi/accounting.properties 2014-05-06 15:41:32 UTC (rev 3782) @@ -49,11 +49,14 @@ # lazy org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.entryBook.tagvalue.lazy=false org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.financialPeriod.tagvalue.lazy=false + org.chorem.lima.entity.Entry.attribute.account.tagvalue.lazy=false org.chorem.lima.entity.Entry.attribute.financialTransaction.tagvalue.lazy=false + org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false org.chorem.lima.entity.FinancialTransaction.attribute.entryBook.tagvalue.lazy=false org.chorem.lima.entity.FinancialStatement.attribute.subFinancialStatements.tagvalue.lazy=false org.chorem.lima.entity.FinancialStatement.attribute.masterFinancialStatement.tagvalue.lazy=false + org.chorem.lima.entity.VatStatement.attribute.subVatStatements.tagvalue.lazy=false org.chorem.lima.entity.VatStatement.attribute.masterVatStatement.tagvalue.lazy=false Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java 2014-05-06 09:22:03 UTC (rev 3781) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java 2014-05-06 15:41:32 UTC (rev 3782) @@ -26,7 +26,9 @@ package org.chorem.lima.enums; -/** Boolean importMode define if it's a import (true) or an export (false) */ +/** first Boolean importMode define if it's a import (true) or an export (false) + * second one to allow or not choce for encoding + * */ public enum ImportExportEnum { CSV_ALL_EXPORT(false, true), CSV_ALL_IMPORT(true, true), CSV_ACCOUNTCHARTS_EXPORT(false, true), CSV_ACCOUNTCHARTS_IMPORT(true, true), Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-05-06 09:22:03 UTC (rev 3781) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-05-06 15:41:32 UTC (rev 3782) @@ -329,10 +329,13 @@ view.getPickerDebut().setDate(defaultDateBegFiscalPeriod); view.getPickerFin().setDate(defaultDateEndCurrent); + filter.setDateStart(defaultDateBegFiscalPeriod); filter.setDateEnd(defaultDateEndCurrent); - filter.setDisplayUnlettred(true); + TypeEntry type = view.getLettredEntryComboBox().getSelectedItem(); + setTypeEntry(type); + updateAllEntries(); }