r3819 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/utils lima-business/src/test/java/org/chorem/lima/business lima-callao/src/main/java/org/chorem/lima/entity lima-callao/src/main/xmi
Author: dcosse Date: 2014-05-27 00:02:37 +0200 (Tue, 27 May 2014) New Revision: 3819 Url: http://forge.chorem.org/projects/lima/repository/revisions/3819 Log: refs #934 some refactoring Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.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/EntryBookServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java trunk/lima-callao/src/main/xmi/accounting-model.zargo Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -169,29 +169,35 @@ //check financial period locked FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao(); FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate()); - if (financialPeriod.isLocked()) { + if (financialPeriod != null && financialPeriod.isLocked()) { throw new LimaBusinessException(t("lima-business.defaultaccountingrules.financialperiodblocked")); } //check all entrybook of his financial period are blocked //FIXME echatellier 20120509 il doit y avoir moyen de faire plus //simple que de recuperer 2 listes et de comparer leur nombres - List<EntryBook> entryBooks = new ArrayList<EntryBook>(); - List<EntryBook> closedEntryBooks = new ArrayList<EntryBook>(); +// List<EntryBook> closedEntryBooks = new ArrayList<EntryBook>(); EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao(); ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao(); - entryBooks = entryBookTopiaDao.findAll(); - for (EntryBook entryBook : entryBooks) { - ClosedPeriodicEntryBook closedPeriodicEntryBook = - closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod( - entryBook, financialPeriod); - if (closedPeriodicEntryBook.isLocked()) { - closedEntryBooks.add(entryBook); - } - } - if (entryBooks.size() == closedEntryBooks.size()) { +// List<EntryBook> entryBooks = entryBookTopiaDao.findAll(); + // The following code should do the work but i'm not 100% sure. + long nbEntryBooksClosed = closedPeriodicEntryBookTopiaDao.forProperties( + ClosedPeriodicEntryBook.PROPERTY_LOCKED, true, + ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod).addNotNull(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK).count(); + +// for (EntryBook entryBook : entryBooks) { +// ClosedPeriodicEntryBook closedPeriodicEntryBook = +// closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod( +// entryBook, financialPeriod); +// if (closedPeriodicEntryBook.isLocked()) { +// closedEntryBooks.add(entryBook); +// } +// } + + long nbEntryBooks = entryBookTopiaDao.count(); + if (nbEntryBooks == nbEntryBooksClosed) { throw new LimaBusinessException(t("lima-business.defaultaccountingrules.allentrybookclosed")); } } catch (TopiaException ex) { Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -117,8 +117,8 @@ while (account == null && accountNumber.length() > 1) { - accountNumber = accountNumber.substring(0, accountNumber.length() - 1); - account = AccountTopiaDao.findByAccountNumber(accountNumber); + accountNumber = accountNumber.substring(0); + account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull(); } } catch (TopiaException ex) { @@ -129,12 +129,12 @@ /** Permet d'obtenir un compte suivant son numero */ @Override - public Account getAccountByNumber(String number) throws LimaException { + public Account getAccountByNumber(String accountNumber) throws LimaException { Account account; try { AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao(); - account = AccountTopiaDao.findByAccountNumber(number); + account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull(); } catch (Exception ex) { throw new LimaException("Can't get master account", ex); } 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 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -675,7 +675,7 @@ if (!entryBookCode.equals(generalEntryBooksDataInList.getCode())) { entryBookCode = generalEntryBooksDataInList.getCode(); code = entryBookCode; - description = Strings.isNullOrEmpty(generalEntryBooksDataInList.getDescription()) == true ? "" : generalEntryBooksDataInList.getDescription(); + description = Strings.isNullOrEmpty(generalEntryBooksDataInList.getDescription()) ? "" : generalEntryBooksDataInList.getDescription(); } else { code = ""; description = ""; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -67,8 +67,7 @@ // check if entrybook with is name already exist EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao(); - result = - entryBookTopiaDao.findByCode(entryBook.getCode()); + result = entryBookTopiaDao.forCodeEquals(entryBook.getCode()).findUniqueOrNull(); if (result != null) { log.error( t("lima-business.entrybook.entrybookalreadyexist", @@ -83,7 +82,8 @@ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao(); // for all unblocked financialperiod - for (FinancialPeriod financialPeriod : financialPeriodTopiaDao.findAllByLocked(false)) { + List<FinancialPeriod> financialPeriods = financialPeriodTopiaDao.forProperties(FinancialPeriod.PROPERTY_LOCKED, true).findAll(); + for (FinancialPeriod financialPeriod : financialPeriods) { //new closed periodic entrybook ClosedPeriodicEntryBook closedPeriodicEntryBook = @@ -187,7 +187,7 @@ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao(); // creation du EntryBook - entryBook = entryBookTopiaDao.findByCode(code); + entryBook = entryBookTopiaDao.forCodeEquals(code).findUniqueOrNull(); } catch (Exception ex) { throw new LimaException("Can't get entry book", ex); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -50,6 +50,8 @@ import org.chorem.lima.entity.FinancialTransactionTopiaDao; import org.chorem.lima.entity.FiscalPeriod; import org.nuiton.topia.persistence.TopiaException; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; import javax.ejb.EJB; import javax.ejb.Remote; @@ -551,21 +553,8 @@ //check rules accountingRules.updateEntryRules(entry, entryOld); - //get new entry amounts - BigDecimal entryAmount = entry.getAmount(); - Boolean entryAmountIsDebit = entry.isDebit(); - - //FIXME PEPIN 20100520 conflict object already instanciate - // Exist best solution ? - entryOld.setAccount(entry.getAccount()); - entryOld.setAmount(entryAmount); - entryOld.setDebit(entryAmountIsDebit); - entryOld.setDescription(entry.getDescription()); - entryOld.setVoucher(entry.getVoucher()); - entryOld.setFinancialTransaction(entry.getFinancialTransaction()); - entryOld.setPosition(entry.getPosition()); - entryOld.setLettering(entry.getLettering()); - + final Binder<Entry, Entry> binder = BinderFactory.newBinder(Entry.class, Entry.class); + binder.copyExcluding(entry, entryOld, Entry.PROPERTY_TOPIA_ID, Entry.PROPERTY_TOPIA_CREATE_DATE); //update entry entryTopiaDao.update(entryOld); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -179,7 +179,7 @@ try { FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); - result = fiscalPeriodTopiaDao.findAllByLocked(true); + result = fiscalPeriodTopiaDao.forLockedEquals(true).findAll(); } catch (Exception ex) { throw new LimaException("Can't create period", ex); } @@ -197,7 +197,7 @@ try { FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); - result = fiscalPeriodTopiaDao.findAllByLocked(false); + result = fiscalPeriodTopiaDao.forLockedEquals(false).findAll(); } catch (Exception ex) { throw new LimaException("Can't get periods", ex); } @@ -326,20 +326,9 @@ throw new LimaException("Can't find fiscal period", ex); } - //Sets entryBook - //search for the entryBook to use using param - boolean found = false; - List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks(); - for (EntryBook entry : entryBooksList) { - if (!found && entry.getCode().equals(entryBook.getCode())) { - entryBook = entry; - found = true; - } - } - //if entrybook isn't found //then create it - if (!found) { + if (!entryBook.isPersisted()) { entryBook = entryBookService.createEntryBook(entryBook); } @@ -388,7 +377,6 @@ FinancialPeriod beginfinancialPeriod = null; //look for the first financial period on the new fiscal year which is unlocked - found = false; List<ClosedPeriodicEntryBook> resultsArray = new ArrayList<ClosedPeriodicEntryBook>(); List<ClosedPeriodicEntryBook> closedPeriodicEntryBook = @@ -401,16 +389,16 @@ // - date after the closing fiscal year // - unlocked entrybook // - right code and label - if (!found && !cPeriodicEntryBook.getFinancialPeriod().isLocked() + if (!cPeriodicEntryBook.getFinancialPeriod().isLocked() && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(localFiscalPeriod.getEndDate()) && !cPeriodicEntryBook.isLocked() && cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode()) && cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) { - found = true; beginfinancialPeriod = cPeriodicEntryBook.getFinancialPeriod(); + break; } } - if (!found) { + if (beginfinancialPeriod == null) { throw new LimaBusinessException(t("lima-business.fiscalperiod.newfinancialperioderror")); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -34,7 +34,7 @@ private static final long serialVersionUID = 1L; - /** sort by accout number in lexicographical order */ + /** sort by account number in lexicographical order */ @Override public int compare(Account o1, Account o2) { return o1.getAccountNumber().compareTo(o2.getAccountNumber()); Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -295,7 +295,7 @@ tr1Entry1.setFinancialTransaction(transaction1); tr1Entry1.setDescription("test desc"); tr1Entry1.setVoucher("voucher"); - tr1Entry1 = financialTransactionService.createEntry(tr1Entry1); + financialTransactionService.createEntry(tr1Entry1); Entry tr1Entry2 = new EntryImpl(); tr1Entry2.setAmount(BigDecimal.valueOf(42.0)); @@ -304,7 +304,7 @@ tr1Entry2.setFinancialTransaction(transaction1); tr1Entry2.setDescription("test desc"); tr1Entry2.setVoucher("voucher"); - tr1Entry2 = financialTransactionService.createEntry(tr1Entry2); + financialTransactionService.createEntry(tr1Entry2); } /** Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -96,7 +96,7 @@ tr1Entry1.setFinancialTransaction(transaction1); //tr1Entry1.setDescription("test desc"); tr1Entry1.setVoucher("voucher"); - tr1Entry1 = financialTransactionService.createEntry(tr1Entry1); + financialTransactionService.createEntry(tr1Entry1); Entry tr1Entry2 = new EntryImpl(); tr1Entry2.setAmount(BigDecimal.valueOf(42.0)); @@ -105,7 +105,7 @@ tr1Entry2.setFinancialTransaction(transaction1); tr1Entry2.setDescription("test desc"); tr1Entry2.setVoucher("voucher"); - tr1Entry2 = financialTransactionService.createEntry(tr1Entry2); + financialTransactionService.createEntry(tr1Entry2); // one in period FiscalPeriod fiscalPeriod = fiscalPeriodService.getAllFiscalPeriods().get(0); @@ -138,7 +138,7 @@ tr1Entry1.setFinancialTransaction(transaction1); tr1Entry1.setDescription("test desc"); tr1Entry1.setVoucher("voucher"); - tr1Entry1 = financialTransactionService.createEntry(tr1Entry1); + financialTransactionService.createEntry(tr1Entry1); // one in period FiscalPeriod fiscalPeriod = fiscalPeriodService.getAllFiscalPeriods().get(0); Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -36,20 +36,6 @@ public class ClosedPeriodicEntryBookTopiaDao extends AbstractClosedPeriodicEntryBookTopiaDao<ClosedPeriodicEntryBook> { /** - * FIXME echatellier, remove this method when implemented in topia - * just overriden to use merge() instead of saveOrUpdate() - */ - public ClosedPeriodicEntryBook merge(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws TopiaException { - try { - closedPeriodicEntryBook = (ClosedPeriodicEntryBook)topiaHibernateSupport.getHibernateSession().merge(closedPeriodicEntryBook); - topiaFiresSupport.warnOnUpdateEntity(closedPeriodicEntryBook); - return closedPeriodicEntryBook; - } catch (HibernateException ex) { - throw new TopiaException(ex); - } - } - - /** * Find all ClosedPeriodicEntryBook with common EntryBook. * * @param entryBook entry book property @@ -72,22 +58,20 @@ EntryBook entryBook, FinancialPeriod financialPeriod) throws TopiaException { - List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks; String query = "FROM " + ClosedPeriodicEntryBook.class.getName(); Map<String, Object> args = Maps.newLinkedHashMap(); - + ClosedPeriodicEntryBook result = null; if (entryBook != null) { args.put("entryBook", entryBook); query += " WHERE entryBook = :entryBook"; if (financialPeriod != null) { args.put("financialPeriod", financialPeriod); query += " AND financialPeriod = :financialPeriod"; - //find(query, 0, 0, "entryBook", entryBook, "financialPeriod", financialPeriod); - closedPeriodicEntryBooks = findAll(query, args); + result = findUniqueOrNull(query, args); + } else { - //find(query, 0, 0, "entryBook", entryBook); - closedPeriodicEntryBooks = findAll(query, args); + result = findAnyOrNull(query, args); } } else { if (financialPeriod != null) { @@ -95,15 +79,9 @@ query += " WHERE financialPeriod = :financialPeriod"; } - //find(query, 0, 0, "financialPeriod", financialPeriod); - closedPeriodicEntryBooks = findAll(query, args); + result = findAnyOrNull(query, args); } - // get only first one - ClosedPeriodicEntryBook result = null; - if (!closedPeriodicEntryBooks.isEmpty()) { - result = closedPeriodicEntryBooks.get(0); - } return result; } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -43,14 +43,12 @@ * Requete generique qui recupere les entrees equilibrées portant entre * deux dates. * - * @param beginDate begin date - * @param endDate end date */ - protected String getEquilibredTransactionQuery(Date beginDate, Date endDate) { + protected String getEquilibredTransactionQuery() { String query = "FROM " + Entry.class.getName() + " E" + // equlibrée (somme des débit = somme des crédit) - " WHERE (select sum(E2.amount) from " + Entry.class.getName() + " E2 where E2.debit = false and E2.financialTransaction = E.financialTransaction) = " + - "(select sum(E2.amount) from " + Entry.class.getName() + " E2 where E2.debit = true and E2.financialTransaction = E.financialTransaction)" + + " WHERE (SELECT sum(E2.amount) FROM " + Entry.class.getName() + " E2 WHERE E2.debit = false AND E2.financialTransaction = E.financialTransaction) = " + + "(SELECT sum(E2.amount) FROM " + Entry.class.getName() + " E2 WHERE E2.debit = true AND E2.financialTransaction = E.financialTransaction)" + // entre les 2 dates " AND :beginDate <= E.financialTransaction.transactionDate" + " AND E.financialTransaction.transactionDate <= :endDate"; @@ -69,7 +67,7 @@ public List<Entry> findAllEntryOfBalancedTransaction(Account account, Date beginDate, Date endDate) { - String query = getEquilibredTransactionQuery(beginDate, endDate) + + String query = getEquilibredTransactionQuery() + // concerne le compte " AND E.account = :account"; Map<String, Object> args = Maps.newLinkedHashMap(); @@ -93,8 +91,8 @@ */ public List<Object[]> getDebitCreditOfBalancedTransaction(Account account, Date beginDate, Date endDate) { - String query = "SELECT E.debit, sum(E.amount) " + - getEquilibredTransactionQuery(beginDate, endDate) + + String query = "SELECT E.debit, SUM(E.amount) " + + getEquilibredTransactionQuery() + // concerne le compte " AND E.account = :account" + " GROUP BY E.debit"; @@ -118,7 +116,7 @@ */ public List<Entry> findAllEntryOfBalancedTransaction(EntryBook entryBook, Date beginDate, Date endDate) { - String query = getEquilibredTransactionQuery(beginDate, endDate) + + String query = getEquilibredTransactionQuery() + // concerne le journal " AND E.financialTransaction.entryBook = :entryBook" + // fix order @@ -134,9 +132,9 @@ } public List<String> findLetters() { - String query = "Select distinct E.lettering FROM " + Entry.class.getName() + " E" + - " where E.lettering <> null" + - " order by E.lettering desc"; + String query = "SELECT DISTINCT E.lettering FROM " + Entry.class.getName() + " E" + + " WHERE E.lettering <> null" + + " ORDER BY E.lettering DESC"; List<String> result = new ArrayList<String>(this.<String>findAll(query)); @@ -158,8 +156,8 @@ */ public List<Object[]> getDebitCreditOfBalancedTransaction(EntryBook entryBook, Date beginDate, Date endDate) { - String query = "SELECT E.debit, sum(E.amount) " + - getEquilibredTransactionQuery(beginDate, endDate) + + String query = "SELECT E.debit, SUM(E.amount) " + + getEquilibredTransactionQuery() + // concerne le journal " AND E.financialTransaction.entryBook = :entryBook" + " GROUP BY E.debit"; @@ -221,18 +219,18 @@ public List<Entry> getAllEntryByAccountLetteringAndDateForEntryBook(LetteringFilter filter) { List<Entry> entries; - String query = "Select E from " + Entry.class.getName() + " E " + - " where 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 or E.lettering = '') "; + query += " AND (E.lettering is null OR E.lettering = '') "; } else if (filter.getDisplayLettered() && !filter.getDisplayUnlettred()){ - query += " and (E.lettering is not null or E.lettering !='') "; + query += " AND (E.lettering is not null OR E.lettering !='') "; } - query += " and E.financialTransaction.transactionDate between :beginDate and :endDate " + - " order by E.financialTransaction.transactionDate, E.financialTransaction." + FinancialTransaction.PROPERTY_TOPIA_CREATE_DATE; + query += " AND E.financialTransaction.transactionDate between :beginDate AND :endDate " + + " ORDER BY E.financialTransaction.transactionDate, E.financialTransaction." + FinancialTransaction.PROPERTY_TOPIA_CREATE_DATE; Map<String, Object> args = Maps.newLinkedHashMap(); args.put("beginDate", filter.getDateStart()); @@ -246,17 +244,17 @@ public List<Entry> getAllEntryByLetteringAndDateForEntryBook(LetteringFilter filter) { List<Entry> entries; - String query = "Select E from " + Entry.class.getName() + " E "; + String query = "SELECT E FROM " + Entry.class.getName() + " E "; - query += " WHERE E.financialTransaction.transactionDate BETWEEN :beginDate and :endDate "; + query += " WHERE E.financialTransaction.transactionDate BETWEEN :beginDate AND :endDate "; if (!filter.getDisplayLettered() && filter.getDisplayUnlettred()){ - query += " and (E.lettering is null or E.lettering = '') "; + query += " AND (E.lettering is null OR E.lettering = '') "; } else if (filter.getDisplayLettered() && !filter.getDisplayUnlettred()){ - query += " and (E.lettering is not null or E.lettering !='') "; + query += " AND (E.lettering is not null OR E.lettering !='') "; } - query += " order by E.financialTransaction.transactionDate, E.financialTransaction." + FinancialTransaction.PROPERTY_TOPIA_CREATE_DATE; + query += " ORDER BY E.financialTransaction.transactionDate, E.financialTransaction." + FinancialTransaction.PROPERTY_TOPIA_CREATE_DATE; Map<String, Object> args = Maps.newLinkedHashMap(); args.put("beginDate", filter.getDateStart()); @@ -275,10 +273,10 @@ public Entry getLastEntry(FinancialTransaction financialTransaction) { List<Entry> entries; Entry lastEntry = null; - String query = "Select E from " + Entry.class.getName() + " E" + - " where E.financialTransaction.transactionDate = :financialTransactionDate " + - " and E.financialTransaction = :financialTransaction" + - " order by E.topiaCreateDate desc"; + String query = "SELECT E FROM " + Entry.class.getName() + " E" + + " WHERE E.financialTransaction.transactionDate = :financialTransactionDate " + + " AND E.financialTransaction = :financialTransaction" + + " ORDER BY E.topiaCreateDate DESC"; Map<String, Object> args = Maps.newLinkedHashMap(); args.put("financialTransactionDate", financialTransaction.getTransactionDate()); @@ -303,7 +301,7 @@ */ public List<Object[]> getDebitCreditOfTransaction(EntryBook entryBook, Date beginDate, Date endDate) { - String query = "SELECT E.debit, sum(E.amount) " + + String query = "SELECT E.debit, SUM(E.amount) " + "FROM " + Entry.class.getName() + " E" + // entre les 2 dates " WHERE :beginDate <= E.financialTransaction.transactionDate" + Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -51,7 +51,7 @@ Map<String, Object> args = Maps.newLinkedHashMap(); args.put("date", date); // add unique result here - FinancialPeriod financialPeriod = (FinancialPeriod)findUnique(query, args); + FinancialPeriod financialPeriod = findUnique(query, args); return financialPeriod; } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java 2014-05-26 15:08:04 UTC (rev 3818) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java 2014-05-26 22:02:37 UTC (rev 3819) @@ -51,20 +51,6 @@ private static final Log log = LogFactory.getLog(FinancialTransactionTopiaDao.class); /** - * FIXME echatellier, remove this method when implemented in topia - * just overriden to use merge() instead of saveOrUpdate() - */ - public FinancialTransaction merge(FinancialTransaction financialTransaction) { - try { - financialTransaction = (FinancialTransaction)topiaHibernateSupport.getHibernateSession().merge(financialTransaction); - topiaFiresSupport.warnOnUpdateEntity(financialTransaction); - return financialTransaction; - } catch (HibernateException ex) { - throw new TopiaException(ex); - } - } - - /** * Return how many transaction are found with specified entryBook. * * @param entryBook entry book Modified: trunk/lima-callao/src/main/xmi/accounting-model.zargo =================================================================== (Binary files differ)
participants (1)
-
dcosse@users.chorem.org