Author: jpepin Date: 2010-06-03 11:59:29 +0200 (Thu, 03 Jun 2010) New Revision: 2928 Url: http://chorem.org/repositories/revision/lima/2928 Log: Requ?\195?\170te affichage des transactions non ?\195?\169quilibr?\195?\169s. Calcul balance, edition compte et journaux ne prend plus en compte les transactions non ?\195?\169quilibr?\195?\169s.Tri des p?\195?\169riodes financi?\195?\168res/journaux. Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.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/ReportServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-06-03 09:59:29 UTC (rev 2928) @@ -206,7 +206,6 @@ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext); closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(entryBook, financialPeriod); - } catch (TopiaException ex) { doCatch(topiaContext, ex, log); @@ -235,8 +234,11 @@ query.addFrom(FiscalPeriod.class, "F") .addInElements("E." + ClosedPeriodicEntryBook.FINANCIAL_PERIOD, "F."+FiscalPeriod.FINANCIAL_PERIOD) - .addEquals("F."+FiscalPeriod.LOCKED, Boolean.FALSE) - .addOrder(FiscalPeriod.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); + .addEquals("F."+FiscalPeriod.LOCKED, Boolean.FALSE); + String orderProperty = + TopiaQuery.getProperty("E", ClosedPeriodicEntryBook.FINANCIAL_PERIOD, + FinancialPeriod.BEGIN_DATE); + query.addOrder(orderProperty); //IMPORTANT : LOADING ClosedPeriodicEntryBook AND IS COLUMN FOR NO LAZY EXCEPTION String loadEntryBookProperty = 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 2010-06-02 15:33:55 UTC (rev 2927) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-06-03 09:59:29 UTC (rev 2928) @@ -23,6 +23,8 @@ import java.util.Date; import java.util.List; import javax.ejb.Stateless; +import javax.management.Query; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountingRules; @@ -30,6 +32,7 @@ import org.chorem.lima.business.FinancialTransactionServiceLocal; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryDAO; @@ -161,20 +164,45 @@ return financialTransactions; } - + + + /** + * Get unbalanced financialtransaction from selected fiscalperiod + */ @Override - //TODO No terminated public List<FinancialTransaction> getAllFinancialTransactionsUnbalanced(FiscalPeriod fiscalPeriod) throws LimaException { TopiaContext topiaContext = null; List<FinancialTransaction> result = null; try { topiaContext = beginTransaction(); - + FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); - - //TODO + TopiaQuery query = financialTransactionDAO.createQuery("E"); + query.addFrom(FiscalPeriod.class, "F") + .addWhere("E.amountCredit != E.amountDebit") + .addInElements("E.financialPeriod", "F.financialPeriod") + .addEquals("F", fiscalPeriod); + result = financialTransactionDAO.findAllByQuery(query); + /* Just for fun : IN HQL + result = topiaContext.find( + "FROM org.chorem.lima.entity.FinancialTransaction "+ + "WHERE amountCredit != amountDebit and (financialPeriod in (" + + "FROM org.chorem.lima.entity.FinancialPeriod " + + "WHERE (fiscalPeriod = :fiscalPeriod)))","fiscalPeriod",fiscalPeriod);*/ + + //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION + for (FinancialTransaction financialTransaction : result) { + + for (Entry entry : financialTransaction.getEntry()) { + entry.getEntryBook(); + entry.getAccount(); + entry.getFinancialTransaction(); + entry.getFinancialTransaction().getFinancialPeriod(); + } + } + } catch (TopiaException ex) { doCatch(topiaContext, ex, log); 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 2010-06-02 15:33:55 UTC (rev 2927) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 09:59:29 UTC (rev 2928) @@ -101,7 +101,6 @@ // First subaccount List<Account> accounts = account.getSubAccounts(); accounts.addAll(account.getSubLedgers()); - log.debug(accounts); if (accounts.size() == 0){ reportsDatas = generateSubAccountReportsWithTransaction(account, beginDate, endDate, topiaContext); @@ -133,6 +132,7 @@ /** * Query for find entries for accountsreports and balancereports + * Just balanced transaction are calculated */ public TopiaQuery createEntryQuery(Account account, Date beginDate, Date endDate, EntryDAO entryDAO, String queryAlias) throws LimaException{ TopiaQuery query = entryDAO.createQuery(queryAlias); @@ -140,7 +140,15 @@ String transactionDateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); - query.addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate") + String amountCreditProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.AMOUNT_CREDIT); + String amountDebitProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.AMOUNT_DEBIT); + query + .addWhere(amountCreditProperty+" = "+amountDebitProperty) + .addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate") .addParam("beginDate", beginDate) .addParam("endDate", endDate) .addEquals(Entry.ACCOUNT, account); @@ -265,6 +273,8 @@ * * Calculate the amounts and the solde * + * Just balanced transaction are calculated + * */ @SuppressWarnings({ "unchecked" }) @Override @@ -282,7 +292,15 @@ String transactionDateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); - query.addEquals(Entry.ENTRY_BOOK, entryBook) + String amountCreditProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.AMOUNT_CREDIT); + String amountDebitProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.AMOUNT_DEBIT); + query + .addWhere(amountCreditProperty+" = "+amountDebitProperty) + .addEquals(Entry.ENTRY_BOOK, entryBook) .addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate") .addParam("beginDate", beginDate) .addParam("endDate", endDate); Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-06-02 15:33:55 UTC (rev 2927) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-06-03 09:59:29 UTC (rev 2928) @@ -26,7 +26,7 @@ @BeforeClass public static void setUpClass() throws Exception { - LimaConfig.getInstance(); + LimaConfig.getInstance(); } /**