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
Author: echatellier
Date: 2012-05-15 10:09:23 +0200 (Tue, 15 May 2012)
New Revision: 3414
Url: http://chorem.org/repositories/revision/lima/3414
Log:
Update topia and nuiton-util
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-14 16:00:59 UTC (rev 3413)
+++ trunk/pom.xml 2012-05-15 08:09:23 UTC (rev 3414)
@@ -318,9 +318,9 @@
<projectId>lima</projectId>
<!-- customized libs version -->
- <nuitonUtilsVersion>2.4.7</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.4.8</nuitonUtilsVersion>
<eugenePluginVersion>2.4.2</eugenePluginVersion>
- <topiaVersion>2.6.9</topiaVersion>
+ <topiaVersion>2.6.10</topiaVersion>
<jaxxVersion>2.5-SNAPSHOT</jaxxVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<openEjbVersion>4.0.0</openEjbVersion>
1
0
r3413 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business/src/test/java/org/chorem/lima/entity lima-callao/src/main/java/org/chorem/lima/entity
by echatellier@users.chorem.org 14 May '12
by echatellier@users.chorem.org 14 May '12
14 May '12
Author: echatellier
Date: 2012-05-14 18:00:59 +0200 (Mon, 14 May 2012)
New Revision: 3413
Url: http://chorem.org/repositories/revision/lima/3413
Log:
Fix all tests
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.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-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -203,19 +203,23 @@
try {
FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
+ // reload object in current transaction
+ closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findByTopiaId(closedPeriodicEntryBook.getTopiaId());
// 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());
+ FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod();
+ List<FinancialTransaction> result = financialTransactionDAO.getAllUnbalancedTransaction(period.getBeginDate(),
+ period.getEndDate(), closedPeriodicEntryBook.getEntryBook());
if (result.size() > 0) {
throw new LimaBusinessException(_("lima-business.defaultaccountingrules.blockerrorequillibrate"));
}
// Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
- result = financialTransactionDAO.getAllUnfilledTransaction(closedPeriodicEntryBook.getFinancialPeriod(),
- closedPeriodicEntryBook.getEntryBook());
+ result = financialTransactionDAO.getAllUnfilledTransaction(period.getBeginDate(),
+ period.getEndDate(), closedPeriodicEntryBook.getEntryBook());
// FIMXE echatellier 20120504 unutile de recuperer une liste
// entiere juste pour tester l'existence
if (result.size() > 0) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-05-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -142,10 +142,12 @@
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ // check rule
+ accountingRules.removeEntryBookRules(entryBook);
+
try {
- // check rule
- accountingRules.removeEntryBookRules(entryBook);
+
// delete all ClosedPeriodicEntryBook from this EntryBook
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -182,12 +182,13 @@
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
getDaoHelper().getClosedPeriodicEntryBookDAO();
- //ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
- // closedPeriodicEntryBookDAO.findByTopiaId(
- // closedPeriodicEntryBook.getTopiaId());
+ // reload object in current transaction
+ ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
+ closedPeriodicEntryBookDAO.findByTopiaId(
+ closedPeriodicEntryBook.getTopiaId());
- closedPeriodicEntryBook.setLocked(true);
- closedPeriodicEntryBookDAO.update(closedPeriodicEntryBook);
+ closedPeriodicEntryBook2.setLocked(true);
+ closedPeriodicEntryBookDAO.update(closedPeriodicEntryBook2);
} catch (TopiaException ex) {
throw new LimaException("Can't block period", ex);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -162,14 +162,14 @@
public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException {
List<FinancialTransaction> result = null;
- List<FinancialTransaction> checkedResult = new ArrayList<FinancialTransaction>();
+ //List<FinancialTransaction> checkedResult = new ArrayList<FinancialTransaction>();
try {
FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
result = financialTransactionDAO.getAllIncorrectTransaction(fiscalPeriod.getBeginDate(),
fiscalPeriod.getEndDate(), null);
- for (FinancialTransaction fTransaction : result) {
+ /*for (FinancialTransaction fTransaction : result) {
BigDecimal credit = fTransaction.getAmountCredit();
BigDecimal debit = fTransaction.getAmountDebit();
credit = credit.setScale(optionsService.getScale(),
@@ -179,7 +179,7 @@
if (credit.equals(debit)) {
checkedResult.add(fTransaction);
}
- }
+ }*/
} catch (Exception ex) {
throw new LimaException("Can't get financial transactions", ex);
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2012-05-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -148,7 +148,7 @@
String pcg = IOUtils.toString(ImportServiceImplTest.class.getResourceAsStream("/import/pcg_base.csv"));
importService.importAsCSV(pcg, ImportExportEntityEnum.ACCOUNT);
- Assert.assertEquals(460, accountService.getAccountCount());
+ Assert.assertEquals(461, accountService.getAccountCount());
}
/**
Modified: trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2012-05-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -65,7 +65,8 @@
TopiaContext tx = getTestContext().beginTransaction();
FinancialTransactionDAO ftDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(tx);
- List<FinancialTransaction> fTransactions = ftDAO.getAllUnbalancedTransaction(financialPeriod, journalDesVentes);
+ List<FinancialTransaction> fTransactions = ftDAO.getAllUnbalancedTransaction(financialPeriod.getBeginDate(),
+ financialPeriod.getEndDate(), journalDesVentes);
Assert.assertNotNull(fTransactions);
}
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-05-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -28,11 +28,26 @@
import java.util.Date;
import java.util.List;
+import org.hibernate.HibernateException;
import org.nuiton.topia.TopiaException;
public class ClosedPeriodicEntryBookDAOImpl<E extends ClosedPeriodicEntryBook> extends ClosedPeriodicEntryBookDAOAbstract<ClosedPeriodicEntryBook> {
/**
+ * FIXME echatellier, remove this method when implemented in topia
+ * just overriden to use merge() instead of saveOrUpdate()
+ */
+ public ClosedPeriodicEntryBook merge(ClosedPeriodicEntryBook e) throws TopiaException {
+ try {
+ e = (ClosedPeriodicEntryBook)getContext().getHibernate().merge(e);
+ getContext().getFiresSupport().warnOnUpdateEntity(e);
+ return e;
+ } catch (HibernateException ex) {
+ throw new TopiaException(ex);
+ }
+ }
+
+ /**
* Find all ClosedPeriodicEntryBook with common EntryBook.
*
* @param entryBook entry book property
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-14 10:38:31 UTC (rev 3412)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-05-14 16:00:59 UTC (rev 3413)
@@ -91,29 +91,6 @@
beginDate, "endDate", endDate, "entryBook", entryBook);
return result;
}
-
- /**
- * Find all unbalanced transactions.
- *
- * @param financialPeriod period
- * @param entryBook entry book
- * @return unbalanced transactions
- * @throws TopiaException
- */
- @Deprecated
- public List<FinancialTransaction> getAllUnbalancedTransaction(FinancialPeriod financialPeriod,
- EntryBook entryBook) throws TopiaException {
- 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 unbalanced transactions.
@@ -184,12 +161,16 @@
*/
public List<FinancialTransaction> getAllIncorrectTransaction(Date beginDate, Date endDate,
EntryBook entryBook) throws TopiaException {
- String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ String query = "SELECT T 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 (SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = true AND financialTransaction = T) IS NULL" +
+ " OR (SELECT sum(amount) FROM " + Entry.class.getName() +
+ " WHERE debit = false AND financialTransaction = T) IS NULL" +
" OR E.account = null" +
" OR E.voucher = null" +
" OR E.voucher = ''" +
@@ -211,25 +192,26 @@
/**
* Find all transaction where some field are not filled in.
*
- * @param financialPeriod period
+ * @param beginDate begin date
+ * @param endDate end date
* @param entryBook entry book
* @return unfilled transaction
* @throws TopiaException
*/
- @Deprecated
- public List<FinancialTransaction> getAllUnfilledTransaction(FinancialPeriod financialPeriod,
- EntryBook entryBook) throws TopiaException {
- String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ public List<FinancialTransaction> getAllUnfilledTransaction(Date beginDate,
+ Date endDate, EntryBook entryBook) throws TopiaException {
+ String query = "SELECT T 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" +
+ " 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);
+ " AND :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate";
+ List<FinancialTransaction> result = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "entryBook", entryBook);
return result;
}
@@ -243,12 +225,12 @@
*/
public List<FinancialTransaction> getAllTransactionWithoutEntryBook() throws TopiaException {
- String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ String query = "SELECT T 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" +
+ " 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 ?
1
0
r3412 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business/accountingrules lima-callao/src/main/java/org/chorem/lima/entity
by echatellier@users.chorem.org 14 May '12
by echatellier@users.chorem.org 14 May '12
14 May '12
Author: echatellier
Date: 2012-05-14 12:38:31 +0200 (Mon, 14 May 2012)
New Revision: 3412
Url: http://chorem.org/repositories/revision/lima/3412
Log:
Redefine DAO to use merge instead of saveOrUpdate
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-11 15:23:45 UTC (rev 3411)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-14 10:38:31 UTC (rev 3412)
@@ -36,7 +36,6 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
@@ -118,7 +117,7 @@
FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
//Checks if is not the first fiscalperiod to create
- if (fiscalPeriodDAO.findAll().size() != 0) {
+ if (fiscalPeriodDAO.count() != 0) {
TopiaQuery query = fiscalPeriodDAO.createQuery();
query.addOrderDesc(FiscalPeriod.PROPERTY_END_DATE);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-11 15:23:45 UTC (rev 3411)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-14 10:38:31 UTC (rev 3412)
@@ -83,7 +83,7 @@
//create financial period
financialPeriod = financialPeriodDAO.create(financialPeriod);
-
+
//create ClosedPeriodicEntryBook for all entrybook
for (EntryBook entryBook : entryBookDAO.findAll()) {
//new closed periodic entrybook
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-11 15:23:45 UTC (rev 3411)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-14 10:38:31 UTC (rev 3412)
@@ -67,7 +67,6 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaContextImpl;
import org.nuiton.topia.framework.TopiaQuery;
/**
@@ -98,21 +97,21 @@
@Override
public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
-
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+
FiscalPeriod result = null;
try {
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
+ // fix begin date at midnight and end date at 23:59:59.999
Date beginDate = fiscalPeriod.getBeginDate();
beginDate = DateUtils.truncate(beginDate, Calendar.DATE);
Date endDate = fiscalPeriod.getEndDate();
endDate = DateUtils.addDays(endDate, 1);
endDate = DateUtils.truncate(endDate, Calendar.DATE);
endDate = DateUtils.addMilliseconds(endDate, -1);
-
fiscalPeriod.setBeginDate(beginDate);
fiscalPeriod.setEndDate(endDate);
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2012-05-11 15:23:45 UTC (rev 3411)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2012-05-14 10:38:31 UTC (rev 3412)
@@ -30,9 +30,7 @@
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.junit.Ignore;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
@@ -73,7 +71,7 @@
FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
//Checks if is not the first fiscalperiod to create
- if (fiscalPeriodDAO.findAll().size() != 0) {
+ if (fiscalPeriodDAO.count() != 0) {
TopiaQuery query = fiscalPeriodDAO.createQuery();
query.addOrderDesc(FiscalPeriod.PROPERTY_END_DATE);
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-05-11 15:23:45 UTC (rev 3411)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-05-14 10:38:31 UTC (rev 3412)
@@ -27,6 +27,7 @@
import java.util.List;
+import org.hibernate.HibernateException;
import org.nuiton.topia.TopiaException;
/**
@@ -41,6 +42,21 @@
public class FiscalPeriodDAOImpl <E extends FiscalPeriod> extends FiscalPeriodDAOAbstract<FiscalPeriod> {
/**
+ * FIXME echatellier, remove this method when implemented in topia
+ * just overriden to use merge() instead of saveOrUpdate()
+ */
+ @Override
+ public FiscalPeriod update(FiscalPeriod e) throws TopiaException {
+ try {
+ getContext().getHibernate().merge(e);
+ getContext().getFiresSupport().warnOnUpdateEntity(e);
+ return e;
+ } catch (HibernateException ex) {
+ throw new TopiaException(ex);
+ }
+ }
+
+ /**
* Find fiscal period by financial period.
*
* @param financialPeriod financial period
@@ -49,7 +65,7 @@
*/
public FiscalPeriod findByFinancialPeriod(FinancialPeriod financialPeriod) throws TopiaException {
String query = "FROM " + FiscalPeriod.class.getName() +
- "WHERE :financialPeriod in elements(financialPeriod)";
+ " WHERE :financialPeriod in elements(financialPeriod)";
List<FiscalPeriod> fiscalPeriods = context.find(query, "financialPeriod", financialPeriod);
FiscalPeriod result = null;
1
0
r3411 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business/accountingrules lima-business-api/src/main/java/org/chorem/lima/business/api
by echatellier@users.chorem.org 11 May '12
by echatellier@users.chorem.org 11 May '12
11 May '12
Author: echatellier
Date: 2012-05-11 17:23:45 +0200 (Fri, 11 May 2012)
New Revision: 3411
Url: http://chorem.org/repositories/revision/lima/3411
Log:
Fix hibernate exception : ids for this class must be manually assigned before calling save(): org.chorem.lima.entity.FinancialPeriodImpl
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-11 10:26:46 UTC (rev 3410)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-11 15:23:45 UTC (rev 3411)
@@ -36,6 +36,7 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
@@ -160,9 +161,8 @@
financialPeriod.setEndDate(loopDate);
}
//create it
- fiscalPeriod.addFinancialPeriod(financialPeriod);
financialPeriods.add(financialPeriod);
- //financialPeriodService.createFinancialPeriodWithTransaction(financialPeriod, transaction);
+
//loop incremente
loopDate = DateUtils.addMilliseconds(loopDate, 1);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-11 15:23:45 UTC (rev 3411)
@@ -25,6 +25,15 @@
package org.chorem.lima.business.ejb;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
@@ -40,14 +49,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import java.util.Date;
-import java.util.List;
-
-
/**
* Gestion des périodes intermédiaires durant l'exercice.
* Chaque timeSpan sera fixe, et devra correspondre à un mois complet.
@@ -64,8 +66,10 @@
* peut être bloquée ou non
*/
@Override
- public void createFinancialPeriods(List<FinancialPeriod> financialPeriods) throws LimaException {
+ public List<FinancialPeriod> createFinancialPeriods(Collection<FinancialPeriod> financialPeriods) throws LimaException {
+ List<FinancialPeriod> result = new ArrayList<FinancialPeriod>();
+
try {
FinancialPeriodDAO financialPeriodDAO =
@@ -76,6 +80,10 @@
getDaoHelper().getEntryBookDAO();
//create all financial period
for (FinancialPeriod financialPeriod : financialPeriods) {
+
+ //create financial period
+ financialPeriod = financialPeriodDAO.create(financialPeriod);
+
//create ClosedPeriodicEntryBook for all entrybook
for (EntryBook entryBook : entryBookDAO.findAll()) {
//new closed periodic entrybook
@@ -88,13 +96,15 @@
// create it
closedPeriodicEntryBookDAO.create(closedPeriodicEntryBook);
}
- //create financial period
- financialPeriodDAO.create(financialPeriod);
+
+ result.add(financialPeriod);
}
} catch (TopiaException ex) {
throw new LimaException("Can't create period", ex);
}
+
+ return result;
}
/** @return all financial period */
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-11 15:23:45 UTC (rev 3411)
@@ -67,6 +67,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImpl;
import org.nuiton.topia.framework.TopiaQuery;
/**
@@ -103,6 +104,8 @@
try {
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
+
Date beginDate = fiscalPeriod.getBeginDate();
beginDate = DateUtils.truncate(beginDate, Calendar.DATE);
Date endDate = fiscalPeriod.getEndDate();
@@ -114,15 +117,21 @@
fiscalPeriod.setEndDate(endDate);
//check rules before create the account
- List<FinancialPeriod> financialPeriods =
- accountingRules.createFiscalPeriodRules(fiscalPeriod);
- financialPeriodService.
- createFinancialPeriods(financialPeriods);
+ List<FinancialPeriod> financialPeriods = accountingRules.createFiscalPeriodRules(fiscalPeriod);
- FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
+ // FIXME echatellier 20120510 il y a un gros problème ici
+ // les periods sont instanciées par la rule
+ // mais crée ensuite par le service et la periodes
+ // est créée au final avec des entités qui n'ont pas les id affectés
+ financialPeriods = financialPeriodService.createFinancialPeriods(financialPeriods);
- //create
+ // create
result = fiscalPeriodDAO.create(fiscalPeriod);
+ result.addAllFinancialPeriod(financialPeriods);
+
+ // udpate
+ result = fiscalPeriodDAO.update(result);
+
} catch (TopiaException ex) {
throw new LimaException("Can't create period", ex);
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2012-05-11 10:26:46 UTC (rev 3410)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2012-05-11 15:23:45 UTC (rev 3411)
@@ -116,7 +116,6 @@
financialPeriod.setEndDate(loopDate);
}
//create it
- fiscalPeriod.addFinancialPeriod(financialPeriod);
financialPeriods.add(financialPeriod);
//financialPeriodService.createFinancialPeriodWithTransaction(financialPeriod, transaction);
//loop incremente
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2012-05-11 10:26:46 UTC (rev 3410)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2012-05-11 15:23:45 UTC (rev 3411)
@@ -25,14 +25,15 @@
package org.chorem.lima.business.api;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
-import java.util.Date;
-import java.util.List;
-
/**
* Financial period service.
*
@@ -47,7 +48,7 @@
List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException;
- void createFinancialPeriods(List<FinancialPeriod> financialPeriods) throws LimaException;
+ List<FinancialPeriod> createFinancialPeriods(Collection<FinancialPeriod> financialPeriods) throws LimaException;
ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
FinancialPeriod financialPeriod) throws LimaException;
1
0
r3410 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business-api/src/main/java/org/chorem/lima/business/api
by echatellier@users.chorem.org 11 May '12
by echatellier@users.chorem.org 11 May '12
11 May '12
Author: echatellier
Date: 2012-05-11 12:26:46 +0200 (Fri, 11 May 2012)
New Revision: 3410
Url: http://chorem.org/repositories/revision/lima/3410
Log:
Remove all ejb local interfaces (not needed anymore)
Removed:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/HttpServerServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportServiceLocal.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -41,7 +41,6 @@
import java.util.List;
import javax.ejb.EJB;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@@ -56,10 +55,9 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.DocumentService;
-import org.chorem.lima.business.api.DocumentServiceLocal;
-import org.chorem.lima.business.api.FinancialStatementServiceLocal;
-import org.chorem.lima.business.api.IdentityServiceLocal;
-import org.chorem.lima.business.api.ReportServiceLocal;
+import org.chorem.lima.business.api.FinancialStatementService;
+import org.chorem.lima.business.api.IdentityService;
+import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryComparator;
@@ -92,19 +90,18 @@
@Stateless
@Remote(DocumentService.class)
-(a)Local(DocumentServiceLocal.class)
@TransactionAttribute
-public class DocumentServiceImpl extends AbstractLimaService implements DocumentService, DocumentServiceLocal {
+public class DocumentServiceImpl extends AbstractLimaService implements DocumentService {
//Services
@EJB
- private IdentityServiceLocal identityService;
+ private IdentityService identityService;
@EJB
- private FinancialStatementServiceLocal financialStatementService;
+ private FinancialStatementService financialStatementService;
@EJB
- private ReportServiceLocal reportService;
+ private ReportService reportService;
@EJB
private VatStatementService vatStatementService;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -29,7 +29,6 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FinancialPeriodService;
-import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
@@ -38,11 +37,9 @@
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@@ -59,9 +56,8 @@
*/
@Stateless
@Remote(FinancialPeriodService.class)
-(a)Local(FinancialPeriodServiceLocal.class)
@TransactionAttribute
-public class FinancialPeriodServiceImpl extends AbstractLimaService implements FinancialPeriodService, FinancialPeriodServiceLocal {
+public class FinancialPeriodServiceImpl extends AbstractLimaService implements FinancialPeriodService {
/**
* Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -36,19 +36,16 @@
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FinancialStatementService;
-import org.chorem.lima.business.api.FinancialStatementServiceLocal;
-import org.chorem.lima.business.api.ReportServiceLocal;
+import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
import javax.ejb.EJB;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@@ -63,12 +60,11 @@
@Stateless
@Remote(FinancialStatementService.class)
-(a)Local(FinancialStatementServiceLocal.class)
@TransactionAttribute
-public class FinancialStatementServiceImpl extends AbstractLimaService implements FinancialStatementService, FinancialStatementServiceLocal {
+public class FinancialStatementServiceImpl extends AbstractLimaService implements FinancialStatementService {
@EJB
- private ReportServiceLocal reportServiceLocal;
+ private ReportService reportService;
@Override
public void createFinancialStatement(FinancialStatement masterFinancialStatement,
@@ -433,7 +429,7 @@
BigDecimal debitTemp = new BigDecimal(0);
BigDecimal creditTemp = new BigDecimal(0);
for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportServiceLocal.
+ ReportsDatas reportsDatas = reportService.
generateAccountsReports(account, true,
selectedBeginDate, selectedEndDate);
if (reportsDatas.getSoldeDebit()) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -31,7 +31,6 @@
import java.util.List;
import javax.ejb.EJB;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@@ -42,11 +41,10 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
-import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.api.FinancialTransactionServiceLocal;
-import org.chorem.lima.business.api.OptionsServiceLocal;
-import org.chorem.lima.business.api.ReportServiceLocal;
+import org.chorem.lima.business.api.OptionsService;
+import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.Entry;
@@ -56,8 +54,6 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
@@ -73,21 +69,20 @@
*/
@Stateless
@Remote(FinancialTransactionService.class)
-(a)Local(FinancialTransactionServiceLocal.class)
@TransactionAttribute
-public class FinancialTransactionServiceImpl extends AbstractLimaService implements FinancialTransactionService, FinancialTransactionServiceLocal {
+public class FinancialTransactionServiceImpl extends AbstractLimaService implements FinancialTransactionService {
@EJB
- protected FinancialPeriodServiceLocal financialPeriodService;
+ protected FinancialPeriodService financialPeriodService;
@EJB
- protected ReportServiceLocal reportService;
+ protected ReportService reportService;
@EJB
protected EntryBookService entryBookService;
@EJB
- protected OptionsServiceLocal optionsService;
+ protected OptionsService optionsService;
@Override
public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -37,7 +37,6 @@
import java.util.List;
import javax.ejb.EJB;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@@ -51,11 +50,10 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
-import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
-import org.chorem.lima.business.api.FinancialTransactionServiceLocal;
+import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
-import org.chorem.lima.business.api.FiscalPeriodServiceLocal;
-import org.chorem.lima.business.api.ReportServiceLocal;
+import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
@@ -79,24 +77,23 @@
*/
@Stateless
@Remote(FiscalPeriodService.class)
-(a)Local(FiscalPeriodServiceLocal.class)
@TransactionAttribute
-public class FiscalPeriodServiceImpl extends AbstractLimaService implements FiscalPeriodService, FiscalPeriodServiceLocal {
+public class FiscalPeriodServiceImpl extends AbstractLimaService implements FiscalPeriodService {
@EJB
protected AccountService accountService;
@EJB
- protected FinancialPeriodServiceLocal financialPeriodService;
+ protected FinancialPeriodService financialPeriodService;
@EJB
protected EntryBookService entryBookService;
@EJB
- protected ReportServiceLocal reportService;
+ protected ReportService reportService;
@EJB
- protected FinancialTransactionServiceLocal financialTransactionService;
+ protected FinancialTransactionService financialTransactionService;
@Override
public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -25,13 +25,33 @@
package org.chorem.lima.business.ejb;
+import static org.nuiton.i18n.I18n._;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.api.DocumentServiceLocal;
+import org.chorem.lima.business.api.DocumentService;
import org.chorem.lima.business.api.HttpServerService;
-import org.chorem.lima.business.api.HttpServerServiceLocal;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
import org.eclipse.jetty.server.Server;
@@ -41,35 +61,13 @@
import org.nuiton.util.FileUtil;
import org.nuiton.util.Resource;
-import javax.ejb.EJB;
-import javax.ejb.Local;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
@Stateless
@Remote(HttpServerService.class)
-(a)Local(HttpServerServiceLocal.class)
@TransactionAttribute
-public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService, HttpServerServiceLocal {
+public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService {
@EJB
- private DocumentServiceLocal documentService;
+ private DocumentService documentService;
protected Server server;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -25,26 +25,22 @@
package org.chorem.lima.business.ejb;
+import java.util.List;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.IdentityService;
-import org.chorem.lima.business.api.IdentityServiceLocal;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.IdentityDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaException;
-import javax.ejb.Local;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
-import java.util.List;
-
@Stateless
@Remote(IdentityService.class)
-(a)Local(IdentityServiceLocal.class)
@TransactionAttribute
-public class IdentityServiceImpl extends AbstractLimaService implements IdentityService, IdentityServiceLocal {
+public class IdentityServiceImpl extends AbstractLimaService implements IdentityService {
@Override
public Identity getIdentity()
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -46,7 +46,6 @@
import java.util.Map;
import javax.ejb.EJB;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@@ -76,13 +75,12 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
-import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
-import org.chorem.lima.business.api.FinancialStatementServiceLocal;
-import org.chorem.lima.business.api.FinancialTransactionServiceLocal;
-import org.chorem.lima.business.api.FiscalPeriodServiceLocal;
-import org.chorem.lima.business.api.IdentityServiceLocal;
+import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.api.FinancialStatementService;
+import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.business.api.FiscalPeriodService;
+import org.chorem.lima.business.api.IdentityService;
import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.api.ImportServiceLocal;
import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.business.utils.AccountEBPComparator;
import org.chorem.lima.business.utils.DocumentsEnum;
@@ -113,11 +111,9 @@
import org.chorem.lima.entity.FiscalPeriodImpl;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.IdentityImpl;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementDAO;
import org.chorem.lima.entity.VatStatementImpl;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import au.com.bytecode.opencsv.CSVReader;
@@ -130,9 +126,8 @@
*/
@Stateless
@Remote(ImportService.class)
-(a)Local(ImportServiceLocal.class)
@TransactionAttribute
-public class ImportServiceImpl extends AbstractLimaService implements ImportService, ImportServiceLocal {
+public class ImportServiceImpl extends AbstractLimaService implements ImportService {
private static final Log log = LogFactory.getLog(ImportServiceImpl.class);
@@ -140,16 +135,16 @@
private AccountService accountService;
@EJB
- private FiscalPeriodServiceLocal fiscalPeriodService;
+ private FiscalPeriodService fiscalPeriodService;
@EJB
- private FinancialPeriodServiceLocal financialPeriodService;
+ private FinancialPeriodService financialPeriodService;
@EJB
- private FinancialTransactionServiceLocal financialTransactionService;
+ private FinancialTransactionService financialTransactionService;
@EJB
- private FinancialStatementServiceLocal financialStatementService;
+ private FinancialStatementService financialStatementService;
@EJB
private VatStatementService vatStatementService;
@@ -158,7 +153,7 @@
private EntryBookService entryBookService;
@EJB
- private IdentityServiceLocal identityService;
+ private IdentityService identityService;
private static final SimpleDateFormat SDATEFORMAT = new SimpleDateFormat(
"dd,MM,yyyy HH:mm:ss");
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -24,18 +24,15 @@
*/
package org.chorem.lima.business.ejb;
-import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.api.OptionsService;
-import org.chorem.lima.business.api.OptionsServiceLocal;
-
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.api.OptionsService;
+
@Stateless
@Remote(OptionsService.class)
-(a)Local(OptionsServiceLocal.class)
-public class OptionsServiceImpl extends AbstractLimaService implements OptionsService, OptionsServiceLocal {
+public class OptionsServiceImpl extends AbstractLimaService implements OptionsService {
protected String scale;
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-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -31,7 +31,6 @@
import java.util.List;
import javax.ejb.EJB;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@@ -43,9 +42,8 @@
import org.chorem.lima.beans.ReportsDatasImpl;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
-import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.ReportService;
-import org.chorem.lima.business.api.ReportServiceLocal;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.Entry;
@@ -57,12 +55,11 @@
@Stateless
@Remote(ReportService.class)
-(a)Local(ReportServiceLocal.class)
@TransactionAttribute
-public class ReportServiceImpl extends AbstractLimaService implements ReportService, ReportServiceLocal {
+public class ReportServiceImpl extends AbstractLimaService implements ReportService {
@EJB
- protected FinancialPeriodServiceLocal financialPeriodService;
+ protected FinancialPeriodService financialPeriodService;
@EJB
protected AccountService accountService;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -24,40 +24,33 @@
*/
package org.chorem.lima.business.ejb;
-import org.apache.commons.lang3.StringUtils;
-import org.chorem.lima.beans.Amounts;
-import org.chorem.lima.beans.AmountsImpl;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.beans.VatStatementAmounts;
import org.chorem.lima.beans.VatStatementAmountsImpl;
import org.chorem.lima.beans.VatStatementDatas;
import org.chorem.lima.beans.VatStatementDatasImpl;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.api.ReportServiceLocal;
+import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementDAO;
import org.chorem.lima.entity.VatStatementImpl;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
-import javax.ejb.EJB;
-import javax.ejb.Local;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringTokenizer;
-
/**
* Permet d'implémenter le plan de la déclaration de TVA
*
@@ -69,7 +62,7 @@
public class VatStatementServiceImpl extends AbstractLimaService implements VatStatementService {
@EJB
- private ReportServiceLocal reportServiceLocal;
+ private ReportService reportService;
@Override
public void createVatStatement(VatStatement masterVatStatement,
@@ -261,7 +254,7 @@
List<Account> accountsList = accountDAO.stringToListAccounts(accountNumbersList, false);
for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportServiceLocal.
+ ReportsDatas reportsDatas = reportService.
generateAccountsReports(account, true,
selectedBeginDate, selectedEndDate);
if (reportsDatas.getSoldeDebit()) {
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,36 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-/**
- * Interface to create pdf and html docs
- *
- * @author john
- */
-
-public interface DocumentServiceLocal extends DocumentService {
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,49 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.nuiton.topia.TopiaContext;
-
-import java.util.List;
-
-
-/**
- * Financial period service.
- *
- * @author chatellier
- * @version $Revision$
- * <p/>
- * Last update : $Date$
- * By : $Author$
- */
-
-public interface FinancialPeriodServiceLocal extends FinancialPeriodService {
-
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,35 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.FinancialStatement;
-import org.nuiton.topia.TopiaContext;
-
-public interface FinancialStatementServiceLocal extends FinancialStatementService {
-
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,46 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.FinancialTransaction;
-import org.nuiton.topia.TopiaContext;
-
-/**
- * Transaction service.
- *
- * @author chatellier
- * @version $Revision$
- * <p/>
- * Last update : $Date$
- * By : $Author$
- */
-
-public interface FinancialTransactionServiceLocal extends FinancialTransactionService {
-
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,44 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.nuiton.topia.TopiaContext;
-
-/**
- * Fiscal period service.
- *
- * @author chatellier
- * @version $Revision$
- * <p/>
- * Last update : $Date$
- * By : $Author$
- */
-public interface FiscalPeriodServiceLocal extends FiscalPeriodService {
-
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/HttpServerServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/HttpServerServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/HttpServerServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,30 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-public interface HttpServerServiceLocal extends HttpServerService {
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,35 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.Identity;
-import org.nuiton.topia.TopiaContext;
-
-public interface IdentityServiceLocal extends IdentityService {
-
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,41 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-/**
- * Import export service.
- * <p/>
- * Currently import and export as XML.
- *
- * @author chatellier
- * @version $Revision$
- * <p/>
- * Last update : $Date$
- * By : $Author$
- */
-public interface ImportServiceLocal extends ImportService {
-
-}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,29 +0,0 @@
-/*
- * #%L
- * Lima :: business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2011 CodeLutin
- * %%
- * 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.business.api;
-
-public interface OptionsServiceLocal extends OptionsService {
-
-}
Deleted: 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-11 10:19:53 UTC (rev 3409)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportServiceLocal.java 2012-05-11 10:26:46 UTC (rev 3410)
@@ -1,55 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.beans.ReportsDatas;
-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;
-
-
-/**
- * Service de generation des rapports.
- * <p/>
- * Actuellement:
- * <ul>
- * <li>Balance</li>
- * <li>Bilan</li>
- * </ul>
- *
- * @author chatellier
- * @version $Revision$
- * <p/>
- * Last update : $Date$
- * By : $Author$
- */
-
-public interface ReportServiceLocal extends ReportService {
-
-}
1
0
r3409 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business/accountingrules lima-business-api/src/main/java/org/chorem/lima/business/api
by echatellier@users.chorem.org 11 May '12
by echatellier@users.chorem.org 11 May '12
11 May '12
Author: echatellier
Date: 2012-05-11 12:19:53 +0200 (Fri, 11 May 2012)
New Revision: 3409
Url: http://chorem.org/repositories/revision/lima/3409
Log:
Removing all topiaContext use in services
Removed:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementServiceLocal.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.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/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -32,7 +32,6 @@
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
-import org.nuiton.topia.TopiaContext;
import java.util.List;
@@ -62,7 +61,7 @@
* @param topiaTransaction
* @throws LimaException
*/
- void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException;
+ void removeEntryBookRules(EntryBook entryBook) throws LimaException;
/**
* Fiscal Period rules
@@ -71,9 +70,9 @@
* @param transaction
* @throws LimaException
*/
- List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException;
+ List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
- void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException;
+ void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
/**
* Entry rules
@@ -82,7 +81,7 @@
* @param topiaTransaction
* @throws LimaException
*/
- void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException;
+ void updateEntryRules(Entry entry, Entry entryOld) throws LimaException;
void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws LimaException;
@@ -93,7 +92,7 @@
* @param topiaContext
* @throws LimaException
*/
- void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException;
+ void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException;
/**
* Check if a financial period can be closed.
@@ -102,5 +101,5 @@
* @param topiaContext
* @throws LimaException
*/
- void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaContext) throws LimaException;
+ void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -30,6 +30,8 @@
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.FinancialStatementDAO;
+import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.IdentityDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -76,7 +78,15 @@
public FinancialPeriodDAO getFinancialPeriodDAO() throws TopiaException {
return LimaCallaoDAOHelper.getFinancialPeriodDAO(context);
}
+
+ public FinancialTransactionDAO getFinancialTransactionDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getFinancialTransactionDAO(context);
+ }
+ public FinancialStatementDAO getFinancialStatementDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getFinancialStatementDAO(context);
+ }
+
public FiscalPeriodDAO getFiscalPeriodDAO() throws TopiaException {
return LimaCallaoDAOHelper.getFiscalPeriodDAO(context);
}
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-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -52,8 +52,6 @@
import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
/**
@@ -103,7 +101,7 @@
/** Rules to check before create fiscals periods */
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
//check if the enddate period is after the begindate period
if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())) {
throw new LimaBusinessException(_("lima-business.defaultaccountingrules.enddateerror"));
@@ -114,7 +112,7 @@
/** Rules to check before block fiscals periods */
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
}
@@ -138,16 +136,17 @@
/** Check if entrybook have financial transaction */
@Override
- public void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException {
+ public void removeEntryBookRules(EntryBook entryBook) throws LimaException {
try {
- FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
+
// Check if entrybook have entries
long nbfinancialtransaction = financialTransactionDAO.getCountByEntryBook(entryBook);
if (nbfinancialtransaction != 0) {
throw new LimaBusinessException(_("lima-business.defaultaccountingrules.deleteentrybookerror"));
}
} catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
+ throw new LimaException("Can't check rule", ex);
}
}
@@ -157,7 +156,7 @@
* check if all entrybook of his financial period are blocked
*/
@Override
- public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException {
+ public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
try {
//check financial period locked
@@ -188,8 +187,8 @@
if (entryBooks.size() == closedEntryBooks.size()) {
throw new LimaBusinessException(_("lima-business.defaultaccountingrules.allentrybookclosed"));
}
- } catch (TopiaException eee) {
- doCatch(topiaContext, eee, log);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't check rule", ex);
}
}
@@ -199,12 +198,11 @@
* Check if all financial transactions have EntryBooks
*/
@Override
- public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaContext)
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook)
throws LimaException {
try {
- FinancialTransactionDAO financialTransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
// Check if all financial transactions of closedperiodicentrybook are equilibrate
// FIMXE echatellier 20120504 unutile de recuperer une liste
@@ -233,7 +231,7 @@
}
} catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
+ throw new LimaException("Can't check rule", ex);
}
}
@@ -245,15 +243,14 @@
* - third, the new choice entrybook belong to a blocked closedPeriodicEntryBook
*/
@Override
- public void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException {
+ public void updateEntryRules(Entry entry, Entry entryOld) throws LimaException {
try {
FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(entry.getFinancialTransaction().getTransactionDate());
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaTransaction);
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
//second case
ClosedPeriodicEntryBook closedPeriodicEntryBook =
@@ -273,8 +270,8 @@
throw new LimaBusinessException(_("lima-Business.defaultaccountingrules.updateentryerror"));
}
- } catch (TopiaException eee) {
- doCatch(topiaTransaction, eee, log);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't check rule", ex);
}
}
@@ -398,28 +395,4 @@
throw new LimaException("Can't check financial transaction", ex);
}
}
-
-
- /**
- * Generic code used to rollback a transaction.
- * <p/>
- * TODO : replace this by JTA
- *
- * @throws LimaException
- */
- protected void doCatch(TopiaContext transaction, Exception cause, Log log) throws LimaException {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", eee);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Exception during query", cause);
- }
- throw new LimaException(_("lima-business.common.queryerror"), cause);
- }
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -39,8 +39,6 @@
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
@@ -112,12 +110,11 @@
* Pas plus de deux exercices fiscaux ne peuvent-être ouvert en même temps
*/
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
- super.createFiscalPeriodRules(fiscalPeriod, transaction);
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
try {
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
//Checks if is not the first fiscalperiod to create
if (fiscalPeriodDAO.findAll().size() != 0) {
@@ -170,7 +167,7 @@
loopDate = DateUtils.addMilliseconds(loopDate, 1);
}
} catch (TopiaException ex) {
- doCatch(transaction, ex, log);
+ throw new LimaException("Can't check rule", ex);
}
return financialPeriods;
}
@@ -179,10 +176,9 @@
* Règles de vérification de fermeture d'un exercice, appliquées à la comptabilité française.
*/
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
try {
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
TopiaQuery query = fiscalPeriodDAO.createQuery();
fiscalPeriodDAO.findAllByQuery(query);
@@ -197,7 +193,7 @@
throw new LimaBusinessException(_("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
}
} catch (TopiaException ex) {
- doCatch(transaction, ex, log);
+ throw new LimaException("Can't check rule", ex);
}
}
@@ -217,9 +213,8 @@
* qu'il reste des ClosedPeriodicEntryBook non clos ?
*/
@Override
- public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaTransaction) throws LimaException {
- super.blockClosedPeriodicEntryBookRules(
- closedPeriodicEntryBook, topiaTransaction);
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
+ super.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod();
@@ -231,7 +226,7 @@
// un period peut ne pas durer un mois
endDate = DateUtils.addMonths(endDate, -1);
- FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaTransaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
//search fiscalperiod have financialperiod
FiscalPeriod fiscalPeriod = fiscalPeriodDAO.findByFinancialPeriod(financialPeriod);
@@ -240,8 +235,7 @@
// et endDate ? il ne provienent pas du même endroit
EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaTransaction);
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
closedPeriodicEntryBookDAO.findAllByEntryBookAndDates(entryBook, beginDate, endDate);
@@ -260,28 +254,7 @@
}
} catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
+ throw new LimaException("Can't check rule", ex);
}
}
-
- /**
- * Generic code used to rollback a transaction.
- *
- * @throws LimaException
- */
- protected void doCatch(TopiaContext transaction, Exception cause, Log log) throws LimaException {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", eee);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Exception during query", cause);
- }
- throw new LimaException(_("lima-business.common.queryerror"), cause);
- }
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -25,21 +25,10 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.Properties;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaDaoHelper;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.LimaInterceptor;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.TopiaRuntimeException;
/**
* Abstract code for all ejb services (get context, catch, finally...).
@@ -61,93 +50,4 @@
protected LimaDaoHelper getDaoHelper() {
return LimaInterceptor.DAO_HELPER.get();
}
-
- protected static TopiaContext acquireRootContext() {
- try {
- LimaConfig config = LimaConfig.getInstance();
- Properties options = config.getFlatOptions();
-
- if (log.isDebugEnabled()) {
- log.debug("Opening context to database : " + options.getProperty("hibernate.connection.url"));
- }
- return TopiaContextFactory.getContext(options);
- } catch (TopiaNotFoundException ex) {
- throw new TopiaRuntimeException("Could not acquire root context", ex);
- }
- }
-
- /**
- * Generic code used to rollback a transaction.
- * <p/>
- * TODO : replace this by JTA
- *
- * @throws LimaException
- */
- protected void doCatch(TopiaContext transaction,
- Exception cause) throws LimaException {
- if (cause instanceof LimaException) {
- throw (LimaException) cause;
- }
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", eee);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Exception during query", cause);
- }
- throw new LimaException(_("lima-business.common.queryerror", cause.getMessage()), cause);
- }
-
- /**
- * Generic code used too close a transaction.
- *
- * @param transaction transaction to close
- * @throws LimaException
- */
- protected void doFinally(TopiaContext transaction) throws LimaException {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't close transaction", ex);
- }
- throw new LimaException(
- _("lima-business.common.close.transactionerror", ex));
- }
- }
- }
-
- protected TopiaContext beginTransaction(TopiaContext rootContext) throws LimaException {
- if (rootContext == null) {
- throw new NullPointerException("rootContext can not be null");
- }
- // basic check done, make check in database
- // TODO move it into JTA
- try {
- TopiaContext topiaContext = rootContext.beginTransaction();
- log.trace("beginTransaction" + topiaContext);
- return topiaContext;
- } catch (TopiaException e) {
- throw new LimaException(
- _("lima-business.common.open.transactionerror", e));
- }
- }
-
- protected void commitTransaction(TopiaContext topiaContext) throws LimaException {
- try {
- topiaContext.commitTransaction();
- } catch (TopiaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error during commit context", eee);
- }
- throw new LimaException(
- _("lima-business.common.commit.transactionerror", eee));
- }
- }
}
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-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -38,7 +38,6 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.LimaInterceptor;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -25,20 +25,27 @@
package org.chorem.lima.business.ejb;
-import com.lowagie.text.BadElementException;
-import com.lowagie.text.Cell;
-import com.lowagie.text.Chapter;
-import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
-import com.lowagie.text.Element;
-import com.lowagie.text.Font;
-import com.lowagie.text.PageSize;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.Phrase;
-import com.lowagie.text.Rectangle;
-import com.lowagie.text.Table;
-import com.lowagie.text.html.HtmlWriter;
-import com.lowagie.text.pdf.PdfWriter;
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import org.apache.pdfbox.examples.fdf.SetField;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.chorem.lima.beans.BalanceTrial;
@@ -53,7 +60,7 @@
import org.chorem.lima.business.api.FinancialStatementServiceLocal;
import org.chorem.lima.business.api.IdentityServiceLocal;
import org.chorem.lima.business.api.ReportServiceLocal;
-import org.chorem.lima.business.api.VatStatementServiceLocal;
+import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.business.utils.FormatsEnum;
@@ -65,40 +72,30 @@
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
-import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.Identity;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.VatStatement;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
-import javax.ejb.EJB;
-import javax.ejb.Local;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import java.awt.*;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import com.lowagie.text.BadElementException;
+import com.lowagie.text.Cell;
+import com.lowagie.text.Chapter;
+import com.lowagie.text.Document;
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Element;
+import com.lowagie.text.Font;
+import com.lowagie.text.PageSize;
+import com.lowagie.text.Paragraph;
+import com.lowagie.text.Phrase;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.Table;
+import com.lowagie.text.html.HtmlWriter;
+import com.lowagie.text.pdf.PdfWriter;
-import static org.nuiton.i18n.I18n._;
-
@Stateless
@Remote(DocumentService.class)
@Local(DocumentServiceLocal.class)
+@TransactionAttribute
public class DocumentServiceImpl extends AbstractLimaService implements DocumentService, DocumentServiceLocal {
- private TopiaContext rootContext;
-
//Services
@EJB
private IdentityServiceLocal identityService;
@@ -110,7 +107,7 @@
private ReportServiceLocal reportService;
@EJB
- private VatStatementServiceLocal vatStatementService;
+ private VatStatementService vatStatementService;
protected String path;
@@ -142,7 +139,6 @@
public DocumentServiceImpl() {
- rootContext = acquireRootContext();
path = LimaConfig.getInstance().getReportsDir().getAbsolutePath();
}
@@ -743,9 +739,7 @@
Date endDate,
FormatsEnum format) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
- TopiaContext transaction = beginTransaction(rootContext);
-
try {
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
@@ -767,8 +761,8 @@
Identity identity = identityService.getIdentity();
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
//Split list by financialstatement type
List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
@@ -851,12 +845,9 @@
document.close();
- } catch (Exception eee) {
- doCatch(transaction, eee);
- } finally {
- doFinally(transaction);
+ } catch (Exception ex) {
+ throw new LimaException("Can't create document", ex);
}
-
}
public Table createEntryBooksHeaderTable() {
@@ -1175,7 +1166,7 @@
public void createGeneralEntryBooksDocuments(Date beginDate,
Date endDate,
FormatsEnum format) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
+
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
try {
@@ -1200,10 +1191,10 @@
Identity identity = identityService.getIdentity();
FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ getDaoHelper().getFinancialPeriodDAO();
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
List<FinancialPeriod> financialPeriods =
financialPeriodDAO.findByDates(beginDate, endDate);
@@ -1315,12 +1306,9 @@
document.close();
- } catch (Exception eee) {
- doCatch(transaction, eee);
- } finally {
- doFinally(transaction);
+ } catch (Exception ex) {
+ throw new LimaException("Can't generate document", ex);
}
-
}
public Table createGeneralEntryBooksHeaderTable() {
@@ -1477,8 +1465,8 @@
doc.save(filePath);
doc.close();
- } catch (Exception eee) {
- doCatch(null, eee);
+ } catch (Exception ex) {
+ throw new LimaException("Can't create document", ex);
}
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -30,7 +30,6 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
-import org.chorem.lima.business.api.EntryBookServiceLocal;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
@@ -38,14 +37,12 @@
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
-import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
-import java.util.ArrayList;
+import javax.ejb.TransactionAttribute;
+
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -58,26 +55,18 @@
*/
@Stateless
@Remote(EntryBookService.class)
-(a)Local(EntryBookServiceLocal.class)
-public class EntryBookServiceImpl extends AbstractLimaService implements EntryBookService, EntryBookServiceLocal {
+@TransactionAttribute
+public class EntryBookServiceImpl extends AbstractLimaService implements EntryBookService {
- private TopiaContext rootContext;
-
- public EntryBookServiceImpl() {
- rootContext = acquireRootContext();
- }
-
@Override
- public EntryBook createEntryBookWithTransaction(EntryBook entryBook,
- TopiaContext topiaContext)
+ public EntryBook createEntryBook(EntryBook entryBook)
throws LimaException {
EntryBook result = null;
try {
// check if entrybook with is name already exist
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
EntryBook existingEntryBook =
entryBookDAO.findByLabel(entryBook.getCode());
if (existingEntryBook != null) {
@@ -91,9 +80,9 @@
//create ClosedPeriodicEntryBook for all unblocked financial period
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+ getDaoHelper().getFinancialPeriodDAO();
// for all unblocked financialperiod
for (FinancialPeriod financialPeriod : financialPeriodDAO.findAllByLocked(false)) {
@@ -108,47 +97,23 @@
closedPeriodicEntryBookDAO.create(closedPeriodicEntryBook);
}
- commitTransaction(topiaContext);
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't create entry book", ex);
}
return result;
}
@Override
- public EntryBook createEntryBook(EntryBook entryBook) throws LimaException {
-
- TopiaContext transaction = beginTransaction(rootContext);
-
- EntryBook result = null;
- try {
-
- result = createEntryBookWithTransaction(entryBook, transaction);
- } catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
- }
-
- return result;
- }
-
- @Override
public List<EntryBook> getAllEntryBooks() throws LimaException {
- List<EntryBook> entryBooksList = new ArrayList<EntryBook>();
- TopiaContext transaction = beginTransaction(rootContext);
- try {
+ List<EntryBook> entryBooksList = null;
+ try {
// check if entrybook with is name already exist
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(transaction);
- List<EntryBook> entryBooks = entryBookDAO.findAll();
- entryBooksList.addAll(entryBooks);
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
+ entryBooksList = entryBookDAO.findAll();
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get entry books", ex);
}
return entryBooksList;
@@ -156,22 +121,17 @@
@Override
public EntryBook updateEntryBook(EntryBook entryBook) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
EntryBook result = null;
try {
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
// creation du EntryBook
result = entryBookDAO.update(entryBook);
- commitTransaction(transaction);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't update entry book", ex);
}
return result;
@@ -180,17 +140,16 @@
@Override
public void removeEntryBook(EntryBook entryBook) throws LimaException {
- TopiaContext topiaTransaction = beginTransaction(rootContext);
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
// check rule
- accountingRules.removeEntryBookRules(entryBook, topiaTransaction);
+ accountingRules.removeEntryBookRules(entryBook);
// delete all ClosedPeriodicEntryBook from this EntryBook
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaTransaction);
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
closedPeriodicEntryBookDAO.findAllByEntryBook(entryBook);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) {
@@ -198,14 +157,11 @@
}
// delete entry book
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction);
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
entryBookDAO.delete(entryBook);
- commitTransaction(topiaTransaction);
} catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
+ throw new LimaException("Can't remove entry book", ex);
}
}
@@ -214,22 +170,17 @@
*/
@Override
public EntryBook getEntryBookByCode(String code) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
+
EntryBook entryBook = null;
try {
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(transaction);
-
// creation du EntryBook
entryBook = entryBookDAO.findByCode(code);
- commitTransaction(transaction);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get entry book", ex);
}
return entryBook;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -47,16 +47,16 @@
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.IdentityDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementDAO;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.List;
@@ -72,17 +72,12 @@
@Stateless
@Remote(ExportService.class)
@Local(ExportServiceLocal.class)
+@TransactionAttribute
public class ExportServiceImpl extends AbstractLimaService implements ExportService, ExportServiceLocal {
- private TopiaContext rootContext;
-
private static final SimpleDateFormat SDATEFORMAT =
new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
- public ExportServiceImpl() {
- rootContext = acquireRootContext();
- }
-
//############## EXPORT EBP
/**
@@ -96,12 +91,11 @@
StringBuilder result = new StringBuilder();
int num = 0;
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
//export entries
FinancialTransactionDAO financialTransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ getDaoHelper().getFinancialTransactionDAO();
List<FinancialTransaction> listFinancialTransaction =
financialTransactionDAO.findAll();
// For all financialTransaction
@@ -155,10 +149,8 @@
}
}
}
- } catch (Exception eeeTE) {
- doCatch(topiaContext, eeeTE);
- } finally {
- doFinally(topiaContext);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export", ex);
}
return result.toString();
}
@@ -173,8 +165,6 @@
StringWriter out = new StringWriter();
CSVWriter csvWriter;
- TopiaContext topiaContext = beginTransaction(rootContext);
-
try {
csvWriter = new CSVWriter(out,
CSVWriter.DEFAULT_SEPARATOR,
@@ -182,8 +172,7 @@
//export accounts
String[] nextLine = new String[10];
// Récupère tous les comptes
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
List<Account> listAccount = accountDAO.findAll();
// Pour tous les comptes
for (Account account : listAccount) {
@@ -195,10 +184,8 @@
// Write cache in string
csvWriter.flush();
csvWriter.close();
- } catch (Exception eeeTE) {
- doCatch(topiaContext, eeeTE);
- } finally {
- doFinally(topiaContext);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export", ex);
}
return out.getBuffer().toString();
}
@@ -212,24 +199,20 @@
StringWriter out = new StringWriter();
CSVWriter csvWriter;
- TopiaContext topiaContext = beginTransaction(rootContext);
-
try {
csvWriter = new CSVWriter(out, ';');
- exportAccountsChartAsCSV(csvWriter, topiaContext);
- exportEntryBookChartAsCSV(csvWriter, topiaContext);
- exportFinancialStatementChartAsCSV(csvWriter, topiaContext);
- exportFiscalPeriodAsCSV(csvWriter, topiaContext);
- exportClosedPeriodicEntryBooksAsCSV(csvWriter, topiaContext);
- exportFinancialTransactionsAndEntriesAsCSV(csvWriter, topiaContext);
- exportIdentityAsCSV(csvWriter, topiaContext);
+ exportAccountsChartAsCSV(csvWriter);
+ exportEntryBookChartAsCSV(csvWriter);
+ exportFinancialStatementChartAsCSV(csvWriter);
+ exportFiscalPeriodAsCSV(csvWriter);
+ exportClosedPeriodicEntryBooksAsCSV(csvWriter);
+ exportFinancialTransactionsAndEntriesAsCSV(csvWriter);
+ exportIdentityAsCSV(csvWriter);
// Write cache in string
csvWriter.flush();
csvWriter.close();
- } catch (Exception eeeTE) {
- doCatch(topiaContext, eeeTE);
- } finally {
- doFinally(topiaContext);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export", ex);
}
return out.getBuffer().toString();
}
@@ -242,17 +225,14 @@
StringWriter out = new StringWriter();
CSVWriter csvWriter;
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
csvWriter = new CSVWriter(out, ';');
- exportFinancialStatementChartAsCSV(csvWriter, topiaContext);
+ exportFinancialStatementChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
csvWriter.close();
- } catch (Exception eeeTE) {
- doCatch(topiaContext, eeeTE);
- } finally {
- doFinally(topiaContext);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export", ex);
}
return out.getBuffer().toString();
}
@@ -268,13 +248,12 @@
* @param topiaContext
* @throws LimaException
*/
- public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter) throws LimaException {
try {
String[] nextLine = new String[12];
// Get all Financialstatements
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+ FinancialStatementDAO financialStatementDAO =
+ getDaoHelper().getFinancialStatementDAO();
TopiaQuery query = financialStatementDAO.createQuery();
query.addOrder(FinancialStatement.TOPIA_CREATE_DATE);
@@ -313,8 +292,8 @@
// Add line in file
csvWriter.writeNext(nextLine);
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
@@ -325,18 +304,14 @@
StringWriter out = new StringWriter();
CSVWriter csvWriter;
- TopiaContext topiaContext = beginTransaction(rootContext);
-
try {
csvWriter = new CSVWriter(out, ';');
- exportVatStatementChartAsCSV(csvWriter, topiaContext);
+ exportVatStatementChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
csvWriter.close();
- } catch (Exception eeeTE) {
- doCatch(topiaContext, eeeTE);
- } finally {
- doFinally(topiaContext);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export", ex);
}
return out.getBuffer().toString();
@@ -351,13 +326,11 @@
* @param topiaContext
* @throws LimaException
*/
- public void exportVatStatementChartAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportVatStatementChartAsCSV(CSVWriter csvWriter) throws LimaException {
try {
String[] nextLine = new String[6];
// Get all Vatstatements
- VatStatementDAO vatStatementDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(topiaContext);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
TopiaQuery query = vatStatementDAO.createQuery();
query.addOrder(VatStatement.TOPIA_CREATE_DATE);
@@ -383,8 +356,8 @@
csvWriter.writeNext(nextLine);
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
@@ -396,18 +369,14 @@
StringWriter out = new StringWriter();
CSVWriter csvWriter;
- TopiaContext topiaContext = beginTransaction(rootContext);
-
try {
csvWriter = new CSVWriter(out, ';');
- exportEntryBookChartAsCSV(csvWriter, topiaContext);
+ exportEntryBookChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
csvWriter.close();
- } catch (Exception eeeTE) {
- doCatch(topiaContext, eeeTE);
- } finally {
- doFinally(topiaContext);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export", ex);
}
return out.getBuffer().toString();
}
@@ -421,13 +390,11 @@
* @param topiaContext
* @throws LimaException
*/
- public void exportEntryBookChartAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportEntryBookChartAsCSV(CSVWriter csvWriter) throws LimaException {
try {
String[] nextLine = new String[3];
// Get all entrybook
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
List<EntryBook> listEntryBook = entryBookDAO.findAll();
// For all EntryBook
for (EntryBook entryBook : listEntryBook) {
@@ -437,8 +404,8 @@
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
@@ -449,18 +416,14 @@
StringWriter out = new StringWriter();
CSVWriter csvWriter;
- TopiaContext topiaContext = beginTransaction(rootContext);
-
try {
csvWriter = new CSVWriter(out, ';');
- exportAccountsChartAsCSV(csvWriter, topiaContext);
+ exportAccountsChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
csvWriter.close();
- } catch (Exception eeeTE) {
- doCatch(topiaContext, eeeTE);
- } finally {
- doFinally(topiaContext);
+ } catch (Exception ex) {
+ throw new LimaException("Can't export", ex);
}
return out.getBuffer().toString();
}
@@ -474,13 +437,12 @@
* @param topiaContext
* @throws LimaException
*/
- public void exportAccountsChartAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportAccountsChartAsCSV(CSVWriter csvWriter) throws LimaException {
try {
String[] nextLine = new String[6];
// Récupère tous les comptes
AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ getDaoHelper().getAccountDAO();
List<Account> listAccount = accountDAO.findAll();
// Pour tous les comptes
for (Account account : listAccount) {
@@ -492,8 +454,8 @@
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
@@ -507,13 +469,12 @@
* @param topiaContext
* @throws LimaException
*/
- public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter) throws LimaException {
int numTransaction = 0;
// Get all financialtransactions
try {
FinancialTransactionDAO financialTransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ getDaoHelper().getFinancialTransactionDAO();
List<FinancialTransaction> listFinancialTransaction =
financialTransactionDAO.findAll();
// For all financialTransaction
@@ -548,8 +509,8 @@
}
numTransaction++;
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
@@ -562,13 +523,12 @@
* @param topiaContext
* @throws LimaException
*/
- public void exportFiscalPeriodAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportFiscalPeriodAsCSV(CSVWriter csvWriter) throws LimaException {
try {
String[] nextLine = new String[4];
// Get all fiscalperiod
FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+ getDaoHelper().getFiscalPeriodDAO();
List<FiscalPeriod> listFiscalPeriod =
fiscalPeriodDAO.findAll();
// For all Entry
@@ -580,8 +540,8 @@
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
@@ -593,13 +553,12 @@
* @param topiaContext
* @throws LimaException
*/
- public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter) throws LimaException {
try {
String[] nextLine = new String[5];
// Get all fiscalperiod
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
closedPeriodicEntryBookDAO.findAll();
// For all Entry
@@ -617,17 +576,16 @@
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
- public void exportIdentityAsCSV(CSVWriter csvWriter,
- TopiaContext topiaContext) throws LimaException {
+ public void exportIdentityAsCSV(CSVWriter csvWriter) throws LimaException {
try {
String[] nextLine = new String[12];
// Get identity
- IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext);
+ IdentityDAO identityDAO = getDaoHelper().getIdentityDAO();
List<Identity> identities = identityDAO.findAll();
if (identities.size() != 0) {
@@ -647,9 +605,8 @@
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
}
- } catch (TopiaException eeeTE) {
- doCatch(topiaContext, eeeTE);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't export", ex);
}
}
-
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -39,13 +39,14 @@
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import java.util.Date;
import java.util.List;
@@ -59,14 +60,9 @@
@Stateless
@Remote(FinancialPeriodService.class)
@Local(FinancialPeriodServiceLocal.class)
+@TransactionAttribute
public class FinancialPeriodServiceImpl extends AbstractLimaService implements FinancialPeriodService, FinancialPeriodServiceLocal {
- private TopiaContext rootContext;
-
- public FinancialPeriodServiceImpl() {
- rootContext = acquireRootContext();
- }
-
/**
* Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période
* peut être bloquée ou non
@@ -74,35 +70,14 @@
@Override
public void createFinancialPeriods(List<FinancialPeriod> financialPeriods) throws LimaException {
- TopiaContext topiaTransaction = beginTransaction(rootContext);
try {
- createFinancialPeriodsWithTransaction(
- financialPeriods, topiaTransaction);
- } catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
- }
- }
-
-
- /**
- * Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période
- * peut être bloquée ou non
- */
- @Override
- public void createFinancialPeriodsWithTransaction(List<FinancialPeriod> financialPeriods,
- TopiaContext topiaContext) throws LimaException {
-
- try {
-
FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+ getDaoHelper().getFinancialPeriodDAO();
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ getDaoHelper().getEntryBookDAO();
//create all financial period
for (FinancialPeriod financialPeriod : financialPeriods) {
//create ClosedPeriodicEntryBook for all entrybook
@@ -120,9 +95,9 @@
//create financial period
financialPeriodDAO.create(financialPeriod);
}
- commitTransaction(topiaContext);
+
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't create period", ex);
}
}
@@ -132,20 +107,16 @@
List<FinancialPeriod> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
- getFinancialPeriodDAO(transaction);
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
TopiaQuery query = financialPeriodDAO.createQuery()
.addOrder(FinancialPeriod.PROPERTY_BEGIN_DATE);
result = financialPeriodDAO.findAllByQuery(query);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get periods", ex);
}
return result;
@@ -157,11 +128,9 @@
List<FinancialPeriod> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
- getFinancialPeriodDAO(transaction);
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
TopiaQuery query = financialPeriodDAO.createQuery()
.addEquals(FinancialPeriod.PROPERTY_LOCKED, Boolean.FALSE)
@@ -169,9 +138,7 @@
result = financialPeriodDAO.findAllByQuery(query);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't create period", ex);
}
return result;
@@ -183,10 +150,8 @@
List<FinancialPeriod> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
- getFinancialPeriodDAO(transaction);
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
TopiaQuery query = financialPeriodDAO.createQuery()
.addBetween(FinancialPeriod.PROPERTY_BEGIN_DATE, beginDate, endDate)
@@ -194,28 +159,22 @@
result = financialPeriodDAO.findAllByQuery(query);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get period", ex);
}
return result;
}
-
@Override
- public void blockClosedPeriodicEntryBookWithTransaction(
- ClosedPeriodicEntryBook closedPeriodicEntryBook,
- TopiaContext topiaContext) throws LimaException {
+ public void blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
// check rules before create the account
- accountingRules.blockClosedPeriodicEntryBookRules(
- closedPeriodicEntryBook, topiaContext);
+ accountingRules.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ getDaoHelper().getClosedPeriodicEntryBookDAO();
//ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
// closedPeriodicEntryBookDAO.findByTopiaId(
@@ -224,45 +183,23 @@
closedPeriodicEntryBook.setLocked(true);
closedPeriodicEntryBookDAO.update(closedPeriodicEntryBook);
- commitTransaction(topiaContext);
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't block period", ex);
}
}
@Override
- public void blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
-
- TopiaContext topiaContext = beginTransaction(rootContext);
- try {
-
- blockClosedPeriodicEntryBookWithTransaction(closedPeriodicEntryBook, topiaContext);
-
- commitTransaction(topiaContext);
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
- }
-
- }
-
- @Override
public ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
FinancialPeriod financialPeriod) throws LimaException {
ClosedPeriodicEntryBook closedPeriodicEntryBook = null;
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't get closed periodic", ex);
}
return closedPeriodicEntryBook;
@@ -273,11 +210,10 @@
List<ClosedPeriodicEntryBook> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO
- = LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
+ = getDaoHelper().getClosedPeriodicEntryBookDAO();
//Get closedperiodicentrybook from unlocked fiscalperiod
TopiaQuery query = closedPeriodicEntryBookDAO.createQuery("E");
@@ -303,9 +239,7 @@
//call query
result = closedPeriodicEntryBookDAO.findAllByQuery(query);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get closed periodics", ex);
}
return result;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -43,7 +43,6 @@
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
@@ -52,6 +51,8 @@
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
@@ -63,26 +64,19 @@
@Stateless
@Remote(FinancialStatementService.class)
@Local(FinancialStatementServiceLocal.class)
+@TransactionAttribute
public class FinancialStatementServiceImpl extends AbstractLimaService implements FinancialStatementService, FinancialStatementServiceLocal {
- private TopiaContext rootContext;
-
@EJB
private ReportServiceLocal reportServiceLocal;
- public FinancialStatementServiceImpl() {
- rootContext = acquireRootContext();
- }
-
@Override
- public void createFinancialStatementWithTransaction(FinancialStatement masterFinancialStatement,
- FinancialStatement financialStatement,
- TopiaContext topiaContext) throws LimaException {
+ public void createFinancialStatement(FinancialStatement masterFinancialStatement,
+ FinancialStatement financialStatement) throws LimaException {
try {
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
financialStatementDAO.create(financialStatement);
@@ -97,37 +91,18 @@
financialStatementDAO.update(masterfinancialStatementUpdate);
}
- commitTransaction(topiaContext);
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't create financial statement", ex);
}
}
@Override
- public void createFinancialStatement(FinancialStatement masterFinancialStatement,
- FinancialStatement financialStatement) throws LimaException {
-
- TopiaContext transaction = beginTransaction(rootContext);
- try {
- createFinancialStatementWithTransaction(masterFinancialStatement, financialStatement, transaction);
- } catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
- }
- }
-
-
- @Override
public void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
try {
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(transaction);
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
-
// remove financialstatement
FinancialStatement financialStatementToDelete =
financialStatementDAO.findByTopiaId(
@@ -149,17 +124,11 @@
}
}
- //commit
- commitTransaction(transaction);
-
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't remove financial statement", ex);
}
}
-
@Override
public void removeAllFinancialStatement() throws LimaException {
for (FinancialStatement financialStatement : getChildrenFinancialStatement(null)) {
@@ -170,15 +139,12 @@
@Override
public List<FinancialStatement> getAllFinancialStatements() throws LimaException {
List<FinancialStatement> financialStatements = null;
- TopiaContext transaction = beginTransaction(rootContext);
+
try {
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(transaction);
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
financialStatements = financialStatementDAO.findAll();
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get financial statements", ex);
}
return financialStatements;
}
@@ -195,25 +161,20 @@
return result;
}
-
@Override
public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) throws LimaException {
List<FinancialStatement> financialStatements = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(transaction);
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
TopiaQuery query = financialStatementDAO.createQuery();
query.addEquals(FinancialStatement.PROPERTY_MASTER_FINANCIAL_STATEMENT, masterFinancialStatement)
.addOrder(FinancialStatement.TOPIA_CREATE_DATE);
financialStatements = financialStatementDAO.findAllByQuery(query);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get childreen statements", ex);
}
return financialStatements;
}
@@ -221,40 +182,34 @@
@Override
public void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
- try {
+ try {
// DAO
- FinancialStatementDAO financialStatementHeaderDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(transaction);
+ FinancialStatementDAO financialStatementHeaderDAO = getDaoHelper().getFinancialStatementDAO();
//update
financialStatementHeaderDAO.update(financialStatement);
- //commit
- commitTransaction(transaction);
+
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't update financial statement", ex);
}
}
- /** remote methode to get list of financial statement */
+ /**
+ * remote methode to get list of financial statement
+ */
@Override
public List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate,
Date selectedEndDate) throws LimaException {
List<FinancialStatementAmounts> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
+
try {
//create list form tree
result = financialStatementReport(null, selectedBeginDate,
- selectedEndDate, new FinancialStatementDatasImpl(),
- transaction).getListResult();
+ selectedEndDate, new FinancialStatementDatasImpl()).getListResult();
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't generate report", ex);
}
return result;
}
@@ -270,107 +225,104 @@
* @return
* @throws LimaException
*/
- public FinancialStatementDatas financialStatementReport(FinancialStatement financialStatement,
+ protected FinancialStatementDatas financialStatementReport(FinancialStatement financialStatement,
Date selectedBeginDate,
Date selectedEndDate,
- FinancialStatementDatas result,
- TopiaContext topiaContext) throws LimaException {
+ FinancialStatementDatas result) throws LimaException {
List<FinancialStatement> financialStatements =
getChildrenFinancialStatement(financialStatement);
- try {
- BigDecimal grossAmount = new BigDecimal(0),
- provisionDeprecationAmount = new BigDecimal(0);
- List<FinancialStatementAmounts> subResult =
- new ArrayList<FinancialStatementAmounts>();
- for (FinancialStatement subFinancialStatement : financialStatements) {
- FinancialStatementAmounts financialStatementAmounts =
- financialStatementAmounts(subFinancialStatement,
- selectedBeginDate, selectedEndDate, topiaContext);
- if (!subFinancialStatement.getHeader()) {
- //on calcul
- grossAmount =
- grossAmount.add(financialStatementAmounts.getGrossAmount());
- provisionDeprecationAmount = provisionDeprecationAmount.add(
- financialStatementAmounts.getProvisionDeprecationAmount());
- subResult.add(financialStatementAmounts);
- } else {
- FinancialStatementDatas financialStatementDatas =
- financialStatementReport(subFinancialStatement,
- selectedBeginDate, selectedEndDate, result, topiaContext);
- grossAmount = grossAmount.add(financialStatementDatas.
- getFinancialStatementAmounts().getGrossAmount());
- provisionDeprecationAmount = provisionDeprecationAmount.
- add(financialStatementDatas.getFinancialStatementAmounts().
- getProvisionDeprecationAmount());
+ BigDecimal grossAmount = new BigDecimal(0),
+ provisionDeprecationAmount = new BigDecimal(0);
+ List<FinancialStatementAmounts> subResult =
+ new ArrayList<FinancialStatementAmounts>();
+ for (FinancialStatement subFinancialStatement : financialStatements) {
+ FinancialStatementAmounts financialStatementAmounts =
+ financialStatementAmounts(subFinancialStatement,
+ selectedBeginDate, selectedEndDate);
+ if (!subFinancialStatement.getHeader()) {
+ //on calcul
+ grossAmount =
+ grossAmount.add(financialStatementAmounts.getGrossAmount());
+ provisionDeprecationAmount = provisionDeprecationAmount.add(
+ financialStatementAmounts.getProvisionDeprecationAmount());
+ subResult.add(financialStatementAmounts);
+ } else {
+ FinancialStatementDatas financialStatementDatas =
+ financialStatementReport(subFinancialStatement,
+ selectedBeginDate, selectedEndDate, result);
+ grossAmount = grossAmount.add(financialStatementDatas.
+ getFinancialStatementAmounts().getGrossAmount());
+ provisionDeprecationAmount = provisionDeprecationAmount.
+ add(financialStatementDatas.getFinancialStatementAmounts().
+ getProvisionDeprecationAmount());
- FinancialStatementAmounts headerfinancialStatementAmounts =
- financialStatementDatas.getFinancialStatementAmounts();
- //Si sous-total
- if (subFinancialStatement.getSubAmount()) {
- FinancialStatementAmounts header =
- new FinancialStatementAmountsImpl();
- header.setLabel(headerfinancialStatementAmounts.getLabel());
- header.setLevel(headerfinancialStatementAmounts.getLevel());
- header.setHeader(true);
- //ajoute header
- subResult.add(header);
- //ajoute liste
- if (financialStatementDatas.getListResult() != null) {
- subResult.addAll(financialStatementDatas.getListResult());
- }
- //ajoute sstotal
- FinancialStatementAmounts subAmount =
- new FinancialStatementAmountsImpl();
- subAmount.setLabel(
- "TOTAL " + headerfinancialStatementAmounts.getLabel());
- subAmount.setLevel(
- headerfinancialStatementAmounts.getLevel());
- subAmount.setGrossAmount(
- headerfinancialStatementAmounts.getGrossAmount());
- subAmount.setProvisionDeprecationAmount(
- headerfinancialStatementAmounts.
- getProvisionDeprecationAmount());
- subAmount.setSubAmount(true);
- subResult.add(subAmount);
- //ajoute une ligne vide
- subResult.add(new FinancialStatementAmountsImpl());
- }//sinon
- else {
-
- if (subFinancialStatement.getHeaderAmount()) {
- subResult.add(headerfinancialStatementAmounts);
- } else {
+ FinancialStatementAmounts headerfinancialStatementAmounts =
+ financialStatementDatas.getFinancialStatementAmounts();
+ //Si sous-total
+ if (subFinancialStatement.getSubAmount()) {
+ FinancialStatementAmounts header =
+ new FinancialStatementAmountsImpl();
+ header.setLabel(headerfinancialStatementAmounts.getLabel());
+ header.setLevel(headerfinancialStatementAmounts.getLevel());
+ header.setHeader(true);
+ //ajoute header
+ subResult.add(header);
+ //ajoute liste
+ if (financialStatementDatas.getListResult() != null) {
+ subResult.addAll(financialStatementDatas.getListResult());
+ }
+ //ajoute sstotal
+ FinancialStatementAmounts subAmount =
+ new FinancialStatementAmountsImpl();
+ subAmount.setLabel(
+ "TOTAL " + headerfinancialStatementAmounts.getLabel());
+ subAmount.setLevel(
+ headerfinancialStatementAmounts.getLevel());
+ subAmount.setGrossAmount(
+ headerfinancialStatementAmounts.getGrossAmount());
+ subAmount.setProvisionDeprecationAmount(
headerfinancialStatementAmounts.
- setGrossAmount(new BigDecimal(0));
- headerfinancialStatementAmounts.
- setProvisionDeprecationAmount(new BigDecimal(0));
- subResult.add(headerfinancialStatementAmounts);
- }
- //ajoute liste
- if (financialStatementDatas.getListResult() != null) {
- subResult.addAll(financialStatementDatas.getListResult());
- }
+ getProvisionDeprecationAmount());
+ subAmount.setSubAmount(true);
+ subResult.add(subAmount);
+ //ajoute une ligne vide
+ subResult.add(new FinancialStatementAmountsImpl());
+
+ }//sinon
+ else {
+
+ if (subFinancialStatement.getHeaderAmount()) {
+ subResult.add(headerfinancialStatementAmounts);
+ } else {
+ headerfinancialStatementAmounts.
+ setGrossAmount(new BigDecimal(0));
+ headerfinancialStatementAmounts.
+ setProvisionDeprecationAmount(new BigDecimal(0));
+ subResult.add(headerfinancialStatementAmounts);
}
+ //ajoute liste
+ if (financialStatementDatas.getListResult() != null) {
+ subResult.addAll(financialStatementDatas.getListResult());
+ }
}
}
- FinancialStatementAmounts financialStatementAmounts =
- new FinancialStatementAmountsImpl();
- financialStatementAmounts.setGrossAmount(grossAmount);
- financialStatementAmounts.setProvisionDeprecationAmount(
- provisionDeprecationAmount);
- if (financialStatement != null) {
- financialStatementAmounts.setLabel(financialStatement.getLabel());
- financialStatementAmounts.setHeader(financialStatement.getHeader());
- financialStatementAmounts.setLevel(financialStatement.getLevel());
- }
- result.setFinancialStatementAmounts(financialStatementAmounts);
- result.setListResult(subResult);
- } catch (LimaException eee) {
- doCatch(topiaContext, eee);
}
+ FinancialStatementAmounts financialStatementAmounts =
+ new FinancialStatementAmountsImpl();
+ financialStatementAmounts.setGrossAmount(grossAmount);
+ financialStatementAmounts.setProvisionDeprecationAmount(
+ provisionDeprecationAmount);
+ if (financialStatement != null) {
+ financialStatementAmounts.setLabel(financialStatement.getLabel());
+ financialStatementAmounts.setHeader(financialStatement.getHeader());
+ financialStatementAmounts.setLevel(financialStatement.getLevel());
+ }
+ result.setFinancialStatementAmounts(financialStatementAmounts);
+ result.setListResult(subResult);
+
return result;
}
@@ -385,10 +337,9 @@
* @return
* @throws LimaException
*/
- public FinancialStatementAmounts financialStatementAmounts(FinancialStatement financialStatement,
+ protected FinancialStatementAmounts financialStatementAmounts(FinancialStatement financialStatement,
Date selectedBeginDate,
- Date selectedEndDate,
- TopiaContext topiaContext) throws LimaException {
+ Date selectedEndDate) throws LimaException {
FinancialStatementAmounts financialStatementAmounts =
new FinancialStatementAmountsImpl();
BigDecimal amount = new BigDecimal(0);
@@ -409,7 +360,7 @@
String accountsString = financialStatement.getAccounts();
if (accountsString != null && !accountsString.equals("")) {
amounts = amountFromAccountList(accountsString,
- selectedBeginDate, selectedEndDate, topiaContext);
+ selectedBeginDate, selectedEndDate);
debitAmount = debitAmount.add(amounts.getDebit());
creditAmount = creditAmount.add(amounts.getCredit());
}
@@ -417,14 +368,14 @@
String debitAccountsString = financialStatement.getDebitAccounts();
if (debitAccountsString != null && !debitAccountsString.equals("")) {
amounts = amountFromAccountList(debitAccountsString,
- selectedBeginDate, selectedEndDate, topiaContext);
+ selectedBeginDate, selectedEndDate);
debitAmount = debitAmount.add(amounts.getDebit());
}
//CREDIT ACCOUNTS LIST
String creditAccountsString = financialStatement.getCreditAccounts();
if (creditAccountsString != null && !creditAccountsString.equals("")) {
amounts = amountFromAccountList(creditAccountsString,
- selectedBeginDate, selectedEndDate, topiaContext);
+ selectedBeginDate, selectedEndDate);
creditAmount = creditAmount.add(amounts.getCredit());
}
// PROVISION & DEPRECATION
@@ -433,7 +384,7 @@
if (provisionDeprecationAccountsString != null && !provisionDeprecationAccountsString.equals("")) {
amounts = amountFromAccountList(
provisionDeprecationAccountsString, selectedBeginDate,
- selectedEndDate, topiaContext);
+ selectedEndDate);
provisionDeprecationAmount =
provisionDeprecationAmount.add(amounts.getCredit());
provisionDeprecationAmount =
@@ -464,17 +415,15 @@
return financialStatementAmounts;
}
-
- public Amounts amountFromAccountList(String accountsNumberList,
+ protected Amounts amountFromAccountList(String accountsNumberList,
Date selectedBeginDate,
- Date selectedEndDate,
- TopiaContext topiaContext) throws LimaException {
+ Date selectedEndDate) throws LimaException {
Amounts amounts = new AmountsImpl();
BigDecimal debit = new BigDecimal(0);
BigDecimal credit = new BigDecimal(0);
Boolean substract = false;
try {
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
//Remove Spaces
String result = StringUtils.deleteWhitespace(accountsNumberList);
StringTokenizer stQuote = new StringTokenizer(result, "-");
@@ -485,8 +434,8 @@
BigDecimal creditTemp = new BigDecimal(0);
for (Account account : accountsList) {
ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(account, true,
- selectedBeginDate, selectedEndDate, topiaContext);
+ generateAccountsReports(account, true,
+ selectedBeginDate, selectedEndDate);
if (reportsDatas.getSoldeDebit()) {
debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
} else {
@@ -506,25 +455,22 @@
}
amounts.setCredit(credit);
amounts.setDebit(debit);
- } catch (TopiaException e) {
- doCatch(topiaContext, e);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't get accounts from list", ex);
}
return amounts;
}
-
@Override
public String checkFinancialStatementChart() throws LimaException {
StringBuilder result =
new StringBuilder(_("lima-business.financialstatement.check.warn"));
- TopiaContext transaction = null;
+
try {
- transaction = beginTransaction(rootContext);
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(transaction);
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(transaction);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
+
List<Account> accountsList = accountDAO.findAllLeafAccounts();
List<FinancialStatement> financialStatementsList =
@@ -557,18 +503,14 @@
}
} catch (TopiaException ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't check financial statement", ex);
}
return result.toString();
}
- public List<FinancialStatement> findFinancialStatementByAccountNumber(String accountNumber,
- TopiaContext topiaContext) throws TopiaException {
+ protected List<FinancialStatement> findFinancialStatementByAccountNumber(String accountNumber) throws TopiaException {
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
TopiaQuery query = financialStatementDAO.createQuery();
String accountProperty =
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -34,13 +34,14 @@
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
import org.chorem.lima.FinancialStatementWayEnum;
import org.chorem.lima.beans.FinancialTransactionSearch;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.api.EntryBookServiceLocal;
+import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FinancialTransactionServiceLocal;
@@ -52,7 +53,6 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
@@ -74,10 +74,9 @@
@Stateless
@Remote(FinancialTransactionService.class)
@Local(FinancialTransactionServiceLocal.class)
+@TransactionAttribute
public class FinancialTransactionServiceImpl extends AbstractLimaService implements FinancialTransactionService, FinancialTransactionServiceLocal {
- private TopiaContext rootContext;
-
@EJB
protected FinancialPeriodServiceLocal financialPeriodService;
@@ -85,88 +84,67 @@
protected ReportServiceLocal reportService;
@EJB
- protected EntryBookServiceLocal entryBookService;
+ protected EntryBookService entryBookService;
@EJB
protected OptionsServiceLocal optionsService;
- public FinancialTransactionServiceImpl() {
- rootContext = acquireRootContext();
- }
-
@Override
- public FinancialTransaction createFinancialTransactionWithTransaction(
- FinancialTransaction financialtransaction, TopiaContext topiaContext)
+ public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
throws LimaException {
FinancialTransaction fTransaction = null;
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
//check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- financialtransaction, topiaContext);
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
- FinancialTransactionDAO financialtransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ FinancialTransactionDAO financialtransactionDAO = getDaoHelper().getFinancialTransactionDAO();
fTransaction = financialtransactionDAO.create(financialtransaction);
- commitTransaction(topiaContext);
-
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't create financial transaction", ex);
}
return fTransaction;
}
- /** Permet de créer une transaction comptable contenant des entrées */
+ /**
+ * Return the list of all financial transaction from two dates.
+ */
@Override
- public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
-
- TopiaContext topiaContext = beginTransaction(rootContext);
- try {
- return createFinancialTransactionWithTransaction(financialtransaction, topiaContext);
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
- }
- return null;
- }
-
- /** Return the list of all financial transaction from two dates */
- @Override
public List<FinancialTransaction> getAllFinancialTransactions(
Date beginDate, Date endDate) throws LimaException {
List<FinancialTransaction> financialTransactions = null;
- TopiaContext topiaTransaction = beginTransaction(rootContext);
+
try {
- FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO();
financialTransactions = transactionDAO.findAllByDates(beginDate, endDate);
} catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
+ throw new LimaException("Can't get financial transactions", ex);
}
return financialTransactions;
}
- /** Return the list of all financial transaction of a financial period */
+ /**
+ * Return the list of all financial transaction of a financial period.
+ */
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
FinancialPeriod period) throws LimaException {
return getAllFinancialTransactions(period, null);
}
- /** Return the list of all financial transaction of a financial period and an entrybook */
+ /**
+ * Return the list of all financial transaction of a financial period and an entrybook.
+ */
@Override
public List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod financialPeriod, EntryBook entryBook) throws LimaException {
List<FinancialTransaction> financialTransactions = null;
- TopiaContext topiaTransaction = beginTransaction(rootContext);
+
try {
- FinancialTransactionDAO transactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO();
if (entryBook != null) {
financialTransactions = transactionDAO.findAllByDates(financialPeriod.getBeginDate(),
@@ -177,26 +155,22 @@
}
} catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
+ throw new LimaException("Can't get financial transactions", ex);
}
return financialTransactions;
}
-
/**
* Get unbalanced financialtransaction from selected fiscalperiod.
*/
@Override
public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException {
- TopiaContext topiaContext = beginTransaction(rootContext);
+
List<FinancialTransaction> result = null;
List<FinancialTransaction> checkedResult = new ArrayList<FinancialTransaction>();
try {
- FinancialTransactionDAO financialTransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
result = financialTransactionDAO.getAllIncorrectTransaction(fiscalPeriod.getBeginDate(),
fiscalPeriod.getEndDate(), null);
@@ -213,85 +187,43 @@
}
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't get financial transactions", ex);
}
return result;
}
- @Override
- public List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException {
- TopiaContext topiaContext = beginTransaction(rootContext);
- List<FinancialTransaction> result = null;
- try {
- result = getAllFinancialTransactionsBalanced(fiscalPeriod, topiaContext);
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
- }
- return result;
- }
-
-
/**
* Get balanced financialtransaction from selected fiscalperiod
*
* @param fiscalPeriod
- * @param topiaContext
* @return
* @throws LimaException
*/
- public List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod,
- TopiaContext topiaContext) throws LimaException {
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException {
List<FinancialTransaction> result = null;
try {
- FinancialTransactionDAO financialTransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
result = financialTransactionDAO.getAllBalancedTransaction(fiscalPeriod.getBeginDate(),
fiscalPeriod.getEndDate(), null);
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't get financial transactions", ex);
}
return result;
}
-
/**
- * update date and amount of a financial transaction
- * call accounting rules
- */
- @Override
- public void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
-
- TopiaContext topiaContext = beginTransaction(rootContext);
- try {
- updateFinancialTransactionWithTransaction(
- financialtransaction, topiaContext);
- commitTransaction(topiaContext);
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
- }
-
- }
-
- /**
* Method used by update entry and remove entry for update amounts.
*/
@Override
- public void updateFinancialTransactionWithTransaction(FinancialTransaction financialtransaction,
- TopiaContext topiaContext) throws LimaException {
+ public void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
- FinancialTransactionDAO transactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO();
FinancialTransaction financialTransactionOld =
transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
@@ -305,7 +237,7 @@
financialtransaction.getEntryBook());
transactionDAO.update(financialTransactionOld);
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't update financial transaction", ex);
}
}
@@ -316,91 +248,59 @@
@Override
public void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
- TopiaContext topiaTransaction = beginTransaction(rootContext);
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
//check if the financial period is blocked
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- financialtransaction, topiaTransaction);
+ financialtransaction);
- FinancialTransactionDAO transactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO();
FinancialTransaction financialTransaction2 =
//patch : conflict object already instanciate
transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
- transactionDAO.delete(financialTransaction2);
- commitTransaction(topiaTransaction);
+
} catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
+ throw new LimaException("Can't remove financial transaction", ex);
}
}
@Override
- public Entry createEntryWithTransaction(Entry entry,
- TopiaContext topiaContext) throws LimaException {
+ public Entry createEntry(Entry entry) throws LimaException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
Entry newEntry = null;
try {
//check if the financial period is blocked
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- entry.getFinancialTransaction(), topiaContext);
+ entry.getFinancialTransaction());
-
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
newEntry = entryDAO.create(entry);
- } catch (TopiaException e) {
- doCatch(topiaContext, e);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't create entry", ex);
}
return newEntry;
}
/**
- * Create new entry
- * the period must not be blocked, call accounting rules
- *
- * @return
+ * update entry, calculate amount of the financial transaction.
*/
@Override
- public Entry createEntry(Entry entry) throws LimaException {
-
- TopiaContext topiaContext = beginTransaction(rootContext);
- try {
-
- Entry newEntry = createEntryWithTransaction(entry, topiaContext);
-
- commitTransaction(topiaContext);
-
- return newEntry;
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
- }
- return null;
- }
-
-
- /** update entry, calculate amount of the financial transaction */
- @Override
public void updateEntry(Entry entry) throws LimaException {
- TopiaContext topiaContext = beginTransaction(rootContext);
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId());
//check rules
- accountingRules.updateEntryRules(entry, entryOld, topiaContext);
+ accountingRules.updateEntryRules(entry, entryOld);
//get new entry amounts
BigDecimal entryAmount = entry.getAmount();
@@ -419,36 +319,31 @@
//update entry
entryDAO.update(entryOld);
- commitTransaction(topiaContext);
+
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't update entry", ex);
}
}
- /** Remove entry, update amounts for the financial transaction */
+ /**
+ * Remove entry, update amounts for the financial transaction.
+ */
@Override
public void removeEntry(Entry entry) throws LimaException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
-
//check if the financial period is blocked
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- entry.getFinancialTransaction(), topiaContext);
+ entry.getFinancialTransaction());
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
//delete
entryDAO.delete(entry);
- //commit
- commitTransaction(topiaContext);
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't remove entry", ex);
}
}
@@ -456,10 +351,9 @@
public List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException {
List<Object> result = new ArrayList<Object>();
List<FinancialTransaction> financialTransactions;
- TopiaContext topiaContext = beginTransaction(rootContext);
+
try {
- FinancialTransactionDAO financialTransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
TopiaQuery query = financialTransactionDAO.createQuery("T");
String dateProperty = TopiaQuery.getProperty(FinancialTransaction.PROPERTY_TRANSACTION_DATE);
@@ -495,7 +389,7 @@
if (account != null) {
query.addEquals("E.account", account);
} else if (accountsList != null) {
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
List<Account> accounts =
accountDAO.stringToListAccounts(accountsList, false);
StringBuffer accountNumbers = new StringBuffer("0,");
@@ -538,7 +432,7 @@
}
financialTransactions = financialTransactionDAO.findAllByQuery(query);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
for (FinancialTransaction financialTransaction : financialTransactions) {
result.add(financialTransaction);
@@ -548,9 +442,7 @@
result.addAll(entries);
}
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't search financial transaction", ex);
}
return result;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -40,6 +40,7 @@
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
import org.apache.commons.lang3.time.DateUtils;
import org.chorem.lima.beans.BalanceTrial;
@@ -49,7 +50,7 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
-import org.chorem.lima.business.api.EntryBookServiceLocal;
+import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
import org.chorem.lima.business.api.FinancialTransactionServiceLocal;
import org.chorem.lima.business.api.FiscalPeriodService;
@@ -67,8 +68,6 @@
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
@@ -81,10 +80,9 @@
@Stateless
@Remote(FiscalPeriodService.class)
@Local(FiscalPeriodServiceLocal.class)
+@TransactionAttribute
public class FiscalPeriodServiceImpl extends AbstractLimaService implements FiscalPeriodService, FiscalPeriodServiceLocal {
- private TopiaContext rootContext;
-
@EJB
protected AccountService accountService;
@@ -92,7 +90,7 @@
protected FinancialPeriodServiceLocal financialPeriodService;
@EJB
- protected EntryBookServiceLocal entryBookService;
+ protected EntryBookService entryBookService;
@EJB
protected ReportServiceLocal reportService;
@@ -100,13 +98,8 @@
@EJB
protected FinancialTransactionServiceLocal financialTransactionService;
- public FiscalPeriodServiceImpl() {
- rootContext = acquireRootContext();
- }
-
@Override
- public FiscalPeriod createFiscalPeriodWithTransaction(FiscalPeriod fiscalPeriod,
- TopiaContext topiaContext) throws LimaException {
+ public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
FiscalPeriod result = null;
@@ -125,82 +118,54 @@
//check rules before create the account
List<FinancialPeriod> financialPeriods =
- accountingRules.createFiscalPeriodRules(fiscalPeriod, topiaContext);
+ accountingRules.createFiscalPeriodRules(fiscalPeriod);
financialPeriodService.
- createFinancialPeriodsWithTransaction(financialPeriods, topiaContext);
+ createFinancialPeriods(financialPeriods);
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
//create
result = fiscalPeriodDAO.create(fiscalPeriod);
-
- commitTransaction(topiaContext);
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't create period", ex);
}
return result;
}
/**
- * To create a fiscalperiod
- * Check localized rules before create
+ * return all fiscal period.
*/
@Override
- public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
-
- TopiaContext transaction = beginTransaction(rootContext);
- FiscalPeriod result = null;
- try {
- result = createFiscalPeriodWithTransaction(fiscalPeriod, transaction);
- } catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
- }
-
- return result;
- }
-
- /** return all fiscal period */
- @Override
public List<FiscalPeriod> getAllFiscalPeriods() throws LimaException {
List<FiscalPeriod> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
result = fiscalPeriodDAO.findAll();
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get periods", ex);
}
return result;
}
- /** return all blocked fiscal periods */
+ /**
+ * return all blocked fiscal periods.
+ */
@Override
public List<FiscalPeriod> getAllBlockedFiscalPeriods() throws LimaException {
List<FiscalPeriod> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
-
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
result = fiscalPeriodDAO.findAllByLocked(true);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't create period", ex);
}
return result;
@@ -213,16 +178,12 @@
List<FiscalPeriod> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
result = fiscalPeriodDAO.findAllByLocked(false);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get periods", ex);
}
return result;
@@ -231,11 +192,10 @@
@Override
public FiscalPeriod getLastFiscalPeriod() throws LimaException {
FiscalPeriod result = null;
- TopiaContext transaction = beginTransaction(rootContext);
+
try {
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
TopiaQuery query = fiscalPeriodDAO.createQuery();
query.addOrderDesc(FiscalPeriod.PROPERTY_END_DATE);
@@ -243,9 +203,7 @@
result = fiscalPeriodDAO.findByQuery(query);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get period", ex);
}
return result;
@@ -258,8 +216,6 @@
*/
@Override
public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
- //open transaction for update
- TopiaContext transaction = beginTransaction(rootContext);
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
@@ -270,10 +226,9 @@
throw new LimaBusinessException(_("lima-business.fiscalperiod.fiscalperiodalreadyblocked"));
}
//check rules
- accountingRules.blockFiscalPeriodRules(fiscalPeriod, transaction);
+ accountingRules.blockFiscalPeriodRules(fiscalPeriod);
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
// Get the old fiscal period instance for no object conflict
FiscalPeriod oldFiscalPeriod =
@@ -288,14 +243,10 @@
result = fiscalPeriodDAO.update(oldFiscalPeriod);
- commitTransaction(transaction);
-
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't block period", ex);
}
-
+
return result;
}
@@ -303,19 +254,28 @@
public void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear,
EntryBook entryBook) throws LimaException {
- TopiaContext topiaContext = beginTransaction(rootContext);
- try {
-
- //sets dates
- // - endRetainedEarnings: last day of the closing year
- // - beginRetainedEarnings: first open day of the following year
+ //sets dates
+ // - endRetainedEarnings: last day of the closing year
+ // - beginRetainedEarnings: first open day of the following year
// Date endRetainedEarnings = fiscalPeriod.getBeginDate();
// Date beginRetainedEarnings = null;
- //Sets entryBook
- //search for the entryBook to use using param
- boolean found = false;
- List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
+ //Sets entryBook
+ //search for the entryBook to use using param
+ boolean found = false;
+ List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
+ for (EntryBook entry : entryBooksList) {
+ if (!found && entry.getCode().equals(entryBook.getCode())
+ && entry.getLabel().equals(entryBook.getLabel())) {
+ entryBook = entry;
+ found = true;
+ }
+ }
+ //if entrybook isn't found
+ //then create it
+ if (!found) {
+ entryBookService.createEntryBook(entryBook);
+ entryBooksList = entryBookService.getAllEntryBooks();
for (EntryBook entry : entryBooksList) {
if (!found && entry.getCode().equals(entryBook.getCode())
&& entry.getLabel().equals(entryBook.getLabel())) {
@@ -323,191 +283,167 @@
found = true;
}
}
- //if entrybook isn't found
- //then create it
- if (!found) {
- entryBookService.createEntryBook(entryBook);
- entryBooksList = entryBookService.getAllEntryBooks();
- for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode())
- && entry.getLabel().equals(entryBook.getLabel())) {
- entryBook = entry;
- found = true;
- }
- }
- }
+ }
- //Sets accounts, check if they exist, if not create them
- //-> 8 COMPTES SPECIAUX
- // -> 89 BILAN
- // -> 890 Bilan d'ouverture
- // -> 891 Bilan de cloture
+ //Sets accounts, check if they exist, if not create them
+ //-> 8 COMPTES SPECIAUX
+ // -> 89 BILAN
+ // -> 890 Bilan d'ouverture
+ // -> 891 Bilan de cloture
- //89 BILAN
- Account accountMaster = accountService.getAccountByNumber("89");
- if (accountMaster == null) {
- accountMaster = new AccountImpl();
- accountMaster.setAccountNumber("89");
- accountMaster.setLabel("BILAN");
- accountService.createAccount(accountMaster);
- accountMaster = accountService.getAccountByNumber("89");
- }
+ //89 BILAN
+ Account accountMaster = accountService.getAccountByNumber("89");
+ if (accountMaster == null) {
+ accountMaster = new AccountImpl();
+ accountMaster.setAccountNumber("89");
+ accountMaster.setLabel("BILAN");
+ accountService.createAccount(accountMaster);
+ accountMaster = accountService.getAccountByNumber("89");
+ }
- //890 Bilan d'ouverture
- Account beginRetainedAccount = accountService.getAccountByNumber("890");
- if (beginRetainedAccount == null) {
- beginRetainedAccount = new AccountImpl();
- beginRetainedAccount.setAccountNumber("890");
- beginRetainedAccount.setLabel("Bilan d'ouverture");
- accountService.createAccount(beginRetainedAccount);
- beginRetainedAccount = accountService.getAccountByNumber("890");
- }
+ //890 Bilan d'ouverture
+ Account beginRetainedAccount = accountService.getAccountByNumber("890");
+ if (beginRetainedAccount == null) {
+ beginRetainedAccount = new AccountImpl();
+ beginRetainedAccount.setAccountNumber("890");
+ beginRetainedAccount.setLabel("Bilan d'ouverture");
+ accountService.createAccount(beginRetainedAccount);
+ beginRetainedAccount = accountService.getAccountByNumber("890");
+ }
- //891 Bilan de cloture
- Account endRetainedAccount = accountService.getAccountByNumber("891");
- if (endRetainedAccount == null) {
- endRetainedAccount = new AccountImpl();
- endRetainedAccount.setAccountNumber("891");
- endRetainedAccount.setLabel("Bilan de clôture");
- accountService.createAccount(endRetainedAccount);
- endRetainedAccount = accountService.getAccountByNumber("891");
- }
+ //891 Bilan de cloture
+ Account endRetainedAccount = accountService.getAccountByNumber("891");
+ if (endRetainedAccount == null) {
+ endRetainedAccount = new AccountImpl();
+ endRetainedAccount.setAccountNumber("891");
+ endRetainedAccount.setLabel("Bilan de clôture");
+ accountService.createAccount(endRetainedAccount);
+ endRetainedAccount = accountService.getAccountByNumber("891");
+ }
- //look for the last financial period from the previous fiscal year
- Collection<FinancialPeriod> fperiod = fiscalPeriod.getFinancialPeriod();
+ //look for the last financial period from the previous fiscal year
+ Collection<FinancialPeriod> fperiod = fiscalPeriod.getFinancialPeriod();
- Iterator<FinancialPeriod> itr = fperiod.iterator();
- FinancialPeriod lastFPeriod = null;
- while (itr.hasNext()) {
- lastFPeriod = itr.next();
- }
- //check if the last financial period isn't blocked
- if (lastFPeriod.getLocked()) {
- throw new LimaBusinessException(_("lima-business.fiscalperiod.previousfiscalperiodalreadyblocked"));
- }
+ Iterator<FinancialPeriod> itr = fperiod.iterator();
+ FinancialPeriod lastFPeriod = null;
+ while (itr.hasNext()) {
+ lastFPeriod = itr.next();
+ }
+ //check if the last financial period isn't blocked
+ if (lastFPeriod.getLocked()) {
+ throw new LimaBusinessException(_("lima-business.fiscalperiod.previousfiscalperiodalreadyblocked"));
+ }
- FinancialPeriod beginfinancialPeriod = null;
- //settings to be done only if a new year exists
- if (newyear) {
- //look for the first financial period on the new fiscal year which is unlocked
- found = false;
- List<ClosedPeriodicEntryBook> resultsArray =
- new ArrayList<ClosedPeriodicEntryBook>();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBook =
- financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- Collections.sort(closedPeriodicEntryBook, new FinancialPeriodComparator());
- resultsArray.addAll(closedPeriodicEntryBook);
- for (ClosedPeriodicEntryBook cPeriodicEntryBook : resultsArray) {
- //check for - unlocked financial period
- // - date after the closing fiscal year
- // - unlocked entrybook
- // - right code and label
- if (!found && !cPeriodicEntryBook.getFinancialPeriod().getLocked()
- && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(fiscalPeriod.getEndDate())
- && !cPeriodicEntryBook.getLocked()
- && cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode())
- && cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) {
- found = true;
- beginfinancialPeriod = cPeriodicEntryBook.getFinancialPeriod();
- }
+ FinancialPeriod beginfinancialPeriod = null;
+ //settings to be done only if a new year exists
+ if (newyear) {
+ //look for the first financial period on the new fiscal year which is unlocked
+ found = false;
+ List<ClosedPeriodicEntryBook> resultsArray =
+ new ArrayList<ClosedPeriodicEntryBook>();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBook =
+ financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
+ Collections.sort(closedPeriodicEntryBook, new FinancialPeriodComparator());
+ resultsArray.addAll(closedPeriodicEntryBook);
+ for (ClosedPeriodicEntryBook cPeriodicEntryBook : resultsArray) {
+ //check for - unlocked financial period
+ // - date after the closing fiscal year
+ // - unlocked entrybook
+ // - right code and label
+ if (!found && !cPeriodicEntryBook.getFinancialPeriod().getLocked()
+ && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(fiscalPeriod.getEndDate())
+ && !cPeriodicEntryBook.getLocked()
+ && cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode())
+ && cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) {
+ found = true;
+ beginfinancialPeriod = cPeriodicEntryBook.getFinancialPeriod();
}
- if (!found) {
- throw new LimaBusinessException(_("lima-business.fiscalperiod.newfinancialperioderror"));
- }
}
+ if (!found) {
+ throw new LimaBusinessException(_("lima-business.fiscalperiod.newfinancialperioderror"));
+ }
+ }
- //holds entries of all closing transactions
- FinancialTransaction endfinancialTransaction = new FinancialTransactionImpl();
- if (lastFPeriod != null) {
+ //holds entries of all closing transactions
+ FinancialTransaction endfinancialTransaction = new FinancialTransactionImpl();
+ if (lastFPeriod != null) {
+ //Sets the endfinancialTransaction
+ endfinancialTransaction.setEntryBook(entryBook);
+ endfinancialTransaction.setTransactionDate(fiscalPeriod.getEndDate());
+ financialTransactionService.createFinancialTransaction(endfinancialTransaction);
+ }
+
+ //holds entries of all opening transactions
+ FinancialTransaction beginfinancialTransaction = new FinancialTransactionImpl();
+ if (newyear) {
+ if (found) {
//Sets the endfinancialTransaction
- endfinancialTransaction.setEntryBook(entryBook);
- endfinancialTransaction.setTransactionDate(fiscalPeriod.getEndDate());
- financialTransactionService.createFinancialTransaction(endfinancialTransaction);
+ beginfinancialTransaction.setEntryBook(entryBook);
+ beginfinancialTransaction.setTransactionDate(beginfinancialPeriod.getBeginDate());
+ financialTransactionService.createFinancialTransaction(beginfinancialTransaction);
}
+ }
- //holds entries of all opening transactions
- FinancialTransaction beginfinancialTransaction = new FinancialTransactionImpl();
- if (newyear) {
- if (found) {
- //Sets the endfinancialTransaction
- beginfinancialTransaction.setEntryBook(entryBook);
- beginfinancialTransaction.setTransactionDate(beginfinancialPeriod.getBeginDate());
- financialTransactionService.createFinancialTransaction(beginfinancialTransaction);
- }
- }
+ //Sets date for description, e.g: Report à nouveau (DATE)
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(fiscalPeriod.getEndDate());
- //Sets date for description, e.g: Report à nouveau (DATE)
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(fiscalPeriod.getEndDate());
+ //Sets entries
+ Entry beginEntry;
- //Sets entries
- Entry beginEntry;
+ BalanceTrial results = reportService.generateBalanceTrial(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), null, false, false);
- BalanceTrial results = reportService.generateBalanceTrial(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), null, false, false);
+ List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
- List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
+ //check if at least one transaction has been reported
+ boolean transaction = false;
- //check if at least one transaction has been reported
- boolean transaction = false;
-
- for (ReportsDatas report : reportsDatasList) {
- //Account class from 1 to 5 and only non zero amount
- if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6
- && !report.getAmountSolde().equals(BigDecimal.ZERO)) {
- transaction = true;
- //close accounts by removing amounts from all class 1 to 5 accounts
+ for (ReportsDatas report : reportsDatasList) {
+ //Account class from 1 to 5 and only non zero amount
+ if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6
+ && !report.getAmountSolde().equals(BigDecimal.ZERO)) {
+ transaction = true;
+ //close accounts by removing amounts from all class 1 to 5 accounts
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(endfinancialTransaction);
+ beginEntry.setAccount(report.getAccount());
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(!report.getSoldeDebit());
+ financialTransactionService.createEntry(beginEntry);
+ //save amounts inside account number 891
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(endfinancialTransaction);
+ beginEntry.setAccount(endRetainedAccount);
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(report.getSoldeDebit());
+ financialTransactionService.createEntry(beginEntry);
+ //open new year accounts if new year exists and a date has been found for the transaction
+ if (newyear && found) {
+ //give back amounts from class 1 to 5 accounts
beginEntry = new EntryImpl();
beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(endfinancialTransaction);
+ beginEntry.setFinancialTransaction(beginfinancialTransaction);
beginEntry.setAccount(report.getAccount());
beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(!report.getSoldeDebit());
- financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
- //save amounts inside account number 891
+ beginEntry.setDebit(report.getSoldeDebit());
+ financialTransactionService.createEntry(beginEntry);
+ //close account by removing amount from account number 890
beginEntry = new EntryImpl();
beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(endfinancialTransaction);
+ beginEntry.setFinancialTransaction(beginfinancialTransaction);
beginEntry.setAccount(endRetainedAccount);
beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(report.getSoldeDebit());
- financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
- //open new year accounts if new year exists and a date has been found for the transaction
- if (newyear && found) {
- //give back amounts from class 1 to 5 accounts
- beginEntry = new EntryImpl();
- beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
- beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(beginfinancialTransaction);
- beginEntry.setAccount(report.getAccount());
- beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(report.getSoldeDebit());
- financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
- //close account by removing amount from account number 890
- beginEntry = new EntryImpl();
- beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
- beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- beginEntry.setFinancialTransaction(beginfinancialTransaction);
- beginEntry.setAccount(endRetainedAccount);
- beginEntry.setAmount(report.getAmountSolde().abs());
- beginEntry.setDebit(!report.getSoldeDebit());
- financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
- }
+ beginEntry.setDebit(!report.getSoldeDebit());
+ financialTransactionService.createEntry(beginEntry);
}
}
- //if no transaction has been reported
- if (!transaction) {
- topiaContext.rollbackTransaction();
- //if no problem appeared, commit
- } else {
- commitTransaction(topiaContext);
- }
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -45,6 +45,7 @@
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -64,6 +65,7 @@
@Stateless
@Remote(HttpServerService.class)
@Local(HttpServerServiceLocal.class)
+@TransactionAttribute
public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService, HttpServerServiceLocal {
@EJB
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -31,88 +31,51 @@
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.IdentityDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import java.util.List;
@Stateless
@Remote(IdentityService.class)
@Local(IdentityServiceLocal.class)
+@TransactionAttribute
public class IdentityServiceImpl extends AbstractLimaService implements IdentityService, IdentityServiceLocal {
- private TopiaContext rootContext;
-
- public IdentityServiceImpl() {
- rootContext = acquireRootContext();
- }
-
@Override
- public Identity getIdentityWithTransaction(TopiaContext topiaContext)
+ public Identity getIdentity()
throws LimaException {
Identity identity = null;
try {
- IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext);
+ IdentityDAO identityDAO = getDaoHelper().getIdentityDAO();
List<Identity> identities = identityDAO.findAll();
if (identities.size() != 0) {
identity = identities.get(0);
}
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't get identity", ex);
}
return identity;
}
@Override
- public Identity getIdentity() throws LimaException {
- TopiaContext topiaContext = beginTransaction(rootContext);
- Identity identity = null;
+ public void updateIdentity(Identity identity) throws LimaException {
try {
-
- identity = getIdentityWithTransaction(topiaContext);
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
- }
- return identity;
- }
-
-
- @Override
- public void updateIdentityWithTransaction(Identity identity,
- TopiaContext topiaContext) throws LimaException {
- try {
- IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(topiaContext);
+ IdentityDAO identityDAO = getDaoHelper().getIdentityDAO();
List<Identity> identities = identityDAO.findAll();
if (identities.size() != 0) {
identityDAO.delete(identities.get(0));
}
identityDAO.create(identity);
- commitTransaction(topiaContext);
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't update identity", ex);
}
}
- @Override
- public void updateIdentity(Identity identity) throws LimaException {
- TopiaContext topiaContext = beginTransaction(rootContext);
- try {
-
- updateIdentityWithTransaction(identity, topiaContext);
-
- commitTransaction(topiaContext);
- } catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
- }
- }
-
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -49,9 +49,8 @@
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.exceptions.COSVisitorException;
@@ -76,7 +75,7 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
-import org.chorem.lima.business.api.EntryBookServiceLocal;
+import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodServiceLocal;
import org.chorem.lima.business.api.FinancialStatementServiceLocal;
import org.chorem.lima.business.api.FinancialTransactionServiceLocal;
@@ -84,7 +83,7 @@
import org.chorem.lima.business.api.IdentityServiceLocal;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.ImportServiceLocal;
-import org.chorem.lima.business.api.VatStatementServiceLocal;
+import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.business.utils.AccountEBPComparator;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryEBPComparator;
@@ -118,7 +117,6 @@
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementDAO;
import org.chorem.lima.entity.VatStatementImpl;
-import org.hsqldb.lib.ArrayUtil;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -133,12 +131,11 @@
@Stateless
@Remote(ImportService.class)
@Local(ImportServiceLocal.class)
+@TransactionAttribute
public class ImportServiceImpl extends AbstractLimaService implements ImportService, ImportServiceLocal {
private static final Log log = LogFactory.getLog(ImportServiceImpl.class);
- private TopiaContext rootContext;
-
@EJB
private AccountService accountService;
@@ -155,10 +152,10 @@
private FinancialStatementServiceLocal financialStatementService;
@EJB
- private VatStatementServiceLocal vatStatementService;
+ private VatStatementService vatStatementService;
@EJB
- private EntryBookServiceLocal entryBookService;
+ private EntryBookService entryBookService;
@EJB
private IdentityServiceLocal identityService;
@@ -166,10 +163,6 @@
private static final SimpleDateFormat SDATEFORMAT = new SimpleDateFormat(
"dd,MM,yyyy HH:mm:ss");
- public ImportServiceImpl() {
- rootContext = acquireRootContext();
- }
-
// ################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
@Override
@@ -180,7 +173,6 @@
SimpleDateFormat epbDateFormat = new SimpleDateFormat("dd/MM/yyyy");
StringBuilder result = new StringBuilder();
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
CSVReader csvReader = new CSVReader(new StringReader(datas));
ColumnPositionMappingStrategy<EntryEBPImpl> strat = new ColumnPositionMappingStrategy<EntryEBPImpl>();
@@ -209,15 +201,12 @@
Collections.sort(list, new EntryEBPComparator());
// DAOs
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods();
Collections.sort(fiscalPeriods, new FiscalPeriodComparator());
int nbFiscalPeriods = fiscalPeriods.size();
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper
- .getFinancialPeriodDAO(topiaContext);
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
if (nbFiscalPeriods == 0) {
throw new LimaBusinessException(
@@ -283,14 +272,12 @@
financialTransaction.setEntryBook(entryBook);
financialTransaction.setTransactionDate(date);
financialTransactionService
- .createFinancialTransactionWithTransaction(
- financialTransaction, topiaContext);
+ .createFinancialTransaction(financialTransaction);
result.append(_("lima-business.import.transactionadded", date, entryBook.getCode()));
}
financialTransaction.addEntry(entry);
- financialTransactionService.createEntryWithTransaction(
- entry, topiaContext);
+ financialTransactionService.createEntry(entry);
result.append(_("lima-business.import.entryadded", entry.getDescription(), entry.getAmount()));
}
}
@@ -300,12 +287,8 @@
log.info("Imported form EBP : " + list.size() + " entries in " + (after-before) + " ms");
}
- // commit
- commitTransaction(topiaContext);
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't import", ex);
}
return result.toString();
}
@@ -315,7 +298,6 @@
long before = System.currentTimeMillis();
StringBuilder result = new StringBuilder();
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
CSVReader csvReader = new CSVReader(new StringReader(datas));
@@ -340,8 +322,7 @@
List<AccountEBPImpl> list = csv.parse(strat, csvReader);
Collections.sort(list, new AccountEBPComparator());
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
for (AccountEBP accountEBP : list) {
String accountNumber = accountEBP.getNumero();
if (accountDAO.findByAccountNumber(accountNumber) != null) {
@@ -362,9 +343,7 @@
}
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't import", ex);
}
return result.toString();
@@ -375,7 +354,6 @@
long before = System.currentTimeMillis();
StringBuilder result = new StringBuilder();
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
CSVReader csvReader = new CSVReader(new StringReader(datas));
@@ -401,15 +379,15 @@
line = csvReader.readNext();
}
+ csvReader.close();
+
if (log.isInfoEnabled()) {
long after = System.currentTimeMillis();
log.info("Imported form EBP : " + count + " accounts in " + (after-before) + " ms");
}
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't import", ex);
}
return result.toString();
@@ -440,7 +418,6 @@
Map<Integer, List<EntryImport>> entries =
new HashMap<Integer, List<EntryImport>>();
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
String[] nextLine;
@@ -452,65 +429,56 @@
if (importExportEntityEnum != null) {
switch (importExportEntityEnum) {
case ACCOUNT:
- result.append(importAccountsChartsCSV(nextLine,
- topiaContext));
+ result.append(importAccountsChartsCSV(nextLine));
break;
case ENTRYBOOK:
- result.append(importEntryBooksChartCSV(nextLine,
- topiaContext));
+ result.append(importEntryBooksChartCSV(nextLine));
break;
case FINANCIALSTATEMENT:
result.append(importFinancialsStatementChartCSV(nextLine,
- financialStatements, topiaContext));
+ financialStatements));
break;
case VATSTATEMENT:
result.append(importVatStatementChartCSV(nextLine,
- vatStatements, topiaContext));
+ vatStatements));
break;
case FISCALPERIOD:
result.append(importFiscalPeriodCSV(nextLine,
- fiscalPeriods, topiaContext));
+ fiscalPeriods));
break;
case CLOSEDPERIODICENTRYBOOK:
importClosedPeriodicEntryBookCSV(nextLine,
- closedPeriodicEntryBooks, topiaContext);
+ closedPeriodicEntryBooks);
break;
case FINANCIALTRANSACTION:
importFinancialTransactionsCSV(nextLine,
- financialTransactions, topiaContext);
+ financialTransactions);
break;
case ENTRY:
- importEntriesCSV(nextLine, entries, topiaContext);
+ importEntriesCSV(nextLine, entries);
break;
case IDENTITY:
- importIdentity(nextLine, topiaContext);
+ importIdentity(nextLine);
break;
}
}
}
// create financialStatements
- result.append(createFinancialStatements(financialStatements,
- topiaContext));
+ result.append(createFinancialStatements(financialStatements));
// create vatStatements
- result.append(createVatStatements(vatStatements,
- topiaContext));
+ result.append(createVatStatements(vatStatements));
// create fiscalperiod
Collections.sort(fiscalPeriods, new FiscalPeriodComparator());
- result.append(createFiscalPeriod(fiscalPeriods, topiaContext));
+ result.append(createFiscalPeriod(fiscalPeriods));
// update closedperiodicentrybooks
- result.append(updateClosedPeriodicEntryBooks(closedPeriodicEntryBooks,
- topiaContext));
+ result.append(updateClosedPeriodicEntryBooks(closedPeriodicEntryBooks));
// create financialtransaction and entries
result.append(createFinancialTransactionsAndEntries(
- financialTransactions, entries, topiaContext));
+ financialTransactions, entries));
- commitTransaction(topiaContext);
-
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't import", ex);
}
return result.toString();
}
@@ -538,7 +506,6 @@
break;
}
- TopiaContext topiaContext = beginTransaction(rootContext);
try {
String[] nextLine;
@@ -548,19 +515,18 @@
if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == importExportEntityEnum) {
switch (importExportEntityEnum) {
case ENTRYBOOK:
- result.append(importEntryBooksChartCSV(nextLine, topiaContext));
+ result.append(importEntryBooksChartCSV(nextLine));
break;
case ACCOUNT:
- result.append(importAccountsChartsCSV(nextLine,
- topiaContext));
+ result.append(importAccountsChartsCSV(nextLine));
break;
case FINANCIALSTATEMENT:
result.append(importFinancialsStatementChartCSV(nextLine,
- financialStatements, topiaContext));
+ financialStatements));
break;
case VATSTATEMENT:
result.append(importVatStatementChartCSV(nextLine,
- vatStatements, topiaContext));
+ vatStatements));
break;
}
}
@@ -569,19 +535,15 @@
//create entity
switch (importExportEntityEnum) {
case FINANCIALSTATEMENT:
- result.append(createFinancialStatements(financialStatements,
- topiaContext));
+ result.append(createFinancialStatements(financialStatements));
break;
case VATSTATEMENT:
- result.append(createVatStatements(vatStatements,
- topiaContext));
+ result.append(createVatStatements(vatStatements));
break;
}
} catch (Exception ex) {
- doCatch(topiaContext, ex);
- } finally {
- doFinally(topiaContext);
+ throw new LimaException("Can't import", ex);
}
return result.toString();
}
@@ -646,38 +608,34 @@
* @param topiaContext
* @return
* @throws LimaException
+ * @throws TopiaException
*/
- protected String importAccountsChartsCSV(String[] nextLine,
- TopiaContext topiaContext)
- throws LimaException {
+ protected String importAccountsChartsCSV(String[] nextLine)
+ throws LimaException, TopiaException {
StringBuilder result = new StringBuilder();
String accountNumber = nextLine[1];
String label = nextLine[2];
String thirdParty = nextLine[3];
- try {
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
- // if not exist, create it
- if (accountDAO.findByAccountNumber(accountNumber) == null) {
+ // if not exist, create it
+ if (accountDAO.findByAccountNumber(accountNumber) == null) {
- Account account = new AccountImpl();
- account.setAccountNumber(accountNumber);
- account.setLabel(label);
- account.setThirdParty(thirdParty);
+ Account account = new AccountImpl();
+ account.setAccountNumber(accountNumber);
+ account.setLabel(label);
+ account.setThirdParty(thirdParty);
- accountDAO.create(account);
- result.append(_("lima-business.import.accountadded",
- account.getAccountNumber(),
- account.getLabel()));
- } else {
- result.append(_("lima-business.import.accountalreadyexist", accountNumber));
- }
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ accountDAO.create(account);
+ result.append(_("lima-business.import.accountadded",
+ account.getAccountNumber(),
+ account.getLabel()));
+ } else {
+ result.append(_("lima-business.import.accountalreadyexist", accountNumber));
}
+
return result.toString();
}
@@ -689,35 +647,30 @@
* @param fiscalPeriods
* @param topiaContext
* @return
- * @throws LimaException
+ * @throws ParseException
+ * @throws TopiaException
*/
protected String importFiscalPeriodCSV(String[] nextLine,
- List<FiscalPeriod> fiscalPeriods,
- TopiaContext topiaContext)
- throws LimaException {
+ List<FiscalPeriod> fiscalPeriods)
+ throws ParseException, TopiaException {
StringBuilder result = new StringBuilder();
- try {
- FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper
- .getFiscalPeriodDAO(topiaContext);
- FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
- Date beginDate = SDATEFORMAT.parse(nextLine[1]);
- fiscalPeriod.setBeginDate(beginDate);
- Date endDate = SDATEFORMAT.parse(nextLine[2]);
- fiscalPeriod.setEndDate(endDate);
- fiscalPeriod.setLocked(Boolean.parseBoolean(nextLine[3]));
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
- // if not exist, skip
- if (fiscalPeriodDAO.findByNaturalId(beginDate, endDate) == null) {
- fiscalPeriods.add(fiscalPeriod);
- } else {
- result.append(_("lima-business.import.fiscalperiodalreadyexist", beginDate, endDate));
- }
- } catch (ParseException ex) {
- log.error("Can't parse date", ex);
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
+ Date beginDate = SDATEFORMAT.parse(nextLine[1]);
+ fiscalPeriod.setBeginDate(beginDate);
+ Date endDate = SDATEFORMAT.parse(nextLine[2]);
+ fiscalPeriod.setEndDate(endDate);
+ fiscalPeriod.setLocked(Boolean.parseBoolean(nextLine[3]));
+
+ // if not exist, skip
+ if (fiscalPeriodDAO.findByNaturalId(beginDate, endDate) == null) {
+ fiscalPeriods.add(fiscalPeriod);
+ } else {
+ result.append(_("lima-business.import.fiscalperiodalreadyexist", beginDate, endDate));
}
+
return result.toString();
}
@@ -727,30 +680,27 @@
* @param nextLine
* @param topiaContext
* @return
- * @throws LimaException
+ * @throws TopiaException
+ * @throws LimaException
*/
- protected String importEntryBooksChartCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ protected String importEntryBooksChartCSV(String[] nextLine) throws TopiaException, LimaException {
StringBuilder result = new StringBuilder();
- try {
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
- EntryBook entryBook = new EntryBookImpl();
- entryBook.setCode(nextLine[1]);
- entryBook.setLabel(nextLine[2]);
+ EntryBook entryBook = new EntryBookImpl();
+ entryBook.setCode(nextLine[1]);
+ entryBook.setLabel(nextLine[2]);
- // if exist, skip
- if (entryBookDAO.findByCode(entryBook.getCode()) != null) {
- result.append(_("lima-business.import.entrybookalreadyexist", entryBook.getLabel()));
- } else {
- // create it
- entryBookService.createEntryBook(entryBook);
- result.append(_("lima-business.import.financialstatementadded", entryBook.getLabel()));
- }
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ // if exist, skip
+ if (entryBookDAO.findByCode(entryBook.getCode()) != null) {
+ result.append(_("lima-business.import.entrybookalreadyexist", entryBook.getLabel()));
+ } else {
+ // create it
+ entryBookService.createEntryBook(entryBook);
+ result.append(_("lima-business.import.financialstatementadded", entryBook.getLabel()));
}
+
return result.toString();
}
@@ -764,8 +714,7 @@
* @throws LimaException
*/
protected void importClosedPeriodicEntryBookCSV(String[] nextLine,
- List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks,
- TopiaContext topiaContext) throws LimaException {
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) throws LimaException {
String locked = nextLine[1];
String beginDate = nextLine[2];
String endDate = nextLine[3];
@@ -794,10 +743,10 @@
* @param topiaContext
* @return
* @throws LimaException
+ * @throws TopiaException
*/
protected String importFinancialsStatementChartCSV(String[] nextLine,
- LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements,
- TopiaContext topiaContext) throws LimaException {
+ LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements) throws LimaException, TopiaException {
StringBuilder result = new StringBuilder();
String label = nextLine[1];
@@ -811,41 +760,37 @@
String masterFinancialStatement = nextLine[9];
String financialStatementWay = nextLine[10];
- try {
- FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper
- .getFinancialStatementDAO(topiaContext);
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
- // if exist, skip
- if (financialStatementDAO.findByLabel(label) == null) {
- // create it
- FinancialStatementImport financialStatementImport = new FinancialStatementImportImpl();
- financialStatementImport.setLabel(label);
- financialStatementImport.setHeader(header);
- financialStatementImport.setAccounts(accounts);
- financialStatementImport.setCreditAccounts(creditAccounts);
- financialStatementImport.setDebitAccounts(debitAccounts);
- financialStatementImport.setHeaderAmount(headerAmount);
- financialStatementImport
- .setProvisionDeprecationAccounts(provisionDeprecationAccounts);
- financialStatementImport.setSubAmount(subAmount);
- financialStatementImport
- .setMasterFinancialStatement(masterFinancialStatement);
- financialStatementImport.setWay(financialStatementWay);
+ // if exist, skip
+ if (financialStatementDAO.findByLabel(label) == null) {
+ // create it
+ FinancialStatementImport financialStatementImport = new FinancialStatementImportImpl();
+ financialStatementImport.setLabel(label);
+ financialStatementImport.setHeader(header);
+ financialStatementImport.setAccounts(accounts);
+ financialStatementImport.setCreditAccounts(creditAccounts);
+ financialStatementImport.setDebitAccounts(debitAccounts);
+ financialStatementImport.setHeaderAmount(headerAmount);
+ financialStatementImport
+ .setProvisionDeprecationAccounts(provisionDeprecationAccounts);
+ financialStatementImport.setSubAmount(subAmount);
+ financialStatementImport
+ .setMasterFinancialStatement(masterFinancialStatement);
+ financialStatementImport.setWay(financialStatementWay);
- // put it in hashlinkedlist
- if (financialStatements.containsKey(label)) {
- financialStatements.get(label).add(financialStatementImport);
- } else {
- List<FinancialStatementImport> list = new ArrayList<FinancialStatementImport>();
- list.add(financialStatementImport);
- financialStatements.put(label, (ArrayList<FinancialStatementImport>) list);
- }
+ // put it in hashlinkedlist
+ if (financialStatements.containsKey(label)) {
+ financialStatements.get(label).add(financialStatementImport);
} else {
- result.append(_("lima-business.import.financialstatementalreadyexist", label));
+ List<FinancialStatementImport> list = new ArrayList<FinancialStatementImport>();
+ list.add(financialStatementImport);
+ financialStatements.put(label, (ArrayList<FinancialStatementImport>) list);
}
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ } else {
+ result.append(_("lima-business.import.financialstatementalreadyexist", label));
}
+
return result.toString();
}
@@ -859,10 +804,10 @@
* @param topiaContext
* @return
* @throws LimaException
+ * @throws TopiaException
*/
protected String importVatStatementChartCSV(String[] nextLine,
- Map<String, ArrayList<VatStatementImport>> vatStatements,
- TopiaContext topiaContext) throws LimaException {
+ Map<String, ArrayList<VatStatementImport>> vatStatements) throws LimaException, TopiaException {
StringBuilder result = new StringBuilder();
@@ -872,35 +817,30 @@
String accounts = nextLine[4];
String masterVatStatement = nextLine[5];
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
- try {
- VatStatementDAO vatStatementDAO = LimaCallaoDAOHelper
- .getVatStatementDAO(topiaContext);
+ // if exist, skip
+ if (vatStatementDAO.findByLabel(label) == null) {
+ // create it
+ VatStatementImport vatStatementImport = new VatStatementImportImpl();
+ vatStatementImport.setLabel(label);
+ vatStatementImport.setBoxName(boxName);
+ vatStatementImport.setHeader(header);
+ vatStatementImport.setAccounts(accounts);
+ vatStatementImport.setMasterVatStatement(masterVatStatement);
- // if exist, skip
- if (vatStatementDAO.findByLabel(label) == null) {
- // create it
- VatStatementImport vatStatementImport = new VatStatementImportImpl();
- vatStatementImport.setLabel(label);
- vatStatementImport.setBoxName(boxName);
- vatStatementImport.setHeader(header);
- vatStatementImport.setAccounts(accounts);
- vatStatementImport.setMasterVatStatement(masterVatStatement);
-
- // put it in hashlinkedlist
- if (vatStatements.containsKey(label)) {
- vatStatements.get(label).add(vatStatementImport);
- } else {
- List<VatStatementImport> list = new ArrayList<VatStatementImport>();
- list.add(vatStatementImport);
- vatStatements.put(label, (ArrayList<VatStatementImport>) list);
- }
+ // put it in hashlinkedlist
+ if (vatStatements.containsKey(label)) {
+ vatStatements.get(label).add(vatStatementImport);
} else {
- result.append(_("lima-business.import.vatstatementalreadyexist", label));
+ List<VatStatementImport> list = new ArrayList<VatStatementImport>();
+ list.add(vatStatementImport);
+ vatStatements.put(label, (ArrayList<VatStatementImport>) list);
}
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ } else {
+ result.append(_("lima-business.import.vatstatementalreadyexist", label));
}
+
return result.toString();
}
@@ -916,8 +856,7 @@
* @throws LimaException
*/
protected void importFinancialTransactionsCSV(String[] nextLine,
- Map<Integer, FinancialTransactionImport> financialTransactions,
- TopiaContext topiaContext) throws LimaException {
+ Map<Integer, FinancialTransactionImport> financialTransactions) throws LimaException {
int num = new Integer(nextLine[1]);
FinancialTransactionImport financialTransactionImport = new FinancialTransactionImportImpl();
financialTransactionImport.setDate(nextLine[2]);
@@ -940,8 +879,7 @@
* @throws LimaException
*/
protected void importEntriesCSV(String[] nextLine,
- Map<Integer, List<EntryImport>> entries,
- TopiaContext topiaContext) throws LimaException {
+ Map<Integer, List<EntryImport>> entries) throws LimaException {
int num = new Integer(nextLine[1]);
EntryImport entryImport = new EntryImportImpl();
@@ -967,170 +905,159 @@
// ################ CREATE ENTITY IN DB FOR IMPORT ################
/**
+ * @throws TopiaException
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
- protected String createFinancialStatements(Map<String, ArrayList<FinancialStatementImport>> financialStatements,
- TopiaContext topiaContext) throws LimaException {
+ protected String createFinancialStatements(Map<String, ArrayList<FinancialStatementImport>> financialStatements) throws LimaException, TopiaException {
StringBuilder result = new StringBuilder();
- try {
- FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper
- .getFinancialStatementDAO(topiaContext);
+ FinancialStatementDAO financialStatementDAO = getDaoHelper().getFinancialStatementDAO();
- while (financialStatements.size() > 0) {
- for (Iterator<ArrayList<FinancialStatementImport>> itr = financialStatements
- .values().iterator(); itr.hasNext(); ) {
- List<FinancialStatementImport> financialStatementImports =
- itr.next();
+ while (financialStatements.size() > 0) {
+ for (Iterator<ArrayList<FinancialStatementImport>> itr = financialStatements
+ .values().iterator(); itr.hasNext(); ) {
+ List<FinancialStatementImport> financialStatementImports =
+ itr.next();
- for (Iterator<FinancialStatementImport> itr2 = financialStatementImports.iterator(); itr2.hasNext(); ) {
- FinancialStatementImport financialStatementImport =
- itr2.next();
- String masterFinancialStatementLabel = financialStatementImport
- .getMasterFinancialStatement();
- FinancialStatement masterFinancialStatement = financialStatementDAO
- .findByLabel(masterFinancialStatementLabel);
+ for (Iterator<FinancialStatementImport> itr2 = financialStatementImports.iterator(); itr2.hasNext(); ) {
+ FinancialStatementImport financialStatementImport =
+ itr2.next();
+ String masterFinancialStatementLabel = financialStatementImport
+ .getMasterFinancialStatement();
+ FinancialStatement masterFinancialStatement = financialStatementDAO
+ .findByLabel(masterFinancialStatementLabel);
- if (masterFinancialStatementLabel.equals("")
- || masterFinancialStatement != null) {
- // create it
- FinancialStatement financialStatement = new FinancialStatementImpl();
- financialStatement.setLabel(financialStatementImport
- .getLabel());
- financialStatement.setHeader(Boolean
- .parseBoolean(financialStatementImport
- .getHeader()));
- financialStatement.setAccounts(financialStatementImport
- .getAccounts());
- financialStatement
- .setDebitAccounts(financialStatementImport
- .getDebitAccounts());
- financialStatement
- .setCreditAccounts(financialStatementImport
- .getCreditAccounts());
- financialStatement
- .setProvisionDeprecationAccounts(financialStatementImport
- .getProvisionDeprecationAccounts());
- financialStatement.setSubAmount(Boolean
- .parseBoolean(financialStatementImport
- .getSubAmount()));
- financialStatement.setHeaderAmount(Boolean
- .parseBoolean(financialStatementImport
- .getHeaderAmount()));
- String financialStatementWay = financialStatementImport.getWay();
- if (!financialStatementWay.equals("")) {
- FinancialStatementWayEnum financialStatementWayEnum =
- FinancialStatementWayEnum.valueOf(financialStatementWay);
- financialStatement.setWay(financialStatementWayEnum);
- }
+ if (masterFinancialStatementLabel.equals("")
+ || masterFinancialStatement != null) {
+ // create it
+ FinancialStatement financialStatement = new FinancialStatementImpl();
+ financialStatement.setLabel(financialStatementImport
+ .getLabel());
+ financialStatement.setHeader(Boolean
+ .parseBoolean(financialStatementImport
+ .getHeader()));
+ financialStatement.setAccounts(financialStatementImport
+ .getAccounts());
+ financialStatement
+ .setDebitAccounts(financialStatementImport
+ .getDebitAccounts());
+ financialStatement
+ .setCreditAccounts(financialStatementImport
+ .getCreditAccounts());
+ financialStatement
+ .setProvisionDeprecationAccounts(financialStatementImport
+ .getProvisionDeprecationAccounts());
+ financialStatement.setSubAmount(Boolean
+ .parseBoolean(financialStatementImport
+ .getSubAmount()));
+ financialStatement.setHeaderAmount(Boolean
+ .parseBoolean(financialStatementImport
+ .getHeaderAmount()));
+ String financialStatementWay = financialStatementImport.getWay();
+ if (!financialStatementWay.equals("")) {
+ FinancialStatementWayEnum financialStatementWayEnum =
+ FinancialStatementWayEnum.valueOf(financialStatementWay);
+ financialStatement.setWay(financialStatementWayEnum);
+ }
- financialStatementService
- .createFinancialStatementWithTransaction(
- masterFinancialStatement,
- financialStatement, topiaContext);
+ financialStatementService
+ .createFinancialStatement(
+ masterFinancialStatement,
+ financialStatement);
- result.append(_("lima-business.import.financialstatementadded",
- financialStatementImport.getLabel()));
+ result.append(_("lima-business.import.financialstatementadded",
+ financialStatementImport.getLabel()));
- itr2.remove();
- } else if (!financialStatements
- .containsKey(masterFinancialStatementLabel)) {
- result.append(_("lima-business.import.financialstatementalnomaster",
- financialStatementImport.getLabel(),
- masterFinancialStatementLabel));
- itr2.remove();
- }
+ itr2.remove();
+ } else if (!financialStatements
+ .containsKey(masterFinancialStatementLabel)) {
+ result.append(_("lima-business.import.financialstatementalnomaster",
+ financialStatementImport.getLabel(),
+ masterFinancialStatementLabel));
+ itr2.remove();
}
- if (financialStatementImports.isEmpty()) {
- itr.remove();
- }
}
+ if (financialStatementImports.isEmpty()) {
+ itr.remove();
+ }
}
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
}
return result.toString();
}
/**
+ * @throws TopiaException
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
- protected String createVatStatements(Map<String, ArrayList<VatStatementImport>> vatStatements,
- TopiaContext topiaContext) throws LimaException {
+ protected String createVatStatements(Map<String, ArrayList<VatStatementImport>> vatStatements) throws LimaException, TopiaException {
StringBuilder result = new StringBuilder();
- try {
- VatStatementDAO vatStatementDAO = LimaCallaoDAOHelper
- .getVatStatementDAO(topiaContext);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
- while (vatStatements.size() > 0) {
- for (Iterator<ArrayList<VatStatementImport>> itr = vatStatements
- .values().iterator(); itr.hasNext(); ) {
- List<VatStatementImport> vatStatementImports =
- itr.next();
+ while (vatStatements.size() > 0) {
+ for (Iterator<ArrayList<VatStatementImport>> itr = vatStatements
+ .values().iterator(); itr.hasNext(); ) {
+ List<VatStatementImport> vatStatementImports =
+ itr.next();
- for (Iterator<VatStatementImport> itr2 = vatStatementImports.iterator(); itr2.hasNext(); ) {
- VatStatementImport vatStatementImport =
- itr2.next();
- String masterVatStatementLabel = vatStatementImport
- .getMasterVatStatement();
- VatStatement masterVatStatement = vatStatementDAO
- .findByLabel(masterVatStatementLabel);
+ for (Iterator<VatStatementImport> itr2 = vatStatementImports.iterator(); itr2.hasNext(); ) {
+ VatStatementImport vatStatementImport =
+ itr2.next();
+ String masterVatStatementLabel = vatStatementImport
+ .getMasterVatStatement();
+ VatStatement masterVatStatement = vatStatementDAO
+ .findByLabel(masterVatStatementLabel);
- if (masterVatStatementLabel.equals("")
- || masterVatStatement != null) {
- // create it
- VatStatement vatStatement = new VatStatementImpl();
- vatStatement.setBoxName(vatStatementImport
- .getBoxName());
- vatStatement.setLabel(vatStatementImport
- .getLabel());
- vatStatement.setAccounts(vatStatementImport
- .getAccounts());
- vatStatement.setHeader(Boolean
- .parseBoolean(vatStatementImport
- .getHeader()));
+ if (masterVatStatementLabel.equals("")
+ || masterVatStatement != null) {
+ // create it
+ VatStatement vatStatement = new VatStatementImpl();
+ vatStatement.setBoxName(vatStatementImport
+ .getBoxName());
+ vatStatement.setLabel(vatStatementImport
+ .getLabel());
+ vatStatement.setAccounts(vatStatementImport
+ .getAccounts());
+ vatStatement.setHeader(Boolean
+ .parseBoolean(vatStatementImport
+ .getHeader()));
- vatStatementService
- .createVatStatementWithTransaction(
- masterVatStatement,
- vatStatement, topiaContext);
+ vatStatementService
+ .createVatStatement(
+ masterVatStatement,
+ vatStatement);
- result.append(_("lima-business.import.vatstatementadded",
- vatStatementImport.getLabel()));
+ result.append(_("lima-business.import.vatstatementadded",
+ vatStatementImport.getLabel()));
- itr2.remove();
- } else if (!vatStatements
- .containsKey(masterVatStatementLabel)) {
- result.append(_("lima-business.import.vatstatementalnomaster",
- vatStatementImport.getLabel(),
- masterVatStatementLabel));
- itr2.remove();
- }
+ itr2.remove();
+ } else if (!vatStatements
+ .containsKey(masterVatStatementLabel)) {
+ result.append(_("lima-business.import.vatstatementalnomaster",
+ vatStatementImport.getLabel(),
+ masterVatStatementLabel));
+ itr2.remove();
}
- if (vatStatementImports.isEmpty()) {
- itr.remove();
- }
}
+ if (vatStatementImports.isEmpty()) {
+ itr.remove();
+ }
}
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
}
+
return result.toString();
}
- protected String createFiscalPeriod(List<FiscalPeriod> fiscalPeriods,
- TopiaContext topiaContext) {
+ protected String createFiscalPeriod(List<FiscalPeriod> fiscalPeriods) {
StringBuilder result = new StringBuilder();
for (FiscalPeriod fiscalPeriod : fiscalPeriods) {
// create fiscalPeriod
try {
- fiscalPeriodService.createFiscalPeriodWithTransaction(
- fiscalPeriod, topiaContext);
+ fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
result.append(_("lima-business.import.fiscalperiodadded",
fiscalPeriod.getBeginDate(),
fiscalPeriod.getEndDate()));
@@ -1142,122 +1069,108 @@
}
/**
+ * @throws ParseException
+ * @throws TopiaException
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
protected String updateClosedPeriodicEntryBooks(
- List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks,
- TopiaContext topiaContext) throws LimaException {
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) throws LimaException, ParseException, TopiaException {
StringBuilder result = new StringBuilder();
- try {
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper
- .getFinancialPeriodDAO(topiaContext);
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = LimaCallaoDAOHelper
- .getClosedPeriodicEntryBookDAO(topiaContext);
- for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) {
- // update closedPeriodicEntryBook
- Date beginDateFinancialPeriod = SDATEFORMAT
- .parse(closedPeriodicEntryBookImport
- .getBeginDateFinancialPeriod());
- Date endDateFinancialPeriod = SDATEFORMAT
- .parse(closedPeriodicEntryBookImport
- .getEndDateFinancialPeriod());
- FinancialPeriod financialPeriod = financialPeriodDAO
- .findByNaturalId(beginDateFinancialPeriod,
- endDateFinancialPeriod);
- String codeEntryBook = closedPeriodicEntryBookImport
- .getCodeEntryBook();
- EntryBook entryBook = entryBookDAO.findByCode(codeEntryBook);
- ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookDAO
- .findByEntryBookAndFinancialPeriod(entryBook,
- financialPeriod);
- try {
- financialPeriodService
- .blockClosedPeriodicEntryBookWithTransaction(
- closedPeriodicEntryBook, topiaContext);
- result.append(_("lima-business.import.closedperiodicentrybookupdated",
- beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook));
- } catch (LimaException eee) {
- result.append(_("lima-business.common.failed", eee));
- }
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
+ for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) {
+ // update closedPeriodicEntryBook
+ Date beginDateFinancialPeriod = SDATEFORMAT
+ .parse(closedPeriodicEntryBookImport
+ .getBeginDateFinancialPeriod());
+ Date endDateFinancialPeriod = SDATEFORMAT
+ .parse(closedPeriodicEntryBookImport
+ .getEndDateFinancialPeriod());
+ FinancialPeriod financialPeriod = financialPeriodDAO
+ .findByNaturalId(beginDateFinancialPeriod,
+ endDateFinancialPeriod);
+ String codeEntryBook = closedPeriodicEntryBookImport
+ .getCodeEntryBook();
+ EntryBook entryBook = entryBookDAO.findByCode(codeEntryBook);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookDAO
+ .findByEntryBookAndFinancialPeriod(entryBook,
+ financialPeriod);
+ try {
+ financialPeriodService
+ .blockClosedPeriodicEntryBook(
+ closedPeriodicEntryBook);
+ result.append(_("lima-business.import.closedperiodicentrybookupdated",
+ beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook));
+ } catch (LimaException eee) {
+ result.append(_("lima-business.common.failed", eee));
}
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
- } catch (ParseException ex) {
- log.error("Can't parse date", ex);
}
+
return result.toString();
}
/**
+ * @throws ParseException
+ * @throws TopiaException
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
protected String createFinancialTransactionsAndEntries(
Map<Integer, FinancialTransactionImport> financialTransactions,
- Map<Integer, List<EntryImport>> entries, TopiaContext topiaContext)
- throws LimaException {
+ Map<Integer, List<EntryImport>> entries)
+ throws LimaException, ParseException, TopiaException {
StringBuilder result = new StringBuilder();
- try {
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper
- .getFinancialPeriodDAO(topiaContext);
- FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper
- .getFinancialTransactionDAO(topiaContext);
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- for (Map.Entry<Integer, FinancialTransactionImport> map : financialTransactions
- .entrySet()) {
- FinancialTransactionImport financialTransactionImport = map
- .getValue();
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- Date dateFinancialTransaction = SDATEFORMAT
- .parse(financialTransactionImport.getDate());
- financialTransaction
- .setTransactionDate(dateFinancialTransaction);
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
+ FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
- EntryBook entryBook = entryBookDAO
- .findByCode(financialTransactionImport
- .getCodeEntryBook());
- financialTransaction.setEntryBook(entryBook);
+ for (Map.Entry<Integer, FinancialTransactionImport> map : financialTransactions
+ .entrySet()) {
+ FinancialTransactionImport financialTransactionImport = map
+ .getValue();
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ Date dateFinancialTransaction = SDATEFORMAT
+ .parse(financialTransactionImport.getDate());
+ financialTransaction
+ .setTransactionDate(dateFinancialTransaction);
- financialTransactionDAO.create(financialTransaction);
+ EntryBook entryBook = entryBookDAO
+ .findByCode(financialTransactionImport
+ .getCodeEntryBook());
+ financialTransaction.setEntryBook(entryBook);
- List<EntryImport> entryImports = entries.get(map.getKey());
- for (EntryImport entryImport : entryImports) {
- Entry entry = new EntryImpl();
- Account account = accountDAO
- .findByAccountNumber(entryImport.getAccount());
- entry.setAccount(account);
- entry.setDescription(entryImport.getDescription());
- entry.setAmount(new BigDecimal(entryImport.getAmount()));
- entry.setDebit(Boolean.parseBoolean(entryImport.getDebit()));
+ financialTransactionDAO.create(financialTransaction);
- entry.setLettering(entryImport.getLettering());
+ List<EntryImport> entryImports = entries.get(map.getKey());
+ for (EntryImport entryImport : entryImports) {
+ Entry entry = new EntryImpl();
+ Account account = accountDAO
+ .findByAccountNumber(entryImport.getAccount());
+ entry.setAccount(account);
+ entry.setDescription(entryImport.getDescription());
+ entry.setAmount(new BigDecimal(entryImport.getAmount()));
+ entry.setDebit(Boolean.parseBoolean(entryImport.getDebit()));
- entry.setDetail(entryImport.getDetail());
- entry.setVoucher(entryImport.getVoucher());
- entry.setPosition(entryImport.getPosition());
- entryDAO.create(entry);
- financialTransaction.addEntry(entry);
- }
+ entry.setLettering(entryImport.getLettering());
+
+ entry.setDetail(entryImport.getDetail());
+ entry.setVoucher(entryImport.getVoucher());
+ entry.setPosition(entryImport.getPosition());
+ entryDAO.create(entry);
+ financialTransaction.addEntry(entry);
}
- } catch (TopiaException ex) {
- doCatch(topiaContext, ex);
- } catch (ParseException ex) {
- log.error("Can't parse date", ex);
}
+
return result.toString();
}
- protected String importIdentity(String[] nextLine,
- TopiaContext topiaContext) throws LimaException {
+ protected String importIdentity(String[] nextLine) throws LimaException {
StringBuilder result = new StringBuilder();
Identity identity = new IdentityImpl();
@@ -1274,7 +1187,7 @@
identity.setClassificationCode(nextLine[10]);
identity.setBusinessNumber(nextLine[11]);
- identityService.updateIdentityWithTransaction(identity, topiaContext);
+ identityService.updateIdentity(identity);
// create it
result.append(_("lima-business.import.identityadded", identity.getName()));
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-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -34,6 +34,7 @@
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.beans.BalanceTrial;
@@ -51,51 +52,21 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
@Stateless
@Remote(ReportService.class)
@Local(ReportServiceLocal.class)
+@TransactionAttribute
public class ReportServiceImpl extends AbstractLimaService implements ReportService, ReportServiceLocal {
- private TopiaContext rootContext;
-
@EJB
protected FinancialPeriodServiceLocal financialPeriodService;
@EJB
protected AccountService accountService;
- public ReportServiceImpl() {
- rootContext = acquireRootContext();
- }
-
- @Override
- public ReportsDatas generateAccountsReports(Account account,
- Boolean thirdPartAccountsMode,
- Date beginDate,
- Date endDate) throws LimaException {
- ReportsDatas reportsDatas = null;
-
- TopiaContext topiaTransaction = beginTransaction(rootContext);
- try {
- reportsDatas =
- generateAccountReportsWithTransaction(account, thirdPartAccountsMode, beginDate,
- endDate, topiaTransaction);
- } catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
- }
-
- return reportsDatas;
- }
-
/**
* Recursiv
* List entries for a period and an account
@@ -104,56 +75,54 @@
* - 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, TopiaException {
+ public ReportsDatas generateAccountsReports(Account account, Boolean thirdPartAccountsMode,
+ 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<Entry> entries = new ArrayList<Entry>();
- //Get allsubaccounts and thirdParts accounts
- List<Account> accounts = accountService.getAllSubAccounts(account);
-
- // is already subaccount
- // TODO echatellier 20120502 c'est vraiment voulu ?
- // il ne peut pas y avoir de transaction sur des comptes non feuilles ?
- // a verifier, sinon, supprimer la récursion
- if (accounts.size() == 0) {
- reportsDatas = 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());
+ try {
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
+ List<Entry> entries = new ArrayList<Entry>();
+
+ //Get allsubaccounts and thirdParts accounts
+ List<Account> accounts = accountService.getAllSubAccounts(account);
+
+ // is already subaccount
+ // TODO echatellier 20120502 c'est vraiment voulu ?
+ // il ne peut pas y avoir de transaction sur des comptes non feuilles ?
+ // a verifier, sinon, supprimer la récursion
+ if (accounts.size() == 0) {
+ reportsDatas = generateSubAccountReports(account,
+ beginDate, endDate);
}
- //solde = debit - credit
- solde = solde.add(debit);
- solde = solde.subtract(credit);
-
- 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 =
+ generateAccountsReports(subAccount, true, beginDate, endDate);
+ debit = debit.add(subReportsDatas.getAmountDebit());
+ credit = credit.add(subReportsDatas.getAmountCredit());
+ entries.addAll(subReportsDatas.getListEntry());
+ }
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+ reportsDatas.setListEntry(entries);
}
- solde = solde.abs();
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
- reportsDatas.setListEntry(entries);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't generate report", ex);
}
-
return reportsDatas;
}
@@ -169,14 +138,14 @@
* @throws LimaException
* @throws TopiaException
*/
- protected ReportsDatas generateSubAccountReportsWithTransaction(Account account,
- Date beginDate, Date endDate, TopiaContext topiaContext) throws TopiaException {
+ protected ReportsDatas generateSubAccountReports(Account account,
+ Date beginDate, Date endDate) throws TopiaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
// trouve les entrees associées à ca compte entre les date données
List<Entry> listEntries = entryDAO.findAllEntryOfBalancedTransaction(account, beginDate, endDate);
@@ -220,14 +189,14 @@
* Get all entries if true
* @throws TopiaException
*/
- public ReportsDatas generateSubAccountBalanceWithTransaction(Account account,
- Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException, TopiaException {
+ public ReportsDatas generateSubAccountBalance(Account account,
+ Date beginDate, Date endDate, Boolean getEntries) throws LimaException, TopiaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
if (getEntries) {
List<Entry> listEntries = entryDAO.findAllEntryOfBalancedTransaction(account, beginDate, endDate);
@@ -282,9 +251,8 @@
BigDecimal solde = new BigDecimal(0);
// Get all entries with a topia query
- TopiaContext topiaTransaction = beginTransaction(rootContext);
try {
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
List<Entry> entries = entryDAO.findAllEntryOfBalancedTransaction(entryBook, beginDate, endDate);
reportsDatas.setListEntry(entries);
@@ -314,10 +282,8 @@
reportsDatas.setAmountCredit(credit);
reportsDatas.setAmountDebit(debit);
reportsDatas.setAmountSolde(solde);
- } catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't generate report", ex);
}
return reportsDatas;
@@ -345,11 +311,10 @@
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- TopiaContext topiaTransaction = beginTransaction(rootContext);
+
try {
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(topiaTransaction);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
//for each account create a balance sheet with a ReportsDatas
List<Account> accounts;
@@ -366,8 +331,8 @@
}
for (Account account : accounts) {
ReportsDatas reportsDatas =
- generateSubAccountBalanceWithTransaction(account, beginDate,
- endDate, getEntries, topiaTransaction);
+ generateSubAccountBalance(account, beginDate,
+ endDate, getEntries);
reportsDatas.setAccount(account);
BigDecimal amount = reportsDatas.getAmountSolde();
if (amount == null) {
@@ -402,9 +367,7 @@
balanceTrial.setAmountDebit(debit);
balanceTrial.setAmountSolde(solde);
} catch (Exception ex) {
- doCatch(topiaTransaction, ex);
- } finally {
- doFinally(topiaTransaction);
+ throw new LimaException("Can't generate report", ex);
}
return balanceTrial;
@@ -426,11 +389,9 @@
endDate,
selectedAccounts,
true,
- movementedFilter
- );
+ movementedFilter);
}
-
/**
* Generate VAT
*
@@ -440,36 +401,30 @@
@Override
public List<Object> generateVat(FiscalPeriod fiscalPeriod) throws LimaException {
List<Object> list = new ArrayList<Object>();
- if (fiscalPeriod != null) {
- TopiaContext topiaTransaction = beginTransaction(rootContext);
- try {
+ try {
- //lists all accounts
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(topiaTransaction);
- List<Account> accountsList;
- //gets all financial periods from the fiscal period
- List<FinancialPeriod> financialPeriod = financialPeriodService.getFinancialPeriods(
- fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate());
- for (FinancialPeriod fp : financialPeriod) {
- list.add(fp);
- 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(),
- true, false));
- }
+ //lists all accounts
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
+ List<Account> accountsList;
+ //gets all financial periods from the fiscal period
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getFinancialPeriods(
+ fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate());
+ for (FinancialPeriod fp : financialPeriod) {
+ list.add(fp);
+ 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(),
+ true, false));
}
}
- } catch (Exception eee) {
- doCatch(topiaTransaction, eee);
- } finally {
- doFinally(topiaTransaction);
}
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't generate report", ex);
}
return list;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -35,7 +35,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.ReportServiceLocal;
import org.chorem.lima.business.api.VatStatementService;
-import org.chorem.lima.business.api.VatStatementServiceLocal;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -51,6 +50,8 @@
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
@@ -64,27 +65,18 @@
*/
@Stateless
@Remote(VatStatementService.class)
-(a)Local(VatStatementServiceLocal.class)
-public class VatStatementServiceImpl extends AbstractLimaService implements VatStatementService, VatStatementServiceLocal {
+@TransactionAttribute
+public class VatStatementServiceImpl extends AbstractLimaService implements VatStatementService {
- private TopiaContext rootContext;
-
@EJB
private ReportServiceLocal reportServiceLocal;
- public VatStatementServiceImpl() {
- rootContext = acquireRootContext();
- }
-
-
@Override
- public void createVatStatementWithTransaction(VatStatement masterVatStatement,
- VatStatement vatStatement,
- TopiaContext topiaContext) throws LimaException {
+ public void createVatStatement(VatStatement masterVatStatement,
+ VatStatement vatStatement) throws LimaException {
try {
- VatStatementDAO vatStatementDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(topiaContext);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
vatStatementDAO.create(vatStatement);
@@ -99,53 +91,26 @@
vatStatementDAO.update(mastervatStatementUpdate);
}
- commitTransaction(topiaContext);
-
} catch (TopiaException ex) {
- doCatch(topiaContext, ex);
+ throw new LimaException("Can't create vat statement", ex);
}
}
-
@Override
- public void createVatStatement(VatStatement masterVatStatement,
- VatStatement vatStatement) throws LimaException {
-
- TopiaContext transaction = beginTransaction(rootContext);
- try {
-
- createVatStatementWithTransaction(masterVatStatement,
- vatStatement,
- transaction);
- } catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
- }
-
- }
-
-
- @Override
public List<VatStatement> getAllVatStatements() throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
List<VatStatement> vatStatements = null;
try {
- VatStatementDAO vatStatementDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(transaction);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
vatStatements = vatStatementDAO.findAll();
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get vat statements", ex);
}
return vatStatements;
}
-
@Override
public List<VatStatement> getAllChildrenVatStatement(
VatStatement vatStatement, List<VatStatement> result) throws LimaException {
@@ -160,25 +125,20 @@
}
-
@Override
public List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement) throws LimaException {
List<VatStatement> vatStatements = null;
- TopiaContext transaction = beginTransaction(rootContext);
try {
- VatStatementDAO vatStatementDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(transaction);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
TopiaQuery query = vatStatementDAO.createQuery();
query.addEquals("masterVatStatement", masterVatStatement)
.addOrder(VatStatement.TOPIA_CREATE_DATE);
vatStatements = vatStatementDAO.findAllByQuery(query);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't get vat statements", ex);
}
return vatStatements;
@@ -187,22 +147,17 @@
@Override
public void updateVatStatement(VatStatement vatStatement) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
try {
// DAO
- VatStatementDAO vatStatementHeaderDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(transaction);
+ VatStatementDAO vatStatementHeaderDAO = getDaoHelper().getVatStatementDAO();
//update
vatStatementHeaderDAO.update(vatStatement);
- //commit
- commitTransaction(transaction);
} catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ throw new LimaException("Can't update vat statement", ex);
}
}
+ /* TODO echatellier 20120510 unused function
public Amounts amountFromAccountList(String accountsNumberList,
Date selectedBeginDate,
Date selectedEndDate,
@@ -248,24 +203,22 @@
doCatch(topiaContext, e);
}
return amounts;
- }
+ }*/
/**
- * Gives the list of account numbers from a VatStatement
+ * Gives the list of account numbers from a VatStatement.
*
* @param vatStatement
* @param topiaContext
* @return accountNumbersList
* @throws LimaException
*/
- public String findAccountNumberByVatStatement(VatStatement vatStatement,
- TopiaContext topiaContext) throws LimaException {
+ protected String findAccountNumberByVatStatement(VatStatement vatStatement) throws LimaException {
String accountNumbersList = null;
try {
- VatStatementDAO vatStatementDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(topiaContext);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
TopiaQuery query = vatStatementDAO.createQuery();
String labelProperty =
@@ -285,8 +238,8 @@
if (vatStatementsList.size() > 0) {
accountNumbersList = vatStatementsList.get(0).getAccounts();
}
- } catch (TopiaException e) {
- doCatch(topiaContext, e);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't find accountNumber by vatStatement", ex);
}
return accountNumbersList;
}
@@ -295,51 +248,30 @@
public VatStatementAmounts vatStatementAmounts(VatStatement vatStatement,
Date selectedBeginDate,
Date selectedEndDate) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
- VatStatementAmounts vatStatementAmount = new VatStatementAmountsImpl();
- try {
- vatStatementAmount = vatStatementAmounts(vatStatement,
- selectedBeginDate,
- selectedEndDate,
- transaction);
- } catch (Exception e) {
- doCatch(transaction, e);
- } finally {
- doFinally(transaction);
- }
- return vatStatementAmount;
- }
+ VatStatementAmounts vatStatementAmounts = new VatStatementAmountsImpl();
- @Override
- public VatStatementAmounts vatStatementAmounts(VatStatement vatStatement,
- Date selectedBeginDate,
- Date selectedEndDate,
- TopiaContext topiacontext) throws LimaException {
- VatStatementAmounts vatStatementAmounts =
- new VatStatementAmountsImpl();
-
BigDecimal debitTemp = new BigDecimal(0);
BigDecimal creditTemp = new BigDecimal(0);
try {
- String accountNumbersList = findAccountNumberByVatStatement(vatStatement, topiacontext);
+ String accountNumbersList = findAccountNumberByVatStatement(vatStatement);
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiacontext);
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
List<Account> accountsList = accountDAO.stringToListAccounts(accountNumbersList, false);
for (Account account : accountsList) {
ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(account, true,
- selectedBeginDate, selectedEndDate, topiacontext);
+ generateAccountsReports(account, true,
+ selectedBeginDate, selectedEndDate);
if (reportsDatas.getSoldeDebit()) {
debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
} else {
creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
}
}
- } catch (TopiaException e) {
- doCatch(topiacontext, e);
+ } catch (TopiaException ex) {
+ throw new LimaException("Error in vatStatementAmounts", ex);
}
//return debitTemp.subtract(creditTemp).abs();
vatStatementAmounts.setAmount(debitTemp.subtract(creditTemp).abs());
@@ -351,12 +283,10 @@
public VatStatement findVatStatementByString(String label) throws LimaException {
VatStatement vatStatement = new VatStatementImpl();
- TopiaContext transaction = beginTransaction(rootContext);
try {
- VatStatementDAO vatStatementDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(transaction);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
TopiaQuery query = vatStatementDAO.createQuery();
String labelProperty =
@@ -378,29 +308,20 @@
vatStatement = vatStatementsList.get(0);
}
- } catch (Exception e) {
- doCatch(transaction, e);
- } finally {
- doFinally(transaction);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't find vatstatement", ex);
}
return vatStatement;
}
/** remote methode to get list of financial statement */
public List<VatStatementAmounts> vatStatementReport(Date beginDate, Date endDate) throws LimaException {
- List<VatStatementAmounts> result = null;
- TopiaContext transaction = beginTransaction(rootContext);
- try {
- //create list form tree
- VatStatementDatas vatStatementDatas = vatStatementReport(null, beginDate, endDate,
- new VatStatementDatasImpl(),
- transaction);
- result = vatStatementDatas.getListResult();
- } catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
- }
+
+ //create list form tree
+ VatStatementDatas vatStatementDatas = vatStatementReport(null, beginDate, endDate,
+ new VatStatementDatasImpl());
+ List<VatStatementAmounts> result = vatStatementDatas.getListResult();
+
return result;
}
@@ -412,78 +333,72 @@
public VatStatementDatas vatStatementReport(VatStatement vatStatement,
Date selectedBeginDate,
Date selectedEndDate,
- VatStatementDatas result,
- TopiaContext topiaContext) throws LimaException {
+ VatStatementDatas result) throws LimaException {
List<VatStatement> vatStatements =
getChildrenVatStatement(vatStatement);
- try {
- BigDecimal amount = new BigDecimal(0);
- List<VatStatementAmounts> subResult =
- new ArrayList<VatStatementAmounts>();
- for (VatStatement subVatStatement : vatStatements) {
- VatStatementAmounts vatStatementAmounts =
- vatStatementAmounts(subVatStatement,
- selectedBeginDate, selectedEndDate, topiaContext);
- vatStatementAmounts.setLabel(subVatStatement.getLabel());
- if (!subVatStatement.getHeader()) {
- //on calcul
- amount =
- amount.add(vatStatementAmounts.getAmount());
- subResult.add(vatStatementAmounts);
- } else {
- VatStatementDatas vatStatementDatas =
- vatStatementReport(subVatStatement,
- selectedBeginDate, selectedEndDate, result, topiaContext);
- amount = amount.add(vatStatementDatas.
- getVatStatementAmounts().getAmount());
+ BigDecimal amount = new BigDecimal(0);
+ List<VatStatementAmounts> subResult =
+ new ArrayList<VatStatementAmounts>();
+ for (VatStatement subVatStatement : vatStatements) {
+ VatStatementAmounts vatStatementAmounts =
+ vatStatementAmounts(subVatStatement,
+ selectedBeginDate, selectedEndDate);
+ vatStatementAmounts.setLabel(subVatStatement.getLabel());
+ if (!subVatStatement.getHeader()) {
+ //on calcul
+ amount =
+ amount.add(vatStatementAmounts.getAmount());
+ subResult.add(vatStatementAmounts);
+ } else {
+ VatStatementDatas vatStatementDatas =
+ vatStatementReport(subVatStatement,
+ selectedBeginDate, selectedEndDate, result);
+ amount = amount.add(vatStatementDatas.
+ getVatStatementAmounts().getAmount());
- VatStatementAmounts headerVatStatementAmounts =
- vatStatementDatas.getVatStatementAmounts();
- //Si sous-total
- if (subVatStatement.getHeader()) {
- VatStatementAmounts header =
- new VatStatementAmountsImpl();
- header.setLabel(headerVatStatementAmounts.getLabel());
- header.setLevel(headerVatStatementAmounts.getLevel());
- header.setHeader(true);
- //ajoute header
- subResult.add(header);
- //ajoute liste
- if (vatStatementDatas.getListResult() != null) {
- subResult.addAll(vatStatementDatas.getListResult());
- }
- //ajoute une ligne vide
- subResult.add(new VatStatementAmountsImpl());
+ VatStatementAmounts headerVatStatementAmounts =
+ vatStatementDatas.getVatStatementAmounts();
+ //Si sous-total
+ if (subVatStatement.getHeader()) {
+ VatStatementAmounts header =
+ new VatStatementAmountsImpl();
+ header.setLabel(headerVatStatementAmounts.getLabel());
+ header.setLevel(headerVatStatementAmounts.getLevel());
+ header.setHeader(true);
+ //ajoute header
+ subResult.add(header);
+ //ajoute liste
+ if (vatStatementDatas.getListResult() != null) {
+ subResult.addAll(vatStatementDatas.getListResult());
}
+ //ajoute une ligne vide
+ subResult.add(new VatStatementAmountsImpl());
+
}
}
- VatStatementAmounts vatStatementAmounts =
- new VatStatementAmountsImpl();
- vatStatementAmounts.setAmount(amount);
- if (vatStatement != null) {
- vatStatementAmounts.setLabel(vatStatement.getLabel());
- vatStatementAmounts.setHeader(vatStatement.getHeader());
- vatStatementAmounts.setLevel(vatStatement.getLevel());
- }
- result.setVatStatementAmounts(vatStatementAmounts);
- result.setListResult(subResult);
- } catch (LimaException eee) {
- doCatch(topiaContext, eee);
}
+ VatStatementAmounts vatStatementAmounts =
+ new VatStatementAmountsImpl();
+ vatStatementAmounts.setAmount(amount);
+ if (vatStatement != null) {
+ vatStatementAmounts.setLabel(vatStatement.getLabel());
+ vatStatementAmounts.setHeader(vatStatement.getHeader());
+ vatStatementAmounts.setLevel(vatStatement.getLevel());
+ }
+ result.setVatStatementAmounts(vatStatementAmounts);
+ result.setListResult(subResult);
+
return result;
}
@Override
public void removeVatStatement(VatStatement vatStatement) throws LimaException {
- TopiaContext transaction = beginTransaction(rootContext);
try {
- VatStatementDAO vatStatementDAO =
- LimaCallaoDAOHelper.getVatStatementDAO(transaction);
+ VatStatementDAO vatStatementDAO = getDaoHelper().getVatStatementDAO();
-
// remove vatstatement
VatStatement vatStatementToDelete =
vatStatementDAO.findByTopiaId(
@@ -505,13 +420,8 @@
}
}
- //commit
- commitTransaction(transaction);
-
- } catch (Exception ex) {
- doCatch(transaction, ex);
- } finally {
- doFinally(transaction);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't remove vatstatement", ex);
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -66,12 +66,11 @@
* Copier/coller de la methode france.
* Le probleme ici est que le default n'en creer aucune.
*/
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
- super.createFiscalPeriodRules(fiscalPeriod, transaction);
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
try {
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
//Checks if is not the first fiscalperiod to create
if (fiscalPeriodDAO.findAll().size() != 0) {
@@ -124,7 +123,7 @@
loopDate = DateUtils.addMilliseconds(loopDate, 1);
}
} catch (TopiaException ex) {
- doCatch(transaction, ex, log);
+ throw new LimaException("Can't check rule", ex);
}
return financialPeriods;
}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookServiceLocal.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -1,47 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.EntryBook;
-import org.nuiton.topia.TopiaContext;
-
-
-/**
- * Entry book service.
- *
- * @author chatellier
- * @version $Revision$
- * <p/>
- * Last update : $Date$
- * By : $Author$
- */
-
-public interface EntryBookServiceLocal extends EntryBookService {
-
- EntryBook createEntryBookWithTransaction(EntryBook entryBook, TopiaContext topiaContext) throws LimaException;
-
-}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -45,11 +45,5 @@
public interface FinancialPeriodServiceLocal extends FinancialPeriodService {
- void createFinancialPeriodsWithTransaction(List<FinancialPeriod> financialPeriods,
- TopiaContext topiaContext) throws LimaException;
- void blockClosedPeriodicEntryBookWithTransaction(ClosedPeriodicEntryBook closedPeriodicEntryBook,
- TopiaContext topiaContext) throws LimaException;
-
-
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -31,9 +31,5 @@
public interface FinancialStatementServiceLocal extends FinancialStatementService {
- void createFinancialStatementWithTransaction(FinancialStatement masterFinancialStatement,
- FinancialStatement financialStatement,
- TopiaContext topiaContext) throws LimaException;
-
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -42,13 +42,5 @@
public interface FinancialTransactionServiceLocal extends FinancialTransactionService {
- FinancialTransaction createFinancialTransactionWithTransaction(FinancialTransaction financialtransaction,
- TopiaContext topiaContext) throws LimaException;
- void updateFinancialTransactionWithTransaction(FinancialTransaction financialtransaction,
- TopiaContext topiaContext) throws LimaException;
-
- Entry createEntryWithTransaction(Entry entry, TopiaContext topiaContext) throws LimaException;
-
-
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -40,8 +40,5 @@
*/
public interface FiscalPeriodServiceLocal extends FiscalPeriodService {
- FiscalPeriod createFiscalPeriodWithTransaction(FiscalPeriod fiscalPeriod,
- TopiaContext topiaContext) throws LimaException;
-
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -31,9 +31,5 @@
public interface IdentityServiceLocal extends IdentityService {
- void updateIdentityWithTransaction(Identity identity,
- TopiaContext topiaContext) throws LimaException;
- Identity getIdentityWithTransaction(TopiaContext topiaContext) throws LimaException;
-
}
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-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -52,28 +52,4 @@
public interface ReportServiceLocal extends ReportService {
- ReportsDatas generateAccountReportsWithTransaction(Account account,
- Boolean thirdPartAccountsMode,
- Date beginDate,
- Date endDate,
- 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;
}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementServiceLocal.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementServiceLocal.java 2012-05-09 15:37:59 UTC (rev 3408)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementServiceLocal.java 2012-05-11 10:19:53 UTC (rev 3409)
@@ -1,52 +0,0 @@
-/*
- * #%L
- * Lima :: business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2011 CodeLutin
- * %%
- * 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.business.api;
-
-import org.chorem.lima.beans.VatStatementAmounts;
-import org.chorem.lima.beans.VatStatementDatas;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.VatStatement;
-import org.nuiton.topia.TopiaContext;
-
-import java.util.Date;
-
-public interface VatStatementServiceLocal extends VatStatementService {
-
- void createVatStatementWithTransaction(
- VatStatement masterVatStatement, VatStatement vatStatement,
- TopiaContext transaction) throws LimaException;
-
- VatStatementAmounts vatStatementAmounts(VatStatement vatStatement,
- Date selectedBeginDate,
- Date selectedEndDate,
- TopiaContext topiacontext) throws LimaException;
-
- VatStatementDatas vatStatementReport(VatStatement vatStatement,
- Date selectedBeginDate,
- Date selectedEndDate,
- VatStatementDatas result,
- TopiaContext topiaContext) throws LimaException;
-
-}
1
0
09 May '12
Author: echatellier
Date: 2012-05-09 17:37:59 +0200 (Wed, 09 May 2012)
New Revision: 3408
Url: http://chorem.org/repositories/revision/lima/3408
Log:
Remove FinancialTransaction link to FinancialPeriod.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.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
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -84,7 +84,7 @@
*/
void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException;
- void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld, TopiaContext topiaContext) throws LimaException;
+ void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws LimaException;
/**
* Financialperiod/entrybook rules
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -26,8 +26,14 @@
package org.chorem.lima.business;
import org.chorem.lima.entity.AccountDAO;
+import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
+import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.FiscalPeriodDAO;
+import org.chorem.lima.entity.IdentityDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.VatStatementDAO;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -67,5 +73,27 @@
return LimaCallaoDAOHelper.getEntryDAO(context);
}
+ public FinancialPeriodDAO getFinancialPeriodDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getFinancialPeriodDAO(context);
+ }
+
+ public FiscalPeriodDAO getFiscalPeriodDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getFiscalPeriodDAO(context);
+ }
+ public ClosedPeriodicEntryBookDAO getClosedPeriodicEntryBookDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(context);
+ }
+
+ public EntryBookDAO getEntryBookDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getEntryBookDAO(context);
+ }
+
+ public VatStatementDAO getVatStatementDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getVatStatementDAO(context);
+ }
+
+ public IdentityDAO getIdentityDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getIdentityDAO(context);
+ }
}
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-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -47,6 +47,7 @@
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
@@ -157,24 +158,25 @@
*/
@Override
public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException {
- //check financial period locked
- if (financialTransaction.getFinancialPeriod().getLocked()) {
- throw new LimaBusinessException(_("lima-business.defaultaccountingrules.financialperiodblocked"));
- }
+
+ try {
+ //check financial period locked
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
+ FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(financialTransaction.getTransactionDate());
+ if (financialPeriod.isLocked()) {
+ throw new LimaBusinessException(_("lima-business.defaultaccountingrules.financialperiodblocked"));
+ }
+
+ //check all entrybook of his financial period are blocked
+ //FIXME echatellier 20120509 il doit y avoir moyen de faire plus
+ //simple que de recuperer 2 listes et de comparer leur nombres
+ List<EntryBook> entryBooks = new ArrayList<EntryBook>();
+ List<EntryBook> closedEntryBooks = new ArrayList<EntryBook>();
- //check all entrybook of his financial period are blocked
- //FIXME Make this check by topia query ?
- List<EntryBook> entryBooks = new ArrayList<EntryBook>();
- List<EntryBook> closedEntryBooks = new ArrayList<EntryBook>();
- try {
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
- FinancialPeriod financialPeriod =
- financialTransaction.getFinancialPeriod();
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
+
entryBooks = entryBookDAO.findAll();
-
for (EntryBook entryBook : entryBooks) {
ClosedPeriodicEntryBook closedPeriodicEntryBook =
closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
@@ -247,8 +249,8 @@
try {
- FinancialPeriod financialPeriod =
- entry.getFinancialTransaction().getFinancialPeriod();
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
+ FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(entry.getFinancialTransaction().getTransactionDate());
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaTransaction);
@@ -288,25 +290,24 @@
*/
@Override
public void updateFinancialTransactionDateRules(
- FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld, TopiaContext topiaContext) throws LimaException {
+ FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws LimaException {
- FinancialPeriod financialPeriod = financialTransaction.getFinancialPeriod();
- FinancialPeriod financialPeriodOld = financialTransactionOld.getFinancialPeriod();
-
- //1. check old financial period locked
- if (financialPeriodOld.getLocked()) {
- throw new LimaBusinessException(_("lima-business.defaultaccountingrules.financialtransactionblocked"));
- }
-
- //2. check new financial period locked
- if (financialPeriod.getLocked()) {
- throw new LimaBusinessException(_("lima-business.defaultaccountingrules.financialnewdateblocked"));
- }
-
try {
+ FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
+ FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(financialTransaction.getTransactionDate());
+ FinancialPeriod financialPeriodOld = financialPeriodDAO.findByDate(financialTransactionOld.getTransactionDate());
+
+ //1. check old financial period locked
+ if (financialPeriodOld.getLocked()) {
+ throw new LimaBusinessException(_("lima-business.defaultaccountingrules.financialtransactionblocked"));
+ }
+
+ //2. check new financial period locked
+ if (financialPeriod.getLocked()) {
+ throw new LimaBusinessException(_("lima-business.defaultaccountingrules.financialnewdateblocked"));
+ }
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
//3. the actual entrybook belong to a blocked closedPeriodicEntryBook
ClosedPeriodicEntryBook closedPeriodicEntryBookOld =
@@ -342,8 +343,7 @@
//7. check if date are on fiscal period
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
//search fiscalperiod have financialperiod in params
FiscalPeriod fiscalPeriod = fiscalPeriodDAO.findByFinancialPeriod(financialPeriod);
@@ -394,8 +394,8 @@
}*/
- } catch (TopiaException eee) {
- doCatch(topiaContext, eee, log);
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't check financial transaction", ex);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -744,8 +744,8 @@
FormatsEnum format) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
TopiaContext transaction = beginTransaction(rootContext);
- ;
+
try {
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
@@ -774,26 +774,17 @@
closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- TopiaQuery query = entryDAO.createQuery();
- String financialPeriodProperty =
- TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_FINANCIAL_PERIOD);
- String entryBookProperty =
- TopiaQuery.getProperty(Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_ENTRY_BOOK);
- query.addWhere(financialPeriodProperty, Op.EQ,
- closedPeriodicEntryBook.getFinancialPeriod())
- .addWhere(entryBookProperty, Op.EQ,
- closedPeriodicEntryBook.getEntryBook());
+ // TODO echatellier 20120509, was not about only
+ // balanced transaction here, normal ?
+ List<Entry> entries = entryDAO.findAllEntryOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
- List<Entry> entries = entryDAO.findAllByQuery(query);
-
- List<Object[]> results;
- BigDecimal debit = new BigDecimal(0);
- BigDecimal credit = new BigDecimal(0);
- query.setSelect(Entry.PROPERTY_DEBIT, "SUM(" + Entry.PROPERTY_AMOUNT + ")");
- query.addGroup(Entry.PROPERTY_DEBIT);
- results = query.execute(transaction);
+ List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
+ BigDecimal debit = null;
+ BigDecimal credit = null;
int nbAmount = results.size();
if (nbAmount == 2) {
debit = (BigDecimal) results.get(0)[1];
@@ -1185,7 +1176,6 @@
Date endDate,
FormatsEnum format) throws LimaException {
TopiaContext transaction = beginTransaction(rootContext);
- ;
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
try {
@@ -1215,15 +1205,8 @@
LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
-
- TopiaQuery financialPeriodsQuery = financialPeriodDAO.createQuery();
- String beginDateProperty = TopiaQuery.getProperty(FinancialPeriod.PROPERTY_BEGIN_DATE);
- String endDateProperty = TopiaQuery.getProperty(FinancialPeriod.PROPERTY_BEGIN_DATE);
- financialPeriodsQuery.addWhere(beginDateProperty, Op.GE, beginDate)
- .addWhere(endDateProperty, Op.LE, endDate)
- .addOrder(beginDateProperty);
List<FinancialPeriod> financialPeriods =
- financialPeriodDAO.findAllByQuery(financialPeriodsQuery);
+ financialPeriodDAO.findByDates(beginDate, endDate);
List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>();
BigDecimal amountDebit = new BigDecimal(0);
@@ -1237,24 +1220,12 @@
BigDecimal subAmountCredit = new BigDecimal(0);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- List<Object[]> results;
- TopiaQuery query = entryDAO.createQuery();
- BigDecimal debit = new BigDecimal(0);
- BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = null;
+ BigDecimal credit = null;
- String financialPeriodProperty = TopiaQuery.getProperty(
- Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_FINANCIAL_PERIOD);
- String entryBookProperty = TopiaQuery.getProperty(
- Entry.PROPERTY_FINANCIAL_TRANSACTION,
- FinancialTransaction.PROPERTY_ENTRY_BOOK);
- query.addWhere(financialPeriodProperty, Op.EQ,
- closedPeriodicEntryBook.getFinancialPeriod())
- .addWhere(entryBookProperty, Op.EQ,
- closedPeriodicEntryBook.getEntryBook())
- .setSelect(Entry.PROPERTY_DEBIT, "SUM(" + Entry.PROPERTY_AMOUNT + ")")
- .addGroup(Entry.PROPERTY_DEBIT);
- results = query.execute(transaction);
+ List<Object[]> results = entryDAO.getDebitCreditOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
int nbAmount = results.size();
if (nbAmount == 2) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -521,19 +521,12 @@
String[] nextLine = new String[8];
nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel();
nextLine[1] = String.valueOf(numTransaction);
- nextLine[2] =
- SDATEFORMAT.format(financialTransaction.getTransactionDate());
+ nextLine[2] = SDATEFORMAT.format(financialTransaction.getTransactionDate());
nextLine[3] = financialTransaction.getAmountDebit().toString();
nextLine[4] = financialTransaction.getAmountCredit().toString();
- nextLine[5] =
- SDATEFORMAT.format(financialTransaction.getFinancialPeriod().
- getBeginDate());
- nextLine[6] =
- SDATEFORMAT.format(financialTransaction.getFinancialPeriod().
- getEndDate());
EntryBook entryBook = financialTransaction.getEntryBook();
if (entryBook != null) {
- nextLine[7] = entryBook.getCode();
+ nextLine[5] = entryBook.getCode();
}
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -134,13 +134,6 @@
return null;
}
- /** Return the list of all financial transaction of a financial period */
- @Override
- public List<FinancialTransaction> getAllFinancialTransactions(
- FinancialPeriod period) throws LimaException {
- return getAllFinancialTransactions(period, null);
- }
-
/** Return the list of all financial transaction from two dates */
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
@@ -148,26 +141,8 @@
List<FinancialTransaction> financialTransactions = null;
TopiaContext topiaTransaction = beginTransaction(rootContext);
try {
- FinancialTransactionDAO transactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
-
- String financialPeriodProperty = TopiaQuery.getProperty(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD);
- String entryBookLabelProperty = TopiaQuery.getProperty(FinancialTransaction.PROPERTY_ENTRY_BOOK);
-
- // filter with topia query
- TopiaQuery query = transactionDAO.createQuery("T")
-
- .addBetween(FinancialTransaction.PROPERTY_TRANSACTION_DATE, beginDate, endDate)
-
- .addDistinct()
- .addOrder("T." + FinancialTransaction.PROPERTY_TRANSACTION_DATE)
- .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
- //load for lazy
- .addLoad(financialPeriodProperty)
- .addLoad(entryBookLabelProperty)
- .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
- .addFetch("E." + Entry.PROPERTY_ACCOUNT);
- financialTransactions = transactionDAO.findAllByQuery(query);
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ financialTransactions = transactionDAO.findAllByDates(beginDate, endDate);
} catch (Exception ex) {
doCatch(topiaTransaction, ex);
} finally {
@@ -176,6 +151,13 @@
return financialTransactions;
}
+ /** Return the list of all financial transaction of a financial period */
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactions(
+ FinancialPeriod period) throws LimaException {
+ return getAllFinancialTransactions(period, null);
+ }
+
/** Return the list of all financial transaction of a financial period and an entrybook */
@Override
public List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod financialPeriod, EntryBook entryBook) throws LimaException {
@@ -185,29 +167,15 @@
try {
FinancialTransactionDAO transactionDAO =
LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
-
- String financialPeriodProperty = TopiaQuery.getProperty(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD);
- String entryBookLabelProperty = TopiaQuery.getProperty(FinancialTransaction.PROPERTY_ENTRY_BOOK);
-
- // filter with topia query
- TopiaQuery query = transactionDAO.createQuery("T");
-
+
if (entryBook != null) {
- query.addEquals(FinancialTransaction.PROPERTY_ENTRY_BOOK, entryBook);
+ financialTransactions = transactionDAO.findAllByDates(financialPeriod.getBeginDate(),
+ financialPeriod.getEndDate(), entryBook);
+ } else {
+ financialTransactions = transactionDAO.findAllByDates(financialPeriod.getBeginDate(),
+ financialPeriod.getEndDate());
}
- if (financialPeriod != null) {
- query.addEquals(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD, financialPeriod);
- }
- query.addDistinct()
- .addOrder("T." + FinancialTransaction.PROPERTY_TRANSACTION_DATE)
- .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
- //load for lazy
- .addLoad(financialPeriodProperty)
- .addLoad(entryBookLabelProperty)
- .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
- .addFetch("E." + Entry.PROPERTY_ACCOUNT);
- financialTransactions = transactionDAO.findAllByQuery(query);
} catch (Exception ex) {
doCatch(topiaTransaction, ex);
} finally {
@@ -217,7 +185,9 @@
}
- /** Get unbalanced financialtransaction from selected fiscalperiod */
+ /**
+ * Get unbalanced financialtransaction from selected fiscalperiod.
+ */
@Override
public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException {
TopiaContext topiaContext = beginTransaction(rootContext);
@@ -228,40 +198,8 @@
FinancialTransactionDAO financialTransactionDAO =
LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
- // SELECT DISTINCT T
- // FROM org.chorem.lima.entity.FinancialTransaction T, org.chorem.lima.entity.FiscalPeriod F
- // LEFT JOIN FETCH T.entry E LEFT JOIN FETCH E.account
- // LEFT JOIN FETCH E.letter
- // WHERE (T.entryBook = null OR E.voucher = null OR E.voucher = '' OR E.description = null
- // OR E.description = '') AND T.financialPeriod IN elements(F.financialPeriod) AND F = :F
- // ORDER BY T.transactionDate, T.topiaCreateDate;
-
- TopiaQuery query = financialTransactionDAO.createQuery("T");
- String financialPeriodProperty = TopiaQuery.getProperty("T", FinancialTransaction.PROPERTY_FINANCIAL_PERIOD);
- String entryBookLabelProperty = TopiaQuery.getProperty("T", FinancialTransaction.PROPERTY_ENTRY_BOOK);
- query.addDistinct()
- .addOrder("T." + FinancialTransaction.PROPERTY_TRANSACTION_DATE)
- .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
- .addFrom(FiscalPeriod.class, "F")
- .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true)
- .addWhere("(select sum(amount) from " + Entry.class.getName() + " where debit = false and financialTransaction = T) <> " +
- "(select sum(amount) from " + Entry.class.getName() + " where debit = true and financialTransaction = T) OR " +
- "(select sum(amount) from " + Entry.class.getName() + " where debit = true and financialTransaction = T) = null OR " +
- "(select sum(amount) from " + Entry.class.getName() + " where debit = false and financialTransaction = T) = null OR " +
- "E.account = null OR T.entryBook = null OR E.voucher = null " +
- "OR E.voucher = '' OR E.description = null OR E.description = ''")
- .addInElements("T.financialPeriod", "F.financialPeriod")
- .addEquals("F", fiscalPeriod)
- // load lazy
- .addFetch("E." + Entry.PROPERTY_ACCOUNT)
- .addLoad(financialPeriodProperty)
- .addLoad(entryBookLabelProperty);
-
- if (log.isDebugEnabled()) {
- log.debug("Query = " + query.toString());
- }
-
- result = financialTransactionDAO.findAllByQuery(query);
+ result = financialTransactionDAO.getAllIncorrectTransaction(fiscalPeriod.getBeginDate(),
+ fiscalPeriod.getEndDate(), null);
for (FinancialTransaction fTransaction : result) {
BigDecimal credit = fTransaction.getAmountCredit();
BigDecimal debit = fTransaction.getAmountDebit();
@@ -312,19 +250,9 @@
FinancialTransactionDAO financialTransactionDAO =
LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
- // WARN No load lazy, modify query with addLoad or addFetch if loading is necessary
- TopiaQuery query = financialTransactionDAO.createQuery("T");
- query.addFrom(FiscalPeriod.class, "F")
- .addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", false)
- .addWhere("(select sum(amount) from " + Entry.class.getName() + " where debit = false and financialTransaction = T) <> " +
- "(select sum(amount) from " + Entry.class.getName() + " where debit = true and financialTransaction = T)")
- .addNotNull("E.account")
- .addNotNull("T.entryBook")
- .addInElements("T.financialPeriod", "F.financialPeriod")
- .addEquals("F", fiscalPeriod);
+ result = financialTransactionDAO.getAllBalancedTransaction(fiscalPeriod.getBeginDate(),
+ fiscalPeriod.getEndDate(), null);
- result = financialTransactionDAO.findAllByQuery(query);
-
} catch (TopiaException ex) {
doCatch(topiaContext, ex);
}
@@ -352,7 +280,9 @@
}
- /** Method used by update entry and remove entry for update amounts */
+ /**
+ * Method used by update entry and remove entry for update amounts.
+ */
@Override
public void updateFinancialTransactionWithTransaction(FinancialTransaction financialtransaction,
TopiaContext topiaContext) throws LimaException {
@@ -365,26 +295,11 @@
FinancialTransaction financialTransactionOld =
transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
- /* if update date change - check :
- * - if old financialtransaction date are on periodblocked
- * - if new date are on fiscalperiod
- * - new financialtransaction date are on periodunblocked
- * - if all closedperiod are open
- */
- Date oldDate = financialTransactionOld.getTransactionDate();
- Date newDate = financialtransaction.getTransactionDate();
- if (newDate.compareTo(oldDate) != 0) {
- financialTransactionOld.setTransactionDate(newDate);
- //change financial period
- FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
- FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(newDate);
- if (financialPeriod != null) {
- financialTransactionOld.setFinancialPeriod(financialPeriod);
- }
- }
+ // FIXME echatellier 20120509, plusieurs chose à verifier ici:
+ // changement de date induisant en changement de période, verifier
+ // la permission (periode close/non close à l'arrivée)
accountingRules.updateFinancialTransactionDateRules(
- financialtransaction, financialTransactionOld, topiaContext);
+ financialtransaction, financialTransactionOld);
financialTransactionOld.setEntryBook(
financialtransaction.getEntryBook());
@@ -553,8 +468,8 @@
query.addDistinct();
query.addLeftJoin("T." + FinancialTransaction.PROPERTY_ENTRY, "E", true);
//Load for lazy
- query.addLoad(FinancialTransaction.PROPERTY_ENTRY_BOOK)
- .addLoad(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD);
+ query.addLoad(FinancialTransaction.PROPERTY_ENTRY_BOOK);
+ // .addLoad(FinancialTransaction.PROPERTY_FINANCIAL_PERIOD);
Date beginDate = financialTransactionSearch.getBeginDate();
Date endDate = financialTransactionSearch.getEndDate();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -421,7 +421,6 @@
if (lastFPeriod != null) {
//Sets the endfinancialTransaction
endfinancialTransaction.setEntryBook(entryBook);
- endfinancialTransaction.setFinancialPeriod(lastFPeriod);
endfinancialTransaction.setTransactionDate(fiscalPeriod.getEndDate());
financialTransactionService.createFinancialTransaction(endfinancialTransaction);
}
@@ -432,7 +431,6 @@
if (found) {
//Sets the endfinancialTransaction
beginfinancialTransaction.setEntryBook(entryBook);
- beginfinancialTransaction.setFinancialPeriod(beginfinancialPeriod);
beginfinancialTransaction.setTransactionDate(beginfinancialPeriod.getBeginDate());
financialTransactionService.createFinancialTransaction(beginfinancialTransaction);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -282,10 +282,6 @@
financialTransaction = new FinancialTransactionImpl();
financialTransaction.setEntryBook(entryBook);
financialTransaction.setTransactionDate(date);
- FinancialPeriod financialPeriod = financialPeriodDAO
- .findByDate(date);
- financialTransaction
- .setFinancialPeriod(financialPeriod);
financialTransactionService
.createFinancialTransactionWithTransaction(
financialTransaction, topiaContext);
@@ -927,9 +923,7 @@
financialTransactionImport.setDate(nextLine[2]);
financialTransactionImport.setAmountDebit(nextLine[3]);
financialTransactionImport.setAmountCredit(nextLine[4]);
- financialTransactionImport.setBeginDateFinancialPeriod(nextLine[5]);
- financialTransactionImport.setEndDateFinancialPeriod(nextLine[6]);
- financialTransactionImport.setCodeEntryBook(nextLine[7]);
+ financialTransactionImport.setCodeEntryBook(nextLine[5]);
financialTransactions.put(num, financialTransactionImport);
}
@@ -1233,11 +1227,7 @@
.getCodeEntryBook());
financialTransaction.setEntryBook(entryBook);
- FinancialPeriod financialPeriod = financialPeriodDAO
- .findByDate(dateFinancialTransaction);
-
financialTransactionDAO.create(financialTransaction);
- financialTransaction.setFinancialPeriod(financialPeriod);
List<EntryImport> entryImports = entries.get(map.getKey());
for (EntryImport entryImport : entryImports) {
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -52,7 +52,6 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
import org.chorem.lima.entity.EntryImpl;
-import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
@@ -280,13 +279,9 @@
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
Account accountVmpVae = accountService.getAccountByNumber("511");
- // TODO echatellier 20120116 improve period choice
- FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0);
-
FinancialTransaction transaction1 = new FinancialTransactionImpl();
transaction1.setTransactionDate(df.parse("April 4, 2012"));
transaction1.setEntryBook(journalDesVentes);
- transaction1.setFinancialPeriod(financialPeriod);
transaction1 = financialTransactionService.createFinancialTransaction(transaction1);
Entry tr1Entry1 = new EntryImpl();
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -27,7 +27,6 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryImpl;
-import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
@@ -83,13 +82,9 @@
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
Account accountVmpVae = accountService.getAccountByNumber("511");
- // TODO echatellier 20120116 improve period choice
- FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0);
-
FinancialTransaction transaction1 = new FinancialTransactionImpl();
transaction1.setTransactionDate(df.parse("April 5, 2012"));
transaction1.setEntryBook(journalDesVentes);
- transaction1.setFinancialPeriod(financialPeriod);
transaction1 = financialTransactionService.createFinancialTransaction(transaction1);
Entry tr1Entry1 = new EntryImpl();
@@ -129,13 +124,9 @@
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
Account accountVmpVae = accountService.getAccountByNumber("511");
- // TODO echatellier 20120116 improve period choice
- FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0);
-
FinancialTransaction transaction1 = new FinancialTransactionImpl();
transaction1.setTransactionDate(df.parse("April 5, 2012"));
transaction1.setEntryBook(journalDesVentes);
- transaction1.setFinancialPeriod(financialPeriod);
transaction1 = financialTransactionService.createFinancialTransaction(transaction1);
Entry tr1Entry1 = new EntryImpl();
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -30,7 +30,6 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryImpl;
-import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.junit.Assert;
@@ -89,13 +88,9 @@
EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
Account accountVmpVae = accountService.getAccountByNumber("511");
- // TODO echatellier 20120116 improve period choice
- FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0);
-
FinancialTransaction transaction1 = new FinancialTransactionImpl();
transaction1.setTransactionDate(df.parse("April 5, 2012"));
transaction1.setEntryBook(journalDesVentes);
- transaction1.setFinancialPeriod(financialPeriod);
transaction1 = financialTransactionService.createFinancialTransaction(transaction1);
Entry tr1Entry1 = new EntryImpl();
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-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -140,4 +140,53 @@
"endDate", endDate, "entryBook", entryBook);
return result;
}
+
+ /**
+ * Retourne les entrees des transaction entre deux dates pour
+ * un journal.
+ *
+ * @param entryBook entry book
+ * @param beginDate begin date
+ * @param endDate end date
+ * @throws TopiaException
+ */
+ public List<Entry> findAllEntryOfTransaction(EntryBook entryBook, Date beginDate,
+ Date endDate) throws TopiaException {
+ String query = "FROM " + Entry.class.getName() + " E" +
+ // entre les 2 dates
+ " WHERE :beginDate <= E.financialTransaction.transactionDate" +
+ " AND E.financialTransaction.transactionDate <= :endDate" +
+ // concerne le compte
+ " AND E.entryBook = :entryBook";
+
+ List<Entry> entries = context.find(query, "beginDate", beginDate,
+ "endDate", endDate, "entryBook", entryBook);
+ return entries;
+ }
+
+ /**
+ * Retourne la somme des entrées des transaction 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[]> getDebitCreditOfTransaction(EntryBook entryBook,
+ Date beginDate, Date endDate) throws TopiaException {
+ String query = "SELECT E.debit, sum(E.amount) " +
+ "FROM " + Entry.class.getName() + " E" +
+ // entre les 2 dates
+ " WHERE :beginDate <= E.financialTransaction.transactionDate" +
+ " AND E.financialTransaction.transactionDate <= :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-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -54,5 +54,24 @@
}
return result;
}
+
+ /**
+ * Return all FinancialPeriod with begin date between two given dates.
+ *
+ * @param beginDate period begin date
+ * @param endDate period end date
+ * @return FinancialPeriod for {@code date}
+ * @throws TopiaException
+ */
+ public List<FinancialPeriod> findByDates(Date beginDate, Date endDate) throws TopiaException {
+ String query = "FROM " + FinancialPeriod.class.getName() +
+ " WHERE :beginDate <= beginDate" +
+ " AND beginDate <= :endDate";
+
+ // add unique result here
+ List<FinancialPeriod> financialPeriod = context.find(query, "beginDate", beginDate, "endDate", endDate);
+ return financialPeriod;
+ }
+
}
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-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -25,6 +25,7 @@
package org.chorem.lima.entity;
+import java.util.Date;
import java.util.List;
import org.nuiton.topia.TopiaException;
@@ -54,6 +55,44 @@
}
/**
+ * Find all transactions between two dates.
+ *
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return unbalanced transactions
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> findAllByDates(Date beginDate, Date endDate) throws TopiaException {
+ String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ " WHERE :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate" +
+ " ORDER BY T.transactionDate, T." + FinancialTransaction.TOPIA_CREATE_DATE;
+ List<FinancialTransaction> result = context.find(query, "beginDate",
+ beginDate, "endDate", endDate);
+ return result;
+ }
+
+ /**
+ * Find all transactions between two dates in an entry book.
+ *
+ * @param beginDate begin date
+ * @param endDate end date
+ * @param entryBook entry book
+ * @return unbalanced transactions
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> findAllByDates(Date beginDate, Date endDate, EntryBook entryBook) throws TopiaException {
+ String query = "FROM " + FinancialTransaction.class.getName() + " T"+
+ " WHERE :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate" +
+ " AND T.entryBook = :entryBook" +
+ " ORDER BY T.transactionDate, T." + FinancialTransaction.TOPIA_CREATE_DATE;
+ List<FinancialTransaction> result = context.find(query, "beginDate",
+ beginDate, "endDate", endDate, "entryBook", entryBook);
+ return result;
+ }
+
+ /**
* Find all unbalanced transactions.
*
* @param financialPeriod period
@@ -61,6 +100,7 @@
* @return unbalanced transactions
* @throws TopiaException
*/
+ @Deprecated
public List<FinancialTransaction> getAllUnbalancedTransaction(FinancialPeriod financialPeriod,
EntryBook entryBook) throws TopiaException {
String query = "FROM " + FinancialTransaction.class.getName() + " T"+
@@ -74,8 +114,101 @@
financialPeriod, "entryBook", entryBook);
return result;
}
+
+ /**
+ * Find all unbalanced transactions.
+ *
+ * @param beginDate beginDate
+ * @param endDate endDate
+ * @param entryBook entry book (can be null)
+ * @return unbalanced transactions
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> getAllUnbalancedTransaction(Date beginDate, Date endDate,
+ EntryBook entryBook) throws TopiaException {
+ 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 :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate";
+ List<FinancialTransaction> result = null;
+ if (entryBook != null) {
+ query += " AND T.entryBook = :entryBook";
+ result = context.find(query, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook);
+ } else {
+ result = context.find(query, "beginDate", beginDate, "endDate", endDate);
+ }
+ return result;
+ }
+
/**
+ * Find all unbalanced transactions.
+ *
+ * @param beginDate beginDate
+ * @param endDate endDate
+ * @param entryBook entry book (can be null)
+ * @return unbalanced transactions
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> getAllBalancedTransaction(Date beginDate, Date endDate,
+ EntryBook entryBook) throws TopiaException {
+ 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 :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate";
+ List<FinancialTransaction> result = null;
+ if (entryBook != null) {
+ query += " AND T.entryBook = :entryBook";
+ result = context.find(query, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook);
+ } else {
+ result = context.find(query, "beginDate", beginDate, "endDate", endDate);
+ }
+
+ return result;
+ }
+
+ /**
+ * Find all unbalanced transactions.
+ *
+ * @param beginDate beginDate
+ * @param endDate endDate
+ * @param entryBook entry book (can be null)
+ * @return unbalanced transactions
+ * @throws TopiaException
+ */
+ public List<FinancialTransaction> getAllIncorrectTransaction(Date beginDate, Date endDate,
+ EntryBook entryBook) throws TopiaException {
+ 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 :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate";
+ List<FinancialTransaction> result = null;
+ if (entryBook != null) {
+ query += " AND T.entryBook = :entryBook";
+ result = context.find(query, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook);
+ } else {
+ result = context.find(query, "beginDate", beginDate, "endDate", endDate);
+ }
+
+ return result;
+ }
+
+ /**
* Find all transaction where some field are not filled in.
*
* @param financialPeriod period
@@ -83,6 +216,7 @@
* @return unfilled transaction
* @throws TopiaException
*/
+ @Deprecated
public List<FinancialTransaction> getAllUnfilledTransaction(FinancialPeriod financialPeriod,
EntryBook entryBook) throws TopiaException {
String query = "FROM " + FinancialTransaction.class.getName() + " T"+
@@ -108,14 +242,6 @@
* @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);*/
String query = "FROM " + FinancialTransaction.class.getName() + " T"+
" LEFT JOIN T.entry AS E" +
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2012-05-09 15:37:59 UTC (rev 3408)
@@ -48,6 +48,8 @@
# lazy
org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false
+org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false
+org.chorem.lima.entity.Entry.attribute.account.tagvalue.lazy=false
org.chorem.lima.entity.FinancialStatement.attribute.subFinancialStatements.tagvalue.lazy=false
org.chorem.lima.entity.FinancialStatement.attribute.masterFinancialStatement.tagvalue.lazy=false
org.chorem.lima.entity.VatStatement.attribute.subVatStatements.tagvalue.lazy=false
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -310,7 +310,6 @@
FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- financialTransaction.setFinancialPeriod(financialPeriod);
// can be defined later by user
if (entryBook != null) {
financialTransaction.setEntryBook(entryBook);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2012-05-09 13:09:24 UTC (rev 3407)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2012-05-09 15:37:59 UTC (rev 3408)
@@ -364,7 +364,7 @@
} else {
throw new LimaException("Can't set new transaction");
}
- financialTransaction.setFinancialPeriod(financialPeriod);
+
//financialTransaction.setSelectedFinancialPeriod(selectedFiscalPeriod);
// get today
Calendar actualCalendar = Calendar.getInstance();
1
0
r3407 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/test/java/org/chorem/lima/entity lima-callao/src/main/java/org/chorem/lima/entity
by echatellier@users.chorem.org 09 May '12
by echatellier@users.chorem.org 09 May '12
09 May '12
Author: echatellier
Date: 2012-05-09 15:09:24 +0200 (Wed, 09 May 2012)
New Revision: 3407
Url: http://chorem.org/repositories/revision/lima/3407
Log:
Refactoring periodic entry book rule
Added:
trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-09 13:03:32 UTC (rev 3406)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-05-09 13:09:24 UTC (rev 3407)
@@ -175,7 +175,9 @@
return financialPeriods;
}
- /** Règles de vérification de fermeture d'un exercice, appliquées à la comptabilité française */
+ /**
+ * Règles de vérification de fermeture d'un exercice, appliquées à la comptabilité française.
+ */
@Override
public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
try {
@@ -209,6 +211,10 @@
* get all blocked closedperiodicentrybook while his same period, return the number
* <p/>
* compare there
+ *
+ * FIXME echatellier 20120504 a quoi ca sert de recuperer un nombre
+ * et de le comparer avec un autre, c'est pas plus simple de verifier
+ * qu'il reste des ClosedPeriodicEntryBook non clos ?
*/
@Override
public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaTransaction) throws LimaException {
@@ -216,51 +222,35 @@
closedPeriodicEntryBook, topiaTransaction);
FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- new ArrayList<ClosedPeriodicEntryBook>();
try {
// Get all closedperiod between for the period and entrybook
- Date endDate = closedPeriodicEntryBook.
- getFinancialPeriod().getBeginDate();
+ Date endDate = closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
+ // FIXME echatellier 20120502 c'est pas un hack ca ?
+ // un period peut ne pas durer un mois
endDate = DateUtils.addMonths(endDate, -1);
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaTransaction);
+ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaTransaction);
- //search fiscalperiod have financialperiod in params
- TopiaQuery query1 = fiscalPeriodDAO.createQuery()
- .addInElements(":financialPeriod", "financialPeriod")
- .addParam("financialPeriod", financialPeriod);
- FiscalPeriod fiscalPeriod = fiscalPeriodDAO.findByQuery(query1);
-
+ //search fiscalperiod have financialperiod
+ FiscalPeriod fiscalPeriod = fiscalPeriodDAO.findByFinancialPeriod(financialPeriod);
Date beginDate = fiscalPeriod.getBeginDate();
-
+ // FIXME echatellier 20120502 quels est la rapport entre beginDate
+ // et endDate ? il ne provienent pas du même endroit
EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaTransaction);
- TopiaQuery query = closedPeriodicEntryBookDAO.createQuery();
- String closedPeriodicEntryBookDateProperty =
- TopiaQuery.getProperty(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD,
- FinancialPeriod.PROPERTY_BEGIN_DATE);
- query.addWhere(closedPeriodicEntryBookDateProperty
- + " BETWEEN :beginDate AND :endDate")
- .addEquals(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook)
- .addParam("beginDate", beginDate)
- .addParam("endDate", endDate);
- closedPeriodicEntryBooks.
- addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
+ closedPeriodicEntryBookDAO.findAllByEntryBookAndDates(entryBook, beginDate, endDate);
+ // FIXME echatellier 20120504 juste un count suffit
int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
// Get all closed between for the period, entrybook and are blocked
- query.addEquals(ClosedPeriodicEntryBook.PROPERTY_LOCKED, true);
- closedPeriodicEntryBooks.clear();
- closedPeriodicEntryBooks.
- addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
+ closedPeriodicEntryBooks = closedPeriodicEntryBookDAO.findAllByEntryBookAndDatesLocked(entryBook, beginDate, endDate);
int nbBlockedClosedPeriodicEntryBooks =
closedPeriodicEntryBooks.size();
Added: trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java (rev 0)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2012-05-09 13:09:24 UTC (rev 3407)
@@ -0,0 +1,71 @@
+/*
+ * #%L
+ *
+ *
+ * $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 Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.entity;
+
+import java.util.List;
+
+import org.chorem.lima.business.AbstractLimaTest;
+import org.chorem.lima.business.LimaException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test for {@link FinancialTransactionDAO}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionDAOTest extends AbstractLimaTest {
+
+ @Before
+ public void initTest() throws Exception {
+ initTestDatabase();
+ }
+
+ /**
+ * Test la recherche des transactions non equilibrées.
+ *
+ * @throws TopiaException
+ * @throws LimaException
+ */
+ @Test
+ public void testFindAllUnbalancedTransactions() throws TopiaException, LimaException {
+
+ FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0);
+ EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv");
+
+ TopiaContext tx = getTestContext().beginTransaction();
+ FinancialTransactionDAO ftDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(tx);
+ List<FinancialTransaction> fTransactions = ftDAO.getAllUnbalancedTransaction(financialPeriod, journalDesVentes);
+ Assert.assertNotNull(fTransactions);
+ }
+}
Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-05-09 13:03:32 UTC (rev 3406)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-05-09 13:09:24 UTC (rev 3407)
@@ -102,5 +102,46 @@
" ORDER BY entryBook.code";
return context.find(query, 0d, 0d, "beginDate", beginDate, "endDate", endDate);
}
+
+ /**
+ * Retourne toutes les ClosedPeriodicEntryBook par interval de date
+ * sur les periodes sur lequelles elles portent pour un journal.
+ *
+ * @param entryBook entry book
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return all ClosedPeriodicEntryBook between begin and end
+ * @throws TopiaException
+ */
+ public List<ClosedPeriodicEntryBook> findAllByEntryBookAndDates(EntryBook entryBook,
+ Date beginDate, Date endDate) throws TopiaException {
+ String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
+ " WHERE :begindate <= financialPeriod.beginDate " +
+ " AND financialPeriod.beginDate <= :endDate" +
+ " AND entryBook = :entryBook";
+ return context.find(query, 0d, 0d, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook);
+ }
+
+ /**
+ * Retourne toutes les ClosedPeriodicEntryBook par interval de date
+ * sur les periodes sur lequelles elles portent pour un journal.
+ *
+ * @param entryBook entry book
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return all ClosedPeriodicEntryBook between begin and end
+ * @throws TopiaException
+ */
+ public List<ClosedPeriodicEntryBook> findAllByEntryBookAndDatesLocked(EntryBook entryBook,
+ Date beginDate, Date endDate) throws TopiaException {
+
+ String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
+ " WHERE :begindate <= financialPeriod.beginDate " +
+ " AND financialPeriod.beginDate <= :endDate" +
+ " AND entryBook = :entryBook" +
+ " AND locked = true";
+ return context.find(query, 0d, 0d, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook);
+ }
+
}
1
0
r3406 - in trunk/lima-business/src: main/java/org/chorem/lima/business main/java/org/chorem/lima/business/accountingrules main/java/org/chorem/lima/business/ejb test/java/org/chorem/lima/business/ejb
by echatellier@users.chorem.org 09 May '12
by echatellier@users.chorem.org 09 May '12
09 May '12
Author: echatellier
Date: 2012-05-09 15:03:32 +0200 (Wed, 09 May 2012)
New Revision: 3406
Url: http://chorem.org/repositories/revision/lima/3406
Log:
Remove topia context in service, juste expose contextable DAOHelper
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/ejb/ClearServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java 2012-05-04 14:51:40 UTC (rev 3405)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaDaoHelper.java 2012-05-09 13:03:32 UTC (rev 3406)
@@ -42,21 +42,30 @@
*/
public class LimaDaoHelper {
- protected static TopiaContext getContextTransaction() {
- TopiaContext result = (TopiaContext)LimaInterceptor.TOPIA_CONTEXT.get();
+ protected TopiaContext context;
+
+ public LimaDaoHelper(TopiaContext context) {
+ this.context = context;
+ }
- if (result == null) {
- throw new IllegalStateException("No opened transaction found. Put @TransactionAttribute on method or class");
- }
+ /**
+ * Get internal topia context.
+ *
+ * Only use full for test.
+ *
+ * @return topia context
+ */
+ public TopiaContext getTopiaContext() {
+ return context;
+ }
- return result;
+ public AccountDAO getAccountDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getAccountDAO(context);
}
- public static AccountDAO getAccountDAO() throws TopiaException {
- return LimaCallaoDAOHelper.getAccountDAO(getContextTransaction());
+ public EntryDAO getEntryDAO() throws TopiaException {
+ return LimaCallaoDAOHelper.getEntryDAO(context);
}
- public static EntryDAO getEntryDAO() throws TopiaException {
- return LimaCallaoDAOHelper.getEntryDAO(getContextTransaction());
- }
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java 2012-05-04 14:51:40 UTC (rev 3405)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java 2012-05-09 13:03:32 UTC (rev 3406)
@@ -38,7 +38,6 @@
import org.chorem.lima.LimaXAResource;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaNotFoundException;
/**
* Interceptor for topia context transaction.
@@ -56,7 +55,7 @@
private static final Log log = LogFactory.getLog(LimaInterceptor.class);
- public static final ThreadLocal<TopiaContext> TOPIA_CONTEXT = new ThreadLocal<TopiaContext>();
+ public static final ThreadLocal<LimaDaoHelper> DAO_HELPER = new ThreadLocal<LimaDaoHelper>();
@Resource
private TransactionManager transactionManager;
@@ -70,7 +69,7 @@
// enter in service layer
// interceptor will be called before each internal
// ejb call, but opening a new transaction in not required
- if (TOPIA_CONTEXT.get() == null) {
+ if (DAO_HELPER.get() == null) {
// maybe take care of TransactionAttributeTypes ?
if (context.getTarget().getClass().getAnnotation(TransactionAttribute.class) != null ||
@@ -84,7 +83,8 @@
TopiaContext rootContext = TopiaContextFactory.getContext(config.getFlatOptions());
TopiaContext tx = rootContext.beginTransaction();
- TOPIA_CONTEXT.set(tx);
+ LimaDaoHelper helper = new LimaDaoHelper(tx);
+ DAO_HELPER.set(helper);
Transaction tr = transactionManager.getTransaction();
@@ -95,7 +95,7 @@
try {
result = context.proceed();
} finally {
- TOPIA_CONTEXT.remove();
+ DAO_HELPER.remove();
}
} else {
result = context.proceed();
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:51:40 UTC (rev 3405)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-05-09 13:03:32 UTC (rev 3406)
@@ -38,6 +38,7 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaDaoHelper;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.LimaInterceptor;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
@@ -68,6 +69,16 @@
LogFactory.getLog(DefaultAccountingRules.class);
/**
+ * Return Dao helper to use in current thread.
+ * Defined by {@link LimaInterceptor}.
+ *
+ * @return dao helper
+ */
+ protected LimaDaoHelper getDaoHelper() {
+ return LimaInterceptor.DAO_HELPER.get();
+ }
+
+ /**
* Rules to check before create accounts.
*/
@Override
@@ -113,7 +124,7 @@
@Override
public void removeAccountRules(Account account) throws LimaException {
try {
- EntryDAO entryDAO = LimaDaoHelper.getEntryDAO();
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
// Check if account have entries
int nbentries = entryDAO.findAllByAccount(account).size();
if (nbentries != 0) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2012-05-04 14:51:40 UTC (rev 3405)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2012-05-09 13:03:32 UTC (rev 3406)
@@ -25,20 +25,22 @@
package org.chorem.lima.business.ejb;
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Properties;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaDaoHelper;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.LimaInterceptor;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.TopiaRuntimeException;
-import java.util.Properties;
-
-import static org.nuiton.i18n.I18n._;
-
/**
* Abstract code for all ejb services (get context, catch, finally...).
*
@@ -50,6 +52,16 @@
/** Logger. */
protected static final Log log = LogFactory.getLog(AbstractLimaService.class);
+ /**
+ * Return Dao helper to use in current thread.
+ * Defined by {@link LimaInterceptor}.
+ *
+ * @return dao helper
+ */
+ protected LimaDaoHelper getDaoHelper() {
+ return LimaInterceptor.DAO_HELPER.get();
+ }
+
protected static TopiaContext acquireRootContext() {
try {
LimaConfig config = LimaConfig.getInstance();
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 14:51:40 UTC (rev 3405)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2012-05-09 13:03:32 UTC (rev 3406)
@@ -37,8 +37,8 @@
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaDaoHelper;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.LimaInterceptor;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
@@ -63,7 +63,7 @@
long result = 0;
try {
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
result = accountDAO.count();
} catch (TopiaException ex) {
throw new LimaException("Can't count", ex);
@@ -91,7 +91,7 @@
account.setAccountNumber(account.getAccountNumber().toUpperCase());
// check if account number already exist
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
Account existAccount =
accountDAO.findByAccountNumber(account.getAccountNumber());
@@ -115,7 +115,7 @@
Account account = null;
try {
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
while (account == null && accountNumber.length() > 1) {
@@ -135,7 +135,7 @@
Account account = null;
try {
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
account = accountDAO.findByAccountNumber(number);
} catch (Exception ex) {
throw new LimaException("Can't get master account", ex);
@@ -152,7 +152,7 @@
List<Account> accountsList;
try {
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
accountsList = accountDAO.findAll();
Collections.sort(accountsList, new AccountComparator());
@@ -171,7 +171,7 @@
List<Account> accountsList = null;
try {
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
accountsList = accountDAO.findAllLeafAccounts();
} catch (Exception ex) {
throw new LimaException("Can't get all leaf accounts", ex);
@@ -189,7 +189,7 @@
List<Account> accountsList = null;
try {
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
accountsList = accountDAO.findAllSubAccounts(account);
} catch (Exception ex) {
throw new LimaException("Can't get all sub accounts", ex);
@@ -218,7 +218,7 @@
accountingRules.removeAccountRules(account);
// remove account
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
Account accountToDelete = accountDAO.findByTopiaId(account.getTopiaId());
accountDAO.delete(accountToDelete);
@@ -244,7 +244,7 @@
Account result = null;
try {
// DAO
- AccountDAO accountDAO = LimaDaoHelper.getAccountDAO();
+ AccountDAO accountDAO = getDaoHelper().getAccountDAO();
accountingRules.updateAccountRules(account);
result = accountDAO.update(account);
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ejb/ClearServiceImpl.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/ejb/ClearServiceImpl.java 2012-05-04 14:51:40 UTC (rev 3405)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/ejb/ClearServiceImpl.java 2012-05-09 13:03:32 UTC (rev 3406)
@@ -24,7 +24,6 @@
package org.chorem.lima.business.ejb;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.LimaInterceptor;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -51,7 +50,7 @@
public void clearDatabase() throws LimaException {
try {
- TopiaContext transaction = LimaInterceptor.TOPIA_CONTEXT.get();
+ TopiaContext transaction = getDaoHelper().getTopiaContext();
transaction.createSchema();
} catch (TopiaException ex) {
throw new LimaException("Can't clear database", ex);
1
0
r3405 - 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:51:40 +0200 (Fri, 04 May 2012)
New Revision: 3405
Url: http://chorem.org/repositories/revision/lima/3405
Log:
Just another topia query removal
Added:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
Added: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-05-04 14:51:40 UTC (rev 3405)
@@ -0,0 +1,61 @@
+/*
+ * #%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;
+
+/**
+ * Fiscal period entity DAO.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodDAOImpl <E extends FiscalPeriod> extends FiscalPeriodDAOAbstract<FiscalPeriod> {
+
+ /**
+ * Find fiscal period by financial period.
+ *
+ * @param financialPeriod financial period
+ * @return fiscal period containing financial period
+ * @throws TopiaException
+ */
+ public FiscalPeriod findByFinancialPeriod(FinancialPeriod financialPeriod) throws TopiaException {
+ String query = "FROM " + FiscalPeriod.class.getName() +
+ "WHERE :financialPeriod in elements(financialPeriod)";
+
+ List<FiscalPeriod> fiscalPeriods = context.find(query, "financialPeriod", financialPeriod);
+ FiscalPeriod result = null;
+ if (!fiscalPeriods.isEmpty()) {
+ result = fiscalPeriods.get(0);
+ }
+ return result;
+ }
+}
Property changes on: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0