Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
May 2012
- 2 participants
- 37 discussions
r3404 - trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules
by echatellier@users.chorem.org 04 May '12
by echatellier@users.chorem.org 04 May '12
04 May '12
Author: echatellier
Date: 2012-05-04 16:44:00 +0200 (Fri, 04 May 2012)
New Revision: 3404
Url: http://chorem.org/repositories/revision/lima/3404
Log:
Just another topia query removal
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
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 2012-05-04 14:36:29 UTC (rev 3403)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-05-04 14:44:00 UTC (rev 3404)
@@ -53,7 +53,6 @@
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
/**
* Defaults rules, if no localized rules classes is instantiated
@@ -195,6 +194,8 @@
LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
// Check if all financial transactions of closedperiodicentrybook are equilibrate
+ // FIMXE echatellier 20120504 unutile de recuperer une liste
+ // entiere juste pour tester l'existence
List<FinancialTransaction> result = financialTransactionDAO.getAllUnbalancedTransaction(closedPeriodicEntryBook.getFinancialPeriod(),
closedPeriodicEntryBook.getEntryBook());
if (result.size() > 0) {
@@ -204,14 +205,16 @@
// Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
result = financialTransactionDAO.getAllUnfilledTransaction(closedPeriodicEntryBook.getFinancialPeriod(),
closedPeriodicEntryBook.getEntryBook());
-
+ // FIMXE echatellier 20120504 unutile de recuperer une liste
+ // entiere juste pour tester l'existence
if (result.size() > 0) {
throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingelements"));
}
// Check if all financial transactions have EntryBooks
result = financialTransactionDAO.getAllTransactionWithoutEntryBook();
-
+ // FIMXE echatellier 20120504 unutile de recuperer une liste
+ // entiere juste pour tester l'existence
if (result.size() > 0) {
throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingentrybook"));
}
@@ -332,10 +335,7 @@
LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
//search fiscalperiod have financialperiod in params
- TopiaQuery query = fiscalPeriodDAO.createQuery()
- .addInElements(":financialPeriod", "financialPeriod")
- .addParam("financialPeriod", financialPeriod);
- FiscalPeriod fiscalPeriod = fiscalPeriodDAO.findByQuery(query);
+ FiscalPeriod fiscalPeriod = fiscalPeriodDAO.findByFinancialPeriod(financialPeriod);
Date beginDateFiscalPeriod = fiscalPeriod.getBeginDate();
Date endDateFiscalPeriod = fiscalPeriod.getEndDate();
1
0
r3403 - trunk/lima-callao/src/main/java/org/chorem/lima/entity
by echatellier@users.chorem.org 04 May '12
by echatellier@users.chorem.org 04 May '12
04 May '12
Author: echatellier
Date: 2012-05-04 16:36:29 +0200 (Fri, 04 May 2012)
New Revision: 3403
Url: http://chorem.org/repositories/revision/lima/3403
Log:
Remove topia query from all dao
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-05-04 13:53:36 UTC (rev 3402)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-05-04 14:36:29 UTC (rev 3403)
@@ -28,7 +28,6 @@
import java.util.List;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
/**
* Ajout de requetes specifiques aux financial transaction sur le DAO.
@@ -57,40 +56,46 @@
/**
* Find all unbalanced transactions.
*
- * @param period period
+ * @param financialPeriod period
* @param entryBook entry book
* @return unbalanced transactions
* @throws TopiaException
*/
- public List<FinancialTransaction> getAllUnbalancedTransaction(FinancialPeriod period,
+ public List<FinancialTransaction> getAllUnbalancedTransaction(FinancialPeriod financialPeriod,
EntryBook entryBook) throws TopiaException {
- TopiaQuery query = createQuery("E");
- query.addWhere("E.amountCredit != E.amountDebit")
- .addEquals(FinancialTransaction.PROPERTY_ENTRY_BOOK, entryBook)
- .addEquals(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD, period);
- List<FinancialTransaction> result = findAllByQuery(query);
+ String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ " WHERE (SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = true AND financialTransaction = T) != " +
+ " (SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = false AND financialTransaction = T)" +
+ " AND T.financialPeriod = :financialPeriod" +
+ " AND T.entryBook = :entryBook";
+ List<FinancialTransaction> result = context.find(query, "financialPeriod",
+ financialPeriod, "entryBook", entryBook);
return result;
}
/**
* Find all transaction where some field are not filled in.
*
- * @param period period
+ * @param financialPeriod period
* @param entryBook entry book
* @return unfilled transaction
* @throws TopiaException
*/
- public List<FinancialTransaction> getAllUnfilledTransaction(FinancialPeriod period,
+ public List<FinancialTransaction> getAllUnfilledTransaction(FinancialPeriod financialPeriod,
EntryBook entryBook) throws TopiaException {
- TopiaQuery query = createQuery("T");
- query.addDistinct()
- .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
- .addFrom(FiscalPeriod.class, "F")
- .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
- .addWhere("T.amountCredit != T.amountDebit OR E.account = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''")
- .addEquals(FinancialTransaction.PROPERTY_ENTRY_BOOK, entryBook)
- .addEquals(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD, period);
- List<FinancialTransaction> result = findAllByQuery(query);
+ String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ " LEFT JOIN T.entry AS E" +
+ " WHERE ((SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = true AND financialTransaction = T) != " +
+ " (SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = false AND financialTransaction = T) + OR E.account = null" +
+ " OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = '')" +
+ " AND T.entryBook = :entryBook" +
+ " AND T.financialPeriod = :financialPeriod";
+ List<FinancialTransaction> result = context.find(query, "financialPeriod",
+ financialPeriod, "entryBook", entryBook);
return result;
}
@@ -98,20 +103,31 @@
* Find all transaction without entry book.
*
* TODO echatellier 20120425 same method as getAllUnfilledTransaction ?
- * doesn't concern a period ?
*
* @return
* @throws TopiaException
*/
public List<FinancialTransaction> getAllTransactionWithoutEntryBook() throws TopiaException {
- TopiaQuery query = createQuery("T");
+ /*TopiaQuery query = createQuery("T");
query.addDistinct()
.addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
.addFrom(FiscalPeriod.class, "F")
.addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
.addWhere("T.amountCredit != T.amountDebit OR E.account = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''")
.addNull(FinancialTransaction.PROPERTY_ENTRY_BOOK);
- List<FinancialTransaction> result = findAllByQuery(query);
+ List<FinancialTransaction> result = findAllByQuery(query);*/
+
+ String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ " LEFT JOIN T.entry AS E" +
+ " WHERE ((SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = true AND financialTransaction = T) != " +
+ " (SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = false AND financialTransaction = T) + OR E.account = null" +
+ " OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = '')" +
+ " AND entryBook = null";
+ // FIXME echatellier 20120504 doesn't concern a period ? all database ?
+ List<FinancialTransaction> result = context.find(query);
+
return result;
}
1
0
r3402 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports
by echatellier@users.chorem.org 04 May '12
by echatellier@users.chorem.org 04 May '12
04 May '12
Author: echatellier
Date: 2012-05-04 15:53:36 +0200 (Fri, 04 May 2012)
New Revision: 3402
Url: http://chorem.org/repositories/revision/lima/3402
Log:
Begin report service refactoring.
Move query to DAO.
Remove topia query.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
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-05-04 13:17:42 UTC (rev 3401)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-05-04 13:53:36 UTC (rev 3402)
@@ -157,42 +157,6 @@
return reportsDatas;
}
- /*
- * Query for find entries for accountsreports and balancereports
- * Just exact and balanced transaction are calculated.
- *
- * @param account
- * @param beginDate
- * @param endDate
- * @param entryDAO
- * @param queryAlias
- * @return
- * @throws LimaException
- *
- protected TopiaQuery createEntryQuery(Account account,
- Date beginDate,
- Date endDate,
- EntryDAO entryDAO,
- String queryAlias) {
- TopiaQuery query = entryDAO.createQuery(queryAlias);
-
- String transactionDateProperty = TopiaQuery.getProperty(
- Entry.PROPERTY_FINANCIAL_TRANSACTION, FinancialTransaction.PROPERTY_TRANSACTION_DATE);
- String entryBookProperty = TopiaQuery.getProperty(
- Entry.PROPERTY_FINANCIAL_TRANSACTION, FinancialTransaction.PROPERTY_ENTRY_BOOK);
-
- // echatellier, oui c'est hardcodé, mais qu'est ce que c'est illisible sans ca
- query .addWhere("(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)")
- .addWhere(transactionDateProperty + " BETWEEN :beginDate AND :endDate")
- .addNotNull(entryBookProperty)
- .addParam("beginDate", beginDate)
- .addParam("endDate", endDate)
- .addEquals(Entry.PROPERTY_ACCOUNT, account);
-
- return query;
- }*/
-
/**
* Get list entries
* Calculate all credit, debit and solde amounts for the accounts reports
@@ -206,9 +170,7 @@
* @throws TopiaException
*/
protected ReportsDatas generateSubAccountReportsWithTransaction(Account account,
- Date beginDate,
- Date endDate,
- TopiaContext topiaContext) throws TopiaException {
+ Date beginDate, Date endDate, TopiaContext topiaContext) throws TopiaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
@@ -217,11 +179,11 @@
EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
// trouve les entrees associées à ca compte entre les date données
- List<Entry> listEntries = entryDAO.findAllEntryOfEquilibredTransaction(account, beginDate, endDate);
+ List<Entry> listEntries = entryDAO.findAllEntryOfBalancedTransaction(account, beginDate, endDate);
reportsDatas.setListEntry(listEntries);
// recupere les totaux pour le compte
- List<Object[]> results = entryDAO.getDebitCreditOfEquilibredTransaction(account, beginDate, endDate);
+ List<Object[]> results = entryDAO.getDebitCreditOfBalancedTransaction(account, beginDate, endDate);
int nbAmount = results.size();
if (nbAmount == 2) {
debit = (BigDecimal) results.get(0)[1];
@@ -259,37 +221,20 @@
* @throws TopiaException
*/
public ReportsDatas generateSubAccountBalanceWithTransaction(Account account,
- Date beginDate,
- Date endDate,
- Boolean getEntries,
- TopiaContext topiaContext) throws LimaException, TopiaException {
+ Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException, TopiaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- //String queryAlias = "E";
EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
if (getEntries) {
- //TopiaQuery entriesQuery =
- // createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- //entriesQuery.addLoad(Entry.PROPERTY_FINANCIAL_TRANSACTION);
- //String loadEntryBookProperty =
- // TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- // FinancialTransaction.PROPERTY_ENTRY_BOOK);
- //entriesQuery.addLoad(loadEntryBookProperty);
- List<Entry> listEntries = entryDAO.findAllEntryOfEquilibredTransaction(account, beginDate, endDate);
+ List<Entry> listEntries = entryDAO.findAllEntryOfBalancedTransaction(account, beginDate, endDate);
reportsDatas.setListEntry(listEntries);
}
- //TopiaQuery amountsQuery =
- // createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- //amountsQuery.setSelect("E." + Entry.PROPERTY_DEBIT, "SUM(E." + Entry.PROPERTY_AMOUNT + ")");
- //amountsQuery.addGroup("E." + Entry.PROPERTY_DEBIT);
- //results = amountsQuery.execute(topiaContext);
- List<Object[]> results = entryDAO.getDebitCreditOfEquilibredTransaction(account, beginDate, endDate);
+ List<Object[]> results = entryDAO.getDebitCreditOfBalancedTransaction(account, beginDate, endDate);
int nbAmount = results.size();
if (nbAmount == 2) {
debit = (BigDecimal) results.get(0)[1];
@@ -330,114 +275,55 @@
*/
@Override
public ReportsDatas generateEntryBooksReports(EntryBook entryBook,
- Date beginDate,
- Date endDate) throws LimaException {
+ Date beginDate, Date endDate) throws LimaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- List<Object[]> results;
- if (entryBook != null && beginDate != null && endDate != null) {
- // Get all entries with a topia query
- TopiaContext topiaTransaction = beginTransaction(rootContext);
- try {
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
- TopiaQuery entriesQuery = createEntryBookReportsQuery(
- entryBook, beginDate, endDate, entryDAO, "E");
- String orderDateProperty =
- TopiaQuery.getProperty("E", Entry.PROPERTY_FINANCIAL_TRANSACTION, FinancialTransaction.PROPERTY_TRANSACTION_DATE);
- String orderIdProperty =
- TopiaQuery.getProperty("E", Entry.PROPERTY_FINANCIAL_TRANSACTION, FinancialTransaction.TOPIA_ID);
- entriesQuery.addOrder(orderDateProperty)
- .addOrder(orderIdProperty);
- reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery));
-
- TopiaQuery amountsQuery =
- createEntryBookReportsQuery(entryBook, beginDate, endDate, entryDAO, "E");
- amountsQuery.setSelect("E." + Entry.PROPERTY_DEBIT, "SUM(E." + Entry.PROPERTY_AMOUNT + ")");
- amountsQuery.addGroup("E." + Entry.PROPERTY_DEBIT);
- results = amountsQuery.execute(topiaTransaction);
- int nbAmount = results.size();
- if (nbAmount == 2) {
+ // Get all entries with a topia query
+ TopiaContext topiaTransaction = beginTransaction(rootContext);
+ try {
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
+ List<Entry> entries = entryDAO.findAllEntryOfBalancedTransaction(entryBook, beginDate, endDate);
+ reportsDatas.setListEntry(entries);
+
+ List<Object[]> results = entryDAO.getDebitCreditOfBalancedTransaction(entryBook, beginDate, endDate);
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
+ }
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
}
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
- debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
- }
- }
+ }
- // set the amounts and solde
- //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);
-
- //commitTransaction(topiaTransaction);
- } catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
+ // set the amounts and solde
+ //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);
+ } catch (Exception ex) {
+ doCatch(topiaTransaction, ex);
+ } finally {
+ doFinally(topiaTransaction);
}
return reportsDatas;
}
/**
- * Query for find entries for accountsreports and balancereports
- * Just balanced transaction are calculated
- *
- * @param entryBook
- * @param beginDate
- * @param endDate
- * @param entryDAO
- * @param queryAlias
- * @return
- * @throws LimaException
- */
- public TopiaQuery createEntryBookReportsQuery(EntryBook entryBook,
- Date beginDate,
- Date endDate,
- EntryDAO entryDAO,
- String queryAlias) throws LimaException {
- TopiaQuery query = entryDAO.createQuery(queryAlias);
- String transactionDateProperty =
- TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_TRANSACTION_DATE);
-
- // FIXME 20120110 echatellier amoutcredit and debit removed since 0.6
- //String amountCreditProperty =
- // TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- // FinancialTransaction.PROPERTY_AMOUNT_CREDIT);
- //String amountDebitProperty =
- // TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- // FinancialTransaction.PROPERTY_AMOUNT_DEBIT);
- String entryBookProperty =
- TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_ENTRY_BOOK);
- query
- //.addWhere(amountCreditProperty + " = " + amountDebitProperty)
- .addEquals(entryBookProperty, entryBook)
- .addWhere(transactionDateProperty + " BETWEEN :beginDate AND :endDate")
- .addParam("beginDate", beginDate)
- .addParam("endDate", endDate);
-
- return query;
- }
-
- /**
* Get balance trial
* <p/>
* Calculate the amounts and the solde for all subaccounts
@@ -476,8 +362,7 @@
}
//build list account from selectedAccounts
else {
- accounts = accountDAO.stringToListAccounts(
- result, false);
+ accounts = accountDAO.stringToListAccounts( result, false);
}
for (Account account : accounts) {
ReportsDatas reportsDatas =
@@ -571,6 +456,8 @@
accountsList = accountDAO.findAll();
for (Account account : accountsList) {
//VAT accounts start only with number 44
+ //FIXME echatellier 44 is hardcoded and depends on
+ //french rule ?
if (account.getAccountNumber().startsWith("44")) {
list.add(generateBalanceTrial(fp.getBeginDate(),
fp.getEndDate(), account.getAccountNumber(),
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-05-04 13:17:42 UTC (rev 3401)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-05-04 13:53:36 UTC (rev 3402)
@@ -33,24 +33,21 @@
public class EntryDAOImpl<E extends Entry> extends EntryDAOAbstract<Entry> {
/**
- * Requete generique qui recupere les entrees equilibrées portant sur un
- * compte entre deux dates.
+ * Requete generique qui recupere les entrees equilibrées portant entre
+ * deux dates.
*
* @param account account
* @param beginDate begin date
* @param endDate end date
*/
- protected String getEquilibredTransactionQuery(Account account,
- Date beginDate, Date endDate) {
+ protected String getEquilibredTransactionQuery(Date beginDate, Date endDate) {
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)" +
// entre les 2 dates
" AND :beginDate <= E.financialTransaction.transactionDate" +
- " AND E.financialTransaction.transactionDate <= :endDate" +
- // concerne le compte
- " AND E.account = :account";
+ " AND E.financialTransaction.transactionDate <= :endDate";
return query;
}
@@ -64,10 +61,12 @@
* @return entries
* @throws TopiaException
*/
- public List<Entry> findAllEntryOfEquilibredTransaction(Account account,
+ public List<Entry> findAllEntryOfBalancedTransaction(Account account,
Date beginDate, Date endDate) throws TopiaException {
- String query = getEquilibredTransactionQuery(account, beginDate, endDate);
+ String query = getEquilibredTransactionQuery(beginDate, endDate) +
+ // concerne le compte
+ " AND E.account = :account";
List<Entry> entries = context.find(query, "beginDate", beginDate,
"endDate", endDate, "account", account);
@@ -78,20 +77,67 @@
* Retourne la somme des entrées des transaction equilibrées entre
* deux dates pour un compte donné.
*
- * @param account le compte
+ * @param account account
* @param beginDate bebin date
* @param endDate end date
* @return list boolean,int (une ligne pour le debit true, une ligne pour le credit)
* @throws TopiaException
*/
- public List<Object[]> getDebitCreditOfEquilibredTransaction(Account account,
+ public List<Object[]> getDebitCreditOfBalancedTransaction(Account account,
Date beginDate, Date endDate) throws TopiaException {
String query = "SELECT E.debit, sum(E.amount) " +
- getEquilibredTransactionQuery(account, beginDate, endDate) +
+ getEquilibredTransactionQuery(beginDate, endDate) +
+ // concerne le compte
+ " AND E.account = :account" +
" GROUP BY E.debit";
List<Object[]> result = context.find(query, "beginDate", beginDate,
"endDate", endDate, "account", account);
return result;
}
+
+ /**
+ * Retourne les entrees des transaction equlibrées entre deux dates pour
+ * un journal.
+ *
+ * @param entryBook entry book
+ * @param beginDate begin date
+ * @param endDate end date
+ * @throws TopiaException
+ */
+ public List<Entry> findAllEntryOfBalancedTransaction(EntryBook entryBook, Date beginDate,
+ Date endDate) throws TopiaException {
+ String query = getEquilibredTransactionQuery(beginDate, endDate) +
+ // concerne le compte
+ " AND E.entryBook = :entryBook" +
+ // fix order
+ " ORDER BY, E.financialTransaction.beginDate, E.financialTransaction.topiaId";
+
+ List<Entry> entries = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "entryBook", entryBook);
+ return entries;
+ }
+
+ /**
+ * Retourne la somme des entrées des transaction equilibrées entre
+ * deux dates pour un journal donné.
+ *
+ * @param entryBook entry book
+ * @param beginDate bebin date
+ * @param endDate end date
+ * @return list boolean,int (une ligne pour le debit true, une ligne pour le credit)
+ * @throws TopiaException
+ */
+ public List<Object[]> getDebitCreditOfBalancedTransaction(EntryBook entryBook,
+ Date beginDate, Date endDate) throws TopiaException {
+ String query = "SELECT E.debit, sum(E.amount) " +
+ getEquilibredTransactionQuery(beginDate, endDate) +
+ // concerne le compte
+ " AND E.entryBook = :entryBook" +
+ " GROUP BY E.debit";
+
+ List<Object[]> result = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "entryBook", entryBook);
+ return result;
+ }
}
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-05-04 13:17:42 UTC (rev 3401)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-05-04 13:53:36 UTC (rev 3402)
@@ -58,7 +58,6 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-
/**
* Handler associated with accounts reports view.
* By : $Author$
1
0
r3401 - trunk/lima-callao/src/main/java/org/chorem/lima/entity
by echatellier@users.chorem.org 04 May '12
by echatellier@users.chorem.org 04 May '12
04 May '12
Author: echatellier
Date: 2012-05-04 15:17:42 +0200 (Fri, 04 May 2012)
New Revision: 3401
Url: http://chorem.org/repositories/revision/lima/3401
Log:
Rename DAO to DAOImpl
Added:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
Removed:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java
Deleted: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -1,190 +0,0 @@
-/*
- * #%L
- * Lima callao
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.entity;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.apache.commons.lang3.StringUtils;
-import org.nuiton.topia.TopiaException;
-
-public class AccountDAO extends AccountDAOImpl<Account> {
-
- /**
- * Retourne tous les comptes qui n'ont pas eux meme de sous compte.
- *
- * @return leaf accounts
- * @throws TopiaException
- */
- public List<Account> findAllLeafAccounts() throws TopiaException {
- // FIXME echatellier 20120413 la requete ne fonctionne pas
- // et retourne vide
- /*String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" +
- "FROM " + Account.class.getName() + " b where b.accountNumber like concat(a.accountNumber,'%'))";
- List<Account> accounts = context.find(query);*/
-
- // code temporaire non performant en attandant:
- List<Account> allAccounts = findAll();
- Iterator<Account> itAccount = allAccounts.iterator();
- while (itAccount.hasNext()) {
- Account acc = itAccount.next();
- Iterator<Account> itAccount2 = allAccounts.iterator();
- while (itAccount2.hasNext()) {
- Account acc2 = itAccount2.next();
- if (!acc2.getAccountNumber().equals(acc.getAccountNumber()) &&
- acc2.getAccountNumber().startsWith(acc.getAccountNumber())) {
- itAccount.remove();
- break;
- }
- }
- }
- return allAccounts;
- }
-
- /**
- * TODO pas compris l'interet de la methode, si on veut un compte feuille
- * par son numero, cela revient a avoir un compte par son numero.
- */
- @Deprecated
- public Account findLeafAccountByNumber(String number) throws TopiaException {
- return findByAccountNumber(number);
- }
-
- /**
- * Find account contained into account number interval.
- *
- * @param accountNumberLow min account number
- * @param accountNumberHigh max account number
- * @return account list
- * @throws TopiaException
- */
- protected List<Account> findIntervalAccountByNumber(String accountNumberLow,
- String accountNumberHigh) throws TopiaException {
- String query = "FROM " + Account.class.getName() + " WHERE :accountNumberLow <= accountNumber AND accountNumber <= :accountNumberHigh";
- return (List<Account>) context.find(query, "accountNumberLow",
- accountNumberLow, "accountNumberHigh", accountNumberHigh);
- }
-
- /**
- * Retourne tous les comptes dont le numero commence par celui specifié.
- *
- * @param account parent account
- * @return
- * @throws TopiaException
- */
- public List<Account> findAllSubAccounts(Account account) throws TopiaException {
-
- String query = "FROM " + Account.class.getName() + " a WHERE a.accountNumber LIKE concat(:accountNumber, '_%')";
- List<Account> accounts = context.find(query, "accountNumber", account.getAccountNumber());
-
- return accounts;
- }
-
- /**
- * @deprecated since 0.6, business method, need to be moved out of dao
- */
- @Deprecated
- public List<Account> stringToListAccounts(String selectedAccounts,
- Boolean leafAccountsMode) throws TopiaException {
- Set<Account> accounts = new HashSet<Account>();
- if (selectedAccounts != null) {
- //Remove Spaces
- String result = StringUtils.deleteWhitespace(selectedAccounts);
-
- Boolean first = true;
- StringTokenizer stStar = new StringTokenizer(result, "-");
- while (stStar.hasMoreTokens()) {
- String subString = stStar.nextToken();
-
- //Split comma
- StringTokenizer stComma = new StringTokenizer(subString, ",");
- while (stComma.hasMoreTokens()) {
- String s = stComma.nextToken();
- //if intervall account
- if (s.contains("..") && !s.endsWith("..")) {
- //Split ..
- String stringDoubleDot[] = s.split("\\.\\.");
-
- List<Account> resultIntervall =
- findIntervalAccountByNumber(stringDoubleDot[0], stringDoubleDot[1]);
-
- //if first add accounts, else remove
- if (first) {
- accounts.addAll(resultIntervall);
- } else {
- accounts.removeAll(resultIntervall);
- }
- }
- //else one account
- else {
- Account account = null;
- if (leafAccountsMode) {
- account = findLeafAccountByNumber(s);
- } else {
- account = findByAccountNumber(s);
- }
- //if exist
- if (account != null) {
- //if first
- if (first) {
- accounts.add(account);
- } else {
- accounts.remove(account);
- }
- }
- //search all account start with accountnumber
- else {
- /*TopiaQuery query = createQuery();
- String subAccountsProperty = TopiaQuery.getProperty(Account.PROPERTY_SUB_ACCOUNTS);
- query.addWhere("not exists elements (" + subAccountsProperty + ")")
- .addWhere(Account.PROPERTY_ACCOUNT_NUMBER, Op.LIKE, s + "%");
- List<Account> accountsResult = (List<Account>) findAllByQuery(query);*/
-
- String query = "FROM " + Account.class.getName() + " a WHERE NOT IN (" +
- "FROM " + Account.class.getName() + " b where b.accountNumber like a.accountNumber+'%')" +
- " AND a.accountNumber LIKE ?";
- List<Account> accountsResult = getContext().find(query, s);
- if (accountsResult != null) {
- //if first
- if (first) {
- accounts.addAll(accountsResult);
- } else {
- accounts.removeAll(accountsResult);
- }
- }
- }
- }
- }
- first = false;
- }
- }
- return new ArrayList(accounts);
- }
-}
Copied: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java (from rev 3400, trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java)
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -0,0 +1,190 @@
+/*
+ * #%L
+ * Lima callao
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.entity;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.commons.lang3.StringUtils;
+import org.nuiton.topia.TopiaException;
+
+public class AccountDAOImpl<E extends Account> extends AccountDAOAbstract<Account> {
+
+ /**
+ * Retourne tous les comptes qui n'ont pas eux meme de sous compte.
+ *
+ * @return leaf accounts
+ * @throws TopiaException
+ */
+ public List<Account> findAllLeafAccounts() throws TopiaException {
+ // FIXME echatellier 20120413 la requete ne fonctionne pas
+ // et retourne vide
+ /*String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" +
+ "FROM " + Account.class.getName() + " b where b.accountNumber like concat(a.accountNumber,'%'))";
+ List<Account> accounts = context.find(query);*/
+
+ // code temporaire non performant en attandant:
+ List<Account> allAccounts = findAll();
+ Iterator<Account> itAccount = allAccounts.iterator();
+ while (itAccount.hasNext()) {
+ Account acc = itAccount.next();
+ Iterator<Account> itAccount2 = allAccounts.iterator();
+ while (itAccount2.hasNext()) {
+ Account acc2 = itAccount2.next();
+ if (!acc2.getAccountNumber().equals(acc.getAccountNumber()) &&
+ acc2.getAccountNumber().startsWith(acc.getAccountNumber())) {
+ itAccount.remove();
+ break;
+ }
+ }
+ }
+ return allAccounts;
+ }
+
+ /**
+ * TODO pas compris l'interet de la methode, si on veut un compte feuille
+ * par son numero, cela revient a avoir un compte par son numero.
+ */
+ @Deprecated
+ public Account findLeafAccountByNumber(String number) throws TopiaException {
+ return findByAccountNumber(number);
+ }
+
+ /**
+ * Find account contained into account number interval.
+ *
+ * @param accountNumberLow min account number
+ * @param accountNumberHigh max account number
+ * @return account list
+ * @throws TopiaException
+ */
+ protected List<Account> findIntervalAccountByNumber(String accountNumberLow,
+ String accountNumberHigh) throws TopiaException {
+ String query = "FROM " + Account.class.getName() + " WHERE :accountNumberLow <= accountNumber AND accountNumber <= :accountNumberHigh";
+ return (List<Account>) context.find(query, "accountNumberLow",
+ accountNumberLow, "accountNumberHigh", accountNumberHigh);
+ }
+
+ /**
+ * Retourne tous les comptes dont le numero commence par celui specifié.
+ *
+ * @param account parent account
+ * @return
+ * @throws TopiaException
+ */
+ public List<Account> findAllSubAccounts(Account account) throws TopiaException {
+
+ String query = "FROM " + Account.class.getName() + " a WHERE a.accountNumber LIKE concat(:accountNumber, '_%')";
+ List<Account> accounts = context.find(query, "accountNumber", account.getAccountNumber());
+
+ return accounts;
+ }
+
+ /**
+ * @deprecated since 0.6, business method, need to be moved out of dao
+ */
+ @Deprecated
+ public List<Account> stringToListAccounts(String selectedAccounts,
+ Boolean leafAccountsMode) throws TopiaException {
+ Set<Account> accounts = new HashSet<Account>();
+ if (selectedAccounts != null) {
+ //Remove Spaces
+ String result = StringUtils.deleteWhitespace(selectedAccounts);
+
+ Boolean first = true;
+ StringTokenizer stStar = new StringTokenizer(result, "-");
+ while (stStar.hasMoreTokens()) {
+ String subString = stStar.nextToken();
+
+ //Split comma
+ StringTokenizer stComma = new StringTokenizer(subString, ",");
+ while (stComma.hasMoreTokens()) {
+ String s = stComma.nextToken();
+ //if intervall account
+ if (s.contains("..") && !s.endsWith("..")) {
+ //Split ..
+ String stringDoubleDot[] = s.split("\\.\\.");
+
+ List<Account> resultIntervall =
+ findIntervalAccountByNumber(stringDoubleDot[0], stringDoubleDot[1]);
+
+ //if first add accounts, else remove
+ if (first) {
+ accounts.addAll(resultIntervall);
+ } else {
+ accounts.removeAll(resultIntervall);
+ }
+ }
+ //else one account
+ else {
+ Account account = null;
+ if (leafAccountsMode) {
+ account = findLeafAccountByNumber(s);
+ } else {
+ account = findByAccountNumber(s);
+ }
+ //if exist
+ if (account != null) {
+ //if first
+ if (first) {
+ accounts.add(account);
+ } else {
+ accounts.remove(account);
+ }
+ }
+ //search all account start with accountnumber
+ else {
+ /*TopiaQuery query = createQuery();
+ String subAccountsProperty = TopiaQuery.getProperty(Account.PROPERTY_SUB_ACCOUNTS);
+ query.addWhere("not exists elements (" + subAccountsProperty + ")")
+ .addWhere(Account.PROPERTY_ACCOUNT_NUMBER, Op.LIKE, s + "%");
+ List<Account> accountsResult = (List<Account>) findAllByQuery(query);*/
+
+ String query = "FROM " + Account.class.getName() + " a WHERE NOT IN (" +
+ "FROM " + Account.class.getName() + " b where b.accountNumber like a.accountNumber+'%')" +
+ " AND a.accountNumber LIKE ?";
+ List<Account> accountsResult = getContext().find(query, s);
+ if (accountsResult != null) {
+ //if first
+ if (first) {
+ accounts.addAll(accountsResult);
+ } else {
+ accounts.removeAll(accountsResult);
+ }
+ }
+ }
+ }
+ }
+ first = false;
+ }
+ }
+ return new ArrayList(accounts);
+ }
+}
Deleted: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -1,106 +0,0 @@
-/*
- * #%L
- * Lima callao
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.entity;
-
-import java.util.Date;
-import java.util.List;
-
-import org.nuiton.topia.TopiaException;
-
-public class ClosedPeriodicEntryBookDAO extends ClosedPeriodicEntryBookDAOImpl<ClosedPeriodicEntryBook> {
-
- /**
- * Find all ClosedPeriodicEntryBook with common EntryBook.
- *
- * @param entryBook entry book property
- * @return ClosedPeriodicEntryBook list
- * @throws TopiaException
- */
- public List<ClosedPeriodicEntryBook> findAllByEntryBook(EntryBook entryBook) throws TopiaException {
- return findAllByProperties(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook);
- }
-
- /**
- * Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod.
- *
- * @param entryBook
- * @param financialPeriod
- * @return ClosedPeriodicEntryBook
- * @throws TopiaException
- */
- public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod(
- EntryBook entryBook, FinancialPeriod financialPeriod)
- throws TopiaException {
-
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks;
- String query = "FROM " + ClosedPeriodicEntryBook.class.getName();
- if (entryBook != null) {
- query += " WHERE entryBook = :entryBook";
- if (financialPeriod != null) {
- query += " AND financialPeriod = :financialPeriod";
- //context.find(query, 0, 0, "entryBook", entryBook, "financialPeriod", financialPeriod);
- closedPeriodicEntryBooks = context.find(query, "entryBook", entryBook, "financialPeriod", financialPeriod);
- } else {
- //context.find(query, 0, 0, "entryBook", entryBook);
- closedPeriodicEntryBooks = context.find(query, "entryBook", entryBook);
- }
- } else {
- if (financialPeriod != null) {
- query += " WHERE financialPeriod = :financialPeriod";
- }
-
- //context.find(query, 0, 0, "financialPeriod", financialPeriod);
- closedPeriodicEntryBooks = context.find(query, "financialPeriod", financialPeriod);
- }
-
- // get only first one
- ClosedPeriodicEntryBook result = null;
- if (!closedPeriodicEntryBooks.isEmpty()) {
- result = closedPeriodicEntryBooks.get(0);
- }
- return result;
- }
-
- /**
- * Retourne toutes les ClosedPeriodicEntryBook par interval de date
- * sur les periodes sur lequelles elles portent ordonnée par journal.
- *
- * @param beginDate begin date
- * @param endDate end date
- * @return all ClosedPeriodicEntryBook between begin and end
- * @throws TopiaException
- */
- public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate,
- Date endDate) throws TopiaException {
-
- String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
- " WHERE :begindate <= financialPeriod.beginDate " +
- " AND financialPeriod.beginDate <= :endDate" +
- " ORDER BY entryBook.code";
- return context.find(query, 0d, 0d, "beginDate", beginDate, "endDate", endDate);
- }
-
-}
Copied: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java (from rev 3400, trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java)
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -0,0 +1,106 @@
+/*
+ * #%L
+ * Lima callao
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import org.nuiton.topia.TopiaException;
+
+public class ClosedPeriodicEntryBookDAOImpl<E extends ClosedPeriodicEntryBook> extends ClosedPeriodicEntryBookDAOAbstract<ClosedPeriodicEntryBook> {
+
+ /**
+ * Find all ClosedPeriodicEntryBook with common EntryBook.
+ *
+ * @param entryBook entry book property
+ * @return ClosedPeriodicEntryBook list
+ * @throws TopiaException
+ */
+ public List<ClosedPeriodicEntryBook> findAllByEntryBook(EntryBook entryBook) throws TopiaException {
+ return findAllByProperties(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook);
+ }
+
+ /**
+ * Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod.
+ *
+ * @param entryBook
+ * @param financialPeriod
+ * @return ClosedPeriodicEntryBook
+ * @throws TopiaException
+ */
+ public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod(
+ EntryBook entryBook, FinancialPeriod financialPeriod)
+ throws TopiaException {
+
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks;
+ String query = "FROM " + ClosedPeriodicEntryBook.class.getName();
+ if (entryBook != null) {
+ query += " WHERE entryBook = :entryBook";
+ if (financialPeriod != null) {
+ query += " AND financialPeriod = :financialPeriod";
+ //context.find(query, 0, 0, "entryBook", entryBook, "financialPeriod", financialPeriod);
+ closedPeriodicEntryBooks = context.find(query, "entryBook", entryBook, "financialPeriod", financialPeriod);
+ } else {
+ //context.find(query, 0, 0, "entryBook", entryBook);
+ closedPeriodicEntryBooks = context.find(query, "entryBook", entryBook);
+ }
+ } else {
+ if (financialPeriod != null) {
+ query += " WHERE financialPeriod = :financialPeriod";
+ }
+
+ //context.find(query, 0, 0, "financialPeriod", financialPeriod);
+ closedPeriodicEntryBooks = context.find(query, "financialPeriod", financialPeriod);
+ }
+
+ // get only first one
+ ClosedPeriodicEntryBook result = null;
+ if (!closedPeriodicEntryBooks.isEmpty()) {
+ result = closedPeriodicEntryBooks.get(0);
+ }
+ return result;
+ }
+
+ /**
+ * Retourne toutes les ClosedPeriodicEntryBook par interval de date
+ * sur les periodes sur lequelles elles portent ordonnée par journal.
+ *
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return all ClosedPeriodicEntryBook between begin and end
+ * @throws TopiaException
+ */
+ public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate,
+ Date endDate) throws TopiaException {
+
+ String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
+ " WHERE :begindate <= financialPeriod.beginDate " +
+ " AND financialPeriod.beginDate <= :endDate" +
+ " ORDER BY entryBook.code";
+ return context.find(query, 0d, 0d, "beginDate", beginDate, "endDate", endDate);
+ }
+
+}
Deleted: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -1,97 +0,0 @@
-/*
- * #%L
- * Lima callao
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.entity;
-
-import java.util.Date;
-import java.util.List;
-
-import org.nuiton.topia.TopiaException;
-
-public class EntryDAO extends EntryDAOImpl<Entry> {
-
- /**
- * Requete generique qui recupere les entrees equilibrées portant sur un
- * compte entre deux dates.
- *
- * @param account account
- * @param beginDate begin date
- * @param endDate end date
- */
- protected String getEquilibredTransactionQuery(Account account,
- Date beginDate, Date endDate) {
- 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)" +
- // entre les 2 dates
- " AND :beginDate <= E.financialTransaction.transactionDate" +
- " AND E.financialTransaction.transactionDate <= :endDate" +
- // concerne le compte
- " AND E.account = :account";
- return query;
- }
-
- /**
- * Query for find entries for accountsreports and balancereports
- * Just exact and balanced transaction are calculated.
- *
- * @param account account
- * @param beginDate begin date
- * @param endDate end date
- * @return entries
- * @throws TopiaException
- */
- public List<Entry> findAllEntryOfEquilibredTransaction(Account account,
- Date beginDate, Date endDate) throws TopiaException {
-
- String query = getEquilibredTransactionQuery(account, beginDate, endDate);
-
- List<Entry> entries = context.find(query, "beginDate", beginDate,
- "endDate", endDate, "account", account);
- return entries;
- }
-
- /**
- * Retourne la somme des entrées des transaction equilibrées entre
- * deux dates pour un compte donné.
- *
- * @param account le compte
- * @param beginDate bebin date
- * @param endDate end date
- * @return list boolean,int (une ligne pour le debit true, une ligne pour le credit)
- * @throws TopiaException
- */
- public List<Object[]> getDebitCreditOfEquilibredTransaction(Account account,
- Date beginDate, Date endDate) throws TopiaException {
- String query = "SELECT E.debit, sum(E.amount) " +
- getEquilibredTransactionQuery(account, beginDate, endDate) +
- " GROUP BY E.debit";
-
- List<Object[]> result = context.find(query, "beginDate", beginDate,
- "endDate", endDate, "account", account);
- return result;
- }
-}
Copied: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java (from rev 3400, trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java)
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -0,0 +1,97 @@
+/*
+ * #%L
+ * Lima callao
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import org.nuiton.topia.TopiaException;
+
+public class EntryDAOImpl<E extends Entry> extends EntryDAOAbstract<Entry> {
+
+ /**
+ * Requete generique qui recupere les entrees equilibrées portant sur un
+ * compte entre deux dates.
+ *
+ * @param account account
+ * @param beginDate begin date
+ * @param endDate end date
+ */
+ protected String getEquilibredTransactionQuery(Account account,
+ Date beginDate, Date endDate) {
+ 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)" +
+ // entre les 2 dates
+ " AND :beginDate <= E.financialTransaction.transactionDate" +
+ " AND E.financialTransaction.transactionDate <= :endDate" +
+ // concerne le compte
+ " AND E.account = :account";
+ return query;
+ }
+
+ /**
+ * Query for find entries for accountsreports and balancereports
+ * Just exact and balanced transaction are calculated.
+ *
+ * @param account account
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return entries
+ * @throws TopiaException
+ */
+ public List<Entry> findAllEntryOfEquilibredTransaction(Account account,
+ Date beginDate, Date endDate) throws TopiaException {
+
+ String query = getEquilibredTransactionQuery(account, beginDate, endDate);
+
+ List<Entry> entries = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "account", account);
+ return entries;
+ }
+
+ /**
+ * Retourne la somme des entrées des transaction equilibrées entre
+ * deux dates pour un compte donné.
+ *
+ * @param account le compte
+ * @param beginDate bebin date
+ * @param endDate end date
+ * @return list boolean,int (une ligne pour le debit true, une ligne pour le credit)
+ * @throws TopiaException
+ */
+ public List<Object[]> getDebitCreditOfEquilibredTransaction(Account account,
+ Date beginDate, Date endDate) throws TopiaException {
+ String query = "SELECT E.debit, sum(E.amount) " +
+ getEquilibredTransactionQuery(account, beginDate, endDate) +
+ " GROUP BY E.debit";
+
+ List<Object[]> result = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "account", account);
+ return result;
+ }
+}
Deleted: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -1,58 +0,0 @@
-/*
- * #%L
- * Lima callao
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.entity;
-
-import java.util.Date;
-import java.util.List;
-
-import org.nuiton.topia.TopiaException;
-
-public class FinancialPeriodDAO extends FinancialPeriodDAOImpl<FinancialPeriod> {
-
- /**
- * Return FinancialPeriod by Date.
- * Date is include between financialperiod begin and end date.
- *
- * @param date period middle date
- * @return FinancialPeriod for {@code date}
- * @throws TopiaException
- */
- public FinancialPeriod findByDate(Date date) throws TopiaException {
-
- String query = "FROM " + FinancialPeriod.class.getName() +
- " WHERE beginDate <= :date" +
- " AND :date <= endDate";
-
- // add unique result here
- List<FinancialPeriod> financialPeriod = context.find(query, "date", date);
- FinancialPeriod result = null;
- if (!financialPeriod.isEmpty()) {
- result = financialPeriod.get(0);
- }
- return result;
- }
-
-}
Copied: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java (from rev 3400, trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java)
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -0,0 +1,58 @@
+/*
+ * #%L
+ * Lima callao
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import org.nuiton.topia.TopiaException;
+
+public class FinancialPeriodDAOImpl<E extends FinancialPeriod> extends FinancialPeriodDAOAbstract<FinancialPeriod> {
+
+ /**
+ * Return FinancialPeriod by Date.
+ * Date is include between financialperiod begin and end date.
+ *
+ * @param date period middle date
+ * @return FinancialPeriod for {@code date}
+ * @throws TopiaException
+ */
+ public FinancialPeriod findByDate(Date date) throws TopiaException {
+
+ String query = "FROM " + FinancialPeriod.class.getName() +
+ " WHERE beginDate <= :date" +
+ " AND :date <= endDate";
+
+ // add unique result here
+ List<FinancialPeriod> financialPeriod = context.find(query, "date", date);
+ FinancialPeriod result = null;
+ if (!financialPeriod.isEmpty()) {
+ result = financialPeriod.get(0);
+ }
+ return result;
+ }
+
+}
Deleted: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -1,118 +0,0 @@
-/*
- * #%L
- * Lima callao
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.entity;
-
-import java.util.List;
-
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-
-/**
- * Ajout de requetes specifiques aux financial transaction sur le DAO.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FinancialTransactionDAO extends FinancialTransactionDAOImpl<FinancialTransaction> {
-
- /**
- * Return how many transaction are found with specified entryBook.
- *
- * @param entryBook entry book
- * @return transaction referencing entry book
- * @throws TopiaException
- */
- public long getCountByEntryBook(EntryBook entryBook) throws TopiaException {
- String query = "SELECT count(*) FROM " + FinancialTransaction.class.getName() + " t WHERE t.entryBook = :entryBook";
- Number count = (Number)context.find(query, "entryBook", entryBook).get(0);
- return count.longValue();
- }
-
- /**
- * Find all unbalanced transactions.
- *
- * @param period period
- * @param entryBook entry book
- * @return unbalanced transactions
- * @throws TopiaException
- */
- public List<FinancialTransaction> getAllUnbalancedTransaction(FinancialPeriod period,
- EntryBook entryBook) throws TopiaException {
- TopiaQuery query = createQuery("E");
- query.addWhere("E.amountCredit != E.amountDebit")
- .addEquals(FinancialTransaction.PROPERTY_ENTRY_BOOK, entryBook)
- .addEquals(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD, period);
- List<FinancialTransaction> result = findAllByQuery(query);
- return result;
- }
-
- /**
- * Find all transaction where some field are not filled in.
- *
- * @param period period
- * @param entryBook entry book
- * @return unfilled transaction
- * @throws TopiaException
- */
- public List<FinancialTransaction> getAllUnfilledTransaction(FinancialPeriod period,
- EntryBook entryBook) throws TopiaException {
- TopiaQuery query = createQuery("T");
- query.addDistinct()
- .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
- .addFrom(FiscalPeriod.class, "F")
- .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
- .addWhere("T.amountCredit != T.amountDebit OR E.account = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''")
- .addEquals(FinancialTransaction.PROPERTY_ENTRY_BOOK, entryBook)
- .addEquals(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD, period);
- List<FinancialTransaction> result = findAllByQuery(query);
- return result;
- }
-
- /**
- * Find all transaction without entry book.
- *
- * TODO echatellier 20120425 same method as getAllUnfilledTransaction ?
- * doesn't concern a period ?
- *
- * @return
- * @throws TopiaException
- */
- public List<FinancialTransaction> getAllTransactionWithoutEntryBook() throws TopiaException {
- TopiaQuery query = createQuery("T");
- query.addDistinct()
- .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
- .addFrom(FiscalPeriod.class, "F")
- .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
- .addWhere("T.amountCredit != T.amountDebit OR E.account = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''")
- .addNull(FinancialTransaction.PROPERTY_ENTRY_BOOK);
- List<FinancialTransaction> result = findAllByQuery(query);
- return result;
- }
-
-} //FinancialTransactionDAO
Copied: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java (from rev 3397, trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java)
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-05-04 13:17:42 UTC (rev 3401)
@@ -0,0 +1,118 @@
+/*
+ * #%L
+ * Lima callao
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.entity;
+
+import java.util.List;
+
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+
+/**
+ * Ajout de requetes specifiques aux financial transaction sur le DAO.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionDAOImpl<E extends FinancialTransaction> extends FinancialTransactionDAOAbstract<FinancialTransaction> {
+
+ /**
+ * Return how many transaction are found with specified entryBook.
+ *
+ * @param entryBook entry book
+ * @return transaction referencing entry book
+ * @throws TopiaException
+ */
+ public long getCountByEntryBook(EntryBook entryBook) throws TopiaException {
+ String query = "SELECT count(*) FROM " + FinancialTransaction.class.getName() + " t WHERE t.entryBook = :entryBook";
+ Number count = (Number)context.find(query, "entryBook", entryBook).get(0);
+ return count.longValue();
+ }
+
+ /**
+ * Find all unbalanced transactions.
+ *
+ * @param period period
+ * @param entryBook entry book
+ * @return unbalanced transactions
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> getAllUnbalancedTransaction(FinancialPeriod period,
+ EntryBook entryBook) throws TopiaException {
+ TopiaQuery query = createQuery("E");
+ query.addWhere("E.amountCredit != E.amountDebit")
+ .addEquals(FinancialTransaction.PROPERTY_ENTRY_BOOK, entryBook)
+ .addEquals(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD, period);
+ List<FinancialTransaction> result = findAllByQuery(query);
+ return result;
+ }
+
+ /**
+ * Find all transaction where some field are not filled in.
+ *
+ * @param period period
+ * @param entryBook entry book
+ * @return unfilled transaction
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> getAllUnfilledTransaction(FinancialPeriod period,
+ EntryBook entryBook) throws TopiaException {
+ TopiaQuery query = createQuery("T");
+ query.addDistinct()
+ .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
+ .addFrom(FiscalPeriod.class, "F")
+ .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
+ .addWhere("T.amountCredit != T.amountDebit OR E.account = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''")
+ .addEquals(FinancialTransaction.PROPERTY_ENTRY_BOOK, entryBook)
+ .addEquals(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD, period);
+ List<FinancialTransaction> result = findAllByQuery(query);
+ return result;
+ }
+
+ /**
+ * Find all transaction without entry book.
+ *
+ * TODO echatellier 20120425 same method as getAllUnfilledTransaction ?
+ * doesn't concern a period ?
+ *
+ * @return
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> getAllTransactionWithoutEntryBook() throws TopiaException {
+ TopiaQuery query = createQuery("T");
+ query.addDistinct()
+ .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
+ .addFrom(FiscalPeriod.class, "F")
+ .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
+ .addWhere("T.amountCredit != T.amountDebit OR E.account = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''")
+ .addNull(FinancialTransaction.PROPERTY_ENTRY_BOOK);
+ List<FinancialTransaction> result = findAllByQuery(query);
+ return result;
+ }
+
+} //FinancialTransactionDAO
1
0
r3400 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity
by echatellier@users.chorem.org 04 May '12
by echatellier@users.chorem.org 04 May '12
04 May '12
Author: echatellier
Date: 2012-05-04 11:43:18 +0200 (Fri, 04 May 2012)
New Revision: 3400
Url: http://chorem.org/repositories/revision/lima/3400
Log:
Begin report service refactoring.
Move query to DAO.
Remove topia query.
Added:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportServiceLocal.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/ReportServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java
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 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -180,6 +180,24 @@
return accountsList;
}
+ /*
+ * @see org.chorem.lima.business.api.AccountService#getAllSubAccounts(org.chorem.lima.entity.Account)
+ */
+ @Override
+ public List<Account> getAllSubAccounts(Account account)
+ throws LimaException {
+ List<Account> accountsList = null;
+
+ try {
+ AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ accountsList = accountDAO.findAllSubAccounts(account);
+ } catch (Exception ex) {
+ throw new LimaException("Can't get all sub accounts", ex);
+ }
+
+ return accountsList;
+ }
+
/**
* Permet d'effacer un compte dans la base de données.
* <p/>
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-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -104,68 +104,60 @@
* - for subaccount
* - for a foldaccounts, contains many accounts
* - for a foldthirdparts accounts
+ * @throws TopiaException
*/
@Override
public ReportsDatas generateAccountReportsWithTransaction(Account account,
Boolean thirdPartAccountsMode,
Date beginDate,
Date endDate,
- TopiaContext topiaContext) throws LimaException {
+ TopiaContext topiaContext) throws LimaException, TopiaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
+
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
List<Entry> entries = new ArrayList<Entry>();
- if (account != null) {
- //Get allsubaccounts and thirdParts accounts
- List<Account> accounts = null; // FIXME review code (List<Account>) account.getSubAccounts();
- if (thirdPartAccountsMode) {
- List<Account> thirdPartAccount = null; // FIXME review code (List<Account>) account.getSubLedgers();
- if (thirdPartAccount != null) {
- ReportsDatas subReportsDatas = generateSubAccountReportsWithTransaction(account,
- beginDate, endDate, topiaContext);
+ //Get allsubaccounts and thirdParts accounts
+ List<Account> accounts = accountService.getAllSubAccounts(account);
- entries.addAll(subReportsDatas.getListEntry());
- debit = debit.add(subReportsDatas.getAmountDebit());
- credit = credit.add(subReportsDatas.getAmountCredit());
- accounts.addAll(thirdPartAccount);
- }
+ // 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 = generateSubAccountReportsWithTransaction(account,
+ beginDate, endDate, topiaContext);
+ }
+ // else is folder accounts contains many subs and thirds accounts
+ else {
+ for (Account subAccount : accounts) {
+ ReportsDatas subReportsDatas =
+ generateAccountReportsWithTransaction(subAccount, true,
+ beginDate, endDate, topiaContext);
+ 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);
- // is already subaccount
- if (accounts.size() == 0) {
- reportsDatas = generateSubAccountReportsWithTransaction(account,
- beginDate, endDate, topiaContext);
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
}
- // else is folder accounts contains many subs and thirds accounts
- else {
- for (Account subAccount : accounts) {
- ReportsDatas subReportsDatas =
- generateAccountReportsWithTransaction(subAccount, true,
- beginDate, endDate, topiaContext);
- 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 = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+ reportsDatas.setListEntry(entries);
}
+
return reportsDatas;
}
- /**
+ /*
* Query for find entries for accountsreports and balancereports
* Just exact and balanced transaction are calculated.
*
@@ -176,12 +168,12 @@
* @param queryAlias
* @return
* @throws LimaException
- */
+ *
protected TopiaQuery createEntryQuery(Account account,
Date beginDate,
Date endDate,
EntryDAO entryDAO,
- String queryAlias) throws LimaException {
+ String queryAlias) {
TopiaQuery query = entryDAO.createQuery(queryAlias);
String transactionDateProperty = TopiaQuery.getProperty(
@@ -190,8 +182,7 @@
Entry.PROPERTY_FINANCIAL_TRANSACTION, FinancialTransaction.PROPERTY_ENTRY_BOOK);
// echatellier, oui c'est hardcodé, mais qu'est ce que c'est illisible sans ca
- query
- .addWhere("(select sum(E2.amount) from " + Entry.class.getName() + " E2 where E2.debit = false and E2.financialTransaction = E.financialTransaction) = " +
+ query .addWhere("(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)")
.addWhere(transactionDateProperty + " BETWEEN :beginDate AND :endDate")
.addNotNull(entryBookProperty)
@@ -200,7 +191,7 @@
.addEquals(Entry.PROPERTY_ACCOUNT, account);
return query;
- }
+ }*/
/**
* Get list entries
@@ -212,68 +203,52 @@
* @param topiaContext
* @return
* @throws LimaException
+ * @throws TopiaException
*/
protected ReportsDatas generateSubAccountReportsWithTransaction(Account account,
Date beginDate,
Date endDate,
- TopiaContext topiaContext) throws LimaException {
+ TopiaContext topiaContext) throws TopiaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- List<Object[]> results;
- String queryAlias = "E";
- if (beginDate != null && endDate != null) {
- try {
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- TopiaQuery entriesQuery =
- createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- String loadEntryBookProperty =
- TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_ENTRY_BOOK);
- entriesQuery.addLoad(loadEntryBookProperty);
- reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery));
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- TopiaQuery amountsQuery =
- createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- amountsQuery.setSelect("E." + Entry.PROPERTY_DEBIT, "SUM(E." + Entry.PROPERTY_AMOUNT + ")");
- amountsQuery.addGroup("E." + Entry.PROPERTY_DEBIT);
- results = amountsQuery.execute(topiaContext);
- int nbAmount = results.size();
- if (nbAmount == 2) {
- debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
- }
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
- debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
- }
- }
+ // trouve les entrees associées à ca compte entre les date données
+ List<Entry> listEntries = entryDAO.findAllEntryOfEquilibredTransaction(account, beginDate, endDate);
+ reportsDatas.setListEntry(listEntries);
- // set the amounts and solde
- //solde = debit - credit
- solde = solde.add(debit);
- solde = solde.subtract(credit);
+ // recupere les totaux pour le compte
+ List<Object[]> results = entryDAO.getDebitCreditOfEquilibredTransaction(account, beginDate, endDate);
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
+ }
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
+ debit = (BigDecimal) results.get(0)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
+ }
+ }
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
- }
- solde = solde.abs();
+ // set the amounts and solde
+ // solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
-
- //commitTransaction(topiaContext);
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
- }
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
}
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
return reportsDatas;
}
@@ -281,75 +256,68 @@
* Calculate all credit, debit and solde amounts for the balance
* <p/>
* Get all entries if true
+ * @throws TopiaException
*/
public ReportsDatas generateSubAccountBalanceWithTransaction(Account account,
Date beginDate,
Date endDate,
Boolean getEntries,
- TopiaContext topiaContext) throws LimaException {
+ TopiaContext topiaContext) throws LimaException, TopiaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
+ //String queryAlias = "E";
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- List<Object[]> results;
- String queryAlias = "E";
- if (beginDate != null && endDate != null) {
- try {
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ if (getEntries) {
+ //TopiaQuery entriesQuery =
+ // createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ //entriesQuery.addLoad(Entry.PROPERTY_FINANCIAL_TRANSACTION);
+ //String loadEntryBookProperty =
+ // TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
+ // FinancialTransaction.PROPERTY_ENTRY_BOOK);
+ //entriesQuery.addLoad(loadEntryBookProperty);
+ List<Entry> listEntries = entryDAO.findAllEntryOfEquilibredTransaction(account, beginDate, endDate);
+ reportsDatas.setListEntry(listEntries);
+ }
- if (getEntries) {
- TopiaQuery entriesQuery =
- createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- entriesQuery.addLoad(Entry.PROPERTY_FINANCIAL_TRANSACTION);
- String loadEntryBookProperty =
- TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_ENTRY_BOOK);
- entriesQuery.addLoad(loadEntryBookProperty);
- reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery));
- }
+ //TopiaQuery amountsQuery =
+ // createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ //amountsQuery.setSelect("E." + Entry.PROPERTY_DEBIT, "SUM(E." + Entry.PROPERTY_AMOUNT + ")");
+ //amountsQuery.addGroup("E." + Entry.PROPERTY_DEBIT);
+ //results = amountsQuery.execute(topiaContext);
+ List<Object[]> results = entryDAO.getDebitCreditOfEquilibredTransaction(account, beginDate, endDate);
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
+ }
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
+ debit = (BigDecimal) results.get(0)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
+ }
+ }
- TopiaQuery amountsQuery =
- createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- amountsQuery.setSelect("E." + Entry.PROPERTY_DEBIT, "SUM(E." + Entry.PROPERTY_AMOUNT + ")");
- amountsQuery.addGroup("E." + Entry.PROPERTY_DEBIT);
- results = amountsQuery.execute(topiaContext);
- int nbAmount = results.size();
- if (nbAmount == 2) {
- debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
- }
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
- debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
- }
- }
+ // set the amounts and solde
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
- // set the amounts and solde
- //solde = debit - credit
- solde = solde.add(debit);
- solde = solde.subtract(credit);
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
-
- }
- solde = solde.abs();
-
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
-
- //commitTransaction(topiaContext);
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
- }
}
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
return reportsDatas;
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -176,6 +176,22 @@
}
/**
+ * Test get all subaccounts.
+ *
+ * @throws LimaException
+ */
+ @Test
+ public void getAllSubAccountsTest() throws LimaException {
+ Account parent = accountService.getAccountByNumber("50");
+ List<Account> listAccount = accountService.getAllSubAccounts(parent);
+ Assert.assertEquals(2, listAccount.size());
+
+ parent = accountService.getAccountByNumber("501");
+ listAccount = accountService.getAllSubAccounts(parent);
+ Assert.assertEquals(0, listAccount.size());
+ }
+
+ /**
* Permet de tester si un compte est bien effacé.
*
* @throws LimaException
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -75,6 +75,15 @@
List<Account> getAllLeafAccounts() throws LimaException;
/**
+ * Return all {@code account}-s subaccounts.
+ *
+ * @param account account to get sub accounts
+ * @return sub accounts
+ * @throws LimaException
+ */
+ List<Account> getAllSubAccounts(Account account) throws LimaException;
+
+ /**
* Create new account. If {@code masterAccount} is not null, {@code account}
* is added in {@code masterAccount}'s subAccounts.
*
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -103,27 +103,7 @@
Date beginDate,
Date endDate) throws LimaException;
-
/**
- * Calculate all credit, debit and solde amounts for the balance.
- * <p/>
- * Get all entries if true
- *
- * @param account
- * @param beginDate
- * @param endDate
- * @param getEntries
- * @param topiaContext
- * @return
- * @throws LimaException
- */
- ReportsDatas generateSubAccountBalanceWithTransaction(Account account,
- Date beginDate,
- Date endDate,
- Boolean getEntries,
- TopiaContext topiaContext) throws LimaException;
-
- /**
* Generation du rapports des journaux.
*
* @param entryBook
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportServiceLocal.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportServiceLocal.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -29,6 +29,7 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
import java.util.Date;
@@ -55,6 +56,24 @@
Boolean thirdPartAccountsMode,
Date beginDate,
Date endDate,
- TopiaContext topiaContext) throws LimaException;
+ TopiaContext topiaContext) throws LimaException, TopiaException;
+ /**
+ * Calculate all credit, debit and solde amounts for the balance.
+ * <p/>
+ * Get all entries if true
+ *
+ * @param account
+ * @param beginDate
+ * @param endDate
+ * @param getEntries
+ * @param topiaContext
+ * @return
+ * @throws LimaException
+ */
+ ReportsDatas generateSubAccountBalanceWithTransaction(Account account,
+ Date beginDate,
+ Date endDate,
+ Boolean getEntries,
+ TopiaContext topiaContext) throws LimaException, TopiaException;
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -33,16 +33,15 @@
import java.util.StringTokenizer;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
-public class AccountDAO extends AccountDAOAbstract<Account> {
+public class AccountDAO extends AccountDAOImpl<Account> {
- private static final Log log = LogFactory.getLog(AccountDAO.class);
-
/**
* Retourne tous les comptes qui n'ont pas eux meme de sous compte.
+ *
+ * @return leaf accounts
+ * @throws TopiaException
*/
public List<Account> findAllLeafAccounts() throws TopiaException {
// FIXME echatellier 20120413 la requete ne fonctionne pas
@@ -94,6 +93,21 @@
}
/**
+ * Retourne tous les comptes dont le numero commence par celui specifié.
+ *
+ * @param account parent account
+ * @return
+ * @throws TopiaException
+ */
+ public List<Account> findAllSubAccounts(Account account) throws TopiaException {
+
+ String query = "FROM " + Account.class.getName() + " a WHERE a.accountNumber LIKE concat(:accountNumber, '_%')";
+ List<Account> accounts = context.find(query, "accountNumber", account.getAccountNumber());
+
+ return accounts;
+ }
+
+ /**
* @deprecated since 0.6, business method, need to be moved out of dao
*/
@Deprecated
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -28,16 +28,10 @@
import java.util.Date;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
public class ClosedPeriodicEntryBookDAO extends ClosedPeriodicEntryBookDAOImpl<ClosedPeriodicEntryBook> {
- private static final Log log = LogFactory.getLog(ClosedPeriodicEntryBookDAO.class);
-
/**
* Find all ClosedPeriodicEntryBook with common EntryBook.
*
@@ -49,33 +43,64 @@
return findAllByProperties(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook);
}
- /** Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod */
+ /**
+ * Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod.
+ *
+ * @param entryBook
+ * @param financialPeriod
+ * @return ClosedPeriodicEntryBook
+ * @throws TopiaException
+ */
public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod(
EntryBook entryBook, FinancialPeriod financialPeriod)
throws TopiaException {
- TopiaQuery query = createQuery();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks;
+ String query = "FROM " + ClosedPeriodicEntryBook.class.getName();
if (entryBook != null) {
- query.addEquals(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook);
+ query += " WHERE entryBook = :entryBook";
+ if (financialPeriod != null) {
+ query += " AND financialPeriod = :financialPeriod";
+ //context.find(query, 0, 0, "entryBook", entryBook, "financialPeriod", financialPeriod);
+ closedPeriodicEntryBooks = context.find(query, "entryBook", entryBook, "financialPeriod", financialPeriod);
+ } else {
+ //context.find(query, 0, 0, "entryBook", entryBook);
+ closedPeriodicEntryBooks = context.find(query, "entryBook", entryBook);
+ }
+ } else {
+ if (financialPeriod != null) {
+ query += " WHERE financialPeriod = :financialPeriod";
+ }
+
+ //context.find(query, 0, 0, "financialPeriod", financialPeriod);
+ closedPeriodicEntryBooks = context.find(query, "financialPeriod", financialPeriod);
}
- if (financialPeriod != null) {
- query.addEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod);
+
+ // get only first one
+ ClosedPeriodicEntryBook result = null;
+ if (!closedPeriodicEntryBooks.isEmpty()) {
+ result = closedPeriodicEntryBooks.get(0);
}
- return findByQuery(query);
+ return result;
}
+ /**
+ * Retourne toutes les ClosedPeriodicEntryBook par interval de date
+ * sur les periodes sur lequelles elles portent ordonnée par journal.
+ *
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return all ClosedPeriodicEntryBook between begin and end
+ * @throws TopiaException
+ */
public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate,
Date endDate) throws TopiaException {
- TopiaQuery query = createQuery();
- if (beginDate != null && endDate != null) {
- String beginDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, FinancialPeriod.PROPERTY_BEGIN_DATE);
- String endDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, FinancialPeriod.PROPERTY_BEGIN_DATE);
- String entrybookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, EntryBook.PROPERTY_CODE);
- query.addWhere(beginDateProperty, Op.GE, beginDate)
- .addWhere(endDateProperty, Op.LE, endDate)
- .addOrder(beginDateProperty, entrybookProperty);
- }
- return (List<ClosedPeriodicEntryBook>) findAllByQuery(query);
+
+ String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
+ " WHERE :begindate <= financialPeriod.beginDate " +
+ " AND financialPeriod.beginDate <= :endDate" +
+ " ORDER BY entryBook.code";
+ return context.find(query, 0d, 0d, "beginDate", beginDate, "endDate", endDate);
}
}
Added: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -0,0 +1,97 @@
+/*
+ * #%L
+ * Lima callao
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import org.nuiton.topia.TopiaException;
+
+public class EntryDAO extends EntryDAOImpl<Entry> {
+
+ /**
+ * Requete generique qui recupere les entrees equilibrées portant sur un
+ * compte entre deux dates.
+ *
+ * @param account account
+ * @param beginDate begin date
+ * @param endDate end date
+ */
+ protected String getEquilibredTransactionQuery(Account account,
+ Date beginDate, Date endDate) {
+ 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)" +
+ // entre les 2 dates
+ " AND :beginDate <= E.financialTransaction.transactionDate" +
+ " AND E.financialTransaction.transactionDate <= :endDate" +
+ // concerne le compte
+ " AND E.account = :account";
+ return query;
+ }
+
+ /**
+ * Query for find entries for accountsreports and balancereports
+ * Just exact and balanced transaction are calculated.
+ *
+ * @param account account
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return entries
+ * @throws TopiaException
+ */
+ public List<Entry> findAllEntryOfEquilibredTransaction(Account account,
+ Date beginDate, Date endDate) throws TopiaException {
+
+ String query = getEquilibredTransactionQuery(account, beginDate, endDate);
+
+ List<Entry> entries = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "account", account);
+ return entries;
+ }
+
+ /**
+ * Retourne la somme des entrées des transaction equilibrées entre
+ * deux dates pour un compte donné.
+ *
+ * @param account le compte
+ * @param beginDate bebin date
+ * @param endDate end date
+ * @return list boolean,int (une ligne pour le debit true, une ligne pour le credit)
+ * @throws TopiaException
+ */
+ public List<Object[]> getDebitCreditOfEquilibredTransaction(Account account,
+ Date beginDate, Date endDate) throws TopiaException {
+ String query = "SELECT E.debit, sum(E.amount) " +
+ getEquilibredTransactionQuery(account, beginDate, endDate) +
+ " GROUP BY E.debit";
+
+ List<Object[]> result = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "account", account);
+ return result;
+ }
+}
Property changes on: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAO.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAO.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,26 +25,34 @@
package org.chorem.lima.entity;
+import java.util.Date;
+import java.util.List;
+
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-import java.util.Date;
-
public class FinancialPeriodDAO extends FinancialPeriodDAOImpl<FinancialPeriod> {
/**
- * Return FinancialPeriod by Date
- * Date is include between financialperiod begin and end date
+ * Return FinancialPeriod by Date.
+ * Date is include between financialperiod begin and end date.
+ *
+ * @param date period middle date
+ * @return FinancialPeriod for {@code date}
+ * @throws TopiaException
*/
public FinancialPeriod findByDate(Date date) throws TopiaException {
- TopiaQuery query = createQuery();
- if (date != null) {
- query.addWhere(FinancialPeriod.PROPERTY_BEGIN_DATE + " <= :value")
- .addWhere(FinancialPeriod.PROPERTY_END_DATE + " >= :value")
- .addParam("value", date);
+ String query = "FROM " + FinancialPeriod.class.getName() +
+ " WHERE beginDate <= :date" +
+ " AND :date <= endDate";
+
+ // add unique result here
+ List<FinancialPeriod> financialPeriod = context.find(query, "date", date);
+ FinancialPeriod result = null;
+ if (!financialPeriod.isEmpty()) {
+ result = financialPeriod.get(0);
}
- return findByQuery(query);
+ return result;
}
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java 2012-05-04 09:42:31 UTC (rev 3399)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java 2012-05-04 09:43:18 UTC (rev 3400)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
1
0
Author: echatellier
Date: 2012-05-04 11:42:31 +0200 (Fri, 04 May 2012)
New Revision: 3399
Url: http://chorem.org/repositories/revision/lima/3399
Log:
Remove openejb default sjf4j impl
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-02 12:33:54 UTC (rev 3398)
+++ trunk/pom.xml 2012-05-04 09:42:31 UTC (rev 3399)
@@ -118,6 +118,12 @@
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
<version>${openEjbVersion}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>slf4j-jdk14</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
<scope>compile</scope>
</dependency>
1
0
Author: echatellier
Date: 2012-05-02 14:33:54 +0200 (Wed, 02 May 2012)
New Revision: 3398
Url: http://chorem.org/repositories/revision/lima/3398
Log:
Udpate h2, openejb and jdom
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-04-25 12:49:56 UTC (rev 3397)
+++ trunk/pom.xml 2012-05-02 12:33:54 UTC (rev 3398)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.2</version>
+ <version>3.3.1</version>
</parent>
<groupId>org.chorem</groupId>
@@ -166,7 +166,7 @@
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
- <version>2.0.0</version>
+ <version>2.0.1</version>
<scope>compile</scope>
</dependency>
@@ -202,7 +202,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
- <version>8.1.2.v20120308</version>
+ <version>8.1.3.v20120416</version>
</dependency>
<!-- pdfbox to create pdf document -->
@@ -317,7 +317,7 @@
<topiaVersion>2.6.9</topiaVersion>
<jaxxVersion>2.5-SNAPSHOT</jaxxVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
- <openEjbVersion>4.0.0-beta-2</openEjbVersion>
+ <openEjbVersion>4.0.0</openEjbVersion>
<slf4jVersion>1.6.4</slf4jVersion>
<!-- license to use -->
1
0