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
- 1853 discussions
r3843 - trunk/lima-business-api/src/main/java/org/chorem/lima/business
by sbavencoff@users.chorem.org 10 Jul '14
by sbavencoff@users.chorem.org 10 Jul '14
10 Jul '14
Author: sbavencoff
Date: 2014-07-10 08:31:00 +0200 (Thu, 10 Jul 2014)
New Revision: 3843
Url: http://forge.chorem.org/projects/lima/repository/revisions/3843
Log:
refs #557 : fix financial transaction exception
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java 2014-07-09 16:00:06 UTC (rev 3842)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java 2014-07-10 06:31:00 UTC (rev 3843)
@@ -5,7 +5,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class FinancialPeriodException extends LimaException {
+public abstract class FinancialPeriodException extends LimaException {
protected FinancialPeriod financialPeriod;
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java 2014-07-09 16:00:06 UTC (rev 3842)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java 2014-07-10 06:31:00 UTC (rev 3843)
@@ -1,6 +1,5 @@
package org.chorem.lima.business;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
/**
1
0
r3842 - trunk/lima-business-api/src/main/java/org/chorem/lima/business
by sbavencoff@users.chorem.org 09 Jul '14
by sbavencoff@users.chorem.org 09 Jul '14
09 Jul '14
Author: sbavencoff
Date: 2014-07-09 18:00:06 +0200 (Wed, 09 Jul 2014)
New Revision: 3842
Url: http://forge.chorem.org/projects/lima/repository/revisions/3842
Log:
refs #557 : fix financial transaction exception
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-07-09 15:58:34 UTC (rev 3841)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-07-09 16:00:06 UTC (rev 3842)
@@ -22,7 +22,6 @@
* #L%
*/
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
/**
1
0
Author: sbavencoff
Date: 2014-07-09 17:58:34 +0200 (Wed, 09 Jul 2014)
New Revision: 3841
Url: http://forge.chorem.org/projects/lima/repository/revisions/3841
Log:
refs #557 : fix financial transaction exception
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AfterLastFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeforeFirstFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/DateException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedFinancialPeriodException.java
Removed:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.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/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/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
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 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -82,15 +82,16 @@
*/
void updateEntryRules(Entry entry, Entry entryOld) throws LockedEntryBookException;
- void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws FinancialTransactionException;
+ void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld)
+ throws BeforeFirstFiscalPeriodException, AfterLastFiscalPeriodException, LockedFinancialPeriodException, LockedEntryBookException;
/**
* Financialperiod/entrybook rules
*
* @param financialTransaction
- * @throws LimaException
+ * @throws LockedFinancialPeriodException, LockedEntryBookException
*/
- void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException;
+ void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LockedFinancialPeriodException, LockedEntryBookException;
/**
* Check if a financial period can be closed.
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -29,11 +29,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.AfterLastFiscalPeriodException;
+import org.chorem.lima.business.BeforeFirstFiscalPeriodException;
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaInterceptor;
import org.chorem.lima.business.LockedEntryBookException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
import org.chorem.lima.business.UnfilledEntriesException;
@@ -45,7 +47,6 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryBookTopiaDao;
import org.chorem.lima.entity.EntryTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
@@ -154,44 +155,25 @@
/**
* check if financial period of a financial transaction is blocked
- * check if all entrybook of his financial period are blocked
+ * check if entrybook of his financial period are locked
*/
@Override
- public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
+ public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LockedFinancialPeriodException, LockedEntryBookException {
//check financial period locked
FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
if (financialPeriod.isLocked()) {
- throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.financialperiodblocked");
+ throw new LockedFinancialPeriodException(financialPeriod);
}
- //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> closedEntryBooks = new ArrayList<EntryBook>();
-
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.forProperties(
+ ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod,
+ ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, financialTransaction.getEntryBook()).findUnique();
-// List<EntryBook> entryBooks = entryBookTopiaDao.findAll();
- // The following code should do the work but i'm not 100% sure.
- long nbEntryBooksClosed = closedPeriodicEntryBookTopiaDao.forProperties(
- ClosedPeriodicEntryBook.PROPERTY_LOCKED, true,
- ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod).addNotNull(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK).count();
-
-// for (EntryBook entryBook : entryBooks) {
-// ClosedPeriodicEntryBook closedPeriodicEntryBook =
-// closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
-// entryBook, financialPeriod);
-// if (closedPeriodicEntryBook.isLocked()) {
-// closedEntryBooks.add(entryBook);
-// }
-// }
-
- long nbEntryBooks = entryBookTopiaDao.count();
- if (nbEntryBooks == nbEntryBooksClosed) {
- throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.allentrybookclosed");
+ if (closedPeriodicEntryBook.isLocked()) {
+ throw new LockedEntryBookException(closedPeriodicEntryBook);
}
}
@@ -283,7 +265,9 @@
*/
@Override
public void updateFinancialTransactionDateRules(
- FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws FinancialTransactionException {
+ FinancialTransaction financialTransaction,
+ FinancialTransaction financialTransactionOld)
+ throws BeforeFirstFiscalPeriodException, AfterLastFiscalPeriodException, LockedFinancialPeriodException, LockedEntryBookException {
Date financialTransactionDate = financialTransaction.getTransactionDate();
FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
@@ -301,42 +285,66 @@
}
//1-date not on a fiscal period
- if (financialTransactionDate.before(beginDateFirstFiscalPeriod) || financialTransactionDate.after(endDateLastFiscalPeriod)){
- if (financialTransactionDate.before(beginDateFirstFiscalPeriod)) {
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction avant (antérieure) la date de début du premier exercice");
- }
- throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.datebeforeerror");
+ if (financialTransactionDate.before(beginDateFirstFiscalPeriod)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Date de la transaction avant (antérieure) la date de début du premier exercice");
}
+ throw new BeforeFirstFiscalPeriodException(beginDateFirstFiscalPeriod);
- if (financialTransactionDate.after(endDateLastFiscalPeriod)) {
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction après (postérieure) la date de fin du dernier exercice");
- }
- throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.dateaftererror");
+ }
+
+ if (financialTransactionDate.after(endDateLastFiscalPeriod)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Date de la transaction après (postérieure) la date de fin du dernier exercice");
}
- }else{ //date on a fiscal period (and consequently on a financial), now test if financial is open
+ throw new AfterLastFiscalPeriodException(endDateLastFiscalPeriod);
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
- FinancialPeriod financialPeriodOld = financialPeriodTopiaDao.findByDate(financialTransactionOld.getTransactionDate());
+ }
- //2. check old financial period locked
- if (financialPeriodOld.isLocked()) {
- if (log.isDebugEnabled()) {
- log.debug("Periode (Old) financière bloquée");
- }
- throw new FinancialTransactionException(financialTransactionOld, "lima-business.defaultaccountingrules.financialtransactionblocked");
+ //date on a fiscal period (and consequently on a financial), now test if financial is open
+
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod financialPeriodOld = financialPeriodTopiaDao.findByDate(financialTransactionOld.getTransactionDate());
+
+ //2. check old financial period locked
+ if (financialPeriodOld.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Periode (Old) financière bloquée");
}
+ throw new LockedFinancialPeriodException(financialPeriodOld);
+ }
- //3. check new financial period locked
- if (financialPeriod.isLocked()) {
- if (log.isDebugEnabled()) {
- log.debug("Periode (New) financière bloquée");
- }
- throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.financialnewdateblocked");
+ //3. check new financial period locked
+ FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
+ if (financialPeriod.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Periode (New) financière bloquée");
}
+ throw new LockedFinancialPeriodException(financialPeriod);
}
+
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+
+ ClosedPeriodicEntryBook closedPeriodicEntryBookOld = closedPeriodicEntryBookTopiaDao.forProperties(
+ ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, financialTransactionOld.getEntryBook(),
+ ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriodOld).findUnique();
+ if (closedPeriodicEntryBookOld.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Journal (old) bloquée");
+ }
+ throw new LockedEntryBookException(closedPeriodicEntryBookOld);
+ }
+
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.forProperties(
+ ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, financialTransaction.getEntryBook(),
+ ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod).findUnique();
+ if (closedPeriodicEntryBook.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Journal (new) bloquée");
+ }
+ throw new LockedEntryBookException(closedPeriodicEntryBook);
+ }
+
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -35,10 +35,12 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LockedEntryBookException;
-import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.AfterLastFiscalPeriodException;
+import org.chorem.lima.business.BeforeFirstFiscalPeriodException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.LockedEntryBookException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.utils.LetteringComparator;
@@ -99,7 +101,7 @@
protected static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
@Override
- public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException {
+ public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws LockedFinancialPeriodException, LockedEntryBookException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
@@ -181,7 +183,8 @@
}
@Override
- public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws FinancialTransactionException {
+ public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected)
+ throws LockedFinancialPeriodException, LockedEntryBookException {
Entry newSameAccountEntry = null;
Entry newCostOrProductEntry = null;
@@ -426,7 +429,8 @@
* Method used by update entry and remove entry for update amounts.
*/
@Override
- public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
+ public void updateFinancialTransaction(FinancialTransaction financialTransaction)
+ throws AfterLastFiscalPeriodException, BeforeFirstFiscalPeriodException, LockedFinancialPeriodException, LockedEntryBookException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
@@ -449,7 +453,8 @@
* call accounting rules
*/
@Override
- public void removeFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
+ public void removeFinancialTransaction(FinancialTransaction financialTransaction)
+ throws LockedFinancialPeriodException, LockedEntryBookException {
// check if the financial period is blocked
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
@@ -468,7 +473,7 @@
}
@Override
- public Entry createEntry(Entry entry) throws FinancialTransactionException {
+ public Entry createEntry(Entry entry) throws LockedFinancialPeriodException, LockedEntryBookException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
//check if the financial period is blocked
@@ -507,7 +512,7 @@
* Remove entry, update amounts for the financial transaction.
*/
@Override
- public void removeEntry(Entry entry) throws FinancialTransactionException {
+ public void removeEntry(Entry entry) throws LockedFinancialPeriodException, LockedEntryBookException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -31,9 +31,10 @@
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.AccountException;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LockedEntryBookException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -271,7 +272,8 @@
@Override
public FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
- boolean retainedEarnings) throws AccountException, FinancialTransactionException, FiscalPeriodException {
+ boolean retainedEarnings)
+ throws AccountException, LockedFinancialPeriodException, LockedEntryBookException, FiscalPeriodException {
if (entryBook != null && retainedEarnings) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -51,10 +51,11 @@
import org.chorem.lima.beans.VatStatementImport;
import org.chorem.lima.beans.VatStatementImportImpl;
import org.chorem.lima.business.AccountException;
-import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.ImportEbpException;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LockedEntryBookException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
import org.chorem.lima.business.UnfilledEntriesException;
@@ -362,8 +363,10 @@
throw new ImportEbpException("Can't import ", e);
} catch (IOException e) {
throw new ImportEbpException("Can't import ", e);
- } catch (FinancialTransactionException e) {
- throw new ImportEbpException("Can't import ", e);
+ } catch (LockedFinancialPeriodException e) {
+ throw new ImportEbpException("Can't import " + t("lima-business.import.FinancialTransaction.error.LockedFinancialPeriod"));
+ } catch (LockedEntryBookException e) {
+ throw new ImportEbpException("Can't import " + t("lima-business.import.FinancialTransaction.error.LockedEntryBook"));
} finally {
if (csvReader != null) {
try {
@@ -1325,8 +1328,10 @@
}
} catch (ParseException e) {
result.append(t("lima-business.common.failed", e.getMessage()));
- } catch (FinancialTransactionException e) {
- result.append(t("lima-business.common.failed", e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ result.append(t("lima-business.common.failed", t("lima-business.import.FinancialTransaction.error.LockedFinancialPeriod")));
+ } catch (LockedEntryBookException e) {
+ result.append(t("lima-business.common.failed", t("lima-business.import.FinancialTransaction.error.LockedEntryBook")));
}
}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-07-09 15:58:34 UTC (rev 3841)
@@ -85,6 +85,8 @@
lima-business.franceaccountingrules.fiscalperiodnotempty=The fiscal period is not empty \!
lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked=
lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=The new fiscal period must adjoining the last
+lima-business.import.FinancialTransaction.error.LockedEntryBook=
+lima-business.import.FinancialTransaction.error.LockedFinancialPeriod=
lima-business.import.accountadded=SUCCES \: Account %s - %s added\n
lima-business.import.accountalreadyexist=FAILED \: Account %s already exist \n
lima-business.import.closedperiodicentrybookupdated=SUCCESS \: The blockClosedPeriodicEntryBook %s - %s - %s is updated \! \n
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-07-09 15:58:34 UTC (rev 3841)
@@ -82,6 +82,8 @@
lima-business.franceaccountingrules.fiscalperiodnotempty=La période fiscale à supprimer n'est pas vide \!
lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked=Impossible de clore la dernière période fiscale ouverte
lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=La nouvelle période fiscale doit suivre la précédente
+lima-business.import.FinancialTransaction.error.LockedEntryBook=Impossible de mettre à jour la transaction \: la période financière de ce nouveau journal est bloquée
+lima-business.import.FinancialTransaction.error.LockedFinancialPeriod=La période financière est bloquée
lima-business.import.accountadded=Succès \: Compte %s - %s ajouté\n
lima-business.import.accountalreadyexist=Échec \: Le compte %s existe déjà \n
lima-business.import.closedPeriodicEntryBook.error.NotLockedPreviousEntryBook=Les périodes financières précédentes pour ce journal doivent être bloquées avant
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AfterLastFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AfterLastFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AfterLastFiscalPeriodException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import java.util.Date;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class AfterLastFiscalPeriodException extends DateException {
+
+ public AfterLastFiscalPeriodException(Date date) {
+ super(date);
+ }
+
+ public AfterLastFiscalPeriodException(Date date, Throwable cause) {
+ super(date, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeforeFirstFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeforeFirstFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeforeFirstFiscalPeriodException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import java.util.Date;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class BeforeFirstFiscalPeriodException extends DateException {
+
+ public BeforeFirstFiscalPeriodException(Date date) {
+ super(date);
+ }
+
+ public BeforeFirstFiscalPeriodException(Date date, Throwable cause) {
+ super(date, cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -1,4 +1,4 @@
-package org.chorem.lima.business.utils;
+package org.chorem.lima.business;
/*
* #%L
@@ -28,7 +28,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class ClosedPeriodicEntryBookException extends LimaException {
+public abstract class ClosedPeriodicEntryBookException extends LimaException {
protected ClosedPeriodicEntryBook closedPeriodicEntryBook;
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/DateException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/DateException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/DateException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -0,0 +1,25 @@
+package org.chorem.lima.business;
+
+import java.util.Date;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DateException extends LimaException {
+
+ protected Date date;
+
+ public DateException(Date date) {
+ super("");
+ this.date = date;
+ }
+
+ public DateException(Date date, Throwable cause) {
+ super("", cause);
+ this.date = date;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -7,7 +7,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class EntriesException extends LimaException {
+public abstract class EntriesException extends LimaException {
protected Collection<Entry> entries;
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -27,7 +27,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class EntryBookException extends LimaException {
+public abstract class EntryBookException extends LimaException {
protected EntryBook entryBook;
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -0,0 +1,25 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FinancialPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialPeriodException extends LimaException {
+
+ protected FinancialPeriod financialPeriod;
+
+ public FinancialPeriodException(FinancialPeriod financialPeriod) {
+ super("");
+ this.financialPeriod = financialPeriod;
+ }
+
+ public FinancialPeriodException(FinancialPeriod financialPeriod, Throwable cause) {
+ super("", cause);
+ this.financialPeriod = financialPeriod;
+ }
+
+ public FinancialPeriod getFinancialPeriod() {
+ return financialPeriod;
+ }
+}
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -1,56 +0,0 @@
-package org.chorem.lima.business;
-
-/*
- * #%L
- * Lima :: business API
- * %%
- * Copyright (C) 2008 - 2014 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%
- */
-
-import org.chorem.lima.entity.FinancialTransaction;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public class FinancialTransactionException extends LimaException {
-
- protected FinancialTransaction financialTransaction;
-
- public FinancialTransactionException(String message) {
- super(message);
- }
-
- public FinancialTransactionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public FinancialTransactionException(FinancialTransaction financialTransaction, String message) {
- super(message);
- this.financialTransaction = financialTransaction;
- }
-
- public FinancialTransactionException(FinancialTransaction financialTransaction, String message, Throwable cause) {
- super(message, cause);
- this.financialTransaction = financialTransaction;
- }
-
- public FinancialTransaction getFinancialTransaction() {
- return financialTransaction;
- }
-
-}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedFinancialPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedFinancialPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedFinancialPeriodException.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -0,0 +1,16 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FinancialPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LockedFinancialPeriodException extends FinancialPeriodException{
+ public LockedFinancialPeriodException(FinancialPeriod financialPeriod) {
+ super(financialPeriod);
+ }
+
+ public LockedFinancialPeriodException(FinancialPeriod financialPeriod, Throwable cause) {
+ super(financialPeriod, cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -27,9 +27,11 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
+import org.chorem.lima.business.AfterLastFiscalPeriodException;
+import org.chorem.lima.business.BeforeFirstFiscalPeriodException;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.LockedEntryBookException;
-import org.chorem.lima.business.FinancialTransactionException;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
@@ -52,11 +54,14 @@
public interface FinancialTransactionService {
- FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
+ FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
+ throws LockedFinancialPeriodException, LockedEntryBookException;
- void updateFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
+ void updateFinancialTransaction(FinancialTransaction financialtransaction)
+ throws AfterLastFiscalPeriodException, BeforeFirstFiscalPeriodException, LockedFinancialPeriodException, LockedEntryBookException;
- void removeFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
+ void removeFinancialTransaction(FinancialTransaction financialtransaction)
+ throws LockedFinancialPeriodException, LockedEntryBookException;
FinancialTransaction getFinancialTransactionWithId(String id);
@@ -74,11 +79,11 @@
List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionFilter);
- Entry createEntry(Entry entry) throws FinancialTransactionException;
+ Entry createEntry(Entry entry) throws LockedFinancialPeriodException, LockedEntryBookException;
void updateEntry(Entry entry) throws LockedEntryBookException;
- void removeEntry(Entry entry) throws FinancialTransactionException;
+ void removeEntry(Entry entry) throws LockedFinancialPeriodException, LockedEntryBookException;
/** Find the last letter used
* and increment them
@@ -99,7 +104,8 @@
* @param SecondEntrySelected second entry selected
* @return table of the two new entries
* */
- Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws FinancialTransactionException;
+ Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected)
+ throws LockedFinancialPeriodException, LockedEntryBookException;
/**
* Retourne toutes les entrées d'une transaction
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -26,8 +26,9 @@
package org.chorem.lima.business.api;
import org.chorem.lima.business.AccountException;
-import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.LockedEntryBookException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FiscalPeriod;
@@ -67,7 +68,8 @@
* @return fiscal period blocked
* */
FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
- boolean retainedEarnings) throws AccountException, FinancialTransactionException, FiscalPeriodException;
+ boolean retainedEarnings)
+ throws AccountException, FiscalPeriodException, LockedFinancialPeriodException, LockedEntryBookException;
/**
* Test if we have retained earnings on a fiscal period
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -26,8 +26,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AfterLastFiscalPeriodException;
+import org.chorem.lima.business.BeforeFirstFiscalPeriodException;
import org.chorem.lima.business.LockedEntryBookException;
-import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Entry;
@@ -124,7 +126,7 @@
*
* @param entry entry to insert
*/
- public Entry addEntry(Entry entry) throws FinancialTransactionException {
+ public Entry addEntry(Entry entry) throws BeforeFirstFiscalPeriodException, AfterLastFiscalPeriodException, LockedFinancialPeriodException, LockedEntryBookException {
Entry newEntry = null;
FinancialTransaction transaction = entry.getFinancialTransaction();
if (contains(transaction)) {
@@ -151,13 +153,13 @@
*
* @param row
*/
- public void removeTransaction(int row) throws FinancialTransactionException {
+ public void removeTransaction(int row) throws LockedFinancialPeriodException, LockedEntryBookException {
FinancialTransaction transaction = getTransactionAt(row);
removeAll(transaction.getEntry());
financialTransactionService.removeFinancialTransaction(transaction);
}
- public void removeEntry(int row) throws FinancialTransactionException {
+ public void removeEntry(int row) throws LockedFinancialPeriodException, LockedEntryBookException {
Entry entry = get(row);
FinancialTransaction transaction = entry.getFinancialTransaction();
if (transaction.sizeEntry() > 1) {
@@ -170,7 +172,7 @@
}
}
- public FinancialTransaction addTransaction(FinancialTransaction transaction) throws FinancialTransactionException {
+ public FinancialTransaction addTransaction(FinancialTransaction transaction) throws LockedFinancialPeriodException, LockedEntryBookException, AfterLastFiscalPeriodException, BeforeFirstFiscalPeriodException {
FinancialTransaction newTransaction = new FinancialTransactionImpl();
newTransaction.setEntryBook(transaction.getEntryBook());
newTransaction.setTransactionDate(transaction.getTransactionDate());
@@ -237,11 +239,34 @@
return updated;
}
- public void updateTransaction(FinancialTransaction transaction) throws FinancialTransactionException {
+ public boolean updateTransaction(FinancialTransaction transaction) {
+ boolean update = false;
+
if (log.isDebugEnabled()) {
log.debug("Update transaction");
}
- financialTransactionService.updateFinancialTransaction(transaction);
+ try {
+ financialTransactionService.updateFinancialTransaction(transaction);
+ update = true;
+
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.update.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (AfterLastFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.update.error.afterLastFiscalPeriod",
+ e.getDate()));
+ } catch (BeforeFirstFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.update.error.beforeFirstFiscalPeriod",
+ e.getDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.update.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
+ }
+ return update;
}
public void fireTransaction(FinancialTransaction transaction) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.common.AbstractColumn;
@@ -67,11 +66,11 @@
FinancialTransaction transaction = tableModel.get(row).getFinancialTransaction();
boolean update = (transaction.getTransactionDate().compareTo((Date) value) != 0);
if (update) {
- try {
- transaction.setTransactionDate((Date) value);
- tableModel.updateTransaction(transaction);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ Date previousDate = transaction.getTransactionDate();
+ transaction.setTransactionDate((Date) value);
+ if (!tableModel.updateTransaction(transaction)) {
+ transaction.setTransactionDate(previousDate);
+ update = false;
}
}
return update;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialTransaction;
@@ -67,11 +66,11 @@
EntryBook entryBook = (EntryBook) value;
boolean update = (transaction.getEntryBook().getCode().compareTo(entryBook.getCode()) != 0);
if (update) {
- try {
- transaction.setEntryBook(entryBook);
- tableModel.updateTransaction(transaction);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ EntryBook previousEntryBook = transaction.getEntryBook();
+ transaction.setEntryBook(entryBook);
+ if (!tableModel.updateTransaction(transaction)) {
+ transaction.setEntryBook(previousEntryBook);
+ update = false;
}
}
return update;
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 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -30,8 +30,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.AfterLastFiscalPeriodException;
+import org.chorem.lima.business.BeforeFirstFiscalPeriodException;
import org.chorem.lima.business.LockedEntryBookException;
-import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -434,8 +436,22 @@
int index = tableModel.indexOf(transaction);
selectionModel.setSelectionInterval(index, index);
table.editCellAt(index, 1);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.paste.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (AfterLastFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.paste.error.afterLastFiscalPeriod",
+ e.getDate()));
+ } catch (BeforeFirstFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.paste.error.beforeFirstFiscalPeriod",
+ e.getDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.paste.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
}
@@ -475,8 +491,22 @@
//focus on second column
table.changeSelection(index, 1, false, false);
table.editCellAt(index, 1);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.paste.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (AfterLastFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.paste.error.afterLastFiscalPeriod",
+ e.getDate()));
+ } catch (BeforeFirstFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.paste.error.beforeFirstFiscalPeriod",
+ e.getDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.paste.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
}
@@ -512,8 +542,22 @@
selectionModel.setSelectionInterval(addIndex, addIndex);
table.changeSelection(addIndex, 1, false, false);
table.editCellAt(addIndex, 1);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.add.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (AfterLastFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.add.error.afterLastFiscalPeriod",
+ e.getDate()));
+ } catch (BeforeFirstFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.add.error.beforeFirstFiscalPeriod",
+ e.getDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.add.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
@@ -602,8 +646,22 @@
row, row);
table.changeSelection(row, 1, false, false);
table.editCellAt(row, 1);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (AfterLastFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.afterLastFiscalPeriod",
+ e.getDate()));
+ } catch (BeforeFirstFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.beforeFirstFiscalPeriod",
+ e.getDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
} else {
if (log.isWarnEnabled()) {
@@ -640,8 +698,16 @@
table.changeSelection(indexSelectedRow, 1, false, false);
table.editCellAt(indexSelectedRow, 1);
}
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
@@ -678,8 +744,16 @@
table.changeSelection(indexSelectedRow, 1, false, false);
table.editCellAt(indexSelectedRow, 1);
}
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -28,7 +28,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
-import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.AfterLastFiscalPeriodException;
+import org.chorem.lima.business.BeforeFirstFiscalPeriodException;
+import org.chorem.lima.business.LockedEntryBookException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
@@ -174,8 +177,22 @@
row, row);
table.changeSelection(row, 1, false, false);
table.editCellAt(row, 1);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (AfterLastFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.afterLastFiscalPeriod",
+ e.getDate()));
+ } catch (BeforeFirstFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.beforeFirstFiscalPeriod",
+ e.getDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.add.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
} else {
if (log.isWarnEnabled()) {
@@ -222,8 +239,16 @@
table.changeSelection(indexSelectedRow, 1, false, false);
table.editCellAt(indexSelectedRow, 1);
}
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
} else {
@@ -271,8 +296,16 @@
table.changeSelection(indexSelectedRow, 1, false, false);
table.editCellAt(indexSelectedRow, 1);
}
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.financialTransaction.delete.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
} else {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-07-09 15:58:34 UTC (rev 3841)
@@ -32,7 +32,7 @@
import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.LetteringFilterImpl;
import org.chorem.lima.business.LockedEntryBookException;
-import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.LockedFinancialPeriodException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -429,8 +429,16 @@
* and the new sameAccountEntry
* */
view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
- } catch (FinancialTransactionException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedFinancialPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.lettering.roundAndCreateEntry.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.lettering.roundAndCreateEntry.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-09 15:58:34 UTC (rev 3841)
@@ -361,6 +361,14 @@
lima.ui.common.update=Update
lima.ui.entries.assign.closed.entryBook.error=
lima.ui.entries.letter.closed.entryBook.error=
+lima.ui.entry.add.error.afterLastFiscalPeriod=
+lima.ui.entry.add.error.beforeFirstFiscalPeriod=
+lima.ui.entry.add.error.lockedEntryBook=
+lima.ui.entry.add.error.lockedFinancialPeriod=
+lima.ui.entry.paste.error.afterLastFiscalPeriod=
+lima.ui.entry.paste.error.beforeFirstFiscalPeriod=
+lima.ui.entry.paste.error.lockedEntryBook=
+lima.ui.entry.paste.error.lockedFinancialPeriod=
lima.ui.entry.update.closed.entryBook.error=
lima.ui.entryBook.delete.used.error=Can't delete entry book %2$s (%1$s) because exist financcial transactions in this entry book.
lima.ui.entrybook.add=
@@ -374,6 +382,20 @@
lima.ui.entrybook.label=
lima.ui.entrybook.remove=
lima.ui.entrybook.update=
+lima.ui.financialTransaction.add.error.afterLastFiscalPeriod=
+lima.ui.financialTransaction.add.error.beforeFirstFiscalPeriod=
+lima.ui.financialTransaction.add.error.lockedEntryBook=
+lima.ui.financialTransaction.add.error.lockedFinancialPeriod=
+lima.ui.financialTransaction.delete.error.lockedEntryBook=
+lima.ui.financialTransaction.delete.error.lockedFinancialPeriod=
+lima.ui.financialTransaction.paste.error.afterLastFiscalPeriod=
+lima.ui.financialTransaction.paste.error.beforeFirstFiscalPeriod=
+lima.ui.financialTransaction.paste.error.lockedEntryBook=
+lima.ui.financialTransaction.paste.error.lockedFinancialPeriod=
+lima.ui.financialTransaction.update.error.afterLastFiscalPeriod=
+lima.ui.financialTransaction.update.error.beforeFirstFiscalPeriod=
+lima.ui.financialTransaction.update.error.lockedEntryBook=
+lima.ui.financialTransaction.update.error.lockedFinancialPeriod=
lima.ui.financialperiod.begin=
lima.ui.financialperiod.block=
lima.ui.financialperiod.block.error.NoLockedPreviousEntryBook.main=
@@ -513,6 +535,8 @@
lima.ui.lettering.endFinancialPeriod=To
lima.ui.lettering.entry=Entries
lima.ui.lettering.period=Periods
+lima.ui.lettering.roundAndCreateEntry.error.lockedEntryBook=
+lima.ui.lettering.roundAndCreateEntry.error.lockedFinancialPeriod=
lima.ui.lettering.selectCredit=
lima.ui.lettering.selectDebit=
lima.ui.lettering.selectEntry=Actual selection
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-09 13:13:18 UTC (rev 3840)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-09 15:58:34 UTC (rev 3841)
@@ -341,9 +341,17 @@
lima.ui.common.remove=Supprimer
lima.ui.common.solde=Solde
lima.ui.common.update=Modifier
-lima.ui.entries.assign.closed.entryBook.error=Impossible d'affecter cette valeur a l'ensemble des entrés de la transaction car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY
-lima.ui.entries.letter.closed.entryBook.error=Impossible de modifier le lettrage des ces entrés car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY
-lima.ui.entry.update.closed.entryBook.error=Impossible de modifier cette entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY
+lima.ui.entries.assign.closed.entryBook.error=Impossible d'affecter cette valeur a l'ensemble des entrés de la transaction car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.entries.letter.closed.entryBook.error=Impossible de modifier le lettrage des ces entrés car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.entry.add.error.afterLastFiscalPeriod=Impossible d'ajouter une entré car la date de la transaction est après le %1$te %1$tB %1$tY fin du dernier exercice.
+lima.ui.entry.add.error.beforeFirstFiscalPeriod=Impossible d'ajouter une entré car la date de la transaction est avant le %1$te %1$tB %1$tY début du premier exercice.
+lima.ui.entry.add.error.lockedEntryBook=Impossible d'ajouter une entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.entry.add.error.lockedFinancialPeriod=Impossible d'ajouter une entré car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée.
+lima.ui.entry.paste.error.afterLastFiscalPeriod=Impossible de copier une entré car la date de la transaction est après le %1$te %1$tB %1$tY fin du dernier exercice.
+lima.ui.entry.paste.error.beforeFirstFiscalPeriod=Impossible de copier une entré car la date de la transaction est avant le %1$te %1$tB %1$tY début du premier exercice.
+lima.ui.entry.paste.error.lockedEntryBook=Impossible de copier une entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.entry.paste.error.lockedFinancialPeriod=Impossible de copier une entré car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée.
+lima.ui.entry.update.closed.entryBook.error=Impossible de modifier cette entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
lima.ui.entryBook.delete.used.error=Imposible de supprimer le journal %2$s (%1$s) car Il existe des transactioins sur ce journal.
lima.ui.entrybook.add=Ajout de journal
lima.ui.entrybook.code=Code
@@ -356,6 +364,20 @@
lima.ui.entrybook.label=Libellé
lima.ui.entrybook.remove=Supprimer
lima.ui.entrybook.update=Modifier
+lima.ui.financialTransaction.add.error.afterLastFiscalPeriod=Impossible d'ajouter une transaction après le %1$te %1$tB %1$tY fin du dernier exercice.
+lima.ui.financialTransaction.add.error.beforeFirstFiscalPeriod=Impossible d'ajouter une transaction avant le %1$te %1$tB %1$tY début du premier exercice.
+lima.ui.financialTransaction.add.error.lockedEntryBook=Impossible d'ajouter une transaction car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.financialTransaction.add.error.lockedFinancialPeriod=Impossible d'ajouter une transaction car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée.
+lima.ui.financialTransaction.delete.error.lockedEntryBook=Impossible de supprimer une transaction car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.financialTransaction.delete.error.lockedFinancialPeriod=Impossible de supprimer une transaction car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée.
+lima.ui.financialTransaction.paste.error.afterLastFiscalPeriod=Impossible de copier une transaction après le %1$te %1$tB %1$tY fin du dernier exercice.
+lima.ui.financialTransaction.paste.error.beforeFirstFiscalPeriod=Impossible de copier une transaction avant le %1$te %1$tB %1$tY début du premier exercice.
+lima.ui.financialTransaction.paste.error.lockedEntryBook=Impossible de copier une transaction car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.financialTransaction.paste.error.lockedFinancialPeriod=Impossible de copier une transaction car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée.
+lima.ui.financialTransaction.update.error.afterLastFiscalPeriod=Impossible de déplacer une transaction après le %1$te %1$tB %1$tY fin du dernier exercice.
+lima.ui.financialTransaction.update.error.beforeFirstFiscalPeriod=Impossible de déplacer une transaction avant le %1$te %1$tB %1$tY début du premier exercice.
+lima.ui.financialTransaction.update.error.lockedEntryBook=Impossible de déplacer une transaction car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.financialTransaction.update.error.lockedFinancialPeriod=Impossible de deplacer une transaction car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée.
lima.ui.financialperiod.begin=Début
lima.ui.financialperiod.block=Cloturer une période
lima.ui.financialperiod.block.error.noLockedPreviousEntryBook.main=Impossible de clôturer cette période car les périodes précedentes ne sont pas clôturer \:
@@ -487,6 +509,8 @@
lima.ui.lettering.endFinancialPeriod=A
lima.ui.lettering.entry=Écritures
lima.ui.lettering.period=Périodes
+lima.ui.lettering.roundAndCreateEntry.error.lockedEntryBook=Impossible de modifier le lettrage d'une entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY.
+lima.ui.lettering.roundAndCreateEntry.error.lockedFinancialPeriod=Impossible de modifier le lettrage d'une entré car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée.
lima.ui.lettering.selectCredit=Crédit
lima.ui.lettering.selectDebit=Débit
lima.ui.lettering.selectEntry=Sélection courante
1
0
Author: sbavencoff
Date: 2014-07-09 15:13:18 +0200 (Wed, 09 Jul 2014)
New Revision: 3840
Url: http://forge.chorem.org/projects/lima/repository/revisions/3840
Log:
refs #557 : fix exception when lock periodic entry book
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBooksException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionsException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotLockedClosedPeriodicEntryBooksException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnbalancedFinancialTransactionsException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnfilledEntriesException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/WithoutEntryBookFinancialTransactionsException.java
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.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/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
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 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -25,7 +25,6 @@
package org.chorem.lima.business;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
@@ -97,7 +96,11 @@
* Check if a financial period can be closed.
*
* @param closedPeriodicEntryBook
- * @throws LimaException
+ * @throws UnfilledEntriesException, WithoutEntryBookFinancialTransactionsException, UnbalancedFinancialTransactionsException, NotLockedClosedPeriodicEntryBooksException
*/
- void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException;
+ void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook)
+ throws UnfilledEntriesException,
+ WithoutEntryBookFinancialTransactionsException,
+ UnbalancedFinancialTransactionsException,
+ NotLockedClosedPeriodicEntryBooksException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -29,14 +29,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaInterceptor;
+import org.chorem.lima.business.LockedEntryBookException;
+import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
+import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
+import org.chorem.lima.business.UnfilledEntriesException;
import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.UsedEntryBookException;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
+import org.chorem.lima.business.WithoutEntryBookFinancialTransactionsException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
@@ -199,7 +202,7 @@
*/
@Override
public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook)
- throws ClosedPeriodicEntryBookException {
+ throws UnbalancedFinancialTransactionsException, UnfilledEntriesException, WithoutEntryBookFinancialTransactionsException, NotLockedClosedPeriodicEntryBooksException {
FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
@@ -209,26 +212,29 @@
// Check if all financial transactions of closedperiodicentrybook are equilibrate
FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod();
- if (financialTransactionTopiaDao.isExistUnbalancedTransaction(
+ List<FinancialTransaction> allUnbalancedTransaction = financialTransactionTopiaDao.getAllUnbalancedTransaction(
period.getBeginDate(),
period.getEndDate(),
- closedPeriodicEntryBook.getEntryBook())) {
- throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.blockerrorequillibrate");
+ closedPeriodicEntryBook.getEntryBook());
+ if (!allUnbalancedTransaction.isEmpty()) {
+ throw new UnbalancedFinancialTransactionsException(allUnbalancedTransaction);
}
// Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
- if (entryDao.isExistUnfilledEntry(
+ List<Entry> allUnfilledEntry = entryDao.findAllUnfilledEntry(
period.getBeginDate(),
period.getEndDate(),
- closedPeriodicEntryBook.getEntryBook())) {
- throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.missingelements");
+ closedPeriodicEntryBook.getEntryBook());
+ if (!allUnfilledEntry.isEmpty()) {
+ throw new UnfilledEntriesException(allUnfilledEntry);
}
// Check if all financial transactions have EntryBooks
- if (financialTransactionTopiaDao.isExistTransactionWithoutEntryBook(
+ List<FinancialTransaction> allTransactionWithoutEntryBook = financialTransactionTopiaDao.findAllTransactionWithoutEntryBook(
period.getBeginDate(),
- period.getEndDate())) {
- throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.missingentrybook");
+ period.getEndDate());
+ if (!allTransactionWithoutEntryBook.isEmpty()) {
+ throw new WithoutEntryBookFinancialTransactionsException(allTransactionWithoutEntryBook);
}
}
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 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -31,7 +31,10 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.InvalidAccountNumberException;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
+import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
+import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
+import org.chorem.lima.business.UnfilledEntriesException;
+import org.chorem.lima.business.WithoutEntryBookFinancialTransactionsException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
@@ -204,17 +207,20 @@
* Check if all previous financial period for a an entrybook are closed before bock the asked closedperiodicentrybook
*/
@Override
- public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException {
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook)
+ throws UnbalancedFinancialTransactionsException, WithoutEntryBookFinancialTransactionsException,
+ UnfilledEntriesException, NotLockedClosedPeriodicEntryBooksException {
+
super.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- boolean existPrevousNotClosed = closedPeriodicEntryBookDao
- .existPreviousClosedPeriodicEntryBooksNotClosed(closedPeriodicEntryBook);
+ List<ClosedPeriodicEntryBook> allPreviousClosedPeriodicEntryBooksNotLocked =
+ closedPeriodicEntryBookDao.findAllPreviousClosedPeriodicEntryBooksNotLocked(closedPeriodicEntryBook);
//Check if the fiscal period to block is the oldest
- if (existPrevousNotClosed) {
- throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook");
+ if (!allPreviousClosedPeriodicEntryBooksNotLocked.isEmpty()) {
+ throw new NotLockedClosedPeriodicEntryBooksException(allPreviousClosedPeriodicEntryBooksNotLocked);
}
}
}
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 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -27,8 +27,11 @@
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
+import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
+import org.chorem.lima.business.UnfilledEntriesException;
+import org.chorem.lima.business.WithoutEntryBookFinancialTransactionsException;
import org.chorem.lima.business.api.FinancialPeriodService;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.EntryBook;
@@ -91,7 +94,7 @@
}
@Override
- public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException {
+ public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws UnbalancedFinancialTransactionsException, UnfilledEntriesException, WithoutEntryBookFinancialTransactionsException, NotLockedClosedPeriodicEntryBooksException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
ClosedPeriodicEntryBook result;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -55,6 +55,10 @@
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.ImportEbpException;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
+import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
+import org.chorem.lima.business.UnfilledEntriesException;
+import org.chorem.lima.business.WithoutEntryBookFinancialTransactionsException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ClosedPeriodicEntryBookService;
import org.chorem.lima.business.api.EntryBookService;
@@ -66,7 +70,6 @@
import org.chorem.lima.business.api.IdentityService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.VatStatementService;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryEBPComparator;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
@@ -1262,8 +1265,14 @@
beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook));
} catch (ParseException e) {
result.append(t("lima-business.common.failed", e.getMessage()));
- } catch (ClosedPeriodicEntryBookException e) {
- result.append(t("lima-business.common.failed", e.getMessage()));
+ } catch (UnbalancedFinancialTransactionsException e) {
+ result.append(t("lima-business.common.failed", t("lima-business.import.closedPeriodicEntryBook.error.unbalanced")));
+ } catch (UnfilledEntriesException e) {
+ result.append(t("lima-business.common.failed", t("lima-business.import.closedPeriodicEntryBook.error.unfilled")));
+ } catch (WithoutEntryBookFinancialTransactionsException e) {
+ result.append(t("lima-business.common.failed", t("lima-business.import.closedPeriodicEntryBook.error.withoutEntryBook")));
+ } catch (NotLockedClosedPeriodicEntryBooksException e) {
+ result.append(t("lima-business.common.failed", t("lima-business.import.closedPeriodicEntryBook.error.NotLockedPreviousEntryBook")));
}
}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-07-09 13:13:18 UTC (rev 3840)
@@ -5,7 +5,6 @@
lima-business.account.accountalreardyexist=Un compte existe déjà avec ce numéro \: %s
lima-business.common.failed=Échec \: %s \n
lima-business.defaultaccountingrules.allentrybookclosed=Tous les journaux de cette période financière sont fermés
-lima-business.defaultaccountingrules.blockerrorequillibrate=Impossible de bloquer la période financière / le journal, il contient des transactions non équilibrées
lima-business.defaultaccountingrules.dateaftererror=La date est postérieure à la période fiscale
lima-business.defaultaccountingrules.datebeforeerror=La date est antérieure à la période fiscale
lima-business.defaultaccountingrules.deleteaccounterror=Impossible de supprimer un comte contenant des entrées
@@ -15,8 +14,6 @@
lima-business.defaultaccountingrules.financialperiodblocked=La période financière est bloquée
lima-business.defaultaccountingrules.financialtransactionblocked=La période financière de cette transaction est bloquée
lima-business.defaultaccountingrules.invalidaccountnumber=Numéro de compte invalide \: %d
-lima-business.defaultaccountingrules.missingelements=Impossible de bloquer la période financière / il manque des éléments dans des transactions
-lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
lima-business.document.account=Compte
lima-business.document.accountnumber=N° Compte
lima-business.document.accounts=Comptes
@@ -81,13 +78,16 @@
lima-business.fiscalperiod.previousfiscalperiodalreadyblocked=La dernière période financière de la période fiscale est bloquée
lima-business.franceaccountingrules.accountnumbernotnumeric=Le numéro de compte n'est pas numérique \: %s
lima-business.franceaccountingrules.accountstartnumbererror=Le numéro du compte général n'est pas compris entre 1 et 8 \: %s
-lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=Les périodes financières précédentes pour ce journal doivent être bloquées avant
lima-business.franceaccountingrules.antefiscalperiodnotblocked=Le nombre maximal d'exercices ouverts est déjà ateint
lima-business.franceaccountingrules.fiscalperiodnotempty=La période fiscale à supprimer n'est pas vide \!
lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked=Impossible de clore la dernière période fiscale ouverte
lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=La nouvelle période fiscale doit suivre la précédente
lima-business.import.accountadded=Succès \: Compte %s - %s ajouté\n
lima-business.import.accountalreadyexist=Échec \: Le compte %s existe déjà \n
+lima-business.import.closedPeriodicEntryBook.error.NotLockedPreviousEntryBook=Les périodes financières précédentes pour ce journal doivent être bloquées avant
+lima-business.import.closedPeriodicEntryBook.error.unbalanced=Impossible de bloquer la période financière / le journal, il contient des transactions non équilibrées
+lima-business.import.closedPeriodicEntryBook.error.unfilled=Impossible de bloquer la période financière / il manque des éléments dans des transactions
+lima-business.import.closedPeriodicEntryBook.error.withoutEntryBook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
lima-business.import.closedperiodicentrybookupdated=Succès \: La période financière %s - %s - %s est ajoutée \! \n
lima-business.import.ebpmissingaccount=Échec \: Compte %s inexistant. \nImportation annulée. \nCréer tous les comptes avant d'importer les écritures.
lima-business.import.ebpnoentry=Échec \: Ce fichier ne contient aucune entrée.
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 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -62,9 +62,9 @@
LimaCallaoTopiaPersistenceContext tcontext = context.newPersistenceContext();
FinancialTransactionTopiaDao ftDAO = tcontext.getFinancialTransactionDao();
- Assert.assertFalse(ftDAO.isExistUnbalancedTransaction(
+ Assert.assertTrue(ftDAO.getAllUnbalancedTransaction(
financialPeriod.getBeginDate(),
financialPeriod.getEndDate(),
- journalDesVentes));
+ journalDesVentes).isEmpty());
}
}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBooksException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBooksException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBooksException.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -0,0 +1,27 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+
+import java.util.Collection;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class ClosedPeriodicEntryBooksException extends LimaException {
+
+ protected Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks;
+
+ public ClosedPeriodicEntryBooksException(Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks) {
+ super("");
+ this.closedPeriodicEntryBooks = closedPeriodicEntryBooks;
+ }
+
+ public ClosedPeriodicEntryBooksException(Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks, Throwable cause) {
+ super("", cause);
+ this.closedPeriodicEntryBooks = closedPeriodicEntryBooks;
+ }
+
+ public Collection<ClosedPeriodicEntryBook> getClosedPeriodicEntryBooks() {
+ return closedPeriodicEntryBooks;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -0,0 +1,27 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.Entry;
+
+import java.util.Collection;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntriesException extends LimaException {
+
+ protected Collection<Entry> entries;
+
+ public EntriesException(Collection<Entry> entries) {
+ super("");
+ this.entries = entries;
+ }
+
+ public EntriesException(Collection<Entry> entries, Throwable cause) {
+ super("", cause);
+ this.entries = entries;
+ }
+
+ public Collection<Entry> getEntries() {
+ return entries;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionsException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionsException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionsException.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -0,0 +1,27 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FinancialTransaction;
+
+import java.util.Collection;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class FinancialTransactionsException extends LimaException {
+
+ protected Collection<FinancialTransaction> financialTransactions;
+
+ public FinancialTransactionsException(Collection<FinancialTransaction> financialTransactions) {
+ super("");
+ this.financialTransactions = financialTransactions;
+ }
+
+ public FinancialTransactionsException(Collection<FinancialTransaction> financialTransactions, Throwable cause) {
+ super("", cause);
+ this.financialTransactions = financialTransactions;
+ }
+
+ public Collection<FinancialTransaction> getFinancialTransactions() {
+ return financialTransactions;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotLockedClosedPeriodicEntryBooksException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotLockedClosedPeriodicEntryBooksException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotLockedClosedPeriodicEntryBooksException.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -0,0 +1,18 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+
+import java.util.Collection;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class NotLockedClosedPeriodicEntryBooksException extends ClosedPeriodicEntryBooksException {
+ public NotLockedClosedPeriodicEntryBooksException(Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks) {
+ super(closedPeriodicEntryBooks);
+ }
+
+ public NotLockedClosedPeriodicEntryBooksException(Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks, Throwable cause) {
+ super(closedPeriodicEntryBooks, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnbalancedFinancialTransactionsException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnbalancedFinancialTransactionsException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnbalancedFinancialTransactionsException.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -0,0 +1,19 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FinancialTransaction;
+
+import java.util.Collection;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class UnbalancedFinancialTransactionsException extends FinancialTransactionsException {
+
+ public UnbalancedFinancialTransactionsException(Collection<FinancialTransaction> financialTransactions) {
+ super(financialTransactions);
+ }
+
+ public UnbalancedFinancialTransactionsException(Collection<FinancialTransaction> financialTransactions, Throwable cause) {
+ super(financialTransactions, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnfilledEntriesException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnfilledEntriesException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnfilledEntriesException.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -0,0 +1,18 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.Entry;
+
+import java.util.Collection;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class UnfilledEntriesException extends EntriesException {
+ public UnfilledEntriesException(Collection<Entry> entries) {
+ super(entries);
+ }
+
+ public UnfilledEntriesException(Collection<Entry> entries, Throwable cause) {
+ super(entries, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/WithoutEntryBookFinancialTransactionsException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/WithoutEntryBookFinancialTransactionsException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/WithoutEntryBookFinancialTransactionsException.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -0,0 +1,18 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FinancialTransaction;
+
+import java.util.Collection;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class WithoutEntryBookFinancialTransactionsException extends FinancialTransactionsException {
+ public WithoutEntryBookFinancialTransactionsException(Collection<FinancialTransaction> financialTransactions) {
+ super(financialTransactions);
+ }
+
+ public WithoutEntryBookFinancialTransactionsException(Collection<FinancialTransaction> financialTransactions, Throwable cause) {
+ super(financialTransactions, cause);
+ }
+}
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 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -25,7 +25,10 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
+import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
+import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
+import org.chorem.lima.business.UnfilledEntriesException;
+import org.chorem.lima.business.WithoutEntryBookFinancialTransactionsException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
@@ -52,7 +55,11 @@
List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException;
+ ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook)
+ throws UnbalancedFinancialTransactionsException,
+ UnfilledEntriesException,
+ WithoutEntryBookFinancialTransactionsException,
+ NotLockedClosedPeriodicEntryBooksException;
List<FinancialPeriod> getAllFinancialPeriods();
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -166,11 +166,11 @@
}
/**
- * if exist previous ClosedPeriodicEntryBook not close
+ * find all previous ClosedPeriodicEntryBook not close
*
- * @return exist previous ClosedPeriodicEntryBook not close
+ * @return previous ClosedPeriodicEntryBook not close
*/
- public boolean existPreviousClosedPeriodicEntryBooksNotClosed(ClosedPeriodicEntryBook closedPeriodicEntryBook) {
+ public List<ClosedPeriodicEntryBook> findAllPreviousClosedPeriodicEntryBooksNotLocked(ClosedPeriodicEntryBook closedPeriodicEntryBook) {
HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
builder.addEquals(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, closedPeriodicEntryBook.getEntryBook());
builder.addEquals(ClosedPeriodicEntryBook.PROPERTY_LOCKED, false);
@@ -178,9 +178,8 @@
ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD + "." + FinancialPeriod.PROPERTY_END_DATE,
closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
- boolean exist = exists(builder.getHql(), builder.getHqlParameters());
-
- return exist;
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = findAll(builder.getHql(), builder.getHqlParameters());
+ return closedPeriodicEntryBooks;
}
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -259,14 +259,14 @@
}
/**
- * if exist entry where some field are not filled in.
+ * gat all entries where some field are not filled in.
*
* @param beginDate begin date
* @param endDate end date
* @param entryBook entry book
- * @return has entry where some field are not filled in
+ * @return all entries where some field are not filled in
*/
- public boolean isExistUnfilledEntry(Date beginDate, Date endDate, EntryBook entryBook) {
+ public List<Entry> findAllUnfilledEntry(Date beginDate, Date endDate, EntryBook entryBook) {
HqlAndParametersBuilder<Entry> builder = newHqlAndParametersBuilder();
builder.addEquals(PROPERTY_ENTRY_BOOK, entryBook);
@@ -278,9 +278,9 @@
"OR " + Entry.PROPERTY_DESCRIPTION + " = null " +
"OR " + Entry.PROPERTY_DESCRIPTION + " = ''" );
- boolean exists = exists(builder.getHql(), builder.getHqlParameters());
+ List<Entry> entries = findAll(builder.getHql(), builder.getHqlParameters());
- return exists;
+ return entries;
}
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionTopiaDao.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -110,14 +110,14 @@
}
/**
- * Find if has unbalanced transactions.
+ * Find all unbalanced transactions.
*
* @param beginDate beginDate
* @param endDate endDate
* @param entryBook entry book (can be null)
* @return if exist unbalanced transactions
*/
- public boolean isExistUnbalancedTransaction(Date beginDate, Date endDate,
+ public List<FinancialTransaction> getAllUnbalancedTransaction(Date beginDate, Date endDate,
EntryBook entryBook) {
HqlAndParametersBuilder<FinancialTransaction> builder = newHqlAndParametersBuilder();
@@ -128,17 +128,17 @@
}
builder.addWhereClause(getBalancedClause(builder.getAlias(), false));
builder.setOrderByArguments(FinancialTransaction.PROPERTY_TRANSACTION_DATE, FinancialTransaction.PROPERTY_TOPIA_CREATE_DATE);
- boolean exists = exists(builder.getHql(), builder.getHqlParameters());
- return exists;
+ List<FinancialTransaction> transactions = findAll(builder.getHql(), builder.getHqlParameters());
+ return transactions;
}
/**
- * Find all unbalanced transactions.
+ * Find all balanced transactions.
*
* @param beginDate beginDate
* @param endDate endDate
* @param entryBook entry book (can be null)
- * @return unbalanced transactions
+ * @return balanced transactions
*/
public List<FinancialTransaction> getAllBalancedTransaction(Date beginDate, Date endDate,
EntryBook entryBook) {
@@ -197,21 +197,22 @@
}
/**
- * if exist transaction without entry book.
+ * find all transactions without entry book.
*
* @param beginDate begin date
* @param endDate end date
- * @return exist transaction without entry books
+ * @return transactions without entry books
*/
- public boolean isExistTransactionWithoutEntryBook(Date beginDate, Date endDate) {
+ public List<FinancialTransaction> findAllTransactionWithoutEntryBook(Date beginDate, Date endDate) {
HqlAndParametersBuilder<FinancialTransaction> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(FinancialTransaction.PROPERTY_TRANSACTION_DATE, beginDate);
builder.addLowerOrEquals(FinancialTransaction.PROPERTY_TRANSACTION_DATE, endDate);
builder.addNull(FinancialTransaction.PROPERTY_ENTRY_BOOK);
- boolean exists = exists(builder.getHql(), builder.getHqlParameters());
- return exists;
+ List<FinancialTransaction> transactions = findAll(builder.getHql(), builder.getHqlParameters());
+ return transactions;
+
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -37,6 +37,32 @@
private static final long serialVersionUID = -2499433026151065390L;
+ public static String format(BigDecimal value) {
+
+ LimaConfig config = LimaContext.getContext().getConfig();
+ String scale = "";
+ for (int i = 0; i < config.getScale(); i++) {
+ scale += "0";
+ }
+ String currency = "";
+ if (config.getCurrency()) {
+ currency = " ¤";
+ }
+ DecimalFormat formatter = new DecimalFormat("##0." + scale + currency);
+ DecimalFormatSymbols symbol = new DecimalFormatSymbols();
+ //set decimalSeparator and thousandSeparator preferences
+ symbol.setDecimalSeparator(config.getDecimalSeparator());
+ symbol.setMonetaryDecimalSeparator(config.getDecimalSeparator());
+ symbol.setGroupingSeparator(config.getThousandSeparator());
+ formatter.setDecimalFormatSymbols(symbol);
+ //always set grouping
+ formatter.setGroupingUsed(true);
+ formatter.setGroupingSize(3);
+ String result = formatter.format(value);
+ return result;
+ }
+
+
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
@@ -50,26 +76,7 @@
public void setValue(Object aValue) {
Object result = aValue;
if (aValue != null && aValue instanceof BigDecimal) {
- LimaConfig config = LimaContext.getContext().getConfig();
- String scale = "";
- for (int i = 0; i < config.getScale(); i++) {
- scale += "0";
- }
- String currency = "";
- if (config.getCurrency()) {
- currency = " ¤";
- }
- DecimalFormat formatter = new DecimalFormat("##0." + scale + currency);
- DecimalFormatSymbols symbol = new DecimalFormatSymbols();
- //set decimalSeparator and thousandSeparator preferences
- symbol.setDecimalSeparator(config.getDecimalSeparator());
- symbol.setMonetaryDecimalSeparator(config.getDecimalSeparator());
- symbol.setGroupingSeparator(config.getThousandSeparator());
- formatter.setDecimalFormatSymbols(symbol);
- //always set grouping
- formatter.setGroupingUsed(true);
- formatter.setGroupingSize(3);
- result = formatter.format(result);
+ result = format((BigDecimal)result);
}
super.setValue(result);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2014-07-09 13:13:18 UTC (rev 3840)
@@ -25,21 +25,33 @@
package org.chorem.lima.ui.financialperiod;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
+import org.chorem.lima.business.UnfilledEntriesException;
+import org.chorem.lima.business.WithoutEntryBookFinancialTransactionsException;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.Collections;
@@ -124,8 +136,48 @@
try {
closedPeriodicEntryBook = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
model.setValue(selectedRow, closedPeriodicEntryBook);
- } catch (ClosedPeriodicEntryBookException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (UnbalancedFinancialTransactionsException e) {
+ String message = t("lima.ui.financialperiod.block.error.unbalanced.main");
+ for (FinancialTransaction transaction : e.getFinancialTransactions()) {
+ message += "\n - " + t("lima.ui.financialperiod.block.error.unbalanced.transaction",
+ transaction.getTransactionDate(),
+ BigDecimalTableCellRenderer.format(transaction.getAmountDebit()),
+ BigDecimalTableCellRenderer.format(transaction.getAmountCredit()));
+ }
+ errorHelper.showErrorMessage(message);
+ } catch (UnfilledEntriesException e) {
+ String message = t("lima.ui.financialperiod.block.error.unfilled.main");
+ for (Entry entry : e.getEntries()) {
+ message += "\n - " + t("lima.ui.financialperiod.block.error.unfilled.entry",
+ entry.getFinancialTransaction().getTransactionDate(),
+ BigDecimalTableCellRenderer.format(entry.getAmount()));
+ if (entry.getAccount() == null) {
+ message += "\n - " + t("lima.ui.financialperiod.block.error.unfilled.noAccount");
+ }
+ if (StringUtils.isBlank(entry.getVoucher())) {
+ message += "\n - " + t("lima.ui.financialperiod.block.error.unfilled.noVoucher");
+ }
+ if (StringUtils.isBlank(entry.getDescription())) {
+ message += "\n - " + t("lima.ui.financialperiod.block.error.unfilled.noDescription");
+ }
+ }
+ errorHelper.showErrorMessage(message);
+ } catch (WithoutEntryBookFinancialTransactionsException e) {
+ String message = t("lima.ui.financialperiod.block.error.withoutEntryBook.main");
+ for (FinancialTransaction transaction : e.getFinancialTransactions()) {
+ message += "\n - " + t("lima.ui.financialperiod.block.error.withoutEntryBook.transaction",
+ transaction.getTransactionDate(),
+ BigDecimalTableCellRenderer.format(transaction.getAmountCredit()));
+ }
+ errorHelper.showErrorMessage(message);
+ } catch (NotLockedClosedPeriodicEntryBooksException e) {
+ String message = t("lima.ui.financialperiod.block.error.noLockedPreviousEntryBook.main");
+ for (ClosedPeriodicEntryBook previousClosedPeriodicEntryBook : e.getClosedPeriodicEntryBooks()) {
+ message += "\n - " + t("lima.ui.financialperiod.block.error.noLockedPreviousEntryBook.previousEntryBook",
+ previousClosedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
+ previousClosedPeriodicEntryBook.getFinancialPeriod().getEndDate());
+ }
+ errorHelper.showErrorMessage(message);
}
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-09 13:13:18 UTC (rev 3840)
@@ -376,6 +376,20 @@
lima.ui.entrybook.update=
lima.ui.financialperiod.begin=
lima.ui.financialperiod.block=
+lima.ui.financialperiod.block.error.NoLockedPreviousEntryBook.main=
+lima.ui.financialperiod.block.error.entry=
+lima.ui.financialperiod.block.error.noLockedPreviousEntryBook.main=
+lima.ui.financialperiod.block.error.noLockedPreviousEntryBook.previousEntryBook=
+lima.ui.financialperiod.block.error.unbalanced.main=
+lima.ui.financialperiod.block.error.unbalanced.transaction=
+lima.ui.financialperiod.block.error.unfilled.entry=
+lima.ui.financialperiod.block.error.unfilled.main=
+lima.ui.financialperiod.block.error.unfilled.noAccount=
+lima.ui.financialperiod.block.error.unfilled.noDescription=
+lima.ui.financialperiod.block.error.unfilled.noVoucher=
+lima.ui.financialperiod.block.error.unfilled.noVouchier=
+lima.ui.financialperiod.block.error.withoutEntryBook.main=
+lima.ui.financialperiod.block.error.withoutEntryBook.transaction=
lima.ui.financialperiod.blockmessage=
lima.ui.financialperiod.blocktitle=
lima.ui.financialperiod.closure=
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-09 09:02:03 UTC (rev 3839)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-09 13:13:18 UTC (rev 3840)
@@ -358,6 +358,17 @@
lima.ui.entrybook.update=Modifier
lima.ui.financialperiod.begin=Début
lima.ui.financialperiod.block=Cloturer une période
+lima.ui.financialperiod.block.error.noLockedPreviousEntryBook.main=Impossible de clôturer cette période car les périodes précedentes ne sont pas clôturer \:
+lima.ui.financialperiod.block.error.noLockedPreviousEntryBook.previousEntryBook=période du %1$te %1$tB %1$tY au %2$te %2$tB %2$tY
+lima.ui.financialperiod.block.error.unbalanced.main=Impossible de clôturer cette période car elle contient des transactions non équilibrées \:
+lima.ui.financialperiod.block.error.unbalanced.transaction=transaction du %1$te/%1$tm/%1$tY d'un débit de %2$s et d'un crédit de %3$s
+lima.ui.financialperiod.block.error.unfilled.entry=entré du %1$te/%1$tm/%1$tY pour un montant de %2$s \:
+lima.ui.financialperiod.block.error.unfilled.main=Impossible de clôturer cette période car elle contient des entrés incomplétes \:
+lima.ui.financialperiod.block.error.unfilled.noAccount=n'a pas de compte
+lima.ui.financialperiod.block.error.unfilled.noDescription=n'a pas de description
+lima.ui.financialperiod.block.error.unfilled.noVoucher=n'a pas de pièce comptable
+lima.ui.financialperiod.block.error.withoutEntryBook.main=Impossible de clôturer cette période car elle contient des transactions sans journal
+lima.ui.financialperiod.block.error.withoutEntryBook.transaction=transaction du %1$te/%1$tm/%1$tY d'un montant de %2$s,
lima.ui.financialperiod.blockmessage=Êtes vous sûre de vouloir clôturer cette période ? Cette action est irréversible \!
lima.ui.financialperiod.blocktitle=Clôture
lima.ui.financialperiod.closure=Clôture
1
0
Author: sbavencoff
Date: 2014-07-09 11:02:03 +0200 (Wed, 09 Jul 2014)
New Revision: 3839
Url: http://forge.chorem.org/projects/lima/repository/revisions/3839
Log:
refs #557 : fix locked entry book exception
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java
Removed:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.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/FinancialTransactionServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
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 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -79,9 +79,9 @@
* Entry rules
*
* @param entry
- * @throws FinancialTransactionException
+ * @throws LockedEntryBookException
*/
- void updateEntryRules(Entry entry, Entry entryOld) throws EntryException;
+ void updateEntryRules(Entry entry, Entry entryOld) throws LockedEntryBookException;
void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws FinancialTransactionException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -29,13 +29,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaInterceptor;
+import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.UsedEntryBookException;
-import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
@@ -240,7 +240,7 @@
* - third, the new choice entrybook belong to a blocked closedPeriodicEntryBook
*/
@Override
- public void updateEntryRules(Entry entry, Entry entryOld) throws EntryException {
+ public void updateEntryRules(Entry entry, Entry entryOld) throws LockedEntryBookException {
FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(entry.getFinancialTransaction().getTransactionDate());
@@ -253,7 +253,7 @@
closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
if (closedPeriodicEntryBook.isLocked()) {
- throw new EntryException(entryOld, "lima-Business.defaultaccountingrules.updateentryerror");
+ throw new LockedEntryBookException(closedPeriodicEntryBook);
}
}
@@ -264,7 +264,7 @@
// Check 2 & 3 cases
if (closedPeriodicEntryBook2.isLocked()) {
- throw new EntryException(entry, "lima-Business.defaultaccountingrules.updateentryerror");
+ throw new LockedEntryBookException(closedPeriodicEntryBook2);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -35,7 +35,7 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
@@ -485,7 +485,7 @@
* update entry, calculate amount of the financial transaction.
*/
@Override
- public void updateEntry(Entry entry) throws EntryException {
+ public void updateEntry(Entry entry) throws LockedEntryBookException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -1,55 +0,0 @@
-package org.chorem.lima.business;
-
-/*
- * #%L
- * Lima :: business API
- * %%
- * Copyright (C) 2008 - 2014 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%
- */
-
-import org.chorem.lima.entity.Entry;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public class EntryException extends LimaException {
-
- protected Entry entry;
-
- public EntryException(String message) {
- super(message);
- }
-
- public EntryException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public EntryException(Entry entry, String message) {
- super(message);
- this.entry = entry;
- }
-
- public EntryException(Entry entry, String message, Throwable cause) {
- super(message, cause);
- this.entry = entry;
- }
-
- public Entry getEntry() {
- return entry;
- }
-}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -0,0 +1,18 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LockedEntryBookException extends ClosedPeriodicEntryBookException {
+
+ public LockedEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook) {
+ super(closedPeriodicEntryBook, "");
+ }
+
+ public LockedEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, Throwable cause) {
+ super(closedPeriodicEntryBook, "", cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -27,7 +27,7 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
-import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Entry;
@@ -76,7 +76,7 @@
Entry createEntry(Entry entry) throws FinancialTransactionException;
- void updateEntry(Entry entry) throws EntryException;
+ void updateEntry(Entry entry) throws LockedEntryBookException;
void removeEntry(Entry entry) throws FinancialTransactionException;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -25,6 +25,8 @@
*/
import com.google.common.collect.Lists;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.util.ErrorHelper;
import javax.swing.table.AbstractTableModel;
import java.util.Collection;
@@ -44,13 +46,17 @@
protected List<Column<AbstractLimaTableModel<E>>> columns;
protected Comparator<E> comparator;
-
+
+ protected ErrorHelper errorHelper;
+
public AbstractLimaTableModel() {
values = Lists.newArrayList();
columns = Lists.newArrayList();
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
+
initColumn();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -26,7 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.utils.EntryComparator;
@@ -46,6 +46,8 @@
import java.util.Collection;
import java.util.List;
+import static org.nuiton.i18n.I18n.t;
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
@@ -216,11 +218,23 @@
return e1.getFinancialTransaction().equals(e2.getFinancialTransaction());
}
- public void updateEntry(Entry entry) throws EntryException {
+ public boolean updateEntry(Entry entry) {
+ boolean updated = false;
+
if (log.isDebugEnabled()) {
log.debug("Update Entry");
}
- financialTransactionService.updateEntry(entry);
+ try {
+ financialTransactionService.updateEntry(entry);
+ updated = true;
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entry.update.closed.entryBook.error",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
+ }
+ return updated;
}
public void updateTransaction(FinancialTransaction transaction) throws FinancialTransactionException {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
@@ -56,11 +55,11 @@
&& account != null
&& !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
if (update) {
- try {
- entry.setAccount(account);
- tableModel.updateEntry(entry);
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ Account previousAccount = entry.getAccount();
+ entry.setAccount(account);
+ if (!tableModel.updateEntry(entry)) {
+ entry.setAccount(previousAccount);
+ update = false;
}
}
return update;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -54,13 +53,16 @@
BigDecimal credit= (BigDecimal) value;
boolean update = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
if (update) {
- try {
- entry.setAmount(credit);
- entry.setDebit(false);
- tableModel.updateEntry(entry);
+ BigDecimal previousAmount = entry.getAmount();
+ boolean previousDebit = entry.isDebit();
+ entry.setAmount(credit);
+ entry.setDebit(false);
+ if(tableModel.updateEntry(entry)) {
tableModel.fireTransaction(entry.getFinancialTransaction());
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } else {
+ entry.setAmount(previousAmount);
+ entry.setDebit(previousDebit);
+ update = false;
}
}
return update;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -54,13 +53,16 @@
BigDecimal debit = (BigDecimal) value;
boolean update = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
if (update) {
- try {
- entry.setAmount(debit);
- entry.setDebit(true);
- tableModel.updateEntry(entry);
+ BigDecimal previousAmount = entry.getAmount();
+ boolean previousDebit = entry.isDebit();
+ entry.setAmount(debit);
+ entry.setDebit(true);
+ if(tableModel.updateEntry(entry)) {
tableModel.fireTransaction(entry.getFinancialTransaction());
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } else {
+ entry.setAmount(previousAmount);
+ entry.setDebit(previousDebit);
+ update = false;
}
}
return update;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -52,11 +51,11 @@
boolean update = (entry.getDescription() == null ||entry.getDescription().compareTo(description) != 0);
if (update) {
- try {
- entry.setDescription(description);
- tableModel.updateEntry(entry);
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ String previousDescription = entry.getDescription();
+ entry.setDescription(description);
+ if (!tableModel.updateEntry(entry)) {
+ entry.setDescription(previousDescription);
+ update = false;
}
}
return update;
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 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -25,11 +25,12 @@
package org.chorem.lima.ui.financialtransaction;
+import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
-import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
@@ -48,7 +49,14 @@
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import org.chorem.lima.util.ErrorHelper;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
+import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TableColumnModelEvent;
@@ -62,6 +70,7 @@
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import static org.nuiton.i18n.I18n.t;
@@ -341,27 +350,30 @@
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
- try {
- Entry entry = tableModel.get(rowSelected);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (entry.isDebit()) {
- debit = debit.subtract(entry.getAmount());
- } else {
- credit = credit.subtract(entry.getAmount());
- }
+ Entry entry = tableModel.get(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
- BigDecimal balance = credit.subtract(debit);
- entry.setAmount(balance.abs());
- entry.setDebit(balance.signum() > 0);
- tableModel.updateEntry(entry);
+ BigDecimal balance = credit.subtract(debit);
+
+ BigDecimal previousAmount = entry.getAmount();
+ boolean previousDebit = entry.isDebit();
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ if (tableModel.updateEntry(entry)) {
int firstRow = tableModel.indexOf(transaction);
int lastRow = firstRow + transaction.sizeEntry() - 1;
tableModel.fireTableRowsUpdated(firstRow, lastRow);
view.setBalance(true);
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } else {
+ entry.setAmount(previousAmount);
+ entry.setDebit(previousDebit);
}
}
}
@@ -683,20 +695,25 @@
int selectedRow = table.getSelectedRow();
int selectedColumn = table.getSelectedColumn();
if (selectedRow >= 0 && (selectedColumn == 1 || selectedColumn == 3)) {
+
+ Entry entrySource = tableModel.get(selectedRow);
+ FinancialTransaction transaction = entrySource.getFinancialTransaction();
+
+ Map<Entry, String> previousValuesMap = Maps.newHashMap();
try {
- Entry entrySource = tableModel.get(selectedRow);
- FinancialTransaction transaction = entrySource.getFinancialTransaction();
for (Entry entryTarget : transaction.getEntry()) {
if (entrySource != entryTarget) {
switch (selectedColumn) {
case 1:
if (!StringUtils.equals(entryTarget.getVoucher(), entrySource.getVoucher())) {
+ previousValuesMap.put(entryTarget, entryTarget.getVoucher());
entryTarget.setVoucher(entrySource.getVoucher());
financialTransactionService.updateEntry(entryTarget);
}
break;
case 3:
if (!StringUtils.equals(entryTarget.getDescription(), entrySource.getDescription())) {
+ previousValuesMap.put(entryTarget, entryTarget.getDescription());
entryTarget.setDescription(entrySource.getDescription());
financialTransactionService.updateEntry(entryTarget);
}
@@ -708,8 +725,25 @@
int lastRow = firstRow + transaction.sizeEntry() - 1;
tableModel.fireTableRowsUpdated(firstRow, lastRow);
table.editCellAt(selectedRow, selectedColumn);
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entries.assign.closed.entryBook.error",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
+ // restaure prévious values
+ for (Map.Entry<Entry, String> mapEntry : previousValuesMap.entrySet()) {
+ Entry entry = mapEntry.getKey();
+ String previousValue = mapEntry.getValue();
+ switch (selectedColumn) {
+ case 1:
+ entry.setVoucher(previousValue);
+ break;
+ case 3:
+ entry.setDescription(previousValue);
+ break;
+ }
+ }
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -53,11 +52,10 @@
boolean update = (entry.getLettering() == null || entry.getLettering().compareTo(letter) != 0);
if (update) {
- try {
- entry.setLettering(letter);
- tableModel.updateEntry(entry);
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ String previousLettering = entry.getLettering();
+ entry.setLettering(letter);
+ if (!tableModel.updateEntry(entry)) {
+ entry.setLettering(previousLettering);
}
}
return update;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -24,7 +24,6 @@
* #L%
*/
-import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -53,11 +52,10 @@
boolean update = (entry.getVoucher() == null || entry.getVoucher().compareTo(voucher) != 0);
if (update) {
- try {
- entry.setVoucher(voucher);
- tableModel.updateEntry(entry);
- } catch (EntryException e) {
- errorHelper.showErrorMessage(e.getMessage());
+ String previousVoucher = entry.getVoucher();
+ entry.setVoucher(voucher);
+ if (!tableModel.updateEntry(entry)) {
+ entry.setVoucher(previousVoucher);
}
}
return update;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -28,7 +28,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
-import org.chorem.lima.business.EntryException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryImpl;
@@ -37,7 +36,13 @@
import org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable;
import org.chorem.lima.util.ErrorHelper;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
+import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellEditor;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -304,21 +309,22 @@
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
- try {
- Entry entry = tableModel.get(rowSelected);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (entry.isDebit()) {
- debit = debit.subtract(entry.getAmount());
- } else {
- credit = credit.subtract(entry.getAmount());
- }
+ Entry entry = tableModel.get(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
- BigDecimal balance = credit.subtract(debit);
- entry.setAmount(balance.abs());
- entry.setDebit(balance.signum() > 0);
- tableModel.updateEntry(entry);
+ BigDecimal balance = credit.subtract(debit);
+ BigDecimal previousAmount = entry.getAmount();
+ boolean previousDebit = entry.isDebit();
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ if (tableModel.updateEntry(entry)) {
int firstRow = tableModel.indexOf(transaction);
int lastRow = firstRow + transaction.sizeEntry() - 1;
tableModel.fireTableRowsUpdated(firstRow, lastRow);
@@ -328,10 +334,10 @@
selectionModel.setSelectionInterval(rowSelected, rowSelected);
table.changeSelection(rowSelected, 1, false, false);
table.editCellAt(rowSelected, 1);
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } else {
+ entry.setAmount(previousAmount);
+ entry.setDebit(previousDebit);
}
-
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-07-09 09:02:03 UTC (rev 3839)
@@ -25,12 +25,13 @@
package org.chorem.lima.ui.lettering;
+import com.google.common.collect.Maps;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.LetteringFilterImpl;
-import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
@@ -44,7 +45,12 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.util.ErrorHelper;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
@@ -52,6 +58,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import static org.nuiton.i18n.I18n.t;
@@ -481,16 +488,28 @@
LetteringTableModel tableModel = view.getTableModel();
+ Map<Entry, String> previousLetterMap = Maps.newHashMap();
+
try {
for (int indexEntry : entrieSelected) {
Entry entry = tableModel.get(indexEntry);
+ previousLetterMap.put(entry, entry.getLettering());
entry.setLettering(newLetters);
financialTransactionService.updateEntry(entry);
tableModel.fireTableRowsUpdated(indexEntry, indexEntry);
}
- } catch (EntryException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LockedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entries.letter.closed.entryBook.error",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
+
+ // restaure prévious letters
+ for (Map.Entry<Entry, String> mapEntry : previousLetterMap.entrySet()) {
+ mapEntry.getKey().setLettering(mapEntry.getValue());
+ }
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-09 09:02:03 UTC (rev 3839)
@@ -359,6 +359,9 @@
lima.ui.common.remove=Remove
lima.ui.common.solde=
lima.ui.common.update=Update
+lima.ui.entries.assign.closed.entryBook.error=
+lima.ui.entries.letter.closed.entryBook.error=
+lima.ui.entry.update.closed.entryBook.error=
lima.ui.entryBook.delete.used.error=Can't delete entry book %2$s (%1$s) because exist financcial transactions in this entry book.
lima.ui.entrybook.add=
lima.ui.entrybook.code=
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-09 07:30:32 UTC (rev 3838)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-09 09:02:03 UTC (rev 3839)
@@ -341,6 +341,9 @@
lima.ui.common.remove=Supprimer
lima.ui.common.solde=Solde
lima.ui.common.update=Modifier
+lima.ui.entries.assign.closed.entryBook.error=Impossible d'affecter cette valeur a l'ensemble des entrés de la transaction car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY
+lima.ui.entries.letter.closed.entryBook.error=Impossible de modifier le lettrage des ces entrés car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY
+lima.ui.entry.update.closed.entryBook.error=Impossible de modifier cette entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY
lima.ui.entryBook.delete.used.error=Imposible de supprimer le journal %2$s (%1$s) car Il existe des transactioins sur ce journal.
lima.ui.entrybook.add=Ajout de journal
lima.ui.entrybook.code=Code
1
0
r3838 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-callao/src/main/java/org/chorem/lima/entity
by sbavencoff@users.chorem.org 09 Jul '14
by sbavencoff@users.chorem.org 09 Jul '14
09 Jul '14
Author: sbavencoff
Date: 2014-07-09 09:30:32 +0200 (Wed, 09 Jul 2014)
New Revision: 3838
Url: http://forge.chorem.org/projects/lima/repository/revisions/3838
Log:
fixes #1042 : Reconstruction de blockClosedPeriodicEntryBookRules
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.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 2014-07-08 14:54:17 UTC (rev 3837)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-07-09 07:30:32 UTC (rev 3838)
@@ -35,7 +35,6 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
-import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FinancialTransactionTopiaDao;
@@ -202,56 +201,19 @@
}
/**
- * Check if old financialperiod for a an entrybook are closed before bock the asked closedperiodicentrybook
- * <p/>
- * get all closedperiodicentrybook between the first financial period of fiscalperiod
- * and the last financial period of the closedperiodicentrybook in param
- * return the number
- * <p/>
- * 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 ?
+ * Check if all previous financial period for a an entrybook are closed before bock the asked closedperiodicentrybook
*/
@Override
public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException {
super.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
- FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- // Get all closedperiod between for the period and entrybook
- 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);
+ boolean existPrevousNotClosed = closedPeriodicEntryBookDao
+ .existPreviousClosedPeriodicEntryBooksNotClosed(closedPeriodicEntryBook);
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
-
- //search fiscalperiod have financialperiod
- FiscalPeriod fiscalPeriod = fiscalPeriodTopiaDao.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();
-
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
-
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- closedPeriodicEntryBookTopiaDao.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
- closedPeriodicEntryBooks = closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDatesLocked(entryBook, beginDate, endDate);
- int nbBlockedClosedPeriodicEntryBooks =
- closedPeriodicEntryBooks.size();
-
//Check if the fiscal period to block is the oldest
- if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks) {
+ if (existPrevousNotClosed) {
throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook");
}
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-07-08 14:54:17 UTC (rev 3837)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-07-09 07:30:32 UTC (rev 3838)
@@ -165,4 +165,22 @@
return closedPeriodicEntryBooks;
}
+ /**
+ * if exist previous ClosedPeriodicEntryBook not close
+ *
+ * @return exist previous ClosedPeriodicEntryBook not close
+ */
+ public boolean existPreviousClosedPeriodicEntryBooksNotClosed(ClosedPeriodicEntryBook closedPeriodicEntryBook) {
+ HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
+ builder.addEquals(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, closedPeriodicEntryBook.getEntryBook());
+ builder.addEquals(ClosedPeriodicEntryBook.PROPERTY_LOCKED, false);
+ builder.addLowerThan(
+ ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD + "." + FinancialPeriod.PROPERTY_END_DATE,
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+
+ boolean exist = exists(builder.getHql(), builder.getHqlParameters());
+
+ return exist;
+ }
+
}
1
0
Author: sbavencoff
Date: 2014-07-08 16:54:17 +0200 (Tue, 08 Jul 2014)
New Revision: 3837
Url: http://forge.chorem.org/projects/lima/repository/revisions/3837
Log:
fixes #1040 : update to jdk 1.7
Added:
trunk/lima-swing/src/main/assembly/lima.bat
Removed:
trunk/lima-swing/src/main/assembly/lima.exe
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
trunk/lima-business/src/license/THIRD-PARTY.properties
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java
trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java
trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java
trunk/lima-swing/pom.xml
trunk/lima-swing/src/main/assembly/bin.xml
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
trunk/pom.xml
Modified: trunk/lima-business/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/lima-business/src/license/THIRD-PARTY.properties 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/license/THIRD-PARTY.properties 2014-07-08 14:54:17 UTC (rev 3837)
@@ -2,14 +2,14 @@
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - AL 2.0
-# - Apache 2.0
# - Apache License 2.0
# - Apache License, version 2.0
# - Apache Software License - Version 2.0
+# - Apache Software License 2.0
# - BSD License
+# - CDDL + GPLv2 with classpath exception
# - CDDL 1.1
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-# - CPL
# - Common Development and Distribution License
# - Common Public License Version 1.0
# - Eclipse Distribution License (EDL), Version 1.0
@@ -37,6 +37,8 @@
# Please fill the missing licenses for dependencies :
#
#
-#Mon May 12 16:36:49 CEST 2014
+#Fri Jul 04 15:48:42 CEST 2014
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=jdomlicence
+org.metatype.sxc--sxc-jaxb-core--0.8=CDDL 1.1
+org.metatype.sxc--sxc-runtime--0.8=CDDL 1.1
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.ejb;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AbstractLimaModel.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.ejb.csv;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.business.api.AccountService;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.ejb.csv;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
import org.nuiton.csv.ExportModel;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryBookModel.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.ejb.csv;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
import org.nuiton.csv.ExportModel;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/EntryModel.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.ejb.csv;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.entity.Entry;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FinancialTransactionModel.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.ejb.csv;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/FiscalPeriodModel.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.ejb.csv;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodImpl;
import org.nuiton.csv.ExportModel;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/migration/MigrationV0_8.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,14 +1,34 @@
package org.chorem.lima.business.migration;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.migration.TopiaMigrationCallbackByClass;
import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.TopiaPersistenceContext;
import org.nuiton.util.Version;
-
import java.util.List;
/**
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.LimaTechnicalException;
import org.nuiton.config.ApplicationConfig;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/NewExportServiceTest.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import com.google.common.collect.Lists;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
@@ -14,13 +36,9 @@
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
/**
* Created by davidcosse on 03/06/14.
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.utils;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.EntryBook;
/**
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.Entry;
/**
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.FinancialTransaction;
/**
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.FiscalPeriod;
/**
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.chorem.lima.entity.EntryBook;
/**
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.business.api;
+/*
+ * #%L
+ * Lima :: business API
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
/**
* Created by davidcosse on 03/06/14.
*/
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -1,5 +1,27 @@
package org.chorem.lima.entity;
+/*
+ * #%L
+ * Lima :: callao
+ * %%
+ * Copyright (C) 2008 - 2014 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%
+ */
+
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-swing/pom.xml 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-swing/pom.xml 2014-07-08 14:54:17 UTC (rev 3837)
@@ -34,8 +34,8 @@
<i18n.bundleOutputName>lima</i18n.bundleOutputName>
<!-- uses some sun.xxx classes -->
- <signatureArtifactId>java16-sun</signatureArtifactId>
- <signatureVersion>1.10</signatureVersion>
+ <signatureArtifactId>java17</signatureArtifactId>
+ <signatureVersion>1.0</signatureVersion>
<!-- Post Release configuration -->
<skipPostRelease>false</skipPostRelease>
@@ -333,12 +333,12 @@
<profile>
<id>jnlp-reporting</id>
- <activation>
+ <!--activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
- </activation>
+ </activation-->
<reporting>
<plugins>
<plugin>
@@ -353,12 +353,12 @@
<profile>
<id>jnlp-profile</id>
- <activation>
+ <!--activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
- </activation>
+ </activation-->
<build>
<plugins>
@@ -467,31 +467,7 @@
</activation>
<build>
<plugins>
-
<plugin>
- <groupId>org.bluestemsoftware.open.maven.plugin</groupId>
- <artifactId>launch4j-plugin</artifactId>
- <executions>
- <execution>
- <id>launch4j</id>
- <phase>package</phase>
- <goals>
- <goal>launch4j</goal>
- </goals>
- <configuration>
- <dontWrapJar>true</dontWrapJar>
- <headerType>gui</headerType>
- <outfile>target/lima.exe</outfile>
- <jar>lima.jar</jar>
- <errTitle>${project.name}</errTitle>
- <jre>
- <minVersion>1.6.0</minVersion>
- </jre>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>lima-${project.version}</finalName>
Modified: trunk/lima-swing/src/main/assembly/bin.xml
===================================================================
--- trunk/lima-swing/src/main/assembly/bin.xml 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-swing/src/main/assembly/bin.xml 2014-07-08 14:54:17 UTC (rev 3837)
@@ -48,7 +48,7 @@
<destName>lima.${project.packaging}</destName>
</file>
<file>
- <source>src/main/assembly/lima.exe</source>
+ <source>src/main/assembly/lima.bat</source>
</file>
<file>
<source>src/main/assembly/lima</source>
Added: trunk/lima-swing/src/main/assembly/lima.bat
===================================================================
--- trunk/lima-swing/src/main/assembly/lima.bat (rev 0)
+++ trunk/lima-swing/src/main/assembly/lima.bat 2014-07-08 14:54:17 UTC (rev 3837)
@@ -0,0 +1,2 @@
+
+java -Xmx1024M -jar lima.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
Deleted: trunk/lima-swing/src/main/assembly/lima.exe
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -24,7 +24,6 @@
* #L%
*/
-import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
@@ -82,7 +81,7 @@
public void setEntryBook(ListSelectionEvent event) {
JList entryBookList = view.getEntryBookList();
- List<EntryBook> selectedValuesList = Lists.newArrayList(entryBookList.getSelectedValuesList());
+ List<EntryBook> selectedValuesList = entryBookList.getSelectedValuesList();
condition.setEntryBooks(selectedValuesList);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -24,7 +24,6 @@
* #L%
*/
-import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
@@ -85,7 +84,7 @@
public void setFinancialPeriod(ListSelectionEvent event) {
JList financialPeriodList = view.getFinancialPeriodList();
- List<FinancialPeriod> selectedValuesList = Lists.newArrayList(financialPeriodList.getSelectedValuesList());
+ List<FinancialPeriod> selectedValuesList = financialPeriodList.getSelectedValuesList();
condition.setFinancialPeriods(selectedValuesList);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-07-08 14:54:17 UTC (rev 3837)
@@ -24,7 +24,6 @@
* #L%
*/
-import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
@@ -83,7 +82,7 @@
public void setFiscalPeriod(ListSelectionEvent event) {
JList fiscalPeriodList = view.getFiscalPeriodList();
- List<FiscalPeriod> selectedValuesList = Lists.newArrayList(fiscalPeriodList.getSelectedValuesList());
+ List<FiscalPeriod> selectedValuesList = fiscalPeriodList.getSelectedValuesList();
condition.setFiscalPeriods(selectedValuesList);
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-07-04 13:41:12 UTC (rev 3836)
+++ trunk/pom.xml 2014-07-08 14:54:17 UTC (rev 3837)
@@ -161,6 +161,15 @@
<platform>chorem.org</platform>
<projectId>lima</projectId>
+ <!-- compiler configuration -->
+
+ <javaVersion>1.7</javaVersion>
+
+ <!--TODO remove this when IDEA won't ask to change jdk level at each pom modification-->
+ <maven.compiler.source>${javaVersion}</maven.compiler.source>
+ <!--TODO remove this when IDEA won't ask to change jdk level at each pom modification-->
+ <maven.compiler.target>${javaVersion}</maven.compiler.target>
+
<!-- customized libs version -->
<jettyPluginVersion>9.1.5.v20140505</jettyPluginVersion>
<nuitonUtilsVersion>3.0-SNAPSHOT</nuitonUtilsVersion>
@@ -181,7 +190,6 @@
<openCsvVersion>2.3</openCsvVersion>
<itextVersion>4.2.1</itextVersion>
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
- <launch4jPluginVersion>1.5.0.0</launch4jPluginVersion>
<jaxxVersion>2.8.8-SNAPSHOT</jaxxVersion>
<openEjbVersion>4.6.0.2</openEjbVersion>
@@ -546,12 +554,6 @@
</dependencies>
</plugin>
- <plugin>
- <groupId>org.bluestemsoftware.open.maven.plugin</groupId>
- <artifactId>launch4j-plugin</artifactId>
- <version>${launch4jPluginVersion}</version>
- </plugin>
-
</plugins>
</pluginManagement>
</build>
1
0
04 Jul '14
Author: sbavencoff
Date: 2014-07-04 15:41:12 +0200 (Fri, 04 Jul 2014)
New Revision: 3836
Url: http://forge.chorem.org/projects/lima/repository/revisions/3836
Log:
refs #557 : fix entry book exception
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.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/EntryBookServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
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 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -61,7 +61,7 @@
* @param entryBook
* @throws LimaException
*/
- void removeEntryBookRules(EntryBook entryBook) throws EntryBookException;
+ void removeEntryBookRules(EntryBook entryBook) throws UsedEntryBookException;
/**
* Fiscal Period rules
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -29,12 +29,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.EntryException;
import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaInterceptor;
+import org.chorem.lima.business.UsedEntryBookException;
import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.Account;
@@ -138,13 +138,13 @@
/** Check if entrybook have financial transaction */
@Override
- public void removeEntryBookRules(EntryBook entryBook) throws EntryBookException {
+ public void removeEntryBookRules(EntryBook entryBook) throws UsedEntryBookException {
FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
// Check if entrybook have entries
long nbfinancialtransaction = financialTransactionTopiaDao.getCountByEntryBook(entryBook);
if (nbfinancialtransaction != 0) {
- throw new EntryBookException(entryBook, "lima-business.defaultaccountingrules.deleteentrybookerror");
+ throw new UsedEntryBookException(entryBook);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -26,8 +26,8 @@
package org.chorem.lima.business.ejb;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.UsedEntryBookException;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
@@ -114,7 +114,7 @@
}
@Override
- public void removeEntryBook(EntryBook entryBook) throws EntryBookException {
+ public void removeEntryBook(EntryBook entryBook) throws UsedEntryBookException {
// check rule
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -79,7 +79,7 @@
*
* @throws LimaException
*/
- @Test(expected=EntryBookException.class)
+ @Test(expected=UsedEntryBookException.class)
public void deleteUsedEntryBook() throws LimaException, ParseException {
EntryBook entryBook = entryBookService.getAllEntryBooks().get(0); // VTE
Assert.assertNotNull(entryBook);
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -9,14 +9,6 @@
protected EntryBook entryBook;
- public EntryBookException(String message) {
- super(message);
- }
-
- public EntryBookException(String message, Throwable cause) {
- super(message, cause);
- }
-
public EntryBookException(EntryBook entryBook, String message) {
super(message);
this.entryBook = entryBook;
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.EntryBook;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class UsedEntryBookException extends EntryBookException {
+
+ public UsedEntryBookException(EntryBook entryBook) {
+ super(entryBook, "");
+ }
+
+ public UsedEntryBookException(EntryBook entryBook, Throwable cause) {
+ super(entryBook, "", cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -25,8 +25,8 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.UsedEntryBookException;
import org.chorem.lima.entity.EntryBook;
import java.util.List;
@@ -82,7 +82,7 @@
* impossible de supprimer celui-ci.
*
* @param entryBook
- * @throws EntryBookException
+ * @throws org.chorem.lima.business.UsedEntryBookException
*/
- void removeEntryBook(EntryBook entryBook) throws EntryBookException;
+ void removeEntryBook(EntryBook entryBook) throws UsedEntryBookException;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2014-07-04 13:41:12 UTC (rev 3836)
@@ -28,7 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
-import org.chorem.lima.business.EntryBookException;
+import org.chorem.lima.business.UsedEntryBookException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ImportService;
@@ -41,7 +41,12 @@
import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@@ -237,8 +242,8 @@
try {
entryBookService.removeEntryBook(selectedEntryBook);
entryBookTableModel.remove(selectedEntryBook);
- } catch (EntryBookException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (UsedEntryBookException e) {
+ errorHelper.showErrorMessage(t("lima.ui.entryBook.delete.used.error", e.getEntryBook().getCode(), e.getEntryBook().getLabel()));
}
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-04 13:41:12 UTC (rev 3836)
@@ -359,6 +359,7 @@
lima.ui.common.remove=Remove
lima.ui.common.solde=
lima.ui.common.update=Update
+lima.ui.entryBook.delete.used.error=Can't delete entry book %2$s (%1$s) because exist financcial transactions in this entry book.
lima.ui.entrybook.add=
lima.ui.entrybook.code=
lima.ui.entrybook.default=
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-02 08:42:53 UTC (rev 3835)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-04 13:41:12 UTC (rev 3836)
@@ -341,6 +341,7 @@
lima.ui.common.remove=Supprimer
lima.ui.common.solde=Solde
lima.ui.common.update=Modifier
+lima.ui.entryBook.delete.used.error=Imposible de supprimer le journal %2$s (%1$s) car Il existe des transactioins sur ce journal.
lima.ui.entrybook.add=Ajout de journal
lima.ui.entrybook.code=Code
lima.ui.entrybook.default=Journaux par défault
1
0
r3835 - trunk/lima-business/src/test/java/org/chorem/lima/business
by sbavencoff@users.chorem.org 02 Jul '14
by sbavencoff@users.chorem.org 02 Jul '14
02 Jul '14
Author: sbavencoff
Date: 2014-07-02 10:42:53 +0200 (Wed, 02 Jul 2014)
New Revision: 3835
Url: http://forge.chorem.org/projects/lima/repository/revisions/3835
Log:
refs #557 : fix test
Modified:
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2014-06-30 07:41:22 UTC (rev 3834)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2014-07-02 08:42:53 UTC (rev 3835)
@@ -213,8 +213,8 @@
*
* @throws LimaException
*/
- @Test(expected = LimaException.class)
- public void removeUnexistedAccountTest() throws LimaException {
+ @Test(expected = Exception.class)
+ public void removeUnexistedAccountTest() throws UsedAccountException {
Account account4 = new AccountImpl();
account4.setAccountNumber("422");
account4.setLabel("Unsaved account");
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-06-30 07:41:22 UTC (rev 3834)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-07-02 08:42:53 UTC (rev 3835)
@@ -79,7 +79,7 @@
*
* @throws LimaException
*/
- @Test(expected=LimaBusinessException.class)
+ @Test(expected=EntryBookException.class)
public void deleteUsedEntryBook() throws LimaException, ParseException {
EntryBook entryBook = entryBookService.getAllEntryBooks().get(0); // VTE
Assert.assertNotNull(entryBook);
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java 2014-06-30 07:41:22 UTC (rev 3834)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java 2014-07-02 08:42:53 UTC (rev 3835)
@@ -1,6 +1,7 @@
package org.chorem.lima.business;
import org.apache.commons.lang3.StringUtils;
+import org.chorem.lima.LimaTechnicalException;
import org.nuiton.config.ApplicationConfig;
import org.nuiton.config.ArgumentsParserException;
@@ -30,7 +31,7 @@
}
instance = this;
} catch (ArgumentsParserException ex) {
- throw new LimaException("Can't read configuration", ex);
+ throw new LimaTechnicalException("Can't read configuration", ex);
}
}
}
1
0
Author: sbavencoff
Date: 2014-06-30 09:41:22 +0200 (Mon, 30 Jun 2014)
New Revision: 3834
Url: http://forge.chorem.org/projects/lima/repository/revisions/3834
Log:
refs #557 : Revoir les exceptions techniques et metiers
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java
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/FinancialStatementService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.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/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.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/EntryServiceImpl.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/NewExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.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
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,6 +25,7 @@
package org.chorem.lima.business;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
@@ -48,11 +49,11 @@
* @param account new account
* @throws LimaException if rule validation fails
*/
- void createAccountRules(Account account) throws LimaException;
+ void createAccountRules(Account account) throws InvalidAccountNumberException;
- void updateAccountRules(Account account) throws LimaException;
+ void updateAccountRules(Account account) throws InvalidAccountNumberException;
- void removeAccountRules(Account account) throws LimaException;
+ void removeAccountRules(Account account) throws UsedAccountException;
/**
* Entrybook rules.
@@ -60,7 +61,7 @@
* @param entryBook
* @throws LimaException
*/
- void removeEntryBookRules(EntryBook entryBook) throws LimaException;
+ void removeEntryBookRules(EntryBook entryBook) throws EntryBookException;
/**
* Fiscal Period rules
@@ -68,21 +69,21 @@
* @param fiscalPeriod
* @throws LimaException
*/
- List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
+ void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException;
+ void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
/**
* Entry rules
*
* @param entry
- * @throws LimaException
+ * @throws FinancialTransactionException
*/
- void updateEntryRules(Entry entry, Entry entryOld) throws LimaException;
+ void updateEntryRules(Entry entry, Entry entryOld) throws EntryException;
- void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws LimaException;
+ void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws FinancialTransactionException;
/**
* Financialperiod/entrybook rules
@@ -90,7 +91,7 @@
* @param financialTransaction
* @throws LimaException
*/
- void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException;
+ void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException;
/**
* Check if a financial period can be closed.
@@ -98,5 +99,5 @@
* @param closedPeriodicEntryBook
* @throws LimaException
*/
- void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException;
+ void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.accountingrules.FranceAccountingRules;
import org.chorem.lima.business.migration.DatabaseMigrationClass;
import org.chorem.lima.entity.LimaCallaoEntityEnum;
@@ -78,7 +79,7 @@
config.parse();
} catch (ArgumentsParserException ex) {
- throw new LimaException("Can't read configuration", ex);
+ throw new LimaTechnicalException("Can't read configuration", ex);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,9 +29,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.EntryBookException;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaInterceptor;
+import org.chorem.lima.business.UsedAccountException;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
@@ -46,13 +51,10 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.chorem.lima.entity.LimaCallaoTopiaDaoSupplier;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n.t;
-
;
/**
@@ -82,44 +84,42 @@
* Rules to check before create accounts.
*/
@Override
- public void createAccountRules(Account account) throws LimaException {
+ public void createAccountRules(Account account) throws InvalidAccountNumberException {
// Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.invalidaccountnumber",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.defaultaccountingrules.invalidaccountnumber");
}
}
@Override
- public void updateAccountRules(Account account) throws LimaException {
+ public void updateAccountRules(Account account) throws InvalidAccountNumberException {
// Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.invalidaccountnumber",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.defaultaccountingrules.invalidaccountnumber");
}
}
/** Rules to check before create fiscals periods */
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
//check if the enddate period is after the begindate period
if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.enddateerror"));
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.defaultaccountingrules.enddateerror");
}
return null;
}
/** Rules to check before block fiscals periods */
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException{
}
/** Rules to check before delete fiscals periods */
@Override
public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod)
- throws LimaException {
+ throws FiscalPeriodException {
}
/**
@@ -127,32 +127,24 @@
* Recursive function
*/
@Override
- public void removeAccountRules(Account account) throws LimaException {
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- // Check if account have entries
- int nbentries = entryTopiaDao.findAllByAccount(account).size();
- if (nbentries != 0) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.deleteaccounterror"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't remvoe account", ex);
+ public void removeAccountRules(Account account) throws UsedAccountException {
+
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ // Check if account have entries
+ if (entryTopiaDao.forAccountEquals(account).exists()) {
+ throw new UsedAccountException(account.getAccountNumber(), "lima-business.defaultaccountingrules.deleteaccounterror");
}
}
/** Check if entrybook have financial transaction */
@Override
- public void removeEntryBookRules(EntryBook entryBook) throws LimaException {
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ public void removeEntryBookRules(EntryBook entryBook) throws EntryBookException {
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- // Check if entrybook have entries
- long nbfinancialtransaction = financialTransactionTopiaDao.getCountByEntryBook(entryBook);
- if (nbfinancialtransaction != 0) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.deleteentrybookerror"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ // Check if entrybook have entries
+ long nbfinancialtransaction = financialTransactionTopiaDao.getCountByEntryBook(entryBook);
+ if (nbfinancialtransaction != 0) {
+ throw new EntryBookException(entryBook, "lima-business.defaultaccountingrules.deleteentrybookerror");
}
}
@@ -162,29 +154,28 @@
* check if all entrybook of his financial period are blocked
*/
@Override
- public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
+ public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
- try {
- //check financial period locked
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
- if (financialPeriod.isLocked()) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.financialperiodblocked"));
- }
-
- //check all entrybook of his financial period are blocked
- //FIXME echatellier 20120509 il doit y avoir moyen de faire plus
- //simple que de recuperer 2 listes et de comparer leur nombres
+ //check financial period locked
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
+ if (financialPeriod.isLocked()) {
+ throw new FinancialTransactionException(financialTransaction, "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> closedEntryBooks = new ArrayList<EntryBook>();
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
// List<EntryBook> entryBooks = entryBookTopiaDao.findAll();
- // The following code should do the work but i'm not 100% sure.
- long nbEntryBooksClosed = closedPeriodicEntryBookTopiaDao.forProperties(
- ClosedPeriodicEntryBook.PROPERTY_LOCKED, true,
- ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod).addNotNull(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK).count();
+ // The following code should do the work but i'm not 100% sure.
+ long nbEntryBooksClosed = closedPeriodicEntryBookTopiaDao.forProperties(
+ ClosedPeriodicEntryBook.PROPERTY_LOCKED, true,
+ ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod).addNotNull(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK).count();
// for (EntryBook entryBook : entryBooks) {
// ClosedPeriodicEntryBook closedPeriodicEntryBook =
@@ -195,12 +186,9 @@
// }
// }
- long nbEntryBooks = entryBookTopiaDao.count();
- if (nbEntryBooks == nbEntryBooksClosed) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.allentrybookclosed"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ long nbEntryBooks = entryBookTopiaDao.count();
+ if (nbEntryBooks == nbEntryBooksClosed) {
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.allentrybookclosed");
}
}
@@ -211,42 +199,37 @@
*/
@Override
public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook)
- throws LimaException {
+ throws ClosedPeriodicEntryBookException {
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- // reload object in current transaction
- closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByTopiaId(closedPeriodicEntryBook.getTopiaId());
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ // reload object in current transaction
+ closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByTopiaId(closedPeriodicEntryBook.getTopiaId());
- // Check if all financial transactions of closedperiodicentrybook are equilibrate
- FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod();
- if (financialTransactionTopiaDao.isExistUnbalancedTransaction(
- period.getBeginDate(),
- period.getEndDate(),
- closedPeriodicEntryBook.getEntryBook())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.blockerrorequillibrate"));
- }
-
- // Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
- if (entryDao.isExistUnfilledEntry(
- period.getBeginDate(),
- period.getEndDate(),
- closedPeriodicEntryBook.getEntryBook())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.missingelements"));
- }
-
- // Check if all financial transactions have EntryBooks
- if (financialTransactionTopiaDao.isExistTransactionWithoutEntryBook(
- period.getBeginDate(),
- period.getEndDate())) {
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.missingentrybook"));
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ // Check if all financial transactions of closedperiodicentrybook are equilibrate
+ FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod();
+ if (financialTransactionTopiaDao.isExistUnbalancedTransaction(
+ period.getBeginDate(),
+ period.getEndDate(),
+ closedPeriodicEntryBook.getEntryBook())) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.blockerrorequillibrate");
}
+
+ // Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in
+ if (entryDao.isExistUnfilledEntry(
+ period.getBeginDate(),
+ period.getEndDate(),
+ closedPeriodicEntryBook.getEntryBook())) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.missingelements");
+ }
+
+ // Check if all financial transactions have EntryBooks
+ if (financialTransactionTopiaDao.isExistTransactionWithoutEntryBook(
+ period.getBeginDate(),
+ period.getEndDate())) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.defaultaccountingrules.missingentrybook");
+ }
}
/**
@@ -257,37 +240,31 @@
* - third, the new choice entrybook belong to a blocked closedPeriodicEntryBook
*/
@Override
- public void updateEntryRules(Entry entry, Entry entryOld) throws LimaException {
+ public void updateEntryRules(Entry entry, Entry entryOld) throws EntryException {
- try {
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(entry.getFinancialTransaction().getTransactionDate());
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(entry.getFinancialTransaction().getTransactionDate());
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
-
- if (entryOld != null) {
- //second case
- ClosedPeriodicEntryBook closedPeriodicEntryBook =
- closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
- entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
- if (closedPeriodicEntryBook.isLocked()) {
- throw new LimaBusinessException(t("lima-Business.defaultaccountingrules.updateentryerror"));
- }
- }
-
- //third case
- ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
+ if (entryOld != null) {
+ //second case
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
- entry.getFinancialTransaction().getEntryBook(), financialPeriod);
-
- // Check 2 & 3 cases
- if (closedPeriodicEntryBook2.isLocked()) {
- throw new LimaBusinessException(t("lima-Business.defaultaccountingrules.updateentryerror"));
+ entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
+ if (closedPeriodicEntryBook.isLocked()) {
+ throw new EntryException(entryOld, "lima-Business.defaultaccountingrules.updateentryerror");
}
+ }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //third case
+ ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
+ closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(
+ entry.getFinancialTransaction().getEntryBook(), financialPeriod);
+
+ // Check 2 & 3 cases
+ if (closedPeriodicEntryBook2.isLocked()) {
+ throw new EntryException(entry, "lima-Business.defaultaccountingrules.updateentryerror");
}
}
@@ -300,65 +277,59 @@
*/
@Override
public void updateFinancialTransactionDateRules(
- FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws LimaException {
+ FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld) throws FinancialTransactionException {
- try {
-
- Date financialTransactionDate = financialTransaction.getTransactionDate();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
- FiscalPeriod firstFiscalPeriod = fiscalPeriodTopiaDao.getFirstFiscalPeriod();
- Date beginDateFirstFiscalPeriod = firstFiscalPeriod.getBeginDate();
- Date endDateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
-
- //check if date are on fiscal period (test if date is after begindate of first f.p. and before enddate of last f.p.)
-
- if (log.isDebugEnabled()) {
- log.debug("Date de transaction modifiée sur l'ui " + financialTransactionDate);
- log.debug("Date de début du premier exercice : " + beginDateFirstFiscalPeriod);
- log.debug("Date de fin du dernier exercice : " + endDateLastFiscalPeriod);
- }
-
- //1-date not on a fiscal period
- if (financialTransactionDate.before(beginDateFirstFiscalPeriod) || financialTransactionDate.after(endDateLastFiscalPeriod)){
- if (financialTransactionDate.before(beginDateFirstFiscalPeriod)) {
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction avant (antérieure) la date de début du premier exercice");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.datebeforeerror"));
+ Date financialTransactionDate = financialTransaction.getTransactionDate();
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
+ FiscalPeriod firstFiscalPeriod = fiscalPeriodTopiaDao.getFirstFiscalPeriod();
+ Date beginDateFirstFiscalPeriod = firstFiscalPeriod.getBeginDate();
+ Date endDateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
+
+ //check if date are on fiscal period (test if date is after begindate of first f.p. and before enddate of last f.p.)
+
+ if (log.isDebugEnabled()) {
+ log.debug("Date de transaction modifiée sur l'ui " + financialTransactionDate);
+ log.debug("Date de début du premier exercice : " + beginDateFirstFiscalPeriod);
+ log.debug("Date de fin du dernier exercice : " + endDateLastFiscalPeriod);
+ }
+
+ //1-date not on a fiscal period
+ if (financialTransactionDate.before(beginDateFirstFiscalPeriod) || financialTransactionDate.after(endDateLastFiscalPeriod)){
+ if (financialTransactionDate.before(beginDateFirstFiscalPeriod)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Date de la transaction avant (antérieure) la date de début du premier exercice");
}
-
- if (financialTransactionDate.after(endDateLastFiscalPeriod)) {
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction après (postérieure) la date de fin du dernier exercice");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.dateaftererror"));
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.datebeforeerror");
+ }
+
+ if (financialTransactionDate.after(endDateLastFiscalPeriod)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Date de la transaction après (postérieure) la date de fin du dernier exercice");
}
- }else{ //date on a fiscal period (and consequently on a financial), now test if financial is open
-
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
- FinancialPeriod financialPeriodOld = financialPeriodTopiaDao.findByDate(financialTransactionOld.getTransactionDate());
-
- //2. check old financial period locked
- if (financialPeriodOld.isLocked()) {
- if (log.isDebugEnabled()) {
- log.debug("Periode (Old) financière bloquée");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.financialtransactionblocked"));
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.dateaftererror");
+ }
+ }else{ //date on a fiscal period (and consequently on a financial), now test if financial is open
+
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod financialPeriod = financialPeriodTopiaDao.findByDate(financialTransaction.getTransactionDate());
+ FinancialPeriod financialPeriodOld = financialPeriodTopiaDao.findByDate(financialTransactionOld.getTransactionDate());
+
+ //2. check old financial period locked
+ if (financialPeriodOld.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Periode (Old) financière bloquée");
}
-
- //3. check new financial period locked
- if (financialPeriod.isLocked()) {
- if (log.isDebugEnabled()) {
- log.debug("Periode (New) financière bloquée");
- }
- throw new LimaBusinessException(t("lima-business.defaultaccountingrules.financialnewdateblocked"));
+ throw new FinancialTransactionException(financialTransactionOld, "lima-business.defaultaccountingrules.financialtransactionblocked");
+ }
+
+ //3. check new financial period locked
+ if (financialPeriod.isLocked()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Periode (New) financière bloquée");
}
+ throw new FinancialTransactionException(financialTransaction, "lima-business.defaultaccountingrules.financialnewdateblocked");
}
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check financial transaction", ex);
}
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,8 +29,10 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.InvalidAccountNumberException;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
+import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.EntryBook;
@@ -39,10 +41,7 @@
import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
-import org.chorem.lima.entity.Account;
-
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -63,7 +62,7 @@
* Règles de vérification de la création du PCG, appliquées à la comptabilité française.
*/
@Override
- public void createAccountRules(Account account) throws LimaException {
+ public void createAccountRules(Account account) throws InvalidAccountNumberException {
super.createAccountRules(account);
String accountNumber = account.getAccountNumber();
@@ -76,28 +75,25 @@
// Check root account starts with 1 to 8
if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.accountstartnumbererror",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountstartnumbererror");
}
}
@Override
- public void updateAccountRules(Account account) throws LimaException {
+ public void updateAccountRules(Account account) throws InvalidAccountNumberException {
super.updateAccountRules(account);
String accountNumber = account.getAccountNumber();
// Check if the number account is type numeric
if (!StringUtils.isNumeric(account.getAccountNumber())) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.accountnumbernotnumeric",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountnumbernotnumeric");
}
// Check root account starts with 1 to 8
if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.accountstartnumbererror",
- account.getAccountNumber()));
+ throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountstartnumbererror");
}
}
@@ -115,61 +111,58 @@
* Pas plus de deux exercices fiscaux ne peuvent-être ouvert en même temps
*/
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- //Checks if is not the first fiscalperiod to create
- if (fiscalPeriodTopiaDao.count() != 0) {
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
+ //Checks if is not the first fiscalperiod to create
+ if (fiscalPeriodTopiaDao.count() != 0) {
- //check the new fiscal period adjoining the last
- Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
- dateLastFiscalPeriod = DateUtils.
- addDays(dateLastFiscalPeriod, 1);
- dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
- Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
-
- if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.newfiscalperiodadjoiningerror"));
- }
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod();
- //We can create a new fiscal period meantime the last fiscal period was not locked
- //But not the ante periodfiscal
- int unblockedFiscalPeriod =
- fiscalPeriodTopiaDao.findAllByLocked(false).size();
- if (unblockedFiscalPeriod > 1) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
- }
+ //check the new fiscal period adjoining the last
+ Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
+ dateLastFiscalPeriod = DateUtils.
+ addDays(dateLastFiscalPeriod, 1);
+ dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
+ Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
+
+ if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.newfiscalperiodadjoiningerror");
}
- // FinancialPeriods of 1 month are created
- Date endDate = fiscalPeriod.getEndDate();
- Date loopDate = fiscalPeriod.getBeginDate();
- while (loopDate.before(endDate)) {
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
- financialPeriod.setLocked(fiscalPeriod.isLocked());
- financialPeriod.setBeginDate(loopDate);
- loopDate = DateUtils.addMonths(loopDate, 1);
- loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
- loopDate = DateUtils.addMilliseconds(loopDate, -1);
- if (loopDate.after(endDate)) {
- financialPeriod.setEndDate(endDate);
- } else {
- financialPeriod.setEndDate(loopDate);
- }
- //create it
- financialPeriods.add(financialPeriod);
+ //We can create a new fiscal period meantime the last fiscal period was not locked
+ //But not the ante periodfiscal
+ int unblockedFiscalPeriod =
+ fiscalPeriodTopiaDao.findAllByLocked(false).size();
+ if (unblockedFiscalPeriod > 1) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.antefiscalperiodnotblocked");
+ }
+ }
- //loop incremente
- loopDate = DateUtils.addMilliseconds(loopDate, 1);
+ // FinancialPeriods of 1 month are created
+ Date endDate = fiscalPeriod.getEndDate();
+ Date loopDate = fiscalPeriod.getBeginDate();
+ while (loopDate.before(endDate)) {
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
+ financialPeriod.setLocked(fiscalPeriod.isLocked());
+ financialPeriod.setBeginDate(loopDate);
+ loopDate = DateUtils.addMonths(loopDate, 1);
+ loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
+ loopDate = DateUtils.addMilliseconds(loopDate, -1);
+ if (loopDate.after(endDate)) {
+ financialPeriod.setEndDate(endDate);
+ } else {
+ financialPeriod.setEndDate(loopDate);
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //create it
+ financialPeriods.add(financialPeriod);
+
+ //loop incremente
+ loopDate = DateUtils.addMilliseconds(loopDate, 1);
}
return financialPeriods;
}
@@ -180,19 +173,15 @@
* On ne peut pas clore la dernière periode comptable ouverte.
*/
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriod oldestUnBlockedFiscalPeriod =
- fiscalPeriodTopiaDao.getLastUnlockedFiscalPeriod();
+ FiscalPeriod oldestUnBlockedFiscalPeriod =
+ fiscalPeriodTopiaDao.getLastUnlockedFiscalPeriod();
- //Check if the fiscal period to block is the oldest
- if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //Check if the fiscal period to block is the oldest
+ if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked");
}
}
@@ -202,19 +191,14 @@
* On ne peut supprimer qu'une periode comptable ouverte vide.
*/
@Override
- public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaBusinessException {
+ public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
- try {
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
-
- //Check if the fiscal period to delete is empty
- if (financialTransactionTopiaDao.findAllByDates(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()).size() != 0) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.fiscalperiodnotempty"));
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
- }
+ //Check if the fiscal period to delete is empty
+ if (financialTransactionTopiaDao.findAllByDates(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()).size() != 0) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.fiscalperiodnotempty");
+ }
}
/**
@@ -233,48 +217,42 @@
* qu'il reste des ClosedPeriodicEntryBook non clos ?
*/
@Override
- public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException {
super.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod();
- try {
+ // Get all closedperiod between for the period and entrybook
+ 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);
- // Get all closedperiod between for the period and entrybook
- 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);
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ //search fiscalperiod have financialperiod
+ FiscalPeriod fiscalPeriod = fiscalPeriodTopiaDao.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();
- //search fiscalperiod have financialperiod
- FiscalPeriod fiscalPeriod = fiscalPeriodTopiaDao.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();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
+ closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDates(entryBook, beginDate, endDate);
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDates(entryBook, beginDate, endDate);
+ // FIXME echatellier 20120504 juste un count suffit
+ int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
- // FIXME echatellier 20120504 juste un count suffit
- int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
+ // Get all closed between for the period, entrybook and are blocked
+ closedPeriodicEntryBooks = closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDatesLocked(entryBook, beginDate, endDate);
+ int nbBlockedClosedPeriodicEntryBooks =
+ closedPeriodicEntryBooks.size();
- // Get all closed between for the period, entrybook and are blocked
- closedPeriodicEntryBooks = closedPeriodicEntryBookTopiaDao.findAllByEntryBookAndDatesLocked(entryBook, beginDate, endDate);
- int nbBlockedClosedPeriodicEntryBooks =
- closedPeriodicEntryBooks.size();
-
- //Check if the fiscal period to block is the oldest
- if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook"));
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //Check if the fiscal period to block is the oldest
+ if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks) {
+ throw new ClosedPeriodicEntryBookException(closedPeriodicEntryBook, "lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook");
}
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,30 +25,29 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
-import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang.StringUtils;
+import org.chorem.lima.business.AccountException;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.AlreadyExistAccountException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
/**
* Permet d'implémenter le Plan Comptable Général.
* Un compte ne peut être supprimé si il contient des écritures comptables.
@@ -63,15 +62,9 @@
public class AccountServiceImpl extends AbstractLimaService implements AccountService {
@Override
- public long getAccountCount() throws LimaException {
- long result;
-
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- result = AccountTopiaDao.count();
- } catch (TopiaException ex) {
- throw new LimaException("Can't count", ex);
- }
+ public long getAccountCount() {
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ long result = AccountTopiaDao.count();
return result;
}
@@ -83,66 +76,48 @@
* @throws LimaException
*/
@Override
- public Account createAccount(Account account) throws LimaException {
+ public Account createAccount(Account account) throws AccountException {
// check rules before create the account
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.createAccountRules(account);
- Account result;
+ // force uppercase account number
+ account.setAccountNumber(account.getAccountNumber().toUpperCase().trim());
- try {
- // force uppercase account number
- account.setAccountNumber(account.getAccountNumber().toUpperCase().trim());
+ // check if account number already exist
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- // check if account number already exist
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
-
- if (AccountTopiaDao.existByNaturalId(account.getAccountNumber())) {
- throw new LimaBusinessException(
- t("lima-business.account.accountalreardyexist",
- account.getAccountNumber()));
- }
-
- //create it
- result = AccountTopiaDao.create(account);
- } catch (TopiaException ex) {
- throw new LimaException("Can't create account", ex);
+ if (AccountTopiaDao.existByNaturalId(account.getAccountNumber())) {
+ throw new AlreadyExistAccountException(account.getAccountNumber(), "lima-business.account.accountalreardyexist");
}
+
+ //create it
+ Account result = AccountTopiaDao.create(account);
return result;
}
@Override
- public Account getMasterAccount(String accountNumber) throws LimaException {
+ public Account getMasterAccount(String accountNumber) {
Account account = null;
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- while (account == null && accountNumber.length() > 1) {
+ while (account == null && accountNumber.length() > 1) {
- accountNumber = accountNumber.substring(0);
- account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't get master account", ex);
+ accountNumber = accountNumber.substring(0);
+ account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
}
return account;
}
/** Permet d'obtenir un compte suivant son numero */
@Override
- public Account getAccountByNumber(String accountNumber) throws LimaException {
+ public Account getAccountByNumber(String accountNumber) {
- Account account;
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
- } catch (Exception ex) {
- throw new LimaException("Can't get master account", ex);
- }
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ Account account = AccountTopiaDao.forAccountNumberEquals(accountNumber).findUniqueOrNull();
return account;
}
@@ -150,18 +125,11 @@
/** Permet d'obtenir tous les comptes. */
@Override
- public List<Account> getAllAccounts() throws LimaException {
+ public List<Account> getAllAccounts() {
- List<Account> accountsList;
-
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- accountsList = AccountTopiaDao.findAll();
- Collections.sort(accountsList, new AccountComparator());
-
- } catch (Exception ex) {
- throw new LimaException("Can't get all accounts", ex);
- }
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> accountsList = AccountTopiaDao.findAll();
+ Collections.sort(accountsList, new AccountComparator());
return accountsList;
}
@@ -169,17 +137,11 @@
/** Permet d'obtenir tout les comptes feuilles */
@Override
- public List<Account> getAllLeafAccounts() throws LimaException {
+ public List<Account> getAllLeafAccounts() {
- List<Account> accountsList;
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> accountsList = AccountTopiaDao.findAllLeafAccounts();
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- accountsList = AccountTopiaDao.findAllLeafAccounts();
- } catch (Exception ex) {
- throw new LimaException("Can't get all leaf accounts", ex);
- }
-
return accountsList;
}
@@ -187,16 +149,10 @@
* @see org.chorem.lima.business.api.AccountService#getAllSubAccounts(org.chorem.lima.entity.Account)
*/
@Override
- public List<Account> getAllSubAccounts(Account account)
- throws LimaException {
- List<Account> accountsList;
+ public List<Account> getAllSubAccounts(Account account) {
- try {
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- accountsList = AccountTopiaDao.findAllSubAccounts(account);
- } catch (Exception ex) {
- throw new LimaException("Can't get all sub accounts", ex);
- }
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ List<Account> accountsList = AccountTopiaDao.findAllSubAccounts(account);
return accountsList;
}
@@ -211,23 +167,17 @@
* @throws LimaException
*/
@Override
- public void removeAccount(Account account) throws LimaException {
+ public void removeAccount(Account account) throws UsedAccountException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
+ // Check rules for account if have entries
+ accountingRules.removeAccountRules(account);
- // Check rules for account if have entries
- accountingRules.removeAccountRules(account);
-
- // remove account
- AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
- Account accountToDelete = AccountTopiaDao.findByTopiaId(account.getTopiaId());
- AccountTopiaDao.delete(accountToDelete);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't remove account", ex);
- }
+ // remove account
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ Account accountToDelete = AccountTopiaDao.findByTopiaId(account.getTopiaId());
+ AccountTopiaDao.delete(accountToDelete);
}
/**
@@ -240,26 +190,20 @@
* @throws LimaException
*/
@Override
- public Account updateAccount(Account account) throws LimaException {
+ public Account updateAccount(Account account) throws InvalidAccountNumberException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- Account result;
- try {
- // DAO
- AccountTopiaDao accountDao = getDaoHelper().getAccountDao();
- accountingRules.updateAccountRules(account);
- result = accountDao.update(account);
+ // DAO
+ AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
+ accountingRules.updateAccountRules(account);
+ Account result = AccountTopiaDao.update(account);
- } catch (Exception ex) {
- throw new LimaException("Can't update account", ex);
- }
-
return result;
}
@Override
- public List<Account> stringToListAccounts(String selectedAccounts) throws TopiaException {
+ public List<Account> stringToListAccounts(String selectedAccounts) {
Set<Account> accounts = new HashSet<Account>();
if (selectedAccounts != null) {
AccountTopiaDao accountDao = getDaoHelper().getAccountDao();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,13 +24,11 @@
* #L%
*/
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.ClosedPeriodicEntryBookService;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@@ -45,13 +43,10 @@
public class ClosedPeriodicEntryBookServiceImpl extends AbstractLimaService implements ClosedPeriodicEntryBookService {
@Override
public ClosedPeriodicEntryBook getByEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) {
- ClosedPeriodicEntryBook result;
- try {
- ClosedPeriodicEntryBookTopiaDao accountTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- result = accountTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
- } catch (TopiaException e) {
- throw new LimaException("Can't find closed period entry book", e);
- }
+
+ ClosedPeriodicEntryBookTopiaDao accountTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ ClosedPeriodicEntryBook result = accountTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
+
return result;
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -31,13 +31,13 @@
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.examples.fdf.SetField;
import org.apache.pdfbox.pdmodel.PDDocument;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.FinancialStatementAmounts;
import org.chorem.lima.beans.GeneralEntryBooksDatas;
import org.chorem.lima.beans.GeneralEntryBooksDatasImpl;
import org.chorem.lima.beans.ReportsDatas;
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.FinancialStatementService;
import org.chorem.lima.business.api.IdentityService;
@@ -56,7 +56,6 @@
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.VatStatement;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Remote;
@@ -111,7 +110,7 @@
@Override
public String createFinancialStatementsDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
List<FinancialStatementAmounts> financialStatementAmounts =
financialStatementService.financialStatementReport(beginDate, endDate);
@@ -244,7 +243,7 @@
"</html>";
} catch (Exception ex) {
- log.error("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
return financialReport;
}
@@ -252,7 +251,7 @@
//############## Ledger ##############
@Override
public String createLedgerDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
List<Object> list = new ArrayList<Object>();
String ledgerReport = constructHtmlHeader(t("lima-business.document.ledger"));
@@ -381,7 +380,7 @@
ledgerReport += "</tbody></table></body>\n</html>";
} catch (Exception ex) {
- log.error("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
}
return ledgerReport;
@@ -389,7 +388,7 @@
@Override
public String createEntryBooksDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
String entryBookReport;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMMM yyyy");
try {
@@ -478,7 +477,7 @@
entryBookReport += "</body>\n</html>";
}
} catch (Exception ex) {
- throw new LimaException("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
return entryBookReport;
@@ -488,7 +487,7 @@
@Override
public String createBalanceDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
BalanceTrial balanceTrial =
reportService.generateBalanceTrial(beginDate, endDate, null, false, true);
@@ -554,7 +553,7 @@
balanceReport += "</body>\n</html>";
} catch (Exception ex) {
- log.error("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
}
@@ -566,7 +565,7 @@
@Override
public String createGeneralEntryBooksDocuments(Date beginDate,
- Date endDate) throws LimaException {
+ Date endDate) {
String entryBookReport;
try {
@@ -707,7 +706,7 @@
"</body>\n</html>";
}
} catch (Exception ex) {
- throw new LimaException("Can't generate document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
return entryBookReport;
}
@@ -717,7 +716,7 @@
@Override
public void createVatDocuments(Date beginDate,
Date endDate,
- String autocomplete) throws LimaException {
+ String autocomplete) {
String filePath = path + File.separator
+ DocumentsEnum.VAT.getFileName() + ".pdf";
@@ -736,14 +735,14 @@
reportsStream = DocumentServiceImpl.class
.getResourceAsStream("/reports/vat_form_fr.pdf");
if (reportsStream == null) {
- throw new LimaException("Could not find such file "
+ throw new LimaTechnicalException("Could not find such file "
+ "/reports/vat_form_fr.pdf");
}
} else {
try {
reportsStream = new FileInputStream(filePathDefault);
} catch (FileNotFoundException eee) {
- throw new LimaException("Could not find such file "
+ throw new LimaTechnicalException("Could not find such file "
+ filePathDefault, eee);
}
}
@@ -785,12 +784,12 @@
doc.close();
} catch (Exception ex) {
- throw new LimaException("Can't create document", ex);
+ throw new LimaTechnicalException("Can't create document", ex);
}
}
@Override
- public String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException {
+ public String createAccountDocument(Date beginDate, Date endDate, String account) {
String accountReport = null;
@@ -856,11 +855,9 @@
accountReport += "</html>";
- }catch (TopiaException e) {
- log.error("Can't find object", e);
}
catch (Exception e) {
- throw new LimaException("Can't create document", e);
+ throw new LimaTechnicalException("Can't create document", e);
}
return accountReport;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,23 +26,20 @@
package org.chorem.lima.business.ejb;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
+import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
-
import java.util.List;
import static org.nuiton.i18n.I18n.t;
@@ -59,140 +56,106 @@
public class EntryBookServiceImpl extends AbstractLimaService implements EntryBookService {
@Override
- public EntryBook createEntryBook(EntryBook entryBook)
- throws LimaException {
+ public EntryBook createEntryBook(EntryBook entryBook) {
- EntryBook result = null;
- try {
+ // check if entrybook with is name already exist
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ EntryBook result = entryBookTopiaDao.forCodeEquals(entryBook.getCode()).findUniqueOrNull();
+ if (result != null) {
+ log.error(
+ t("lima-business.entrybook.entrybookalreadyexist",
+ entryBook.getCode()));
+ } else {
+ // creation du EntryBook
+ result = entryBookTopiaDao.create(entryBook);
- // check if entrybook with is name already exist
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- result = entryBookTopiaDao.forCodeEquals(entryBook.getCode()).findUniqueOrNull();
- if (result != null) {
- log.error(
- t("lima-business.entrybook.entrybookalreadyexist",
- entryBook.getCode()));
- } else {
- // creation du EntryBook
- result = entryBookTopiaDao.create(entryBook);
+ //create ClosedPeriodicEntryBook for all unblocked financial period
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
+ FinancialPeriodTopiaDao financialPeriodTopiaDao =
+ getDaoHelper().getFinancialPeriodDao();
+ // for all unblocked financialperiod
+ List<FinancialPeriod> financialPeriods = financialPeriodTopiaDao.forProperties(FinancialPeriod.PROPERTY_LOCKED, true).findAll();
+ for (FinancialPeriod financialPeriod : financialPeriods) {
- //create ClosedPeriodicEntryBook for all unblocked financial period
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
- FinancialPeriodTopiaDao financialPeriodTopiaDao =
- getDaoHelper().getFinancialPeriodDao();
- // for all unblocked financialperiod
- List<FinancialPeriod> financialPeriods = financialPeriodTopiaDao.forProperties(FinancialPeriod.PROPERTY_LOCKED, true).findAll();
- for (FinancialPeriod financialPeriod : financialPeriods) {
-
- //new closed periodic entrybook
- ClosedPeriodicEntryBook closedPeriodicEntryBook =
- new ClosedPeriodicEntryBookImpl();
- // set entrybook
- closedPeriodicEntryBook.setEntryBook(entryBook);
- // set financial period
- closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
- // create it
- closedPeriodicEntryBookTopiaDao.create(closedPeriodicEntryBook);
- }
+ //new closed periodic entrybook
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ new ClosedPeriodicEntryBookImpl();
+ // set entrybook
+ closedPeriodicEntryBook.setEntryBook(entryBook);
+ // set financial period
+ closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
+ // create it
+ closedPeriodicEntryBookTopiaDao.create(closedPeriodicEntryBook);
}
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create entry book", ex);
}
return result;
}
@Override
- public List<EntryBook> getAllEntryBooks() throws LimaException {
+ public List<EntryBook> getAllEntryBooks() {
- List<EntryBook> entryBooksList;
+ // check if entrybook with is name already exist
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ List<EntryBook> entryBooksList = entryBookTopiaDao.findAll();
- try {
- // check if entrybook with is name already exist
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- entryBooksList = entryBookTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get entry books", ex);
- }
-
return entryBooksList;
}
@Override
- public EntryBook updateEntryBook(EntryBook entryBook) throws LimaException {
+ public EntryBook updateEntryBook(EntryBook entryBook) {
- EntryBook result;
- try {
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ // creation du EntryBook
+ EntryBook result = entryBookTopiaDao.update(entryBook);
- // creation du EntryBook
- result = entryBookTopiaDao.update(entryBook);
-
- } catch (Exception ex) {
- throw new LimaException("Can't update entry book", ex);
- }
-
return result;
}
@Override
- public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ public void removeEntryBook(EntryBook entryBook) throws EntryBookException {
// check rule
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.removeEntryBookRules(entryBook);
- try {
+ // re-attach to current transaction
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ EntryBook localEntryBook = entryBookTopiaDao.findByTopiaId(entryBook.getTopiaId());
- // re-attach to current transaction
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- EntryBook localEntryBook = entryBookTopiaDao.findByTopiaId(entryBook.getTopiaId());
-
- // delete all ClosedPeriodicEntryBook from this EntryBook
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- closedPeriodicEntryBookTopiaDao.findAllByEntryBook(localEntryBook);
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) {
- if (log.isDebugEnabled()) {
- log.debug("Deleting closed " + closedPeriodicEntryBook.getTopiaId());
- }
-
- // fix : ObjectDeletedException: deleted object would be re-saved by cascade
- closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
- closedPeriodicEntryBook.getFinancialPeriod().removeEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBook);
-
- closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
+ // delete all ClosedPeriodicEntryBook from this EntryBook
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
+ closedPeriodicEntryBookTopiaDao.findAllByEntryBook(localEntryBook);
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) {
+ if (log.isDebugEnabled()) {
+ log.debug("Deleting closed " + closedPeriodicEntryBook.getTopiaId());
}
- // delete entry book
- entryBookTopiaDao.delete(localEntryBook);
+ // fix : ObjectDeletedException: deleted object would be re-saved by cascade
+ closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ closedPeriodicEntryBook.getFinancialPeriod().removeEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBook);
- } catch (Exception ex) {
- throw new LimaException("Can't remove entry book", ex);
+ closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
}
+
+ // delete entry book
+ entryBookTopiaDao.delete(localEntryBook);
}
/*
* @see org.chorem.lima.business.ejbinterface.EntryBookService#getEntryBookByCode(java.lang.String)
*/
@Override
- public EntryBook getEntryBookByCode(String code) throws LimaException {
+ public EntryBook getEntryBookByCode(String code) {
- EntryBook entryBook;
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- try {
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ // creation du EntryBook
+ EntryBook entryBook = entryBookTopiaDao.forCodeEquals(code).findUniqueOrNull();
- // creation du EntryBook
- entryBook = entryBookTopiaDao.forCodeEquals(code).findUniqueOrNull();
-
- } catch (Exception ex) {
- throw new LimaException("Can't get entry book", ex);
- }
-
return entryBook;
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,16 +24,13 @@
* #L%
*/
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryService;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
-import java.util.Collection;
/**
* Created by davidcosse on 17/01/14.
@@ -45,13 +42,10 @@
@Override
public Entry createEntry(Entry entry) {
- Entry result;
- try {
- EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
- result = entryDao.create(entry);
- } catch (TopiaException e) {
- throw new LimaException("Can't create entry", e);
- }
+
+ EntryTopiaDao entryDao = getDaoHelper().getEntryDao();
+ Entry result = entryDao.create(entry);
+
return result;
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,6 +28,7 @@
import au.com.bytecode.opencsv.CSVWriter;
import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.FinancialStatementWayEnum;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ExportService;
@@ -50,14 +51,12 @@
import org.chorem.lima.entity.IdentityTopiaDao;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
-
import java.io.IOException;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
@@ -93,7 +92,7 @@
* 01/01/2013,AN,101,Capital,1,0,100000.00,C
*/
@Override
- public String exportEntriesAsEBP() throws LimaException {
+ public String exportEntriesAsEBP() {
SimpleDateFormat epbDateFormat = new SimpleDateFormat(DATE_PATTERN);
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -171,8 +170,8 @@
}
// Write cache in string
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -192,7 +191,7 @@
* 411DUPOND,DUPOND,,21 rue du bois, 78120, Rambouillet, France,,0135698475,0135698475
*/
@Override
- public String exportAccountsAsEBP() throws LimaException {
+ public String exportAccountsAsEBP() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -222,8 +221,8 @@
// Write cache in string
csvWriter.flush();
csvWriter.close();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -238,7 +237,7 @@
}
@Override
- public String exportEntryBooksAsEBP() throws LimaException {
+ public String exportEntryBooksAsEBP() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -270,8 +269,8 @@
// Write cache in string
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -290,7 +289,7 @@
/** Export integrality of database in CSV */
@Override
- public String exportAsCSV() throws LimaException {
+ public String exportAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -305,8 +304,8 @@
exportIdentityAsCSV(csvWriter);
// Write cache in string
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -323,7 +322,7 @@
/** Remote methode call from UI. */
@Override
- public String exportFinancialStatementChartAsCSV() throws LimaException {
+ public String exportFinancialStatementChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -333,8 +332,9 @@
exportFinancialStatementChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -358,52 +358,48 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[12];
- // Get all Financialstatements
- FinancialStatementTopiaDao financialStatementTopiaDao =
- getDaoHelper().getFinancialStatementDao();
+ public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[12];
+ // Get all Financialstatements
+ FinancialStatementTopiaDao financialStatementTopiaDao =
+ getDaoHelper().getFinancialStatementDao();
- List<FinancialStatement> listFinancialStatements =
- financialStatementTopiaDao.findAllOrderedByCreateDate();
+ List<FinancialStatement> listFinancialStatements =
+ financialStatementTopiaDao.findAllOrderedByCreateDate();
- // For all Financialstatements
- for (FinancialStatement financialStatement : listFinancialStatements) {
- nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel();
- nextLine[1] = financialStatement.getLabel();
- nextLine[2] = Boolean.toString(
- financialStatement.isHeader());
- nextLine[3] = financialStatement.getAccounts();
- nextLine[4] = financialStatement.getDebitAccounts();
- nextLine[5] = financialStatement.getCreditAccounts();
- nextLine[6] = financialStatement.
- getProvisionDeprecationAccounts();
- nextLine[7] = Boolean.toString(
- financialStatement.isSubAmount());
- nextLine[8] = Boolean.toString(
- financialStatement.isHeaderAmount());
- FinancialStatement masterFinancialStatement =
- financialStatement.getMasterFinancialStatement();
- String masterFinancialStatementString = masterFinancialStatement == null ? "" : StringUtils.remove(masterFinancialStatement.getLabel(), ";");
- nextLine[9] = masterFinancialStatementString;
- FinancialStatementWayEnum financialStatementWayEnum = financialStatement.getWay();
- String financialStatementWay = "";
- if (financialStatementWayEnum != null) {
- financialStatementWay = financialStatementWayEnum.name();
- }
- nextLine[10] = financialStatementWay;
- // Add line in file
- csvWriter.writeNext(nextLine);
+ // For all Financialstatements
+ for (FinancialStatement financialStatement : listFinancialStatements) {
+ nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel();
+ nextLine[1] = financialStatement.getLabel();
+ nextLine[2] = Boolean.toString(
+ financialStatement.isHeader());
+ nextLine[3] = financialStatement.getAccounts();
+ nextLine[4] = financialStatement.getDebitAccounts();
+ nextLine[5] = financialStatement.getCreditAccounts();
+ nextLine[6] = financialStatement.
+ getProvisionDeprecationAccounts();
+ nextLine[7] = Boolean.toString(
+ financialStatement.isSubAmount());
+ nextLine[8] = Boolean.toString(
+ financialStatement.isHeaderAmount());
+ FinancialStatement masterFinancialStatement =
+ financialStatement.getMasterFinancialStatement();
+ String masterFinancialStatementString = masterFinancialStatement == null ? "" : StringUtils.remove(masterFinancialStatement.getLabel(), ";");
+ nextLine[9] = masterFinancialStatementString;
+ FinancialStatementWayEnum financialStatementWayEnum = financialStatement.getWay();
+ String financialStatementWay = "";
+ if (financialStatementWayEnum != null) {
+ financialStatementWay = financialStatementWayEnum.name();
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ nextLine[10] = financialStatementWay;
+ // Add line in file
+ csvWriter.writeNext(nextLine);
}
}
/** Remote method call from UI. */
@Override
- public String exportVatStatementChartAsCSV() throws LimaException {
+ public String exportVatStatementChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -413,8 +409,8 @@
exportVatStatementChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -437,43 +433,39 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportVatStatementChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[6];
- // Get all Vatstatements
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ public void exportVatStatementChartAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[6];
+ // Get all Vatstatements
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- List<VatStatement> listVatStatements =
- vatStatementTopiaDao.findAllOrderedByCreateDate();
+ List<VatStatement> listVatStatements =
+ vatStatementTopiaDao.findAllOrderedByCreateDate();
- // For all Vatstatements
- for (VatStatement vatStatement : listVatStatements) {
- nextLine[0] = ImportExportEntityEnum.VATSTATEMENT.getLabel();
- nextLine[1] = vatStatement.getBoxName();
- nextLine[2] = vatStatement.getLabel();
- nextLine[3] = Boolean.toString(
- vatStatement.isHeader());
- nextLine[4] = vatStatement.getAccounts();
- VatStatement masterVatStatement =
- vatStatement.getMasterVatStatement();
- String masterVatStatementString = "";
- if (masterVatStatement != null) {
- masterVatStatementString =
- masterVatStatement.getLabel();
- }
- nextLine[5] = masterVatStatementString;
-
- csvWriter.writeNext(nextLine);
+ // For all Vatstatements
+ for (VatStatement vatStatement : listVatStatements) {
+ nextLine[0] = ImportExportEntityEnum.VATSTATEMENT.getLabel();
+ nextLine[1] = vatStatement.getBoxName();
+ nextLine[2] = vatStatement.getLabel();
+ nextLine[3] = Boolean.toString(
+ vatStatement.isHeader());
+ nextLine[4] = vatStatement.getAccounts();
+ VatStatement masterVatStatement =
+ vatStatement.getMasterVatStatement();
+ String masterVatStatementString = "";
+ if (masterVatStatement != null) {
+ masterVatStatementString =
+ masterVatStatement.getLabel();
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ nextLine[5] = masterVatStatementString;
+
+ csvWriter.writeNext(nextLine);
}
}
/** Remote methode call from UI. */
@Override
- public String exportEntryBookChartAsCSV() throws LimaException {
+ public String exportEntryBookChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -483,8 +475,8 @@
exportEntryBookChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -506,29 +498,26 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportEntryBookChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[3];
- // Get all entrybook
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- List<EntryBook> listEntryBook = entryBookTopiaDao.findAll();
- // For all EntryBook
- for (EntryBook entryBook : listEntryBook) {
- nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel();
- nextLine[1] = entryBook.getCode();
- nextLine[2] = StringUtils.remove(entryBook.getLabel(), ";");
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ public void exportEntryBookChartAsCSV(CSVWriter csvWriter) {
+
+ String[] nextLine = new String[3];
+ // Get all entrybook
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ List<EntryBook> listEntryBook = entryBookTopiaDao.findAll();
+ // For all EntryBook
+ for (EntryBook entryBook : listEntryBook) {
+ nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel();
+ nextLine[1] = entryBook.getCode();
+ nextLine[2] = StringUtils.remove(entryBook.getLabel(), ";");
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
/** Remote methode call from UI. */
@Override
- public String exportAccountsChartAsCSV() throws LimaException {
+ public String exportAccountsChartAsCSV() {
StringWriter out = new StringWriter();
CSVWriter csvWriter = null;
@@ -537,8 +526,8 @@
exportAccountsChartAsCSV(csvWriter);
// Write cache in file
csvWriter.flush();
- } catch (Exception ex) {
- throw new LimaException("Can't export", ex);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
if (csvWriter != null) {
try {
@@ -560,25 +549,21 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportAccountsChartAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[6];
- // Récupère tous les comptes
- AccountTopiaDao accountTopiaDao =
- getDaoHelper().getAccountDao();
- List<Account> listAccount = accountTopiaDao.findAll();
- // Pour tous les comptes
- for (Account account : listAccount) {
- nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel();
- nextLine[1] = account.getAccountNumber();
- nextLine[2] = StringUtils.remove(account.getLabel(), ";");
- nextLine[3] = account.getThirdParty();
+ public void exportAccountsChartAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[6];
+ // Récupère tous les comptes
+ AccountTopiaDao accountTopiaDao =
+ getDaoHelper().getAccountDao();
+ List<Account> listAccount = accountTopiaDao.findAll();
+ // Pour tous les comptes
+ for (Account account : listAccount) {
+ nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel();
+ nextLine[1] = account.getAccountNumber();
+ nextLine[2] = StringUtils.remove(account.getLabel(), ";");
+ nextLine[3] = account.getThirdParty();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
@@ -591,48 +576,45 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter) throws LimaException {
+ public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter) {
int numTransaction = 0;
// Get all financialtransactions
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao =
- getDaoHelper().getFinancialTransactionDao();
- List<FinancialTransaction> listFinancialTransaction =
- financialTransactionTopiaDao.findAll();
- // For all financialTransaction
- for (FinancialTransaction financialTransaction : listFinancialTransaction) {
- String[] nextLine = new String[8];
- nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel();
+
+ FinancialTransactionTopiaDao financialTransactionTopiaDao =
+ getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> listFinancialTransaction =
+ financialTransactionTopiaDao.findAll();
+ // For all financialTransaction
+ for (FinancialTransaction financialTransaction : listFinancialTransaction) {
+ String[] nextLine = new String[8];
+ nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel();
+ nextLine[1] = String.valueOf(numTransaction);
+ nextLine[2] = SDATEFORMAT.format(financialTransaction.getTransactionDate());
+ nextLine[3] = financialTransaction.getAmountDebit().toString();
+ nextLine[4] = financialTransaction.getAmountCredit().toString();
+ EntryBook entryBook = financialTransaction.getEntryBook();
+ if (entryBook != null) {
+ nextLine[5] = entryBook.getCode();
+ }
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+
+ nextLine = new String[10];
+ for (Entry entry : financialTransaction.getEntry()) {
+ nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel();
nextLine[1] = String.valueOf(numTransaction);
- nextLine[2] = SDATEFORMAT.format(financialTransaction.getTransactionDate());
- nextLine[3] = financialTransaction.getAmountDebit().toString();
- nextLine[4] = financialTransaction.getAmountCredit().toString();
- EntryBook entryBook = financialTransaction.getEntryBook();
- if (entryBook != null) {
- nextLine[5] = entryBook.getCode();
- }
+ nextLine[2] = entry.getDescription();
+ nextLine[3] = entry.getAmount().toString();
+ nextLine[4] = Boolean.toString(entry.isDebit());
+ nextLine[5] = entry.getLettering();
+ nextLine[6] = entry.getDetail();
+ nextLine[7] = entry.getVoucher();
+ nextLine[8] = entry.getPosition();
+ nextLine[9] = entry.getAccount().getAccountNumber();
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
-
- nextLine = new String[10];
- for (Entry entry : financialTransaction.getEntry()) {
- nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel();
- nextLine[1] = String.valueOf(numTransaction);
- nextLine[2] = entry.getDescription();
- nextLine[3] = entry.getAmount().toString();
- nextLine[4] = Boolean.toString(entry.isDebit());
- nextLine[5] = entry.getLettering();
- nextLine[6] = entry.getDetail();
- nextLine[7] = entry.getVoucher();
- nextLine[8] = entry.getPosition();
- nextLine[9] = entry.getAccount().getAccountNumber();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- numTransaction++;
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ numTransaction++;
}
}
@@ -644,25 +626,21 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportFiscalPeriodAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[4];
- // Get all fiscalperiod
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao =
- getDaoHelper().getFiscalPeriodDao();
- List<FiscalPeriod> listFiscalPeriod =
- fiscalPeriodTopiaDao.findAll();
- // For all Entry
- for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
- nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel();
- nextLine[1] = SDATEFORMAT.format(fiscalPeriod.getBeginDate());
- nextLine[2] = SDATEFORMAT.format(fiscalPeriod.getEndDate());
- nextLine[3] = Boolean.toString(fiscalPeriod.isLocked());
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ public void exportFiscalPeriodAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[4];
+ // Get all fiscalperiod
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao =
+ getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> listFiscalPeriod =
+ fiscalPeriodTopiaDao.findAll();
+ // For all Entry
+ for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
+ nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel();
+ nextLine[1] = SDATEFORMAT.format(fiscalPeriod.getBeginDate());
+ nextLine[2] = SDATEFORMAT.format(fiscalPeriod.getEndDate());
+ nextLine[3] = Boolean.toString(fiscalPeriod.isLocked());
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
@@ -673,60 +651,52 @@
* @param csvWriter
* @throws LimaException
*/
- public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[5];
- // Get all fiscalperiod
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
- List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
- closedPeriodicEntryBookTopiaDao.findAll();
- // For all Entry
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
- nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel();
- nextLine[1] = Boolean.toString(
- closedPeriodicEntryBook.isLocked());
- nextLine[2] =
- SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
- getBeginDate());
- nextLine[3] =
- SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
- getEndDate());
- nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[5];
+ // Get all fiscalperiod
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
+ closedPeriodicEntryBookTopiaDao.findAll();
+ // For all Entry
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
+ nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel();
+ nextLine[1] = Boolean.toString(
+ closedPeriodicEntryBook.isLocked());
+ nextLine[2] =
+ SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
+ getBeginDate());
+ nextLine[3] =
+ SDATEFORMAT.format(closedPeriodicEntryBook.getFinancialPeriod().
+ getEndDate());
+ nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
- public void exportIdentityAsCSV(CSVWriter csvWriter) throws LimaException {
- try {
- String[] nextLine = new String[12];
- // Get identity
- IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
- List<Identity> identities = identityTopiaDao.findAll();
- if (identities.size() != 0) {
+ public void exportIdentityAsCSV(CSVWriter csvWriter) {
+ String[] nextLine = new String[12];
+ // Get identity
+ IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
+ List<Identity> identities = identityTopiaDao.findAll();
+ if (identities.size() != 0) {
- Identity identity = identities.get(0);
- nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel();
- nextLine[1] = identity.getName();
- nextLine[2] = identity.getDescription();
- nextLine[3] = identity.getAddress();
- nextLine[4] = identity.getAddress2();
- nextLine[5] = identity.getCity();
- nextLine[6] = identity.getPhoneNumber();
- nextLine[7] = identity.getEmail();
- nextLine[8] = identity.getZipCode();
- nextLine[9] = identity.getVatNumber();
- nextLine[10] = identity.getClassificationCode();
- nextLine[11] = identity.getBusinessNumber();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't export", ex);
+ Identity identity = identities.get(0);
+ nextLine[0] = ImportExportEntityEnum.IDENTITY.getLabel();
+ nextLine[1] = identity.getName();
+ nextLine[2] = identity.getDescription();
+ nextLine[3] = identity.getAddress();
+ nextLine[4] = identity.getAddress2();
+ nextLine[5] = identity.getCity();
+ nextLine[6] = identity.getPhoneNumber();
+ nextLine[7] = identity.getEmail();
+ nextLine[8] = identity.getZipCode();
+ nextLine[9] = identity.getVatNumber();
+ nextLine[10] = identity.getClassificationCode();
+ nextLine[11] = identity.getBusinessNumber();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
}
}
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,28 +25,22 @@
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;
import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryBookTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+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.
@@ -60,119 +54,79 @@
/** @return all financial period */
@Override
- public List<FinancialPeriod> getAllFinancialPeriods() throws LimaException {
+ public List<FinancialPeriod> getAllFinancialPeriods() {
- List<FinancialPeriod> result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ List<FinancialPeriod> result = financialPeriodTopiaDao.findAllOrderByBeginDate();
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findAllOrderByBeginDate();
- } catch (Exception ex) {
- throw new LimaException("Can't get periods", ex);
- }
-
return result;
}
/** @return all unblocked financial period */
@Override
- public List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException {
+ public List<FinancialPeriod> getUnblockedFinancialPeriods() {
- List<FinancialPeriod> result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ List<FinancialPeriod>result = financialPeriodTopiaDao.findAllUnlockedOrderByBeginDate();
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findAllUnlockedOrderByBeginDate();
- } catch (Exception ex) {
- throw new LimaException("Can't create period", ex);
- }
-
return result;
}
/** @return all financial period from a fiscal period */
@Override
- public List<FinancialPeriod> getFinancialPeriods(Date beginDate, Date endDate) throws LimaException {
+ public List<FinancialPeriod> getFinancialPeriods(Date beginDate, Date endDate) {
- List<FinancialPeriod> result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ List<FinancialPeriod> result = financialPeriodTopiaDao.findByDates(beginDate, endDate);
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findByDates(beginDate, endDate);
- } catch (Exception ex) {
- throw new LimaException("Can't get period", ex);
- }
-
return result;
}
- public FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate) throws LimaException {
+ public FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate) {
- FinancialPeriod result;
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod result = financialPeriodTopiaDao.findByNaturalId(beginDate, endDate);
- try {
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- result = financialPeriodTopiaDao.findByNaturalId(beginDate, endDate);
- } catch (Exception ex) {
- throw new LimaException("Can't get period", ex);
- }
-
return result;
}
@Override
- public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
+ public ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
ClosedPeriodicEntryBook result;
- try {
- // check rules before create the account
- accountingRules.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
+ // check rules before create the account
+ accountingRules.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook);
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
- getDaoHelper().getClosedPeriodicEntryBookDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao =
+ getDaoHelper().getClosedPeriodicEntryBookDao();
- // reload object in current transaction
- result = closedPeriodicEntryBookTopiaDao.findByTopiaId(
- closedPeriodicEntryBook.getTopiaId());
+ // reload object in current transaction
+ result = closedPeriodicEntryBookTopiaDao.findByTopiaId(
+ closedPeriodicEntryBook.getTopiaId());
- result.setLocked(true);
- result = closedPeriodicEntryBookTopiaDao.update(result);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't block period", ex);
- }
+ result.setLocked(true);
+ result = closedPeriodicEntryBookTopiaDao.update(result);
return result;
}
@Override
public ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
- FinancialPeriod financialPeriod) throws LimaException {
- ClosedPeriodicEntryBook closedPeriodicEntryBook;
+ FinancialPeriod financialPeriod) {
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- try {
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
- } catch (Exception ex) {
- throw new LimaException("Can't get closed periodic", ex);
- }
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookTopiaDao.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
return closedPeriodicEntryBook;
}
@Override
- public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException {
+ public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() {
- List<ClosedPeriodicEntryBook> result;
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> result = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- try {
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- result = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- } catch (Exception ex) {
- 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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,19 +25,6 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -57,8 +44,19 @@
import org.chorem.lima.entity.AccountTopiaDao;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+import javax.ejb.EJB;
+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;
+
+import static org.nuiton.i18n.I18n.t;
+
@Stateless
@Remote(FinancialStatementService.class)
@TransactionAttribute
@@ -74,86 +72,70 @@
@Override
public void createFinancialStatement(FinancialStatement masterFinancialStatement,
- FinancialStatement financialStatement) throws LimaException {
+ FinancialStatement financialStatement) {
- try {
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ financialStatementTopiaDao.create(financialStatement);
- financialStatementTopiaDao.create(financialStatement);
+ FinancialStatement masterfinancialStatementUpdate = null;
+ if (masterFinancialStatement != null) {
+ masterfinancialStatementUpdate = financialStatementTopiaDao.forLabelEquals(masterFinancialStatement.getLabel()).findAnyOrNull();
+ }
- FinancialStatement masterfinancialStatementUpdate = null;
- if (masterFinancialStatement != null) {
- masterfinancialStatementUpdate = financialStatementTopiaDao.forLabelEquals(masterFinancialStatement.getLabel()).findAnyOrNull();
- }
-
- // check if parent account exist;
- if (masterfinancialStatementUpdate != null) {
- masterfinancialStatementUpdate.addSubFinancialStatements(financialStatement);
- financialStatementTopiaDao.update(masterfinancialStatementUpdate);
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create financial statement", ex);
+ // check if parent account exist;
+ if (masterfinancialStatementUpdate != null) {
+ masterfinancialStatementUpdate.addSubFinancialStatements(financialStatement);
+ financialStatementTopiaDao.update(masterfinancialStatementUpdate);
}
}
@Override
- public void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException {
+ public void removeFinancialStatement(FinancialStatement financialStatement) {
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- // remove financialstatement
- FinancialStatement financialStatementToDelete =
- financialStatementTopiaDao.findByTopiaId(
- financialStatement.getTopiaId());
- financialStatementTopiaDao.delete(financialStatementToDelete);
+ // remove financialstatement
+ FinancialStatement financialStatementToDelete =
+ financialStatementTopiaDao.findByTopiaId(
+ financialStatement.getTopiaId());
+ financialStatementTopiaDao.delete(financialStatementToDelete);
- //get all subFinancialStatement
- List<FinancialStatement> financialStatements =
- getAllChildrenFinancialStatement(financialStatement,
- new ArrayList<FinancialStatement>());
+ //get all subFinancialStatement
+ List<FinancialStatement> financialStatements =
+ getAllChildrenFinancialStatement(financialStatement,
+ new ArrayList<FinancialStatement>());
- //if FinancialStatement have subFinancialStatement
- if (financialStatements.size() > 0) {
- for (FinancialStatement subFinancialStatement : financialStatements) {
- FinancialStatement subFinancialStatementToDelete =
- financialStatementTopiaDao.findByTopiaId(
- subFinancialStatement.getTopiaId());
- financialStatementTopiaDao.delete(subFinancialStatementToDelete);
- }
+ //if FinancialStatement have subFinancialStatement
+ if (financialStatements.size() > 0) {
+ for (FinancialStatement subFinancialStatement : financialStatements) {
+ FinancialStatement subFinancialStatementToDelete =
+ financialStatementTopiaDao.findByTopiaId(
+ subFinancialStatement.getTopiaId());
+ financialStatementTopiaDao.delete(subFinancialStatementToDelete);
}
-
- } catch (Exception ex) {
- throw new LimaException("Can't remove financial statement", ex);
}
}
@Override
- public void removeAllFinancialStatement() throws LimaException {
+ public void removeAllFinancialStatement() {
for (FinancialStatement financialStatement : getChildrenFinancialStatement(null)) {
removeFinancialStatement(financialStatement);
}
}
@Override
- public List<FinancialStatement> getAllFinancialStatements() throws LimaException {
- List<FinancialStatement> financialStatements;
+ public List<FinancialStatement> getAllFinancialStatements() {
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ List<FinancialStatement> financialStatements = financialStatementTopiaDao.findAll();
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- financialStatements = financialStatementTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get financial statements", ex);
- }
return financialStatements;
}
@Override
public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement,
- List<FinancialStatement> result) throws LimaException {
+ List<FinancialStatement> result) {
List<FinancialStatement> childFinancialStatements =
getChildrenFinancialStatement(financialStatement);
for (FinancialStatement childFinancialStatement : childFinancialStatements) {
@@ -164,31 +146,23 @@
}
@Override
- public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) throws LimaException {
- List<FinancialStatement> financialStatements;
+ public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) {
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- financialStatements = financialStatementTopiaDao.findChildrenFinancialStatement(masterFinancialStatement);
- } catch (Exception ex) {
- throw new LimaException("Can't get childreen statements", ex);
- }
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ List<FinancialStatement> financialStatements = financialStatementTopiaDao.findChildrenFinancialStatement(masterFinancialStatement);
+
return financialStatements;
}
@Override
- public void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException {
+ public void updateFinancialStatement(FinancialStatement financialStatement) {
- try {
- // TopiaDao
- FinancialStatementTopiaDao financialStatementHeaderTopiaDao = getDaoHelper().getFinancialStatementDao();
- //update
- financialStatementHeaderTopiaDao.update(financialStatement);
+ // TopiaDao
+ FinancialStatementTopiaDao financialStatementHeaderTopiaDao = getDaoHelper().getFinancialStatementDao();
+ //update
+ financialStatementHeaderTopiaDao.update(financialStatement);
- } catch (Exception ex) {
- throw new LimaException("Can't update financial statement", ex);
- }
}
@@ -197,18 +171,11 @@
*/
@Override
public List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
- List<FinancialStatementAmounts> result;
+ Date selectedEndDate) {
+ //create list form tree
+ List<FinancialStatementAmounts> result = financialStatementReport(null, selectedBeginDate,
+ selectedEndDate, new FinancialStatementDatasImpl()).getListResult();
- try {
-
- //create list form tree
- result = financialStatementReport(null, selectedBeginDate,
- selectedEndDate, new FinancialStatementDatasImpl()).getListResult();
-
- } catch (Exception ex) {
- throw new LimaException("Can't generate report", ex);
- }
return result;
}
@@ -225,7 +192,7 @@
protected FinancialStatementDatas financialStatementReport(FinancialStatement financialStatement,
Date selectedBeginDate,
Date selectedEndDate,
- FinancialStatementDatas result) throws LimaException {
+ FinancialStatementDatas result) {
List<FinancialStatement> financialStatements = getChildrenFinancialStatement(financialStatement);
@@ -332,7 +299,7 @@
*/
protected FinancialStatementAmounts financialStatementAmounts(FinancialStatement financialStatement,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
+ Date selectedEndDate) {
FinancialStatementAmounts financialStatementAmounts =
new FinancialStatementAmountsImpl();
BigDecimal amount = new BigDecimal(0);
@@ -406,121 +373,106 @@
protected Amounts amountFromAccountList(String accountsNumberList,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
+ Date selectedEndDate) {
Amounts amounts = new AmountsImpl();
BigDecimal debit = new BigDecimal(0);
BigDecimal credit = new BigDecimal(0);
Boolean substract = false;
- try {
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- //Remove Spaces
- String result = StringUtils.deleteWhitespace(accountsNumberList);
- StringTokenizer stQuote = new StringTokenizer(result, "-");
- while (stQuote.hasMoreTokens()) {
- String s = stQuote.nextToken();
- //List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
- List<Account> accountsList = accountService.stringToListAccounts(s);
- BigDecimal debitTemp = new BigDecimal(0);
- BigDecimal creditTemp = new BigDecimal(0);
- for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportService.
- generateAccountsReports(
- account,
- true,
- selectedBeginDate, selectedEndDate);
- if (reportsDatas.getSoldeDebit()) {
- debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
- } else {
- creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
- }
+
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ //Remove Spaces
+ String result = StringUtils.deleteWhitespace(accountsNumberList);
+ StringTokenizer stQuote = new StringTokenizer(result, "-");
+ while (stQuote.hasMoreTokens()) {
+ String s = stQuote.nextToken();
+ //List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
+ List<Account> accountsList = accountService.stringToListAccounts(s);
+ BigDecimal debitTemp = new BigDecimal(0);
+ BigDecimal creditTemp = new BigDecimal(0);
+ for (Account account : accountsList) {
+ ReportsDatas reportsDatas = reportService.
+ generateAccountsReports(
+ account,
+ true,
+ selectedBeginDate, selectedEndDate);
+ if (reportsDatas.getSoldeDebit()) {
+ debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
+ } else {
+ creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
}
- if (!substract) {
- debit = debitTemp;
- credit = creditTemp;
- }
- //compte(s) précédé du signe -
- else {
- debit = debit.subtract(debitTemp);
- credit = credit.subtract(creditTemp);
- }
- substract = true;
}
- amounts.setCredit(credit);
- amounts.setDebit(debit);
- } catch (TopiaException ex) {
- throw new LimaException("Can't get accounts from list", ex);
+ if (!substract) {
+ debit = debitTemp;
+ credit = creditTemp;
+ }
+ //compte(s) précédé du signe -
+ else {
+ debit = debit.subtract(debitTemp);
+ credit = credit.subtract(creditTemp);
+ }
+ substract = true;
}
+ amounts.setCredit(credit);
+ amounts.setDebit(debit);
return amounts;
}
@Override
- public String checkFinancialStatementChart() throws LimaException {
+ public String checkFinancialStatementChart() {
StringBuilder result =
new StringBuilder(t("lima-business.financialstatement.check.warn"));
- try {
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ List<Account> accountsList = accountTopiaDao.findAllLeafAccounts();
- List<Account> accountsList = accountTopiaDao.findAllLeafAccounts();
+ List<FinancialStatement> financialStatementsList =
+ financialStatementTopiaDao.findAll();
- List<FinancialStatement> financialStatementsList =
- financialStatementTopiaDao.findAll();
+ for (FinancialStatement financialStatement : financialStatementsList) {
- for (FinancialStatement financialStatement : financialStatementsList) {
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getAccounts()));
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getAccounts()));
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getCreditAccounts()));
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getCreditAccounts()));
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getDebitAccounts()));
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getDebitAccounts()));
+ accountsList.removeAll(
+ accountService.stringToListAccounts(
+ financialStatement.getProvisionDeprecationAccounts()));
+ }
- accountsList.removeAll(
- accountService.stringToListAccounts(
- financialStatement.getProvisionDeprecationAccounts()));
- }
+ for (Account account : accountsList) {
- for (Account account : accountsList) {
-
- result.append(t("lima-business.financialstatement.check.nothing",
- account.getAccountNumber(), account.getLabel()));
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't check financial statement", ex);
+ result.append(t("lima-business.financialstatement.check.nothing",
+ account.getAccountNumber(), account.getLabel()));
}
+
return result.toString();
}
@Override
- public boolean checkFinancialStatementExist(String label) throws LimaException {
- boolean result;
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- result = financialStatementTopiaDao.forProperties(FinancialStatement.PROPERTY_LABEL, label).exists();
- } catch (TopiaException e) {
- throw new LimaException("Can't check financial statement", e);
- }
+ public boolean checkFinancialStatementExist(String label) {
+
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ boolean result = financialStatementTopiaDao.forProperties(FinancialStatement.PROPERTY_LABEL, label).exists();
+
return result;
}
@Override
- public FinancialStatement getFinancialStatementByLabel(String label) throws LimaException {
- FinancialStatement result;
- try {
- FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
- result = financialStatementTopiaDao.findByLabel(label);
- } catch (TopiaException e) {
- throw new LimaException("Can't find financial statement", e);
- }
+ public FinancialStatement getFinancialStatementByLabel(String label) {
+ FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao();
+ FinancialStatement result = financialStatementTopiaDao.findByLabel(label);
+
return result;
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -35,6 +35,8 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
import org.chorem.lima.business.AccountingRules;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.AccountService;
@@ -43,13 +45,12 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryTopiaDao;
import org.chorem.lima.entity.EntryImpl;
+import org.chorem.lima.entity.EntryTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -98,22 +99,17 @@
protected static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
@Override
- public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
- throws LimaException {
- FinancialTransaction result;
+ public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException {
+
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
- FinancialTransactionTopiaDao financialtransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransactionTopiaDao financialtransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- result = financialtransactionTopiaDao.create(financialtransaction);
+ FinancialTransaction result = financialtransactionTopiaDao.create(financialtransaction);
- } catch (TopiaException ex) {
- throw new LimaException("Can't create financial transaction", ex);
- }
return result;
}
@@ -122,15 +118,11 @@
*/
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
- Date beginDate, Date endDate) throws LimaException {
- List<FinancialTransaction> financialTransactions;
+ Date beginDate, Date endDate) {
- try {
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- financialTransactions = transactionTopiaDao.findAllByDates(beginDate, endDate);
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> financialTransactions = transactionTopiaDao.findAllByDates(beginDate, endDate);
+
return financialTransactions;
}
@@ -138,20 +130,14 @@
* and increment them
* */
@Override
- public String getNextLetters() throws LimaException {
- String lastActualLetters;
- String nextLetters;
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ public String getNextLetters() {
- List<String> letters = new ArrayList<String>(entryTopiaDao.findLetters());
- lastActualLetters = findLastLetter(letters);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- } catch (Exception ex) {
- throw new LimaException("Can't get new letters", ex);
- }
+ List<String> letters = new ArrayList<String>(entryTopiaDao.findLetters());
+ String lastActualLetters = findLastLetter(letters);
- nextLetters = lettersAfter(lastActualLetters);
+ String nextLetters = lettersAfter(lastActualLetters);
return nextLetters;
}
@@ -185,22 +171,17 @@
}
@Override
- public List<String> getAllLetters() throws LimaException {
- List<String> letters;
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ public List<String> getAllLetters() {
- letters = new ArrayList<String>(entryTopiaDao.findLetters());
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- } catch (Exception ex) {
- throw new LimaException("Can't get all letters", ex);
- }
+ List<String> letters = new ArrayList<String>(entryTopiaDao.findLetters());
return letters;
}
@Override
- public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException{
+ public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws FinancialTransactionException {
Entry newSameAccountEntry = null;
Entry newCostOrProductEntry = null;
@@ -337,7 +318,7 @@
*/
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
- FinancialPeriod period) throws LimaException {
+ FinancialPeriod period) {
return getAllFinancialTransactions(period, null);
}
@@ -346,15 +327,10 @@
*/
@Override
public List<FinancialTransaction> getAllFinancialTransactions(
- FiscalPeriod period) throws LimaException {
- List<FinancialTransaction> financialTransactions;
+ FiscalPeriod period) {
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> financialTransactions = transactionTopiaDao.findAllByDates(period.getBeginDate(), period.getEndDate());
- try {
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- financialTransactions = transactionTopiaDao.findAllByDates(period.getBeginDate(), period.getEndDate());
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
return financialTransactions;
}
@@ -362,24 +338,20 @@
* 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 {
+ public List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod financialPeriod, EntryBook entryBook) {
List<FinancialTransaction> financialTransactions;
- try {
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- if (entryBook != null) {
- financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
- financialPeriod.getEndDate(), entryBook);
- } else {
- financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
- financialPeriod.getEndDate());
- }
-
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
+ if (entryBook != null) {
+ financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
+ financialPeriod.getEndDate(), entryBook);
+ } else {
+ financialTransactions = transactionTopiaDao.findAllByDates(financialPeriod.getBeginDate(),
+ financialPeriod.getEndDate());
}
+
return financialTransactions;
}
@@ -387,31 +359,26 @@
* Get unbalanced financialtransaction from selected fiscalperiod.
*/
@Override
- public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) {
- List<FinancialTransaction> result;
//List<FinancialTransaction> checkedResult = new ArrayList<FinancialTransaction>();
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- result = financialTransactionTopiaDao.getAllIncorrectTransaction(fiscalPeriod.getBeginDate(),
- fiscalPeriod.getEndDate(), null);
- /*for (FinancialTransaction fTransaction : result) {
- BigDecimal credit = fTransaction.getAmountCredit();
- BigDecimal debit = fTransaction.getAmountDebit();
- credit = credit.setScale(optionsService.getScale(),
- BigDecimal.ROUND_HALF_UP);
- debit = debit.setScale(optionsService.getScale(),
- BigDecimal.ROUND_HALF_UP);
- if (credit.equals(debit)) {
- checkedResult.add(fTransaction);
- }
- }*/
+ List<FinancialTransaction> result = financialTransactionTopiaDao.getAllIncorrectTransaction(fiscalPeriod.getBeginDate(),
+ fiscalPeriod.getEndDate(), null);
+ /*for (FinancialTransaction fTransaction : result) {
+ BigDecimal credit = fTransaction.getAmountCredit();
+ BigDecimal debit = fTransaction.getAmountDebit();
+ credit = credit.setScale(optionsService.getScale(),
+ BigDecimal.ROUND_HALF_UP);
+ debit = debit.setScale(optionsService.getScale(),
+ BigDecimal.ROUND_HALF_UP);
+ if (credit.equals(debit)) {
+ checkedResult.add(fTransaction);
+ }
+ }*/
- } catch (Exception ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
return result;
}
@@ -423,50 +390,35 @@
* @throws LimaException
*/
@Override
- public List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException {
- List<FinancialTransaction> result;
- try {
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ public List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) {
- result = financialTransactionTopiaDao.getAllBalancedTransaction(fiscalPeriod.getBeginDate(),
- fiscalPeriod.getEndDate(), null);
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- } catch (TopiaException ex) {
- throw new LimaException("Can't get financial transactions", ex);
- }
+ List<FinancialTransaction> result = financialTransactionTopiaDao.getAllBalancedTransaction(fiscalPeriod.getBeginDate(),
+ fiscalPeriod.getEndDate(), null);
+
return result;
}
@Override
- public List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) throws LimaException {
- List<Entry> entries;
+ public List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) {
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- entries = entryTopiaDao.findAllEntryByFilter(filter);
- } catch (Exception ex) {
- throw new LimaException("Can't get entries", ex);
- }
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ List<Entry> entries = entryTopiaDao.findAllEntryByFilter(filter);
- if (log.isInfoEnabled()) {
- log.info("Entries size : " + entries.size());
- }
+ if (log.isInfoEnabled()) {
+ log.info("Entries size : " + entries.size());
+ }
- return entries;
+ return entries;
}
@Override
- public Entry getLastEntry(FinancialTransaction financialTransaction) throws LimaException {
- Entry lastEntry;
+ public Entry getLastEntry(FinancialTransaction financialTransaction) {
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- lastEntry = entryTopiaDao.getLastEntry(financialTransaction);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ Entry lastEntry = entryTopiaDao.getLastEntry(financialTransaction);
- } catch (Exception ex) {
- throw new LimaException("Can't get entries", ex);
- }
-
return lastEntry;
}
@@ -474,26 +426,22 @@
* Method used by update entry and remove entry for update amounts.
*/
@Override
- public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
+ public void updateFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
+ //FIXME mallon 22/06/2012 : Revoir l'utilisation du rattachement à la session et celle des deux objets 'financialTransactionOld'
+ //et 'financialTransaction'
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
- //FIXME mallon 22/06/2012 : Revoir l'utilisation du rattachement à la session et celle des deux objets 'financialTransactionOld'
- //et 'financialTransaction'
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
+ accountingRules.updateFinancialTransactionDateRules(financialTransaction, financialTransactionOld);
- accountingRules.updateFinancialTransactionDateRules(financialTransaction, financialTransactionOld);
+ financialTransactionOld.setEntryBook(financialTransaction.getEntryBook());
+ financialTransactionOld.setTransactionDate(financialTransaction.getTransactionDate());
- financialTransactionOld.setEntryBook(financialTransaction.getEntryBook());
- financialTransactionOld.setTransactionDate(financialTransaction.getTransactionDate());
+ transactionTopiaDao.update(financialTransactionOld);
- transactionTopiaDao.update(financialTransactionOld);
- } catch (TopiaException ex) {
- throw new LimaException("Can't update financial transaction", ex);
- }
}
/**
@@ -501,46 +449,35 @@
* call accounting rules
*/
@Override
- public void removeFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
+ public void removeFinancialTransaction(FinancialTransaction financialTransaction) throws FinancialTransactionException {
// check if the financial period is blocked
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
- try {
-
- FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
- transactionTopiaDao.delete(financialTransactionOld);
-
- } catch (Exception ex) {
- throw new LimaException("Can't remove financial transaction", ex);
- }
+ FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ FinancialTransaction financialTransactionOld = transactionTopiaDao.findByTopiaId(financialTransaction.getTopiaId());
+ transactionTopiaDao.delete(financialTransactionOld);
}
@Override
- public FinancialTransaction getFinancialTransactionWithId(String id) throws LimaException {
+ public FinancialTransaction getFinancialTransactionWithId(String id) {
FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
FinancialTransaction result = transactionTopiaDao.findByTopiaId(id);
return result;
}
@Override
- public Entry createEntry(Entry entry) throws LimaException {
+ public Entry createEntry(Entry entry) throws FinancialTransactionException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- Entry newEntry;
- try {
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- entry.getFinancialTransaction());
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
+ entry.getFinancialTransaction());
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- newEntry = entryTopiaDao.create(entry);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ Entry newEntry = entryTopiaDao.create(entry);
- } catch (TopiaException ex) {
- throw new LimaException("Can't create entry", ex);
- }
return newEntry;
}
@@ -548,71 +485,55 @@
* update entry, calculate amount of the financial transaction.
*/
@Override
- public void updateEntry(Entry entry) throws LimaException {
+ public void updateEntry(Entry entry) throws EntryException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
+ Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
- //check rules
- accountingRules.updateEntryRules(entry, entryOld);
+ //check rules
+ accountingRules.updateEntryRules(entry, entryOld);
- final Binder<Entry, Entry> binder = BinderFactory.newBinder(Entry.class, Entry.class);
- binder.copyExcluding(entry, entryOld, Entry.PROPERTY_TOPIA_ID, Entry.PROPERTY_TOPIA_CREATE_DATE);
- //update entry
- entryTopiaDao.update(entryOld);
+ final Binder<Entry, Entry> binder = BinderFactory.newBinder(Entry.class, Entry.class);
+ binder.copyExcluding(entry, entryOld, Entry.PROPERTY_TOPIA_ID, Entry.PROPERTY_TOPIA_CREATE_DATE);
+ //update entry
+ entryTopiaDao.update(entryOld);
- } catch (Exception ex) {
- throw new LimaException("Can't update entry", ex);
- }
}
/**
* Remove entry, update amounts for the financial transaction.
*/
@Override
- public void removeEntry(Entry entry) throws LimaException {
+ public void removeEntry(Entry entry) throws FinancialTransactionException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- try {
- FinancialTransaction financialTransaction = entry.getFinancialTransaction();
+ FinancialTransaction financialTransaction = entry.getFinancialTransaction();
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialTransaction);
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
- entryOld.getFinancialTransaction().removeEntry(entryOld);
- entryTopiaDao.delete(entryOld);
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ Entry entryOld = entryTopiaDao.findByTopiaId(entry.getTopiaId());
+ entryOld.getFinancialTransaction().removeEntry(entryOld);
+ entryTopiaDao.delete(entryOld);
- } catch (TopiaException ex) {
- throw new LimaException("Can't remove entry", ex);
- }
}
@Override
- public List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionCondition) throws LimaException {
- List<FinancialTransaction> result;
+ public List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionCondition) {
FilterGenerator generator = new FilterGenerator();
financialTransactionCondition.accept(generator);
FinancialTransactionFilter filter = generator.getFilter();
+ // next on financial transaction dao
+ FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
+ List<FinancialTransaction> result = financialTransactionTopiaDao.searchFinancialTransaction(filter);
- try {
- // next on financial transaction dao
- FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
- result = financialTransactionTopiaDao.searchFinancialTransaction(filter);
-
-
- } catch (Exception ex) {
- throw new LimaException("Can't search financial transaction", ex);
- }
-
if (log.isDebugEnabled()) {
log.debug("Size of results list : " + result.size());
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,10 +29,11 @@
import org.apache.commons.lang3.time.DateUtils;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.business.AccountException;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
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.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -53,10 +54,8 @@
import org.chorem.lima.entity.FinancialPeriodTopiaDao;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
-import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
import javax.ejb.EJB;
import javax.ejb.Remote;
@@ -100,60 +99,53 @@
protected FinancialTransactionService financialTransactionService;
@Override
- public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+ public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
- FiscalPeriod result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao();
+ AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ // 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);
- // 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);
+ //check rules before create the account
+ List<FinancialPeriod> financialPeriods = accountingRules.createFiscalPeriodRules(fiscalPeriod);
- //check rules before create the account
- List<FinancialPeriod> financialPeriods = accountingRules.createFiscalPeriodRules(fiscalPeriod);
+ // create
+ fiscalPeriod.addAllFinancialPeriod(financialPeriods);
- // create
- fiscalPeriod.addAllFinancialPeriod(financialPeriods);
+ //create all financial period
+ for (FinancialPeriod financialPeriod : financialPeriods) {
- //create all financial period
- for (FinancialPeriod financialPeriod : financialPeriods) {
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = Lists.newArrayList();
+ //create ClosedPeriodicEntryBook for all entrybook
+ for (EntryBook entryBook : entryBookTopiaDao.findAll()) {
+ //new closed periodic entrybook
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
+ // set entrybook
+ closedPeriodicEntryBook.setEntryBook(entryBook);
+ // set financial period
+ closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = Lists.newArrayList();
- //create ClosedPeriodicEntryBook for all entrybook
- for (EntryBook entryBook : entryBookTopiaDao.findAll()) {
- //new closed periodic entrybook
- ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
- // set entrybook
- closedPeriodicEntryBook.setEntryBook(entryBook);
- // set financial period
- closedPeriodicEntryBook.setFinancialPeriod(financialPeriod);
-
- closedPeriodicEntryBooks.add(closedPeriodicEntryBook);
- }
- financialPeriod.addAllEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBooks);
-
+ closedPeriodicEntryBooks.add(closedPeriodicEntryBook);
}
+ financialPeriod.addAllEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBooks);
- result = fiscalPeriodTopiaDao.create(fiscalPeriod);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create period", ex);
}
+ FiscalPeriod result = fiscalPeriodTopiaDao.create(fiscalPeriod);
+
return result;
}
@@ -161,18 +153,11 @@
* return all fiscal period.
*/
@Override
- public List<FiscalPeriod> getAllFiscalPeriods() throws LimaException {
+ public List<FiscalPeriod> getAllFiscalPeriods() {
- List<FiscalPeriod> result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> result = fiscalPeriodTopiaDao.findAll();
- try {
-
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- result = fiscalPeriodTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get periods", ex);
- }
-
return result;
}
@@ -180,52 +165,32 @@
* return all blocked fiscal periods.
*/
@Override
- public List<FiscalPeriod> getAllBlockedFiscalPeriods() throws LimaException {
+ public List<FiscalPeriod> getAllBlockedFiscalPeriods() {
- List<FiscalPeriod> result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> result = fiscalPeriodTopiaDao.forLockedEquals(true).findAll();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- result = fiscalPeriodTopiaDao.forLockedEquals(true).findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't create period", ex);
- }
-
return result;
}
/** return all unblocked fiscal periods */
@Override
- public List<FiscalPeriod> getAllUnblockedFiscalPeriods() throws LimaException {
+ public List<FiscalPeriod> getAllUnblockedFiscalPeriods() {
- List<FiscalPeriod> result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ List<FiscalPeriod> result = fiscalPeriodTopiaDao.forLockedEquals(false).findAll();
- try {
-
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- result = fiscalPeriodTopiaDao.forLockedEquals(false).findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get periods", ex);
- }
-
return result;
}
@Override
- public FiscalPeriod getLastFiscalPeriod() throws LimaException {
- FiscalPeriod result;
+ public FiscalPeriod getLastFiscalPeriod() {
- try {
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ //get the last fiscal period
+ FiscalPeriod result = fiscalPeriodTopiaDao.getLastFiscalPeriod();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- //get the last fiscal period
- result = fiscalPeriodTopiaDao.getLastFiscalPeriod();
-
- } catch (Exception ex) {
- throw new LimaException("Can't get period", ex);
- }
-
return result;
}
@@ -235,43 +200,36 @@
* check localized rules before block it
*/
@Override
- public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+ public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
- FiscalPeriod result;
- try {
+ if (fiscalPeriod.isLocked()) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.fiscalperiod.fiscalperiodalreadyblocked");
+ }
+ //check rules
+ accountingRules.blockFiscalPeriodRules(fiscalPeriod);
- if (fiscalPeriod.isLocked()) {
- throw new LimaBusinessException(t("lima-business.fiscalperiod.fiscalperiodalreadyblocked"));
- }
- //check rules
- accountingRules.blockFiscalPeriodRules(fiscalPeriod);
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ // Get the old fiscal period instance for no object conflict
+ FiscalPeriod oldFiscalPeriod =
+ fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
- // Get the old fiscal period instance for no object conflict
- FiscalPeriod oldFiscalPeriod =
- fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
-
- // lock fiscalperiod
- oldFiscalPeriod.setLocked(true);
- // locked all financialperiod of the fiscalperiod
- for (FinancialPeriod financialPeriod : oldFiscalPeriod.getFinancialPeriod()) {
- financialPeriod.setLocked(true);
- }
-
- result = fiscalPeriodTopiaDao.update(oldFiscalPeriod);
-
- } catch (Exception ex) {
- throw new LimaException("Can't block period", ex);
+ // lock fiscalperiod
+ oldFiscalPeriod.setLocked(true);
+ // locked all financialperiod of the fiscalperiod
+ for (FinancialPeriod financialPeriod : oldFiscalPeriod.getFinancialPeriod()) {
+ financialPeriod.setLocked(true);
}
+ FiscalPeriod result = fiscalPeriodTopiaDao.update(oldFiscalPeriod);
+
return result;
}
@Override
- public boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) throws LimaException{
+ public boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) {
boolean found = false;
List<FinancialTransaction> financialTransactionsList =
financialTransactionService.getAllFinancialTransactions(
@@ -296,43 +254,32 @@
}
@Override
- public FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod) throws LimaException {
+ public FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod) {
- FiscalPeriod result;
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ String topiaId = fiscalPeriod.getTopiaId();
+ FiscalPeriod fiscalPeriodOld = fiscalPeriodTopiaDao.findByTopiaId(topiaId);
- String topiaId = fiscalPeriod.getTopiaId();
- FiscalPeriod fiscalPeriodOld = fiscalPeriodTopiaDao.findByTopiaId(topiaId);
+ Date endDate = fiscalPeriod.getEndDate();
+ fiscalPeriodOld.setEndDate(endDate);
- Date endDate = fiscalPeriod.getEndDate();
- fiscalPeriodOld.setEndDate(endDate);
+ FiscalPeriod result = fiscalPeriodTopiaDao.update(fiscalPeriodOld);
- result = fiscalPeriodTopiaDao.update(fiscalPeriodOld);
-
- } catch (TopiaException e) {
- throw new LimaException("Can't update period", e);
- }
-
return result;
}
@Override
public FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
- boolean retainedEarnings) throws LimaException {
+ boolean retainedEarnings) throws AccountException, FinancialTransactionException, FiscalPeriodException {
if (entryBook != null && retainedEarnings) {
// re-attach entities to current session
- FiscalPeriod localFiscalPeriod;
- try {
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
- } catch (TopiaException ex) {
- throw new LimaException("Can't find fiscal period", ex);
- }
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
+
//if entrybook isn't found
//then create it
if (!entryBook.isPersisted()) {
@@ -406,7 +353,7 @@
}
}
if (beginfinancialPeriod == null) {
- throw new LimaBusinessException(t("lima-business.fiscalperiod.newfinancialperioderror"));
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.fiscalperiod.newfinancialperioderror");
}
//holds entries of all closing transactions
@@ -496,43 +443,30 @@
* check localized rules before delete it
*/
@Override
- public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod)
- throws LimaException {
+ public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ //get entities with TopiaDao
+ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
- try {
- try {
- //get entities with TopiaDao
- FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
+ // re-attach entities to current session
+ FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
- // re-attach entities to current session
- FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId());
+ //check rules
+ accountingRules.deleteFiscalPeriodRules(localFiscalPeriod);
- //check rules
- accountingRules.deleteFiscalPeriodRules(localFiscalPeriod);
+ //all "ClosedPeriodicEntryBooks" for the fiscal period
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookTopiaDaoList = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod);
- //all "ClosedPeriodicEntryBooks" for the fiscal period
- ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookTopiaDaoList = closedPeriodicEntryBookTopiaDao.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod);
-
- //delete closedPeriodicEntryBook before fiscal period
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookTopiaDaoList) {
- // fix : ObjectDeletedException: deleted object would be re-saved by cascade (Need to delete association between entryBook and financial period via closedPeriodEntityBook)
- closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
- closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
- }
-
- fiscalPeriodTopiaDao.delete(localFiscalPeriod);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't find fiscal period", ex);
- }
-
- } catch (Exception ex) {
- throw new LimaException("Can't delete period", ex);
+ //delete closedPeriodicEntryBook before fiscal period
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookTopiaDaoList) {
+ // fix : ObjectDeletedException: deleted object would be re-saved by cascade (Need to delete association between entryBook and financial period via closedPeriodEntityBook)
+ closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ closedPeriodicEntryBookTopiaDao.delete(closedPeriodicEntryBook);
}
+ fiscalPeriodTopiaDao.delete(localFiscalPeriod);
}
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,29 +25,6 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-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 javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -55,7 +32,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.DocumentService;
import org.chorem.lima.business.api.HttpServerService;
@@ -69,6 +45,28 @@
import org.nuiton.util.FileUtil;
import org.nuiton.util.Resource;
+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 java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
@Stateless
@Remote(HttpServerService.class)
@TransactionAttribute
@@ -215,8 +213,6 @@
autocomplete);
break;
}
- } catch (LimaException eeeLE) {
- log.error("Can't call document service for create html document", eeeLE);
} catch (ParseException eeePE) {
log.error("Can't parse date", eeePE);
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/IdentityServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,53 +25,40 @@
package org.chorem.lima.business.ejb;
-import java.util.List;
+import org.chorem.lima.business.api.IdentityService;
+import org.chorem.lima.entity.Identity;
+import org.chorem.lima.entity.IdentityTopiaDao;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
+import java.util.List;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.api.IdentityService;
-import org.chorem.lima.entity.Identity;
-import org.chorem.lima.entity.IdentityTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
-
@Stateless
@Remote(IdentityService.class)
@TransactionAttribute
public class IdentityServiceImpl extends AbstractLimaService implements IdentityService {
@Override
- public Identity getIdentity()
- throws LimaException {
+ public Identity getIdentity() {
Identity identity = null;
- try {
- IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
- List<Identity> identities = identityTopiaDao.findAll();
- if (identities.size() != 0) {
- identity = identities.get(0);
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't get identity", ex);
+ IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
+ List<Identity> identities = identityTopiaDao.findAll();
+ if (identities.size() != 0) {
+ identity = identities.get(0);
}
return identity;
}
@Override
- public void updateIdentity(Identity identity) throws LimaException {
- try {
- IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
- List<Identity> identities = identityTopiaDao.findAll();
- if (identities.size() != 0) {
- identityTopiaDao.delete(identities.get(0));
- }
- identityTopiaDao.create(identity);
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't update identity", ex);
+ public void updateIdentity(Identity identity) {
+ IdentityTopiaDao identityTopiaDao = getDaoHelper().getIdentityDao();
+ List<Identity> identities = identityTopiaDao.findAll();
+ if (identities.size() != 0) {
+ identityTopiaDao.delete(identities.get(0));
}
+ identityTopiaDao.create(identity);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,31 +25,9 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n.t;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
+import au.com.bytecode.opencsv.CSVReader;
+import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
+import au.com.bytecode.opencsv.bean.CsvToBean;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -72,9 +50,11 @@
import org.chorem.lima.beans.FinancialTransactionImportImpl;
import org.chorem.lima.beans.VatStatementImport;
import org.chorem.lima.beans.VatStatementImportImpl;
-import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.ImportEbpException;
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.ClosedPeriodicEntryBookService;
import org.chorem.lima.business.api.EntryBookService;
@@ -86,6 +66,7 @@
import org.chorem.lima.business.api.IdentityService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.VatStatementService;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryEBPComparator;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
@@ -110,10 +91,30 @@
import org.chorem.lima.entity.VatStatementImpl;
import org.nuiton.topia.persistence.TopiaException;
-import au.com.bytecode.opencsv.CSVReader;
-import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
-import au.com.bytecode.opencsv.bean.CsvToBean;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import static org.nuiton.i18n.I18n.t;
+
/**
* Import export service.
* Currently import and export as CSV and EBP.
@@ -176,10 +177,10 @@
// ################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
@Override
- public String importEntriesFromEbp(String datas) throws LimaException {
+ public String importEntriesFromEbp(String datas) throws ImportEbpException{
if (datas.isEmpty()) {
- throw new LimaBusinessException(t("lima-business.import.ebpnoentry"));
+ throw new ImportEbpException(t("lima-business.import.ebpnoentry"));
}
// use for logs
@@ -219,7 +220,7 @@
headEntry.add(EntryEBP.PROPERTY_CREDIT);
headEntry.add(EntryEBP.PROPERTY_LETTRE);
if (!Arrays.asList(strat.getColumnMapping()).containsAll(headEntry)) {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.ebpnoheader"));
}
@@ -236,7 +237,7 @@
// There are no valid fiscalPeriods -> exception
int nbFiscalPeriods = fiscalPeriods.size();
if (nbFiscalPeriods == 0) {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.nofiscalperiodopen"));
}
@@ -270,7 +271,7 @@
// if account not exist not export -> exception
else if (account == null) {
//// TODO DCossé 28/05/14 this message is not displayed on user's error window.
- throw new LimaBusinessException(t(
+ throw new ImportEbpException(t(
"lima-business.import.ebpmissingaccount",
entryEBP.getCompte()));
}
@@ -354,8 +355,12 @@
log.info("Imported form EBP : " + list.size() + " entries in "
+ (after - before) + " ms");
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (ParseException e) {
+ throw new ImportEbpException("Can't import ", e);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import ", e);
+ } catch (FinancialTransactionException e) {
+ throw new ImportEbpException("Can't import ", e);
} finally {
if (csvReader != null) {
try {
@@ -369,7 +374,7 @@
}
@Override
- public String importAccountsChartFromEbp(String datas) throws LimaException {
+ public String importAccountsChartFromEbp(String datas) throws ImportEbpException{
long before = System.currentTimeMillis();
List<Account> accounts = accountService.getAllAccounts();
if (accounts == null) {
@@ -417,7 +422,7 @@
line = csvReader.readNext();
}
} else {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.noaccount"));
}
@@ -427,8 +432,10 @@
+ (after - before) + " ms");
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (AccountException e) {
+ throw new ImportEbpException("Can't import", e);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -442,7 +449,7 @@
}
@Override
- public String importEntryBookFromEbp(String datas) throws LimaException {
+ public String importEntryBookFromEbp(String datas) throws ImportEbpException{
long before = System.currentTimeMillis();
List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
@@ -473,7 +480,7 @@
// check if file have a good header
if (entryBookCodeIndex == null || entryBookLabelIndex == null) {
- throw new LimaBusinessException(
+ throw new ImportEbpException(
t("lima-business.import.noaccount"));
}
@@ -500,8 +507,8 @@
log.info("Imported form EBP : " + count + " accounts in " + (after-before) + " ms");
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -520,7 +527,7 @@
/** Remote methode to call all entities import from UI */
@Override
- public String importAllAsCSV(String datas) throws LimaException {
+ public String importAllAsCSV(String datas) throws ImportEbpException {
StringBuilder result = new StringBuilder();
Map<String, List<FinancialStatementImport>> financialStatements =
@@ -600,8 +607,8 @@
result.append(createFinancialTransactionsAndEntries(
financialTransactions, entries));
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -620,8 +627,7 @@
*/
@Override
public String importAsCSV(String datas,
- ImportExportEntityEnum importExportEntityEnum)
- throws LimaException {
+ ImportExportEntityEnum importExportEntityEnum) throws ImportEbpException {
StringBuilder result = new StringBuilder();
// FinancialStatements
@@ -707,8 +713,8 @@
break;
}
- } catch (Exception ex) {
- throw new LimaException("Can't import", ex);
+ } catch (IOException e) {
+ throw new ImportEbpException("Can't import", e);
} finally {
if (csvReader != null) {
try {
@@ -724,7 +730,7 @@
@Override
public String importAsPDF(String datas,
ImportExportEntityEnum importExportEntityEnum,
- boolean setMode) throws LimaException {
+ boolean setMode) {
StringBuilder result = new StringBuilder();
@@ -786,15 +792,13 @@
*
* @param nextLine The line to import
* @return Success or error message
- * @throws LimaException If the line format is invalid
- * @throws TopiaException
+ * @throws ImportEbpException If the line format is invalid
*/
- protected String importAccountsChartsCSV(String[] nextLine)
- throws LimaException, TopiaException {
+ protected String importAccountsChartsCSV(String[] nextLine) throws ImportEbpException{
// Check line format
if (nextLine.length < 3
|| ! nextLine[0].equals(ImportExportEntityEnum.ACCOUNT.getLabel())) {
- throw new LimaException(t("lima-business.import.lineformatmismatch"));
+ throw new ImportEbpException(t("lima-business.import.lineformatmismatch"));
}
StringBuilder result = new StringBuilder();
@@ -812,7 +816,11 @@
account.setThirdParty(thirdParty);
}
- accountService.createAccount(account);
+ try {
+ accountService.createAccount(account);
+ } catch (AccountException e) {
+ result.append(t("lima-business.import.accountalreadyexist", accountNumber));
+ }
result.append(t("lima-business.import.accountadded",
account.getAccountNumber(),
account.getLabel()));
@@ -830,26 +838,28 @@
* @param nextLine
* @param fiscalPeriods
* @return
- * @throws ParseException
- * @throws TopiaException
+ * @throws ParseException
*/
protected String importFiscalPeriodCSV(String[] nextLine,
- List<FiscalPeriod> fiscalPeriods)
- throws ParseException, TopiaException {
+ List<FiscalPeriod> fiscalPeriods) {
StringBuilder result = new StringBuilder();
- 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]));
+ try {
+ 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 (financialPeriodService.getFinancialPeriods(beginDate, endDate) == null) {
- fiscalPeriods.add(fiscalPeriod);
- } else {
- result.append(t("lima-business.import.fiscalperiodalreadyexist", beginDate, endDate));
+ // if not exist, skip
+ if (financialPeriodService.getFinancialPeriods(beginDate, endDate) == null) {
+ fiscalPeriods.add(fiscalPeriod);
+ } else {
+ result.append(t("lima-business.import.fiscalperiodalreadyexist", beginDate, endDate));
+ }
+ } catch (ParseException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
return result.toString();
@@ -860,10 +870,8 @@
*
* @param nextLine
* @return
- * @throws TopiaException
- * @throws LimaException
*/
- protected String importEntryBooksChartCSV(String[] nextLine) throws TopiaException, LimaException {
+ protected String importEntryBooksChartCSV(String[] nextLine) {
StringBuilder result = new StringBuilder();
EntryBook entryBook = new EntryBookImpl();
@@ -888,10 +896,9 @@
*
* @param nextLine
* @param closedPeriodicEntryBooks
- * @throws LimaException
*/
protected void importClosedPeriodicEntryBookCSV(String[] nextLine,
- List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) throws LimaException {
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) {
String locked = nextLine[1];
String beginDate = nextLine[2];
String endDate = nextLine[3];
@@ -918,11 +925,9 @@
* @param nextLine
* @param financialStatements
* @return
- * @throws LimaException
- * @throws TopiaException
*/
protected String importFinancialsStatementChartCSV(String[] nextLine,
- Map<String, List<FinancialStatementImport>> financialStatements) throws LimaException, TopiaException {
+ Map<String, List<FinancialStatementImport>> financialStatements) {
StringBuilder result = new StringBuilder();
String label = StringUtils.trimToNull(nextLine[1]);
@@ -976,11 +981,9 @@
* @param nextLine
* @param vatStatements
* @return
- * @throws LimaException
- * @throws TopiaException
*/
protected String importVatStatementChartCSV(String[] nextLine,
- Map<String, List<VatStatementImport>> vatStatements) throws LimaException, TopiaException {
+ Map<String, List<VatStatementImport>> vatStatements) {
StringBuilder result = new StringBuilder();
@@ -1022,10 +1025,9 @@
*
* @param nextLine
* @param financialTransactions
- * @throws LimaException
*/
protected void importFinancialTransactionsCSV(String[] nextLine,
- Map<Integer, FinancialTransactionImport> financialTransactions) throws LimaException {
+ Map<Integer, FinancialTransactionImport> financialTransactions) {
int num = new Integer(nextLine[1]);
FinancialTransactionImport financialTransactionImport = new FinancialTransactionImportImpl();
financialTransactionImport.setDate(nextLine[2]);
@@ -1042,10 +1044,9 @@
*
* @param nextLine
* @param entries
- * @throws LimaException
*/
protected void importEntriesCSV(String[] nextLine,
- Map<Integer, List<EntryImport>> entries) throws LimaException {
+ Map<Integer, List<EntryImport>> entries) {
int num = new Integer(nextLine[1]);
EntryImport entryImport = new EntryImportImpl();
@@ -1075,7 +1076,7 @@
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
- protected String createFinancialStatements(Map<String, List<FinancialStatementImport>> financialStatements) throws LimaException, TopiaException {
+ protected String createFinancialStatements(Map<String, List<FinancialStatementImport>> financialStatements) {
StringBuilder result = new StringBuilder();
while (financialStatements.size() > 0) {
@@ -1155,7 +1156,7 @@
* @deprecated do only one method import without bean use (and remove beans)
*/
@Deprecated
- protected String createVatStatements(Map<String, List<VatStatementImport>> vatStatements) throws LimaException, TopiaException {
+ protected String createVatStatements(Map<String, List<VatStatementImport>> vatStatements) {
StringBuilder result = new StringBuilder();
@@ -1221,8 +1222,8 @@
result.append(t("lima-business.import.fiscalperiodadded",
fiscalPeriod.getBeginDate(),
fiscalPeriod.getEndDate()));
- } catch (LimaException eee) {
- result.append(t("lima-business.common.failed", eee.getMessage()));
+ } catch (FiscalPeriodException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
}
return result.toString();
@@ -1235,31 +1236,34 @@
*/
@Deprecated
protected String updateClosedPeriodicEntryBooks(
- List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) throws LimaException, ParseException, TopiaException {
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks) {
StringBuilder result = new StringBuilder();
for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) {
// update closedPeriodicEntryBook
- Date beginDateFinancialPeriod = SDATEFORMAT
- .parse(closedPeriodicEntryBookImport
- .getBeginDateFinancialPeriod());
- Date endDateFinancialPeriod = SDATEFORMAT
- .parse(closedPeriodicEntryBookImport
- .getEndDateFinancialPeriod());
- FinancialPeriod financialPeriod = financialPeriodService.getFinancialPeriodByNaturalIds(beginDateFinancialPeriod, endDateFinancialPeriod);
+ try {
+ Date beginDateFinancialPeriod = SDATEFORMAT
+ .parse(closedPeriodicEntryBookImport
+ .getBeginDateFinancialPeriod());
+ Date endDateFinancialPeriod = SDATEFORMAT
+ .parse(closedPeriodicEntryBookImport
+ .getEndDateFinancialPeriod());
+ FinancialPeriod financialPeriod = financialPeriodService.getFinancialPeriodByNaturalIds(beginDateFinancialPeriod, endDateFinancialPeriod);
- String codeEntryBook = closedPeriodicEntryBookImport
- .getCodeEntryBook();
- EntryBook entryBook = entryBookService.getEntryBookByCode(codeEntryBook);
- ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookService.getByEntryBookAndFinancialPeriod(entryBook,
- financialPeriod);
- try {
+ String codeEntryBook = closedPeriodicEntryBookImport
+ .getCodeEntryBook();
+ EntryBook entryBook = entryBookService.getEntryBookByCode(codeEntryBook);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookService.getByEntryBookAndFinancialPeriod(entryBook,
+ financialPeriod);
+
financialPeriodService
.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
result.append(t("lima-business.import.closedperiodicentrybookupdated",
beginDateFinancialPeriod, endDateFinancialPeriod, codeEntryBook));
- } catch (LimaException eee) {
- result.append(t("lima-business.common.failed", eee));
+ } catch (ParseException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
+ } catch (ClosedPeriodicEntryBookException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
}
@@ -1267,52 +1271,60 @@
}
/**
- * @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)
- throws LimaException, ParseException, TopiaException {
+ Map<Integer, List<EntryImport>> entries) {
+ StringBuilder result = new StringBuilder();
+
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);
+ try {
+ FinancialTransactionImport financialTransactionImport = map
+ .getValue();
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ Date dateFinancialTransaction = null;
- EntryBook entryBook = entryBookService.getEntryBookByCode(financialTransactionImport
- .getCodeEntryBook());
- financialTransaction.setEntryBook(entryBook);
+ dateFinancialTransaction = SDATEFORMAT
+ .parse(financialTransactionImport.getDate());
+ financialTransaction
+ .setTransactionDate(dateFinancialTransaction);
- financialTransactionService.createFinancialTransaction(financialTransaction);
+ EntryBook entryBook = entryBookService.getEntryBookByCode(financialTransactionImport
+ .getCodeEntryBook());
+ financialTransaction.setEntryBook(entryBook);
- List<EntryImport> entryImports = entries.get(map.getKey());
- for (EntryImport entryImport : entryImports) {
- Entry entry = new EntryImpl();
- Account account = accountService.getAccountByNumber(entryImport.getAccount());
- entry.setAccount(account);
- entry.setDescription(StringUtils.trimToNull(entryImport.getDescription()));
- entry.setAmount(new BigDecimal(entryImport.getAmount()));
- entry.setDebit(Boolean.parseBoolean(entryImport.getDebit()));
- entry.setLettering(StringUtils.trimToNull(entryImport.getLettering()));
- entry.setDetail(StringUtils.trimToNull(entryImport.getDetail()));
- entry.setVoucher(StringUtils.trimToNull(entryImport.getVoucher()));
- entry.setPosition(StringUtils.trimToNull(entryImport.getPosition()));
- entryService.createEntry(entry);
- financialTransaction.addEntry(entry);
+ financialTransactionService.createFinancialTransaction(financialTransaction);
+
+ List<EntryImport> entryImports = entries.get(map.getKey());
+ for (EntryImport entryImport : entryImports) {
+ Entry entry = new EntryImpl();
+ Account account = accountService.getAccountByNumber(entryImport.getAccount());
+ entry.setAccount(account);
+ entry.setDescription(StringUtils.trimToNull(entryImport.getDescription()));
+ entry.setAmount(new BigDecimal(entryImport.getAmount()));
+ entry.setDebit(Boolean.parseBoolean(entryImport.getDebit()));
+ entry.setLettering(StringUtils.trimToNull(entryImport.getLettering()));
+ entry.setDetail(StringUtils.trimToNull(entryImport.getDetail()));
+ entry.setVoucher(StringUtils.trimToNull(entryImport.getVoucher()));
+ entry.setPosition(StringUtils.trimToNull(entryImport.getPosition()));
+ entryService.createEntry(entry);
+ financialTransaction.addEntry(entry);
+ }
+ } catch (ParseException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
+ } catch (FinancialTransactionException e) {
+ result.append(t("lima-business.common.failed", e.getMessage()));
}
+
}
- return "";
+ return result.toString();
}
- protected String importIdentity(String[] nextLine) throws LimaException {
+ protected String importIdentity(String[] nextLine) {
StringBuilder result = new StringBuilder();
Identity identity = new IdentityImpl();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,9 +26,10 @@
package org.chorem.lima.business.ejb;
import com.google.common.collect.Lists;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialTransactionService;
@@ -49,9 +50,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.nuiton.csv.Export;
-import org.apache.commons.codec.binary.Base64;
-
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@@ -59,13 +58,13 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import static org.nuiton.i18n.I18n.t;
-
/**
* CSV import export service.
*
@@ -91,7 +90,7 @@
private FinancialTransactionService financialTransactionService;
@Override
- public String exportAllAsCSV(String charset) throws LimaException {
+ public String exportAllAsCSV(String charset) {
ByteArrayOutputStream rstBao = new ByteArrayOutputStream();
ZipOutputStream export = null;
try {
@@ -119,7 +118,7 @@
export.flush();
} catch (Exception e) {
- throw new LimaException("Can't export All",e);
+ throw new LimaTechnicalException(e);
} finally {
IOUtils.closeQuietly(export);
}
@@ -140,14 +139,18 @@
}
@Override
- public String exportAccountsStream(String charset) throws LimaException {
+ public String exportAccountsStream(String charset) {
String result;
try {
File file = exportAccountsFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export accounts", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -166,14 +169,18 @@
@Override
- public String exportEntryBooksStream(String charset) throws LimaException {
+ public String exportEntryBooksStream(String charset) {
String result;
try {
File file = exportEntryBooksFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export entry books", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -192,14 +199,18 @@
}
@Override
- public String exportFiscalPeriodsStream(String charset) throws LimaException {
+ public String exportFiscalPeriodsStream(String charset) {
String result;
try {
File file = exportFiscalPeriodFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export financial transactions", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -220,14 +231,18 @@
}
@Override
- public String exportFinancialTransactionsAsStream(String charset) throws LimaException {
+ public String exportFinancialTransactionsAsStream(String charset) {
String result;
try {
File file = exportFinancialTransactionsFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export financial transactions", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
@@ -244,14 +259,18 @@
}
@Override
- public String exportEntriesAsCSV(String charset) throws LimaException {
+ public String exportEntriesAsCSV(String charset) {
String result;
try {
File file = exportEntriesFile(charset);
FileInputStream inputStream = new FileInputStream(file);
result = IOUtils.toString(inputStream);
- } catch (Exception ex) {
- throw new LimaException("Can't export financial transactions", ex);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
+ } catch (Exception e) {
+ throw new LimaTechnicalException(e);
}
return result;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -6,7 +6,7 @@
import com.google.common.collect.Maps;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.LimaTechnicalException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialTransactionService;
@@ -35,7 +35,9 @@
import javax.ejb.TransactionAttribute;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;
@@ -60,7 +62,7 @@
private FinancialTransactionService financialTransactionService;
@Override
- public void importAccountAsCSV(String contents) throws LimaException {
+ public void importAccountAsCSV(String contents) {
InputStream contentStream = IOUtils.toInputStream(contents);
try {
@@ -84,7 +86,7 @@
}
@Override
- public void importEntryBooksAsCSV(String contents) throws LimaException {
+ public void importEntryBooksAsCSV(String contents) {
InputStream contentStream = IOUtils.toInputStream(contents);
try {
ImportModel<EntryBook> model = new EntryBookModel();
@@ -98,7 +100,7 @@
}
@Override
- public void importFiscalPeriodsAsCSV(String contents) throws LimaException {
+ public void importFiscalPeriodsAsCSV(String contents) {
InputStream contentStream = IOUtils.toInputStream(contents);
try {
ImportModel<FiscalPeriod> model = new FiscalPeriodModel();
@@ -112,7 +114,7 @@
}
@Override
- public void importFinancialTransactionsAsCSV(String contents) throws LimaException {
+ public void importFinancialTransactionsAsCSV(String contents) {
// import and save FinancialTransactions
InputStream contentStream = IOUtils.toInputStream(contents);
try {
@@ -134,7 +136,7 @@
};
@Override
- public void importEntriesAsCSV(String contents) throws LimaException {
+ public void importEntriesAsCSV(String contents) {
// import and save entries
InputStream contentStream = IOUtils.toInputStream(contents);
try {
@@ -165,7 +167,7 @@
}
@Override
- public void importAllAsCSV(String zippedBase64Str) throws LimaException {
+ public void importAllAsCSV(String zippedBase64Str) {
ZipInputStream zipInputStream = null;
InputStream transactionsStream = null, entryBooksStream = null, fiscalPeriodsStream = null, entriesStream = null, accountsStream = null;
@@ -225,8 +227,10 @@
String accountsStreamString = IOUtils.toString(accountsStream);
importAccountAsCSV(accountsStreamString);
- } catch (Exception e) {
- throw new LimaException("Could not import", e);
+ } catch (FileNotFoundException e) {
+ throw new LimaTechnicalException(e);
+ } catch (IOException e) {
+ throw new LimaTechnicalException(e);
} finally {
IOUtils.closeQuietly(zipInputStream);
IOUtils.closeQuietly(transactionsStream);
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -80,49 +80,44 @@
*/
@Override
public ReportsDatas generateAccountsReports(Account account, Boolean thirdPartAccountsMode,
- Date beginDate, Date endDate) throws LimaException {
- ReportsDatas reportsDatas;
+ Date beginDate, Date endDate) {
- try {
- BigDecimal credit = new BigDecimal(0);
- BigDecimal debit = new BigDecimal(0);
- BigDecimal solde = new BigDecimal(0);
- List<Entry> entries = new ArrayList<Entry>();
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
+ List<Entry> entries = new ArrayList<Entry>();
- reportsDatas = generateSubAccountReports(account,
+ ReportsDatas reportsDatas = generateSubAccountReports(account,
+ beginDate, endDate);
+ debit = debit.add(reportsDatas.getAmountDebit());
+ credit = credit.add(reportsDatas.getAmountCredit());
+ entries.addAll(reportsDatas.getListEntry());
+
+ //Get allsubaccounts and thirdParts accounts
+ List<Account> accounts = accountService.getAllSubAccounts(account);
+
+ for (Account subAccount : accounts) {
+ reportsDatas = generateSubAccountReports(subAccount,
beginDate, endDate);
debit = debit.add(reportsDatas.getAmountDebit());
credit = credit.add(reportsDatas.getAmountCredit());
entries.addAll(reportsDatas.getListEntry());
+ }
- //Get allsubaccounts and thirdParts accounts
- List<Account> accounts = accountService.getAllSubAccounts(account);
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
- for (Account subAccount : accounts) {
- reportsDatas = generateSubAccountReports(subAccount,
- beginDate, endDate);
- debit = debit.add(reportsDatas.getAmountDebit());
- credit = credit.add(reportsDatas.getAmountCredit());
- entries.addAll(reportsDatas.getListEntry());
- }
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
- //solde = debit - credit
- solde = solde.add(debit);
- solde = solde.subtract(credit);
+ reportsDatas.setListEntry(entries);
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
- }
- 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;
}
@@ -134,11 +129,9 @@
* @param beginDate
* @param endDate
* @return
- * @throws LimaException
- * @throws TopiaException
*/
protected ReportsDatas generateSubAccountReports(Account account,
- Date beginDate, Date endDate) throws TopiaException {
+ Date beginDate, Date endDate) {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
@@ -189,7 +182,7 @@
* @throws TopiaException
*/
public ReportsDatas generateSubAccountBalance(Account account,
- Date beginDate, Date endDate, Boolean getEntries) throws LimaException, TopiaException {
+ Date beginDate, Date endDate, Boolean getEntries) {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
@@ -243,48 +236,44 @@
*/
@Override
public ReportsDatas generateEntryBooksReports(EntryBook entryBook,
- Date beginDate, Date endDate) throws LimaException {
+ Date beginDate, Date endDate) {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
// Get all entries with a topia query
- try {
- EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
- List<Entry> entries = entryTopiaDao.findAllEntryOfBalancedTransaction(entryBook, beginDate, endDate);
- reportsDatas.setListEntry(entries);
-
- List<Object[]> results = entryTopiaDao.getDebitCreditOfBalancedTransaction(entryBook, beginDate, endDate);
- int nbAmount = results.size();
- if (nbAmount == 2) {
+ EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
+ List<Entry> entries = entryTopiaDao.findAllEntryOfBalancedTransaction(entryBook, beginDate, endDate);
+ reportsDatas.setListEntry(entries);
+
+ List<Object[]> results = entryTopiaDao.getDebitCreditOfBalancedTransaction(entryBook, beginDate, endDate);
+ int nbAmount = results.size();
+ if (nbAmount == 2) {
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal) results.get(1)[1];
+ }
+ if (nbAmount == 1) {
+ if ((Boolean) results.get(0)[0]) {
debit = (BigDecimal) results.get(0)[1];
- credit = (BigDecimal) results.get(1)[1];
+ } else {
+ credit = (BigDecimal) results.get(0)[1];
}
- if (nbAmount == 1) {
- if ((Boolean) results.get(0)[0]) {
- debit = (BigDecimal) results.get(0)[1];
- } else {
- credit = (BigDecimal) results.get(0)[1];
- }
- }
+ }
- // set the amounts and solde
- //solde = debit - credit;
- solde = solde.add(debit);
- solde = solde.subtract(credit);
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- reportsDatas.setSoldeDebit(true);
- }
- solde = solde.abs();
-
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
- } catch (TopiaException ex) {
- throw new LimaException("Can't generate report", ex);
+ // set the amounts and solde
+ //solde = debit - credit;
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ reportsDatas.setSoldeDebit(true);
}
+ solde = solde.abs();
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
return reportsDatas;
}
@@ -304,74 +293,69 @@
Date endDate,
String selectedAccounts,
Boolean getEntries,
- Boolean movementedFilter) throws LimaException {
+ Boolean movementedFilter) {
BalanceTrial balanceTrial = new BalanceTrialImpl();
balanceTrial.setReportsDatas(new ArrayList<ReportsDatas>());
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
- try {
+ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
+ //for each account create a balance sheet with a ReportsDatas
- AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao();
- //for each account create a balance sheet with a ReportsDatas
+ List<Account> accounts;
- List<Account> accounts;
+ //Remove Spaces
+ // TODO DCossé 12/06/14 selectedAccounts is allways NULL
+ String result = StringUtils.deleteWhitespace(selectedAccounts);
+ //if no filter account
+ if (result == null || result.equals("")) {
+ accounts = accountTopiaDao.findAll();
+ }
+ //build list account from selectedAccounts
+ else {
+ accounts = accountService.stringToListAccounts(result);
+ }
- //Remove Spaces
- // TODO DCossé 12/06/14 selectedAccounts is allways NULL
- String result = StringUtils.deleteWhitespace(selectedAccounts);
- //if no filter account
- if (result == null || result.equals("")) {
- accounts = accountTopiaDao.findAll();
- }
- //build list account from selectedAccounts
- else {
- accounts = accountService.stringToListAccounts(result);
- }
+ Collections.sort(accounts, new AccountComparator());
- Collections.sort(accounts, new AccountComparator());
-
- for (Account account : accounts) {
- ReportsDatas reportsDatas =
- generateSubAccountBalance(account, beginDate,
- endDate, getEntries);
- reportsDatas.setAccount(account);
- BigDecimal amount = reportsDatas.getAmountSolde();
- if (amount == null) {
- amount = new BigDecimal(0);
- }
- if (movementedFilter) {
- if (!reportsDatas.getAmountCredit().equals(BigDecimal.ZERO)
- || !reportsDatas.getAmountDebit().equals(BigDecimal.ZERO)) {
- // add balance sheet to balance trial
- balanceTrial.addReportsDatas(reportsDatas);
- }
- } else {
+ for (Account account : accounts) {
+ ReportsDatas reportsDatas =
+ generateSubAccountBalance(account, beginDate,
+ endDate, getEntries);
+ reportsDatas.setAccount(account);
+ BigDecimal amount = reportsDatas.getAmountSolde();
+ if (amount == null) {
+ amount = new BigDecimal(0);
+ }
+ if (movementedFilter) {
+ if (!reportsDatas.getAmountCredit().equals(BigDecimal.ZERO)
+ || !reportsDatas.getAmountDebit().equals(BigDecimal.ZERO)) {
// add balance sheet to balance trial
balanceTrial.addReportsDatas(reportsDatas);
}
+ } else {
+ // add balance sheet to balance trial
+ balanceTrial.addReportsDatas(reportsDatas);
+ }
- if (reportsDatas.getSoldeDebit()) {
- debit = debit.add(amount);
- } else {
- credit = credit.add(amount);
- }
+ if (reportsDatas.getSoldeDebit()) {
+ debit = debit.add(amount);
+ } else {
+ credit = credit.add(amount);
}
- // set the amounts and solde
- //solde = debit - credit;
- solde = solde.add(debit);
- solde = solde.subtract(credit);
- if (solde.compareTo(BigDecimal.ZERO) == 1) {
- balanceTrial.setSoldeDebit(true);
- }
- solde = solde.abs();
- balanceTrial.setAmountCredit(credit);
- balanceTrial.setAmountDebit(debit);
- balanceTrial.setAmountSolde(solde);
- } catch (Exception ex) {
- throw new LimaException("Can't generate report", ex);
}
+ // set the amounts and solde
+ //solde = debit - credit;
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+ if (solde.compareTo(BigDecimal.ZERO) == 1) {
+ balanceTrial.setSoldeDebit(true);
+ }
+ solde = solde.abs();
+ balanceTrial.setAmountCredit(credit);
+ balanceTrial.setAmountDebit(debit);
+ balanceTrial.setAmountSolde(solde);
return balanceTrial;
}
@@ -387,7 +371,7 @@
public BalanceTrial generateLedger(Date beginDate,
Date endDate,
String selectedAccounts,
- Boolean movementedFilter) throws LimaException {
+ Boolean movementedFilter) {
return generateBalanceTrial(beginDate, endDate, selectedAccounts, true, movementedFilter);
}
@@ -398,30 +382,26 @@
* @throws LimaException, TopiaException
*/
@Override
- public List<Object> generateVat(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<Object> generateVat(FiscalPeriod fiscalPeriod) {
List<Object> list = new ArrayList<Object>();
- try {
- //lists all accounts
- AccountTopiaDao accountTopiaDao = 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 = accountTopiaDao.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
+ AccountTopiaDao accountTopiaDao = 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 = accountTopiaDao.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 (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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,16 +24,6 @@
*/
package org.chorem.lima.business.ejb;
-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;
@@ -46,8 +36,16 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementTopiaDao;
-import org.nuiton.topia.persistence.TopiaException;
+import javax.ejb.EJB;
+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;
+
/**
* Permet d'implémenter le plan de la déclaration de TVA
*
@@ -66,47 +64,38 @@
@Override
public void createVatStatement(VatStatement masterVatStatement,
- VatStatement vatStatement) throws LimaException {
+ VatStatement vatStatement) {
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatementTopiaDao.create(vatStatement);
+ vatStatementTopiaDao.create(vatStatement);
- VatStatement mastervatStatementUpdate = null;
- if (masterVatStatement != null) {
- mastervatStatementUpdate = vatStatementTopiaDao.forLabelEquals(masterVatStatement.getLabel()).findUniqueOrNull();
- }
+ VatStatement mastervatStatementUpdate = null;
+ if (masterVatStatement != null) {
+ mastervatStatementUpdate = vatStatementTopiaDao.forLabelEquals(masterVatStatement.getLabel()).findUniqueOrNull();
+ }
- // check if parent account exist;
- if (mastervatStatementUpdate != null) {
- mastervatStatementUpdate.addSubVatStatements(vatStatement);
- vatStatementTopiaDao.update(mastervatStatementUpdate);
- }
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't create vat statement", ex);
+ // check if parent account exist;
+ if (mastervatStatementUpdate != null) {
+ mastervatStatementUpdate.addSubVatStatements(vatStatement);
+ vatStatementTopiaDao.update(mastervatStatementUpdate);
}
}
@Override
- public List<VatStatement> getAllVatStatements() throws LimaException {
+ public List<VatStatement> getAllVatStatements() {
- List<VatStatement> vatStatements;
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatements = vatStatementTopiaDao.findAll();
- } catch (Exception ex) {
- throw new LimaException("Can't get vat statements", ex);
- }
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ List<VatStatement> vatStatements = vatStatementTopiaDao.findAll();
+
return vatStatements;
}
@Override
public List<VatStatement> getAllChildrenVatStatement(
- VatStatement vatStatement, List<VatStatement> result) throws LimaException {
+ VatStatement vatStatement, List<VatStatement> result) {
List<VatStatement> childVatStatements =
getChildrenVatStatement(vatStatement);
@@ -119,132 +108,67 @@
}
@Override
- public List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement) throws LimaException {
+ public List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement) {
- List<VatStatement> vatStatements;
- try {
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ List<VatStatement> vatStatements = vatStatementTopiaDao.getChildrenVatStatement(masterVatStatement);
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatements = vatStatementTopiaDao.getChildrenVatStatement(masterVatStatement);
- } catch (TopiaException ex) {
- throw new LimaException("Can't get vat statements", ex);
- }
return vatStatements;
}
@Override
- public void updateVatStatement(VatStatement vatStatement) throws LimaException {
+ public void updateVatStatement(VatStatement vatStatement) {
- try {
- // TopiaDao
- VatStatementTopiaDao vatStatementHeaderTopiaDao = getDaoHelper().getVatStatementDao();
- //update
- vatStatementHeaderTopiaDao.update(vatStatement);
- } catch (TopiaException ex) {
- throw new LimaException("Can't update vat statement", ex);
- }
+ // TopiaDao
+ VatStatementTopiaDao vatStatementHeaderTopiaDao = getDaoHelper().getVatStatementDao();
+ //update
+ vatStatementHeaderTopiaDao.update(vatStatement);
+
}
- /* TODO echatellier 20120510 unused function
- public Amounts amountFromAccountList(String accountsNumberList,
- Date selectedBeginDate,
- Date selectedEndDate,
- TopiaContext topiaContext) throws LimaException {
- Amounts amounts = new AmountsImpl();
- BigDecimal debit = new BigDecimal(0);
- BigDecimal credit = new BigDecimal(0);
- Boolean substract = false;
- try {
- AccountTopiaDao accountTopiaDao = LimaCallaoTopiaDaoHelper.getAccountTopiaDao(topiaContext);
- //Remove Spaces
- String result = StringUtils.deleteWhitespace(accountsNumberList);
- StringTokenizer stQuote = new StringTokenizer(result, ",");
- while (stQuote.hasMoreTokens()) {
- String s = stQuote.nextToken();
- List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false);
- BigDecimal debitTemp = new BigDecimal(0);
- BigDecimal creditTemp = new BigDecimal(0);
- for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(account, true,
- selectedBeginDate, selectedEndDate, topiaContext);
- if (reportsDatas.getSoldeDebit()) {
- debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
- } else {
- creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
- }
- }
- if (!substract) {
- debit = debitTemp;
- credit = creditTemp;
- }
- //compte(s) précédé du signe -
- else {
- debit = debit.subtract(debitTemp);
- credit = credit.subtract(creditTemp);
- }
- substract = true;
- }
- amounts.setCredit(credit);
- amounts.setDebit(debit);
- } catch (TopiaException e) {
- doCatch(topiaContext, e);
- }
- return amounts;
- }*/
-
/**
* Gives the list of account numbers from a VatStatement.
*
* @param vatStatement
* @return accountNumbersList
- * @throws LimaException
*/
- protected String findAccountNumberByVatStatement(VatStatement vatStatement) throws LimaException {
+ protected String findAccountNumberByVatStatement(VatStatement vatStatement) {
String accountNumbersList = null;
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- VatStatement vatStatement2 = vatStatementTopiaDao.findVatStatementByLabel(vatStatement.getLabel());
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatement vatStatement2 = vatStatementTopiaDao.findVatStatementByLabel(vatStatement.getLabel());
- if (vatStatement2 != null) {
- accountNumbersList = vatStatement2.getAccounts();
- }
- } catch (TopiaException ex) {
- throw new LimaException("Can't find accountNumber by vatStatement", ex);
+ if (vatStatement2 != null) {
+ accountNumbersList = vatStatement2.getAccounts();
}
+
return accountNumbersList;
}
@Override
public VatStatementAmounts vatStatementAmounts(VatStatement vatStatement,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException {
+ Date selectedEndDate) {
VatStatementAmounts vatStatementAmounts = new VatStatementAmountsImpl();
BigDecimal debitTemp = new BigDecimal(0);
BigDecimal creditTemp = new BigDecimal(0);
- try {
+ String accountNumbersList = findAccountNumberByVatStatement(vatStatement);
- String accountNumbersList = findAccountNumberByVatStatement(vatStatement);
+ List<Account> accountsList = accountService.stringToListAccounts(accountNumbersList);
- List<Account> accountsList = accountService.stringToListAccounts(accountNumbersList);
-
- for (Account account : accountsList) {
- ReportsDatas reportsDatas = reportService.
- generateAccountsReports(account, true,
- selectedBeginDate, selectedEndDate);
- if (reportsDatas.getSoldeDebit()) {
- debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
- } else {
- creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
- }
+ for (Account account : accountsList) {
+ ReportsDatas reportsDatas = reportService.
+ generateAccountsReports(account, true,
+ selectedBeginDate, selectedEndDate);
+ if (reportsDatas.getSoldeDebit()) {
+ debitTemp = debitTemp.add(reportsDatas.getAmountSolde());
+ } else {
+ creditTemp = creditTemp.add(reportsDatas.getAmountSolde());
}
- } catch (TopiaException ex) {
- throw new LimaException("Error in vatStatementAmounts", ex);
}
//return debitTemp.subtract(creditTemp).abs();
vatStatementAmounts.setAmount(debitTemp.subtract(creditTemp).abs());
@@ -253,23 +177,16 @@
}
@Override
- public VatStatement findVatStatementByLabel(String label) throws LimaException {
+ public VatStatement findVatStatementByLabel(String label) {
- VatStatement vatStatement;
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatement vatStatement = vatStatementTopiaDao.findVatStatementByLabel(label);
- try {
-
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- vatStatement = vatStatementTopiaDao.findVatStatementByLabel(label);
-
- } 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 {
+ public List<VatStatementAmounts> vatStatementReport(Date beginDate, Date endDate) {
//create list form tree
VatStatementDatas vatStatementDatas = vatStatementReport(null, beginDate, endDate,
@@ -287,7 +204,7 @@
public VatStatementDatas vatStatementReport(VatStatement vatStatement,
Date selectedBeginDate,
Date selectedEndDate,
- VatStatementDatas result) throws LimaException {
+ VatStatementDatas result) {
List<VatStatement> vatStatements =
getChildrenVatStatement(vatStatement);
@@ -348,51 +265,43 @@
}
@Override
- public void removeVatStatement(VatStatement vatStatement) throws LimaException {
+ public void removeVatStatement(VatStatement vatStatement) {
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- // remove vatstatement
- VatStatement vatStatementToDelete =
- vatStatementTopiaDao.findByTopiaId(
- vatStatement.getTopiaId());
- vatStatementTopiaDao.delete(vatStatementToDelete);
+ // remove vatstatement
+ VatStatement vatStatementToDelete =
+ vatStatementTopiaDao.findByTopiaId(
+ vatStatement.getTopiaId());
+ vatStatementTopiaDao.delete(vatStatementToDelete);
- //get all subVatStatement
- List<VatStatement> vatStatements =
- getAllChildrenVatStatement(vatStatement,
- new ArrayList<VatStatement>());
+ //get all subVatStatement
+ List<VatStatement> vatStatements =
+ getAllChildrenVatStatement(vatStatement,
+ new ArrayList<VatStatement>());
- //if VatStatement have subVatStatement
- if (vatStatements.size() > 0) {
- for (VatStatement subVatStatement : vatStatements) {
- VatStatement subVatStatementToDelete =
- vatStatementTopiaDao.findByTopiaId(
- subVatStatement.getTopiaId());
- vatStatementTopiaDao.delete(subVatStatementToDelete);
- }
+ //if VatStatement have subVatStatement
+ if (vatStatements.size() > 0) {
+ for (VatStatement subVatStatement : vatStatements) {
+ VatStatement subVatStatementToDelete =
+ vatStatementTopiaDao.findByTopiaId(
+ subVatStatement.getTopiaId());
+ vatStatementTopiaDao.delete(subVatStatementToDelete);
}
-
- } catch (TopiaException ex) {
- throw new LimaException("Can't remove vatstatement", ex);
}
- }
+}
@Override
- public boolean checkVatStatementExist(String label) throws LimaException {
- boolean result;
- try {
- VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
- result = vatStatementTopiaDao.forProperties(VatStatement.PROPERTY_LABEL, label).exists();
- } catch (TopiaException e) {
- throw new LimaException("Can't check VAT statement", e);
- }
+ public boolean checkVatStatementExist(String label) {
+
+ VatStatementTopiaDao vatStatementTopiaDao = getDaoHelper().getVatStatementDao();
+ boolean result = vatStatementTopiaDao.forProperties(VatStatement.PROPERTY_LABEL, label).exists();
+
return result;
}
@Override
- public void removeAllVatStatement() throws LimaException {
+ public void removeAllVatStatement() {
for (VatStatement vatStatement : getChildrenVatStatement(null)) {
removeVatStatement(vatStatement);
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,22 +24,18 @@
package org.chorem.lima.business.accountingrules;
import org.apache.commons.lang3.time.DateUtils;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
import org.junit.Ignore;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n.t;
-
/**
* Cette classe existe car les tests tourne 2 fois:
* - default
@@ -63,58 +59,54 @@
* Copier/coller de la methode france.
* Le probleme ici est que le default n'en creer aucune.
*/
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
- try {
- FiscalPeriodTopiaDao fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDao();
+ FiscalPeriodTopiaDao fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDao();
- //Checks if is not the first fiscalperiod to create
- if (fiscalPeriodDAO.count() != 0) {
+ //Checks if is not the first fiscalperiod to create
+ if (fiscalPeriodDAO.count() != 0) {
- FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.getLastFiscalPeriod();
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.getLastFiscalPeriod();
- //check the new fiscal period adjoining the last
- Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
- dateLastFiscalPeriod = DateUtils.addDays(dateLastFiscalPeriod, 1);
- dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
- Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
- if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.newfiscalperiodadjoiningerror"));
- }
+ //check the new fiscal period adjoining the last
+ Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
+ dateLastFiscalPeriod = DateUtils.addDays(dateLastFiscalPeriod, 1);
+ dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
+ Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
+ if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.newfiscalperiodadjoiningerror");
+ }
- //We can create a new fiscal period meantime the last fiscal period was not locked
- //But not the ante periodfiscal
- int unblockedFiscalPeriod = fiscalPeriodDAO.forLockedEquals(false).findAll().size();
- if (unblockedFiscalPeriod > 1) {
- throw new LimaBusinessException(t("lima-business.franceaccountingrules.antefiscalperiodnotblocked"));
- }
+ //We can create a new fiscal period meantime the last fiscal period was not locked
+ //But not the ante periodfiscal
+ int unblockedFiscalPeriod = fiscalPeriodDAO.forLockedEquals(false).findAll().size();
+ if (unblockedFiscalPeriod > 1) {
+ throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.antefiscalperiodnotblocked");
}
+ }
- // FinancialPeriods of 1 month are created
- Date endDate = fiscalPeriod.getEndDate();
- Date loopDate = fiscalPeriod.getBeginDate();
- while (loopDate.before(endDate)) {
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
- financialPeriod.setLocked(fiscalPeriod.isLocked());
- financialPeriod.setBeginDate(loopDate);
- loopDate = DateUtils.addMonths(loopDate, 1);
- loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
- loopDate = DateUtils.addMilliseconds(loopDate, -1);
- if (loopDate.after(endDate)) {
- financialPeriod.setEndDate(endDate);
- } else {
- financialPeriod.setEndDate(loopDate);
- }
- //create it
- financialPeriods.add(financialPeriod);
- //financialPeriodService.createFinancialPeriodWithTransaction(financialPeriod, transaction);
- //loop incremente
- loopDate = DateUtils.addMilliseconds(loopDate, 1);
+ // FinancialPeriods of 1 month are created
+ Date endDate = fiscalPeriod.getEndDate();
+ Date loopDate = fiscalPeriod.getBeginDate();
+ while (loopDate.before(endDate)) {
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
+ financialPeriod.setLocked(fiscalPeriod.isLocked());
+ financialPeriod.setBeginDate(loopDate);
+ loopDate = DateUtils.addMonths(loopDate, 1);
+ loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
+ loopDate = DateUtils.addMilliseconds(loopDate, -1);
+ if (loopDate.after(endDate)) {
+ financialPeriod.setEndDate(endDate);
+ } else {
+ financialPeriod.setEndDate(loopDate);
}
- } catch (TopiaException ex) {
- throw new LimaException("Can't check rule", ex);
+ //create it
+ financialPeriods.add(financialPeriod);
+ //financialPeriodService.createFinancialPeriodWithTransaction(financialPeriod, transaction);
+ //loop incremente
+ loopDate = DateUtils.addMilliseconds(loopDate, 1);
}
return financialPeriods;
}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,23 @@
+package org.chorem.lima;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LimaTechnicalException extends RuntimeException {
+
+ public LimaTechnicalException() {
+ }
+
+ public LimaTechnicalException(String message) {
+ super(message);
+ }
+
+ public LimaTechnicalException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public LimaTechnicalException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,23 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class AccountException extends LimaException {
+
+ protected String accountNumber;
+
+ public AccountException(String accountNumber, String message) {
+ super(message);
+ this.accountNumber = accountNumber;
+ }
+
+ public AccountException(String accountNumber, String message, Throwable cause) {
+ super(message, cause);
+ this.accountNumber = accountNumber;
+ }
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class AlreadyExistAccountException extends AccountException {
+ public AlreadyExistAccountException(String accountNumber, String message) {
+ super(accountNumber, message);
+ }
+
+ public AlreadyExistAccountException(String accountNumber, String message, Throwable cause) {
+ super(accountNumber, message, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,34 @@
+package org.chorem.lima.business.utils;
+
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class ClosedPeriodicEntryBookException extends LimaException {
+
+ protected ClosedPeriodicEntryBook closedPeriodicEntryBook;
+
+ public ClosedPeriodicEntryBookException(String message) {
+ super(message);
+ }
+
+ public ClosedPeriodicEntryBookException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ClosedPeriodicEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, String message) {
+ super(message);
+ this.closedPeriodicEntryBook = closedPeriodicEntryBook;
+ }
+
+ public ClosedPeriodicEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, String message, Throwable cause) {
+ super(message, cause);
+ this.closedPeriodicEntryBook = closedPeriodicEntryBook;
+ }
+
+ public ClosedPeriodicEntryBook getClosedPeriodicEntryBook() {
+ return closedPeriodicEntryBook;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,33 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.EntryBook;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntryBookException extends LimaException {
+
+ protected EntryBook entryBook;
+
+ public EntryBookException(String message) {
+ super(message);
+ }
+
+ public EntryBookException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EntryBookException(EntryBook entryBook, String message) {
+ super(message);
+ this.entryBook = entryBook;
+ }
+
+ public EntryBookException(EntryBook entryBook, String message, Throwable cause) {
+ super(message, cause);
+ this.entryBook = entryBook;
+ }
+
+ public EntryBook getEntryBook() {
+ return entryBook;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,33 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.Entry;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntryException extends LimaException {
+
+ protected Entry entry;
+
+ public EntryException(String message) {
+ super(message);
+ }
+
+ public EntryException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EntryException(Entry entry, String message) {
+ super(message);
+ this.entry = entry;
+ }
+
+ public EntryException(Entry entry, String message, Throwable cause) {
+ super(message, cause);
+ this.entry = entry;
+ }
+
+ public Entry getEntry() {
+ return entry;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,34 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FinancialTransaction;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialTransactionException extends LimaException {
+
+ protected FinancialTransaction financialTransaction;
+
+ public FinancialTransactionException(String message) {
+ super(message);
+ }
+
+ public FinancialTransactionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public FinancialTransactionException(FinancialTransaction financialTransaction, String message) {
+ super(message);
+ this.financialTransaction = financialTransaction;
+ }
+
+ public FinancialTransactionException(FinancialTransaction financialTransaction, String message, Throwable cause) {
+ super(message, cause);
+ this.financialTransaction = financialTransaction;
+ }
+
+ public FinancialTransaction getFinancialTransaction() {
+ return financialTransaction;
+ }
+
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,33 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FiscalPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FiscalPeriodException extends LimaException {
+
+ protected FiscalPeriod fiscalPeriod;
+
+ public FiscalPeriodException(String message) {
+ super(message);
+ }
+
+ public FiscalPeriodException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public FiscalPeriodException(FiscalPeriod fiscalPeriod, String message) {
+ super(message);
+ this.fiscalPeriod = fiscalPeriod;
+ }
+
+ public FiscalPeriodException(FiscalPeriod fiscalPeriod, String message, Throwable cause) {
+ super(message, cause);
+ this.fiscalPeriod = fiscalPeriod;
+ }
+
+ public FiscalPeriod getFiscalPeriod() {
+ return fiscalPeriod;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class ImportEbpException extends LimaException {
+ public ImportEbpException(String message) {
+ super(message);
+ }
+
+ public ImportEbpException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class InvalidAccountNumberException extends AccountException {
+ public InvalidAccountNumberException(String accountNumber, String message) {
+ super(accountNumber, message);
+ }
+
+ public InvalidAccountNumberException(String accountNumber, String message, Throwable cause) {
+ super(accountNumber, message, cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -37,7 +37,7 @@
* By : $Author$
*/
@ApplicationException
-public class LimaException extends RuntimeException {
+public class LimaException extends Exception {
/**
* serialVersionUID.
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class UsedAccountException extends AccountException {
+ public UsedAccountException(String accountNumber, String message) {
+ super(accountNumber, message);
+ }
+
+ public UsedAccountException(String accountNumber, String message, Throwable cause) {
+ super(accountNumber, message, cause);
+ }
+}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,9 +25,11 @@
package org.chorem.lima.business.api;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.entity.Account;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.List;
@@ -48,7 +50,7 @@
* @return account count
* @throws LimaException technical exception
*/
- long getAccountCount() throws LimaException;
+ long getAccountCount();
/**
* Obtain the master account for the given account number.
@@ -61,9 +63,9 @@
* @return the master account number
* @throws LimaException if any pb while loading account
*/
- Account getMasterAccount(String accountNumber) throws LimaException;
+ Account getMasterAccount(String accountNumber);
- Account getAccountByNumber(String number) throws LimaException;
+ Account getAccountByNumber(String number);
/**
* Return all account ordered by account name.
@@ -71,9 +73,9 @@
* @return all account
* @throws LimaException
*/
- List<Account> getAllAccounts() throws LimaException;
+ List<Account> getAllAccounts();
- List<Account> getAllLeafAccounts() throws LimaException;
+ List<Account> getAllLeafAccounts();
/**
* Return all {@code account}-s subaccounts.
@@ -82,7 +84,7 @@
* @return sub accounts
* @throws LimaException
*/
- List<Account> getAllSubAccounts(Account account) throws LimaException;
+ List<Account> getAllSubAccounts(Account account);
/**
* Create new account. If {@code masterAccount} is not null, {@code account}
@@ -91,11 +93,11 @@
* @param account account
* @throws LimaException
*/
- Account createAccount(Account account) throws LimaException;
+ Account createAccount(Account account) throws AccountException;
- Account updateAccount(Account account) throws LimaException;
+ Account updateAccount(Account account) throws InvalidAccountNumberException;
- void removeAccount(Account account) throws LimaException;
+ void removeAccount(Account account) throws UsedAccountException;
- List<Account> stringToListAccounts(String selectedAccounts) throws TopiaException;
+ List<Account> stringToListAccounts(String selectedAccounts);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/DocumentService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,9 +25,6 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.utils.FormatsEnum;
-
import java.util.Date;
/**
@@ -38,17 +35,17 @@
public interface DocumentService {
- String createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createFinancialStatementsDocuments(Date beginDate, Date endDate);
- String createLedgerDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createLedgerDocuments(Date beginDate, Date endDate);
- String createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createBalanceDocuments(Date beginDate, Date endDate);
- String createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createEntryBooksDocuments(Date beginDate, Date endDate);
- String createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ String createGeneralEntryBooksDocuments(Date beginDate, Date endDate);
- void createVatDocuments(Date beginDate, Date endDate, String autocomplete) throws LimaException;
+ void createVatDocuments(Date beginDate, Date endDate, String autocomplete);
- String createAccountDocument(Date beginDate, Date endDate, String account) throws LimaException;
+ String createAccountDocument(Date beginDate, Date endDate, String account);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,6 +25,7 @@
package org.chorem.lima.business.api;
+import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
@@ -48,7 +49,7 @@
* @return
* @throws LimaException
*/
- EntryBook getEntryBookByCode(String code) throws LimaException;
+ EntryBook getEntryBookByCode(String code);
/**
* Get all entry book.
@@ -56,7 +57,7 @@
* @return all entrybook
* @throws LimaException
*/
- List<EntryBook> getAllEntryBooks() throws LimaException;
+ List<EntryBook> getAllEntryBooks();
/**
* Create new entry book.
@@ -64,7 +65,7 @@
* @param entryBook
* @throws LimaException
*/
- EntryBook createEntryBook(EntryBook entryBook) throws LimaException;
+ EntryBook createEntryBook(EntryBook entryBook);
/**
* Permet de modifier un journal.
@@ -72,7 +73,7 @@
* @param entryBook journal
* @throws LimaException
*/
- EntryBook updateEntryBook(EntryBook entryBook) throws LimaException;
+ EntryBook updateEntryBook(EntryBook entryBook);
/**
* Permet d'effacer un EntryBook dans la base de données.
@@ -81,7 +82,7 @@
* impossible de supprimer celui-ci.
*
* @param entryBook
- * @throws LimaException
+ * @throws EntryBookException
*/
- void removeEntryBook(EntryBook entryBook) throws LimaException;
+ void removeEntryBook(EntryBook entryBook) throws EntryBookException;
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -47,42 +47,42 @@
* @return export as byte array
* @throws LimaException
*/
- String exportAsCSV() throws LimaException;
+ String exportAsCSV();
/**
* export entrybook chart as CSV.
*/
- String exportEntryBookChartAsCSV() throws LimaException;
+ String exportEntryBookChartAsCSV();
/**
* export financialstatement chart as CSV.
*/
- String exportFinancialStatementChartAsCSV() throws LimaException;
+ String exportFinancialStatementChartAsCSV();
/**
* export vatstatement chart as CSV
*/
- String exportVatStatementChartAsCSV() throws LimaException;
+ String exportVatStatementChartAsCSV();
/**
* export accounts chart as CSV.
*/
- String exportAccountsChartAsCSV() throws LimaException;
+ String exportAccountsChartAsCSV();
/**
* export entries as EBP
*/
- String exportEntriesAsEBP() throws LimaException;
+ String exportEntriesAsEBP();
/**
* export accounts as EBP
*/
- String exportAccountsAsEBP() throws LimaException;
+ String exportAccountsAsEBP();
/**
* export entryBooks as EBP
* @return
* @throws LimaException
*/
- String exportEntryBooksAsEBP() throws LimaException;
+ String exportEntryBooksAsEBP();
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,15 +25,14 @@
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.business.utils.ClosedPeriodicEntryBookException;
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.
*
@@ -46,19 +45,19 @@
public interface FinancialPeriodService {
- List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException;
+ List<FinancialPeriod> getUnblockedFinancialPeriods();
ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
- FinancialPeriod financialPeriod) throws LimaException;
+ FinancialPeriod financialPeriod);
- List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException;
+ List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException;
+ ClosedPeriodicEntryBook blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws ClosedPeriodicEntryBookException;
- List<FinancialPeriod> getAllFinancialPeriods() throws LimaException;
+ List<FinancialPeriod> getAllFinancialPeriods();
List<FinancialPeriod> getFinancialPeriods(Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
- FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate) throws LimaException;
+ FinancialPeriod getFinancialPeriodByNaturalIds(Date beginDate, Date endDate);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialStatementService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -36,25 +36,25 @@
void createFinancialStatement(FinancialStatement masterFinancialStatement,
- FinancialStatement financialStatement) throws LimaException;
+ FinancialStatement financialStatement);
- void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException;
+ void updateFinancialStatement(FinancialStatement financialStatement);
- void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException;
+ void removeFinancialStatement(FinancialStatement financialStatement);
- void removeAllFinancialStatement() throws LimaException;
+ void removeAllFinancialStatement();
- List<FinancialStatement> getAllFinancialStatements() throws LimaException;
+ List<FinancialStatement> getAllFinancialStatements();
- List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement financialStatement) throws LimaException;
+ List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement financialStatement);
List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement,
- List<FinancialStatement> financialStatements) throws LimaException;
+ List<FinancialStatement> financialStatements);
List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate,
- Date selectedEndDate) throws LimaException;
+ Date selectedEndDate);
- String checkFinancialStatementChart() throws LimaException;
+ String checkFinancialStatementChart();
/**
* Check if Financial Statement exist according the label given as parameter.
@@ -62,7 +62,7 @@
* @return true if a statement with same label exist otherwise false.
* @throws LimaException
*/
- boolean checkFinancialStatementExist(String label) throws LimaException;
+ boolean checkFinancialStatementExist(String label);
- FinancialStatement getFinancialStatementByLabel(String label) throws LimaException;
+ FinancialStatement getFinancialStatementByLabel(String label);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,6 +27,8 @@
import org.chorem.lima.beans.FinancialTransactionCondition;
import org.chorem.lima.beans.LetteringFilter;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
@@ -50,44 +52,44 @@
public interface FinancialTransactionService {
- FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
- void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ void updateFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
- void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ void removeFinancialTransaction(FinancialTransaction financialtransaction) throws FinancialTransactionException;
- FinancialTransaction getFinancialTransactionWithId(String id) throws LimaException;
+ FinancialTransaction getFinancialTransactionWithId(String id);
- List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period);
- List<FinancialTransaction> getAllFinancialTransactions(Date beginDate, Date endDate) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(Date beginDate, Date endDate);
- List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period, EntryBook entryBook) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period, EntryBook entryBook);
- List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod);
- List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod);
- List<FinancialTransaction> getAllFinancialTransactions(FiscalPeriod period) throws LimaException;
+ List<FinancialTransaction> getAllFinancialTransactions(FiscalPeriod period);
- List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionFilter) throws LimaException;
+ List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionCondition financialTransactionFilter);
- Entry createEntry(Entry entry) throws LimaException;
+ Entry createEntry(Entry entry) throws FinancialTransactionException;
- void updateEntry(Entry entry) throws LimaException;
+ void updateEntry(Entry entry) throws EntryException;
- void removeEntry(Entry entry) throws LimaException;
+ void removeEntry(Entry entry) throws FinancialTransactionException;
/** Find the last letter used
* and increment them
* @return a string representing the last letter
* */
- String getNextLetters() throws LimaException;
+ String getNextLetters();
/** Find all the letters used
* @return a list of string containing all the letters
* */
- List<String> getAllLetters() throws LimaException;
+ List<String> getAllLetters();
/**
* From to selected entries, create one with same account and
@@ -97,7 +99,7 @@
* @param SecondEntrySelected second entry selected
* @return table of the two new entries
* */
- Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException;
+ Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws FinancialTransactionException;
/**
* Retourne toutes les entrées d'une transaction
@@ -105,11 +107,11 @@
* @param filter filtre sur les entrees, selon le compte, les dates de debut et de fin, et le lettrage
* @throws LimaException
* */
- List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) throws LimaException;
+ List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter);
/**
* Retourne la dernière entrée d'une transaction
* @param financialTransaction transaction sur laquelle la derniere entree est selectionnee
* */
- Entry getLastEntry(FinancialTransaction financialTransaction) throws LimaException;
+ Entry getLastEntry(FinancialTransaction financialTransaction);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,7 +25,9 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.FinancialTransactionException;
+import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FiscalPeriod;
@@ -42,19 +44,19 @@
*/
public interface FiscalPeriodService {
- List<FiscalPeriod> getAllFiscalPeriods() throws LimaException;
+ List<FiscalPeriod> getAllFiscalPeriods();
- List<FiscalPeriod> getAllBlockedFiscalPeriods() throws LimaException;
+ List<FiscalPeriod> getAllBlockedFiscalPeriods();
- List<FiscalPeriod> getAllUnblockedFiscalPeriods() throws LimaException;
+ List<FiscalPeriod> getAllUnblockedFiscalPeriods();
- FiscalPeriod getLastFiscalPeriod() throws LimaException;
+ FiscalPeriod getLastFiscalPeriod();
- FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
- void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
/**
* Eventually add retained earnings on last unclosed fiscal period,
@@ -65,14 +67,14 @@
* @return fiscal period blocked
* */
FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
- boolean retainedEarnings) throws LimaException;
+ boolean retainedEarnings) throws AccountException, FinancialTransactionException, FiscalPeriodException;
/**
* Test if we have retained earnings on a fiscal period
* @param fiscalPeriod
* @return true if retained earnings are possible
* */
- boolean isRetainedEarnings(FiscalPeriod fiscalPeriod) throws LimaException;
+ boolean isRetainedEarnings(FiscalPeriod fiscalPeriod);
- FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod) throws LimaException;
+ FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/IdentityService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,13 +25,12 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Identity;
public interface IdentityService {
- Identity getIdentity() throws LimaException;
+ Identity getIdentity();
- void updateIdentity(Identity identity) throws LimaException;
+ void updateIdentity(Identity identity);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,6 +25,7 @@
package org.chorem.lima.business.api;
+import org.chorem.lima.business.ImportEbpException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.ImportExportEntityEnum;
@@ -41,7 +42,7 @@
* @return result log
* @throws LimaException
*/
- String importAccountsChartFromEbp(String data) throws LimaException;
+ String importAccountsChartFromEbp(String data) throws ImportEbpException;
/**
* Import entry books as EBP import.
@@ -50,7 +51,7 @@
* @return
* @throws LimaException
*/
- String importEntryBookFromEbp(String datas) throws LimaException;
+ String importEntryBookFromEbp(String datas) throws ImportEbpException;
/**
* Import entries as EBP import.
@@ -59,7 +60,7 @@
* @return result log
* @throws LimaException
*/
- String importEntriesFromEbp(String data) throws LimaException;
+ String importEntriesFromEbp(String data) throws ImportEbpException;
/**
* Import data as lima CSV import.
@@ -70,7 +71,7 @@
* @return result log
* @throws LimaException
*/
- String importAllAsCSV(String data) throws LimaException;
+ String importAllAsCSV(String data) throws ImportEbpException;
/**
* Import content as CSV depending on import type.
@@ -81,7 +82,7 @@
* @throws LimaException
*/
String importAsCSV(String data,
- ImportExportEntityEnum importExportEntityEnum) throws LimaException;
+ ImportExportEntityEnum importExportEntityEnum) throws ImportEbpException;
/**
* @deprecated import file (local, can't be used in remote mode)
@@ -89,7 +90,7 @@
*/
String importAsPDF(String data,
ImportExportEntityEnum importExportEntityEnum,
- boolean saveMode) throws LimaException;
+ boolean saveMode);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewExportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,10 +25,6 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
-
-import java.io.File;
-
/**
* Import export service.
* <p/>
@@ -42,15 +38,15 @@
*/
public interface NewExportService {
- String exportAllAsCSV(String charset) throws LimaException;
+ String exportAllAsCSV(String charset);
- String exportAccountsStream(String charset) throws LimaException;
+ String exportAccountsStream(String charset);
- String exportEntryBooksStream(String charset) throws LimaException;
+ String exportEntryBooksStream(String charset);
- String exportFiscalPeriodsStream(String charset) throws LimaException;
+ String exportFiscalPeriodsStream(String charset);
- String exportFinancialTransactionsAsStream(String charset) throws LimaException;
+ String exportFinancialTransactionsAsStream(String charset);
- String exportEntriesAsCSV(String charset) throws LimaException;
+ String exportEntriesAsCSV(String charset);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -1,21 +1,19 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.LimaException;
-
/**
* Created by davidcosse on 03/06/14.
*/
public interface NewImportService {
- void importAccountAsCSV(String contents) throws LimaException;
+ void importAccountAsCSV(String contents);
- void importEntryBooksAsCSV(String contents) throws LimaException;
+ void importEntryBooksAsCSV(String contents);
- void importFiscalPeriodsAsCSV(String contents) throws LimaException;
+ void importFiscalPeriodsAsCSV(String contents);
- void importFinancialTransactionsAsCSV(String contents) throws LimaException;
+ void importFinancialTransactionsAsCSV(String contents);
- void importEntriesAsCSV(String contents) throws LimaException;
+ void importEntriesAsCSV(String contents);
- void importAllAsCSV(String zippedBase64Str) throws LimaException;
+ void importAllAsCSV(String zippedBase64Str);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ReportService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -69,7 +69,7 @@
Date endDate,
String selectedAccounts,
Boolean getEntries,
- Boolean movementedFilter) throws LimaException;
+ Boolean movementedFilter);
/**
* Generation du grand-livre.
@@ -84,7 +84,7 @@
BalanceTrial generateLedger(Date beginDate,
Date endDate,
String selectedAccounts,
- Boolean movementedFilter) throws LimaException;
+ Boolean movementedFilter);
/**
@@ -100,7 +100,7 @@
ReportsDatas generateAccountsReports(Account account,
Boolean thirdPartAccountsMode,
Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
/**
* Generation du rapports des journaux.
@@ -113,7 +113,7 @@
*/
ReportsDatas generateEntryBooksReports(EntryBook entryBook,
Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
/**
* Generate VAT.
@@ -122,6 +122,6 @@
* @return
* @throws LimaException
*/
- List<Object> generateVat(FiscalPeriod fiscalPeriod) throws LimaException;
+ List<Object> generateVat(FiscalPeriod fiscalPeriod);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/VatStatementService.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -34,29 +34,29 @@
public interface VatStatementService {
void createVatStatement(VatStatement masterVatStatement,
- VatStatement vatStatement) throws LimaException;
+ VatStatement vatStatement);
- List<VatStatement> getAllVatStatements() throws LimaException;
+ List<VatStatement> getAllVatStatements();
List<VatStatement> getAllChildrenVatStatement(VatStatement vatStatement,
- List<VatStatement> result) throws LimaException;
+ List<VatStatement> result);
- List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement) throws LimaException;
+ List<VatStatement> getChildrenVatStatement(VatStatement masterVatStatement);
- void updateVatStatement(VatStatement vatStatement) throws LimaException;
+ void updateVatStatement(VatStatement vatStatement);
VatStatementAmounts vatStatementAmounts(VatStatement vatStatement,
Date selectedBeginDate,
- Date selectedEndDate) throws LimaException;
+ Date selectedEndDate);
- VatStatement findVatStatementByLabel(String label) throws LimaException;
+ VatStatement findVatStatementByLabel(String label);
List<VatStatementAmounts> vatStatementReport(Date beginDate,
- Date endDate) throws LimaException;
+ Date endDate);
- void removeAllVatStatement() throws LimaException;
+ void removeAllVatStatement();
- void removeVatStatement(VatStatement vatStatement) throws LimaException;
+ void removeVatStatement(VatStatement vatStatement);
/**
* Check if VAT Statement exist according the label given as parameter.
@@ -64,7 +64,7 @@
* @return true if a VAT statement with same label exist otherwise false.
* @throws LimaException
*/
- boolean checkVatStatementExist(String label) throws LimaException;
+ boolean checkVatStatementExist(String label);
}
\ No newline at end of file
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -39,9 +39,8 @@
* Retourne tous les comptes qui n'ont pas eux meme de sous compte.
*
* @return leaf accounts
- * @throws TopiaException
*/
- public List<Account> findAllLeafAccounts() throws TopiaException {
+ public List<Account> findAllLeafAccounts() {
// FIXME echatellier 20120413 la requete ne fonctionne pas
// et retourne vide
/*String query = "FROM " + Account.class.getName() + " a WHERE a NOT IN (" +
@@ -71,7 +70,7 @@
* par son numero, cela revient a avoir un compte par son numero.
*/
@Deprecated
- public Account findLeafAccountByNumber(String number) throws TopiaException {
+ public Account findLeafAccountByNumber(String number) {
return forAccountNumberEquals(number).findUniqueOrNull();
}
@@ -81,10 +80,9 @@
* @param accountNumberLow min account number
* @param accountNumberHigh max account number
* @return account list
- * @throws TopiaException
*/
public List<Account> findIntervalAccountByNumber(String accountNumberLow,
- String accountNumberHigh) throws TopiaException {
+ String accountNumberHigh) {
HqlAndParametersBuilder<Account> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(Account.PROPERTY_ACCOUNT_NUMBER, accountNumberLow);
builder.addLowerOrEquals(Account.PROPERTY_ACCOUNT_NUMBER, accountNumberHigh);
@@ -97,9 +95,8 @@
*
* @param account parent account
* @return
- * @throws TopiaException
*/
- public List<Account> findAllSubAccounts(Account account) throws TopiaException {
+ public List<Account> findAllSubAccounts(Account account) {
HqlAndParametersBuilder<Account> builder = newHqlAndParametersBuilder();
builder.addLike(Account.PROPERTY_ACCOUNT_NUMBER, account.getAccountNumber() + "_%");
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,7 +26,6 @@
package org.chorem.lima.entity;
import org.nuiton.topia.persistence.HqlAndParametersBuilder;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep;
import java.util.Date;
@@ -44,9 +43,8 @@
*
* @param entryBook entry book property
* @return ClosedPeriodicEntryBook list
- * @throws TopiaException
*/
- public List<ClosedPeriodicEntryBook> findAllByEntryBook(EntryBook entryBook) throws TopiaException {
+ public List<ClosedPeriodicEntryBook> findAllByEntryBook(EntryBook entryBook) {
return forProperties(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook).findAll();
}
@@ -56,11 +54,9 @@
* @param entryBook
* @param financialPeriod
* @return ClosedPeriodicEntryBook
- * @throws TopiaException
*/
public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod(
- EntryBook entryBook, FinancialPeriod financialPeriod)
- throws TopiaException {
+ EntryBook entryBook, FinancialPeriod financialPeriod) {
TopiaQueryBuilderAddCriteriaOrRunQueryStep<ClosedPeriodicEntryBook> queryStep = newQueryBuilder();
@@ -72,7 +68,7 @@
queryStep = queryStep.addEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod);
}
- ClosedPeriodicEntryBook closedPeriodicEntryBook = queryStep.findFirstOrNull();
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = queryStep.findAnyOrNull();
return closedPeriodicEntryBook;
}
@@ -84,10 +80,9 @@
* @param beginDate begin date
* @param endDate end date
* @return all ClosedPeriodicEntryBook between begin and end
- * @throws TopiaException
*/
public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate,
- Date endDate) throws TopiaException {
+ Date endDate) {
HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(PROPERTY_BEGIN_DATE, beginDate);
@@ -106,10 +101,9 @@
* @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 {
+ Date beginDate, Date endDate) {
HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(PROPERTY_BEGIN_DATE, beginDate);
@@ -128,10 +122,9 @@
* @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 {
+ Date beginDate, Date endDate) {
HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(PROPERTY_BEGIN_DATE, beginDate);
@@ -147,9 +140,8 @@
* Retourne les ClosedPeriodicEntryBook de toutes les exercices encore ouverts.
*
* @return les ClosedPeriodicEntryBook
- * @throws TopiaException
*/
- public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws TopiaException {
+ public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() {
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
forEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD + "." + FinancialPeriod.PROPERTY_LOCKED, false)
@@ -163,9 +155,8 @@
* Retourne les ClosedPeriodicEntryBook d'un exercice ouvert.
*
* @return les ClosedPeriodicEntryBook
- * @throws TopiaException
*/
- public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromFiscalPeriod(FiscalPeriod fiscalPeriod) throws TopiaException {
+ public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromFiscalPeriod(FiscalPeriod fiscalPeriod) {
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
forEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, fiscalPeriod)
.setOrderByArguments(PROPERTY_BEGIN_DATE)
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,7 +26,6 @@
package org.chorem.lima.entity;
import org.nuiton.topia.persistence.HqlAndParametersBuilder;
-import org.nuiton.topia.persistence.TopiaException;
import java.util.Date;
import java.util.List;
@@ -39,9 +38,8 @@
*
* @param date period middle date
* @return FinancialPeriod for {@code date}
- * @throws TopiaException
*/
- public FinancialPeriod findByDate(Date date) throws TopiaException {
+ public FinancialPeriod findByDate(Date date) {
HqlAndParametersBuilder<FinancialPeriod> builder = newHqlAndParametersBuilder();
builder.addLowerOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, date);
@@ -57,9 +55,8 @@
* @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 {
+ public List<FinancialPeriod> findByDates(Date beginDate, Date endDate) {
HqlAndParametersBuilder<FinancialPeriod> builder = newHqlAndParametersBuilder();
builder.addGreaterOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, beginDate);
@@ -74,9 +71,8 @@
* Retourne toutes les periodes ordonnées par date de debut de periode.
*
* @return all period ordered
- * @throws TopiaException
*/
- public List<FinancialPeriod> findAllOrderByBeginDate() throws TopiaException {
+ public List<FinancialPeriod> findAllOrderByBeginDate() {
List<FinancialPeriod> financialPeriod = newQueryBuilder()
.setOrderByArguments(FinancialPeriod.PROPERTY_BEGIN_DATE)
@@ -89,9 +85,8 @@
* Retourne toutes les periodes ordonnées par date de debut de periode.
*
* @return all period ordered
- * @throws TopiaException
*/
- public List<FinancialPeriod> findAllUnlockedOrderByBeginDate() throws TopiaException {
+ public List<FinancialPeriod> findAllUnlockedOrderByBeginDate() {
List<FinancialPeriod> financialPeriod = forLockedEquals(false)
.setOrderByArguments(FinancialPeriod.PROPERTY_BEGIN_DATE)
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,8 +25,6 @@
package org.chorem.lima.entity;
-import org.nuiton.topia.persistence.TopiaException;
-
/**
* Fiscal period entity DAO.
*
@@ -43,9 +41,8 @@
*
* @param financialPeriod financial period
* @return fiscal period containing financial period
- * @throws TopiaException
*/
- public FiscalPeriod findByFinancialPeriod(FinancialPeriod financialPeriod) throws TopiaException {
+ public FiscalPeriod findByFinancialPeriod(FinancialPeriod financialPeriod) {
FiscalPeriod result = forFinancialPeriodContains(financialPeriod).findUniqueOrNull();
@@ -56,9 +53,8 @@
* Get last fiscal period (higher end date).
*
* @return last fiscal period
- * @throws TopiaException
*/
- public FiscalPeriod getLastFiscalPeriod() throws TopiaException {
+ public FiscalPeriod getLastFiscalPeriod() {
FiscalPeriod result = newQueryBuilder()
.setOrderByArguments(FinancialPeriod.PROPERTY_END_DATE + " DESC")
@@ -71,9 +67,8 @@
* Get first fiscal period (higher end date).
*
* @return last fiscal period
- * @throws TopiaException
*/
- public FiscalPeriod getFirstFiscalPeriod() throws TopiaException {
+ public FiscalPeriod getFirstFiscalPeriod() {
FiscalPeriod result = newQueryBuilder()
.setOrderByArguments(FinancialPeriod.PROPERTY_END_DATE)
.findFirstOrNull();
@@ -85,9 +80,8 @@
* Get last non locked fiscal period (higher end date).
*
* @return last fiscal period
- * @throws TopiaException
*/
- public FiscalPeriod getLastUnlockedFiscalPeriod() throws TopiaException {
+ public FiscalPeriod getLastUnlockedFiscalPeriod() {
FiscalPeriod result = forLockedEquals(false)
.setOrderByArguments(FinancialPeriod.PROPERTY_END_DATE + " DESC")
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/LimaCallaoTopiaPersistenceContext.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -1,11 +1,8 @@
package org.chorem.lima.entity;
-import java.util.List;
-
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.TopiaIdFactory;
import org.nuiton.topia.persistence.internal.HibernateProvider;
import org.nuiton.topia.persistence.internal.TopiaHibernateSessionRegistry;
@@ -15,6 +12,8 @@
import org.nuiton.topia.persistence.support.TopiaSqlSupport;
import org.nuiton.topia.persistence.support.TopiaSqlWork;
+import java.util.List;
+
public class LimaCallaoTopiaPersistenceContext extends AbstractLimaCallaoTopiaPersistenceContext implements TopiaHibernateSupport, TopiaSqlSupport {
public LimaCallaoTopiaPersistenceContext(HibernateProvider hibernateProvider, TopiaListenableSupport listenableSupport, TopiaIdFactory topiaIdFactory, TopiaHibernateSessionRegistry sessionRegistry) {
@@ -47,12 +46,12 @@
}
@Override
- public <O> O findSingleResult(TopiaSqlQuery<O> query) throws TopiaException {
+ public <O> O findSingleResult(TopiaSqlQuery<O> query) {
return getSqlSupport().findSingleResult(query);
}
@Override
- public <O> List<O> findMultipleResult(TopiaSqlQuery<O> query) throws TopiaException {
+ public <O> List<O> findMultipleResult(TopiaSqlQuery<O> query) {
return getSqlSupport().findMultipleResult(query);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/EntryBookCondition/EntryBookConditionHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,14 +29,14 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
import org.chorem.lima.beans.EntryBookCondition;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.Filter.ConditionHandler;
import org.chorem.lima.ui.Filter.financialTransactionCondition.FinancialTransactionConditionHandler;
-import javax.swing.*;
+import javax.swing.JComponent;
+import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import java.util.List;
@@ -75,16 +75,8 @@
public Object[] getEntryBookList() {
EntryBookService entryBookService = LimaServiceFactory.getService(EntryBookService.class);
- Object[] result = {};
- List<EntryBook> periods = null;
- try {
- periods = entryBookService.getAllEntryBooks();
- result = periods.toArray();
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
- }
+ List<EntryBook> periods = entryBookService.getAllEntryBooks();
+ Object[] result = periods.toArray();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/financialPeriodCondition/FinancialPeriodConditionHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,7 +29,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
import org.chorem.lima.beans.FinancialPeriodCondition;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -37,7 +36,8 @@
import org.chorem.lima.ui.Filter.financialTransactionCondition.FinancialTransactionConditionHandler;
import org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchViewHandler;
-import javax.swing.*;
+import javax.swing.JComponent;
+import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import java.util.List;
@@ -78,16 +78,8 @@
public Object[] getFinancialPeriodList() {
FinancialPeriodService financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
- Object[] result = {};
- List<FinancialPeriod> periods = null;
- try {
- periods = financialPeriodService.getAllFinancialPeriods();
- result = periods.toArray();
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
- }
+ List<FinancialPeriod> periods = financialPeriodService.getAllFinancialPeriods();
+ Object[] result = periods.toArray();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/fiscalPeriodCondition/FiscalPeriodConditionHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,14 +29,14 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.Condition;
import org.chorem.lima.beans.FiscalPeriodCondition;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.Filter.ConditionHandler;
import org.chorem.lima.ui.Filter.financialTransactionCondition.FinancialTransactionConditionHandler;
-import javax.swing.*;
+import javax.swing.JComponent;
+import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import java.util.List;
@@ -76,16 +76,8 @@
public Object[] getFiscalPeriodList() {
FiscalPeriodService fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
- Object[] result = {};
- List<FiscalPeriod> periods;
- try {
- periods = fiscalPeriodService.getAllFiscalPeriods();
- result = periods.toArray();
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Fiscal Period list", ex);
- }
- }
+ List<FiscalPeriod> periods = fiscalPeriodService.getAllFiscalPeriods();
+ Object[] result = periods.toArray();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.UsedAccountException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.Account;
@@ -35,6 +39,7 @@
import org.chorem.lima.enums.ImportExportEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTreeTable;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
@@ -78,6 +83,8 @@
protected AccountView view;
+ protected ErrorHelper errorHelper;
+
/**
* Sort account with label length.
*/
@@ -112,6 +119,7 @@
// Gets factory service
LimaServiceFactory.addServiceListener(ImportService.class, this);
accountService = LimaServiceFactory.getService(AccountService.class);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
/**
@@ -263,6 +271,8 @@
model.insertNodeInto(newNode, node, node.getChildCount());
treeTable.expandPath(new TreePath(model.getPathToRoot(node)));
+ } catch (AccountException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
} finally {
dialog.dispose();
}
@@ -367,6 +377,8 @@
//lastPathComponent.setUserObject(account);
model.valueForPathChanged(treePath, account);
+ } catch (InvalidAccountNumberException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
} finally {
// close dialog
dialog.dispose();
@@ -391,18 +403,22 @@
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- accountService.removeAccount(account);
+ try {
+ accountService.removeAccount(account);
- // add all sub accounts to parent
- DefaultTreeTableModel model = (DefaultTreeTableModel)treeTable.getTreeTableModel();
- MutableTreeTableNode parent = (MutableTreeTableNode)lastNode.getParent();
- for (int childIndex = lastNode.getChildCount() -1 ; childIndex >= 0 ; childIndex--) {
- MutableTreeTableNode child = (MutableTreeTableNode)lastNode.getChildAt(childIndex);
- model.insertNodeInto(child, parent, parent.getChildCount());
+ // add all sub accounts to parent
+ DefaultTreeTableModel model = (DefaultTreeTableModel) treeTable.getTreeTableModel();
+ MutableTreeTableNode parent = (MutableTreeTableNode) lastNode.getParent();
+ for (int childIndex = lastNode.getChildCount() - 1; childIndex >= 0; childIndex--) {
+ MutableTreeTableNode child = (MutableTreeTableNode) lastNode.getChildAt(childIndex);
+ model.insertNodeInto(child, parent, parent.getChildCount());
+ }
+
+ // remove node
+ model.removeNodeFromParent(lastNode);
+ } catch (UsedAccountException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
-
- // remove node
- model.removeNodeFromParent(lastNode);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,14 +27,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.*;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
import java.util.List;
/** Account combo box model. */
@@ -84,14 +84,7 @@
}
public List<Account> getDataList() {
- List<Account> result = null;
- try {
- result = accountService.getAllAccounts();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list accounts", eee);
- }
- }
+ List<Account> result = accountService.getAllAccounts();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,20 +25,18 @@
package org.chorem.lima.ui.combobox;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import java.util.List;
+
/**
* Opened financial period combo box model.
*
@@ -92,14 +90,7 @@
/** get the accounts list */
public List<EntryBook> getDataList() {
- List<EntryBook> result = null;
- try {
- result = entryBookService.getAllEntryBooks();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list entry books", eee);
- }
- }
+ List<EntryBook> result = entryBookService.getAllEntryBooks();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FiscalPeriodService;
@@ -36,7 +35,8 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.*;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
import java.util.List;
/**
@@ -129,16 +129,10 @@
//get unblocked financial periods data list
public List<FinancialPeriod> getDataList() {
List<FinancialPeriod> result = null;
- try {
- if (selectedFiscalPeriod != null) {
- result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
- } else {
- result = financialPeriodService.getUnblockedFinancialPeriods();
- }
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
+ if (selectedFiscalPeriod != null) {
+ result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
+ } else {
+ result = financialPeriodService.getUnblockedFinancialPeriods();
}
return result;
}
@@ -146,16 +140,10 @@
//get all financial periods data list
public List<FinancialPeriod> getAllDataList() {
List<FinancialPeriod> result = null;
- try {
- if (selectedFiscalPeriod != null) {
- result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
- } else {
- result = financialPeriodService.getAllFinancialPeriods();
- }
- } catch (LimaException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Financial Period list", ex);
- }
+ if (selectedFiscalPeriod != null) {
+ result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate());
+ } else {
+ result = financialPeriodService.getAllFinancialPeriods();
}
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,22 +25,18 @@
package org.chorem.lima.ui.combobox;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.entity.FiscalPeriodImpl;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import java.util.List;
+
public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
private static final long serialVersionUID = 1L;
@@ -106,14 +102,8 @@
//get unblocked fiscal periods data list
public List<FiscalPeriod> getDataList() {
- List<FiscalPeriod> result = null;
- try {
- result = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list accounts", eee);
- }
- }
+ List<FiscalPeriod> result = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+
if (log.isDebugEnabled()) {
log.debug("Size of result : " + result.size());
log.debug("Beginning and end dates of first fiscal period : " + result.get(0).getBeginDate() + ", " + result.get(0).getEndDate());
@@ -125,14 +115,7 @@
//get all fiscal periods data list
public List<FiscalPeriod> getAllDataList() {
- List<FiscalPeriod> result = null;
- try {
- result = fiscalPeriodService.getAllFiscalPeriods();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list accounts", eee);
- }
- }
+ List<FiscalPeriod> result = fiscalPeriodService.getAllFiscalPeriods();
if (log.isDebugEnabled()) {
log.debug("Size of result : " + result);
log.debug("Beginning and end dates of first fiscal period : " + result.get(0).getBeginDate() + ", " + result.get(0).getEndDate());
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
@@ -35,8 +34,8 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.*;
-import java.util.ArrayList;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
import java.util.Collections;
import java.util.List;
@@ -85,14 +84,7 @@
}
public List<Account> getDataList() {
- List<Account> result = new ArrayList<Account>();
- try {
- result = accountService.getAllLeafAccounts();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list subaccounts", eee);
- }
- }
+ List<Account> result = accountService.getAllLeafAccounts();
Collections.sort(result, new AccountComparator());
return result;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,12 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
import javax.swing.AbstractListModel;
@@ -86,14 +82,7 @@
}
public List<String> getDataList() {
- List<String> result = null;
- try {
- result = financialTransactionService.getAllLetters();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get list letters", eee);
- }
- }
+ List<String> result = financialTransactionService.getAllLetters();
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,9 @@
* #L%
*/
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.util.ErrorHelper;
+
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
@@ -37,10 +40,13 @@
protected boolean editable;
+ protected ErrorHelper errorHelper;
+
public AbstractColumn(Class<?> columnClass, String columnName, boolean editable) {
this.columnClass = columnClass;
this.columnName = columnName;
this.editable = editable;
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
public Class<?> getColumnClass() {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,6 +26,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Entry;
@@ -120,7 +122,7 @@
*
* @param entry entry to insert
*/
- public Entry addEntry(Entry entry) {
+ public Entry addEntry(Entry entry) throws FinancialTransactionException {
Entry newEntry = null;
FinancialTransaction transaction = entry.getFinancialTransaction();
if (contains(transaction)) {
@@ -147,13 +149,13 @@
*
* @param row
*/
- public void removeTransaction(int row) {
+ public void removeTransaction(int row) throws FinancialTransactionException {
FinancialTransaction transaction = getTransactionAt(row);
removeAll(transaction.getEntry());
financialTransactionService.removeFinancialTransaction(transaction);
}
- public void removeEntry(int row) {
+ public void removeEntry(int row) throws FinancialTransactionException {
Entry entry = get(row);
FinancialTransaction transaction = entry.getFinancialTransaction();
if (transaction.sizeEntry() > 1) {
@@ -166,7 +168,7 @@
}
}
- public FinancialTransaction addTransaction(FinancialTransaction transaction) {
+ public FinancialTransaction addTransaction(FinancialTransaction transaction) throws FinancialTransactionException {
FinancialTransaction newTransaction = new FinancialTransactionImpl();
newTransaction.setEntryBook(transaction.getEntryBook());
newTransaction.setTransactionDate(transaction.getTransactionDate());
@@ -214,14 +216,14 @@
return e1.getFinancialTransaction().equals(e2.getFinancialTransaction());
}
- public void updateEntry(Entry entry) {
+ public void updateEntry(Entry entry) throws EntryException {
if (log.isDebugEnabled()) {
log.debug("Update Entry");
}
financialTransactionService.updateEntry(entry);
}
- public void updateTransaction(FinancialTransaction transaction) {
+ public void updateTransaction(FinancialTransaction transaction) throws FinancialTransactionException {
if (log.isDebugEnabled()) {
log.debug("Update transaction");
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,6 +27,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.EntryBookException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ImportService;
@@ -36,6 +38,7 @@
import org.chorem.lima.enums.ImportExportEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
import javax.swing.*;
@@ -64,10 +67,13 @@
protected EntryBookService entryBookService;
+ protected ErrorHelper errorHelper;
+
public EntryBookViewHandler(EntryBookView view) {
this.view = view;
entryBookService = LimaServiceFactory.getService(EntryBookService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
public void init() {
@@ -228,9 +234,12 @@
JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
-
- entryBookService.removeEntryBook(selectedEntryBook);
- entryBookTableModel.remove(selectedEntryBook);
+ try {
+ entryBookService.removeEntryBook(selectedEntryBook);
+ entryBookTableModel.remove(selectedEntryBook);
+ } catch (EntryBookException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,13 +27,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException;
import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
import javax.swing.*;
@@ -61,12 +64,15 @@
protected FinancialPeriodView view;
+ protected ErrorHelper errorHelper;
+
protected FinancialPeriodViewHandler(FinancialPeriodView view) {
this.view = view;
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
/**
@@ -115,8 +121,12 @@
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- closedPeriodicEntryBook = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
- model.setValue(selectedRow, closedPeriodicEntryBook);
+ try {
+ closedPeriodicEntryBook = financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ model.setValue(selectedRow, closedPeriodicEntryBook);
+ } catch (ClosedPeriodicEntryBookException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,21 +25,19 @@
package org.chorem.lima.ui.financialstatementchart;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.tree.TreePath;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.FinancialStatementService;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementImpl;
import org.chorem.lima.service.LimaServiceFactory;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+import javax.swing.tree.TreePath;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
/**
* Tree table model for account edition.
*
@@ -100,21 +98,13 @@
public int getChildCount(Object node) {
int result = 0;
if (node == getRoot()) {
- try {
- result = financialStatementService.
- getChildrenFinancialStatement(null).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = financialStatementService.
+ getChildrenFinancialStatement(null).size();
} else {
FinancialStatement parentFinancialStatementHeader =
(FinancialStatement) node;
- try {
- result = financialStatementService.getChildrenFinancialStatement(
- parentFinancialStatementHeader).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = financialStatementService.getChildrenFinancialStatement(
+ parentFinancialStatementHeader).size();
}
return result;
}
@@ -123,23 +113,15 @@
public Object getChild(Object parent, int index) {
Object result = null;
if (parent == getRoot()) {
- try {
- List<FinancialStatement> financialStatements =
- financialStatementService.getChildrenFinancialStatement(null);
- result = financialStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ List<FinancialStatement> financialStatements =
+ financialStatementService.getChildrenFinancialStatement(null);
+ result = financialStatements.get(index);
} else {
FinancialStatement parentFinancialStatement =
- (FinancialStatement) parent;
- try {
- List<FinancialStatement> financialStatements = financialStatementService.
- getChildrenFinancialStatement(parentFinancialStatement);
- result = financialStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ (FinancialStatement) parent;
+ List<FinancialStatement> financialStatements = financialStatementService.
+ getChildrenFinancialStatement(parentFinancialStatement);
+ result = financialStatements.get(index);
}
return result;
}
@@ -148,24 +130,16 @@
public int getIndexOfChild(Object parent, Object child) {
int result = 0;
- if (parent == getRoot()) {
- try {
- List<FinancialStatement> financialStatements =
- financialStatementService.getChildrenFinancialStatement(null);
- result = financialStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ if (parent == getRoot()) {
+ List<FinancialStatement> financialStatements =
+ financialStatementService.getChildrenFinancialStatement(null);
+ result = financialStatements.indexOf(child);
} else {
FinancialStatement parentFinancialStatement =
(FinancialStatement) parent;
- try {
- List<FinancialStatement> financialStatements = financialStatementService.
- getChildrenFinancialStatement(parentFinancialStatement);
- result = financialStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ List<FinancialStatement> financialStatements = financialStatementService.
+ getChildrenFinancialStatement(parentFinancialStatement);
+ result = financialStatements.indexOf(child);
}
return result;
}
@@ -206,7 +180,7 @@
/** Refresh FinancialStatementChart. */
- public void refreshTree() throws LimaException {
+ public void refreshTree() {
modelSupport.fireNewRoot();
}
@@ -217,9 +191,8 @@
*
* @param path
* @param financialStatement
- * @throws LimaException
*/
- public void addFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException {
+ public void addFinancialStatement(TreePath path, FinancialStatement financialStatement) {
// Calling account service
FinancialStatement parentFinancialStatementHeader =
(FinancialStatement) path.getLastPathComponent();
@@ -237,9 +210,8 @@
*
* @param path
* @param financialStatement
- * @throws LimaException
*/
- public void updateFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException {
+ public void updateFinancialStatement(TreePath path, FinancialStatement financialStatement) {
financialStatementService.updateFinancialStatement(financialStatement);
modelSupport.fireTreeStructureChanged(path);
@@ -251,9 +223,8 @@
*
* @param path
* @param financialStatement
- * @throws LimaException
*/
- public void removeFinancialStatementObject(TreePath path, FinancialStatement financialStatement) throws LimaException {
+ public void removeFinancialStatementObject(TreePath path, FinancialStatement financialStatement) {
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), financialStatement);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
@@ -55,8 +56,12 @@
&& account != null
&& !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
if (update) {
- entry.setAccount(account);
- tableModel.updateEntry(entry);
+ try {
+ entry.setAccount(account);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -53,10 +54,14 @@
BigDecimal credit= (BigDecimal) value;
boolean update = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
if (update) {
- entry.setAmount(credit);
- entry.setDebit(false);
- tableModel.updateEntry(entry);
- tableModel.fireTransaction(entry.getFinancialTransaction());
+ try {
+ entry.setAmount(credit);
+ entry.setDebit(false);
+ tableModel.updateEntry(entry);
+ tableModel.fireTransaction(entry.getFinancialTransaction());
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.common.AbstractColumn;
@@ -66,8 +67,12 @@
FinancialTransaction transaction = tableModel.get(row).getFinancialTransaction();
boolean update = (transaction.getTransactionDate().compareTo((Date) value) != 0);
if (update) {
- transaction.setTransactionDate((Date) value);
- tableModel.updateTransaction(transaction);
+ try {
+ transaction.setTransactionDate((Date) value);
+ tableModel.updateTransaction(transaction);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -53,10 +54,14 @@
BigDecimal debit = (BigDecimal) value;
boolean update = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
if (update) {
- entry.setAmount(debit);
- entry.setDebit(true);
- tableModel.updateEntry(entry);
- tableModel.fireTransaction(entry.getFinancialTransaction());
+ try {
+ entry.setAmount(debit);
+ entry.setDebit(true);
+ tableModel.updateEntry(entry);
+ tableModel.fireTransaction(entry.getFinancialTransaction());
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -51,8 +52,12 @@
boolean update = (entry.getDescription() == null ||entry.getDescription().compareTo(description) != 0);
if (update) {
- entry.setDescription(description);
- tableModel.updateEntry(entry);
+ try {
+ entry.setDescription(description);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialTransaction;
@@ -66,8 +67,12 @@
EntryBook entryBook = (EntryBook) value;
boolean update = (transaction.getEntryBook().getCode().compareTo(entryBook.getCode()) != 0);
if (update) {
- transaction.setEntryBook(entryBook);
- tableModel.updateTransaction(transaction);
+ try {
+ transaction.setEntryBook(entryBook);
+ tableModel.updateTransaction(transaction);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -49,6 +49,5 @@
return error;
-
}
}
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 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,6 +28,9 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -43,6 +46,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
+import org.chorem.lima.util.ErrorHelper;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@@ -85,7 +89,9 @@
protected FiscalPeriodService fiscalPeriodService;
protected FinancialTransactionService financialTransactionService;
protected Date lastAssignDate;
-
+
+ protected ErrorHelper errorHelper;
+
public FinancialTransactionViewHandler(FinancialTransactionView view) {
this.view = view;
@@ -96,6 +102,7 @@
LimaServiceFactory.addServiceListener(FinancialPeriodService.class, this);
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
LimaServiceFactory.addServiceListener(ImportService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
initShortCuts();
}
@@ -334,25 +341,28 @@
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
+ try {
+ Entry entry = tableModel.get(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
- Entry entry = tableModel.get(rowSelected);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (entry.isDebit()) {
- debit = debit.subtract(entry.getAmount());
- } else {
- credit = credit.subtract(entry.getAmount());
+ BigDecimal balance = credit.subtract(debit);
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ tableModel.updateEntry(entry);
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ view.setBalance(true);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
-
- BigDecimal balance = credit.subtract(debit);
- entry.setAmount(balance.abs());
- entry.setDebit(balance.signum() > 0);
- tableModel.updateEntry(entry);
- int firstRow = tableModel.indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- tableModel.fireTableRowsUpdated(firstRow, lastRow);
- view.setBalance(true);
}
}
@@ -394,23 +404,27 @@
ListSelectionModel selectionModel = table.getSelectionModel();
if (clipBoard != null && clipBoard instanceof FinancialTransaction) {
- FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
- FinancialTransaction transaction = (FinancialTransaction) clipBoard;
+ try {
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ FinancialTransaction transaction = (FinancialTransaction) clipBoard;
- EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem();
+ EntryBook entryBook = (EntryBook) view.getEntryBookComboBox().getSelectedItem();
- transaction.setEntryBook(entryBook);
- transaction.setTransactionDate(getUseDate());
+ transaction.setEntryBook(entryBook);
+ transaction.setTransactionDate(getUseDate());
- tableModel.addTransaction(transaction);
+ tableModel.addTransaction(transaction);
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+ int index = tableModel.indexOf(transaction);
+ selectionModel.setSelectionInterval(index, index);
+ table.editCellAt(index, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- int index = tableModel.indexOf(transaction);
- selectionModel.setSelectionInterval(index, index);
- table.editCellAt(index, 1);
}
}
@@ -426,28 +440,32 @@
ListSelectionModel selectionModel = table.getSelectionModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1 && clipBoard != null && clipBoard instanceof Entry) {
- Entry entryTmp = (Entry) clipBoard;
- FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
- Entry entry = new EntryImpl();
- entry.setFinancialTransaction(transaction);
- entry.setVoucher(entryTmp.getVoucher());
- entry.setAccount(entryTmp.getAccount());
- entry.setDescription(entryTmp.getDescription());
- entry.setAmount(entryTmp.getAmount());
- entry.setDebit(entryTmp.isDebit());
+ try {
+ Entry entryTmp = (Entry) clipBoard;
+ FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
+ Entry entry = new EntryImpl();
+ entry.setFinancialTransaction(transaction);
+ entry.setVoucher(entryTmp.getVoucher());
+ entry.setAccount(entryTmp.getAccount());
+ entry.setDescription(entryTmp.getDescription());
+ entry.setAmount(entryTmp.getAmount());
+ entry.setDebit(entryTmp.isDebit());
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
- }
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
- tableModel.addEntry(entry);
+ tableModel.addEntry(entry);
- int index = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
- selectionModel.setSelectionInterval(index, index);
- //focus on second column
- table.changeSelection(index, 1, false, false);
- table.editCellAt(index, 1);
+ int index = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
+ selectionModel.setSelectionInterval(index, index);
+ //focus on second column
+ table.changeSelection(index, 1, false, false);
+ table.editCellAt(index, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
@@ -455,33 +473,36 @@
* Add new transaction.
*/
public void addFinancialTransaction() {
- FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem();
- FinancialTransactionTable table = view.getFinancialTransactionTable();
- FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
-
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- // can be defined later by user
- if (entryBook != null) {
- financialTransaction.setEntryBook(entryBook);
- }
+ try {
+ EntryBook entryBook = (EntryBook) view.getEntryBookComboBox().getSelectedItem();
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
- // set date to the financial transaction
- financialTransaction.setTransactionDate(getUseDate());
- // create it
- financialTransaction = tableModel.addTransaction(financialTransaction);
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ // can be defined later by user
+ if (entryBook != null) {
+ financialTransaction.setEntryBook(entryBook);
+ }
- int addIndex = tableModel.indexOf(financialTransaction);
+ // set date to the financial transaction
+ financialTransaction.setTransactionDate(getUseDate());
+ // create it
+ financialTransaction = tableModel.addTransaction(financialTransaction);
- //select the new line
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
+ int addIndex = tableModel.indexOf(financialTransaction);
+
+ //select the new line
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(addIndex, addIndex);
+ table.changeSelection(addIndex, 1, false, false);
+ table.editCellAt(addIndex, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(addIndex, addIndex);
- table.changeSelection(addIndex, 1, false, false);
- table.editCellAt(addIndex, 1);
}
/**
@@ -500,74 +521,78 @@
if (cellEditor != null) {
cellEditor.cancelCellEditing();
}
- //First case, where line selected is an entry : take its transaction
- //to select the last entry of the transaction
- Entry entryAt = tableModel.get(indexSelectedRow);
- FinancialTransaction transaction = entryAt.getFinancialTransaction();
- int rowLasEntry = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
- Entry lastEntry = tableModel.get(rowLasEntry);
- if (log.isDebugEnabled()) {
- log.debug("Selected row : " + indexSelectedRow);
- }
+ try {
+ //First case, where line selected is an entry : take its transaction
+ //to select the last entry of the transaction
+ Entry entryAt = tableModel.get(indexSelectedRow);
+ FinancialTransaction transaction = entryAt.getFinancialTransaction();
+ int rowLasEntry = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
+ Entry lastEntry = tableModel.get(rowLasEntry);
- String defaultVoucher = null;
- String defaultDescription = null;
+ if (log.isDebugEnabled()) {
+ log.debug("Selected row : " + indexSelectedRow);
+ }
- if (lastEntry != null) {
- defaultVoucher = lastEntry.getVoucher();
- defaultDescription = lastEntry.getDescription();
- }
+ String defaultVoucher = null;
+ String defaultDescription = null;
- // creates the new entry
- Entry entry = new EntryImpl();
- entry.setVoucher(defaultVoucher);
- if (log.isDebugEnabled()) {
- log.debug("Description of precedent entry : " + defaultDescription);
- }
- entry.setDescription(defaultDescription);
+ if (lastEntry != null) {
+ defaultVoucher = lastEntry.getVoucher();
+ defaultDescription = lastEntry.getDescription();
+ }
- String defaultAccount;
- //Actual (2012) tva percentage : 19,6%
- BigDecimal tvaPercentAdd = new BigDecimal(0.196);
- BigDecimal tvaTax = null;
+ // creates the new entry
+ Entry entry = new EntryImpl();
+ entry.setVoucher(defaultVoucher);
+ if (log.isDebugEnabled()) {
+ log.debug("Description of precedent entry : " + defaultDescription);
+ }
+ entry.setDescription(defaultDescription);
- //Calculation of tva tax only if first entry is a sale
- if (lastEntry != null && lastEntry.getAccount()!= null){
- defaultAccount = lastEntry.getAccount().getAccountNumber();
- if (defaultAccount.equals("410") || defaultAccount.equals("418")){
- tvaTax = (lastEntry.getAmount()).multiply(tvaPercentAdd);
+ String defaultAccount;
+ //Actual (2012) tva percentage : 19,6%
+ BigDecimal tvaPercentAdd = new BigDecimal(0.196);
+ BigDecimal tvaTax = null;
+
+ //Calculation of tva tax only if first entry is a sale
+ if (lastEntry != null && lastEntry.getAccount() != null) {
+ defaultAccount = lastEntry.getAccount().getAccountNumber();
+ if (defaultAccount.equals("410") || defaultAccount.equals("418")) {
+ tvaTax = (lastEntry.getAmount()).multiply(tvaPercentAdd);
+ }
}
- }
- //Set tva tax on the debit of the new entry
- if (tvaTax != null){
- entry.setAmount(tvaTax);
- entry.setDebit(true);
- }
+ //Set tva tax on the debit of the new entry
+ if (tvaTax != null) {
+ entry.setAmount(tvaTax);
+ entry.setDebit(true);
+ }
- if (log.isInfoEnabled()) {
- log.info("tva : " + tvaTax);
- }
+ if (log.isInfoEnabled()) {
+ log.info("tva : " + tvaTax);
+ }
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- entry.setDebit(credit.compareTo(debit) > 0);
- entry.setAmount(credit.subtract(debit).abs());
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ entry.setDebit(credit.compareTo(debit) > 0);
+ entry.setAmount(credit.subtract(debit).abs());
- entry.setFinancialTransaction(transaction);
+ entry.setFinancialTransaction(transaction);
- // create it in service
- tableModel.addEntry(entry);
+ // create it in service
+ tableModel.addEntry(entry);
- //select the new line
- int row = rowLasEntry + 1;
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(
- row, row);
- table.changeSelection(row, 1, false, false);
- table.editCellAt(row, 1);
-
+ //select the new line
+ int row = rowLasEntry + 1;
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ row, row);
+ table.changeSelection(row, 1, false, false);
+ table.editCellAt(row, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
} else {
if (log.isWarnEnabled()) {
log.warn("Call addentry selected transaction without selection");
@@ -591,17 +616,20 @@
t("lima.ui.financialtransaction.titleremovetransaction"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
+ try {
+ tableModel.removeTransaction(indexSelectedRow);
- tableModel.removeTransaction(indexSelectedRow);
-
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
@@ -626,17 +654,20 @@
t("lima.ui.financialtransaction.titleremoveentry"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
+ try {
+ tableModel.removeEntry(indexSelectedRow);
- tableModel.removeEntry(indexSelectedRow);
-
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
}
@@ -652,30 +683,34 @@
int selectedRow = table.getSelectedRow();
int selectedColumn = table.getSelectedColumn();
if (selectedRow >= 0 && (selectedColumn == 1 || selectedColumn == 3)) {
- Entry entrySource = tableModel.get(selectedRow);
- FinancialTransaction transaction = entrySource.getFinancialTransaction();
- for (Entry entryTarget : transaction.getEntry()) {
- if (entrySource != entryTarget) {
- switch (selectedColumn) {
- case 1 :
- if (!StringUtils.equals(entryTarget.getVoucher(), entrySource.getVoucher())) {
- entryTarget.setVoucher(entrySource.getVoucher());
- financialTransactionService.updateEntry(entryTarget);
- }
- break;
- case 3 :
- if (!StringUtils.equals(entryTarget.getDescription(), entrySource.getDescription())) {
- entryTarget.setDescription(entrySource.getDescription());
- financialTransactionService.updateEntry(entryTarget);
- }
- break;
+ try {
+ Entry entrySource = tableModel.get(selectedRow);
+ FinancialTransaction transaction = entrySource.getFinancialTransaction();
+ for (Entry entryTarget : transaction.getEntry()) {
+ if (entrySource != entryTarget) {
+ switch (selectedColumn) {
+ case 1:
+ if (!StringUtils.equals(entryTarget.getVoucher(), entrySource.getVoucher())) {
+ entryTarget.setVoucher(entrySource.getVoucher());
+ financialTransactionService.updateEntry(entryTarget);
+ }
+ break;
+ case 3:
+ if (!StringUtils.equals(entryTarget.getDescription(), entrySource.getDescription())) {
+ entryTarget.setDescription(entrySource.getDescription());
+ financialTransactionService.updateEntry(entryTarget);
+ }
+ break;
+ }
}
}
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ table.editCellAt(selectedRow, selectedColumn);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- int firstRow = tableModel.indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- tableModel.fireTableRowsUpdated(firstRow, lastRow);
- table.editCellAt(selectedRow, selectedColumn);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -52,8 +53,12 @@
boolean update = (entry.getLettering() == null || entry.getLettering().compareTo(letter) != 0);
if (update) {
- entry.setLettering(letter);
- tableModel.updateEntry(entry);
+ try {
+ entry.setLettering(letter);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.chorem.lima.business.EntryException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.common.AbstractColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -52,8 +53,12 @@
boolean update = (entry.getVoucher() == null || entry.getVoucher().compareTo(voucher) != 0);
if (update) {
- entry.setVoucher(voucher);
- tableModel.updateEntry(entry);
+ try {
+ entry.setVoucher(voucher);
+ tableModel.updateEntry(entry);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(e.getMessage());
+ }
}
return update;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,11 +27,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable;
+import org.chorem.lima.util.ErrorHelper;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
@@ -58,8 +62,11 @@
protected FinancialTransactionUnbalancedView view;
+ protected ErrorHelper errorHelper;
+
protected FinancialTransactionUnbalancedViewHandler(FinancialTransactionUnbalancedView view) {
this.view = view;
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
initShortCuts();
}
@@ -141,26 +148,30 @@
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- TableCellEditor cellEditor = table.getCellEditor();
- if (cellEditor != null) {
- cellEditor.cancelCellEditing();
- }
+ try {
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
+ }
- Entry entry = tableModel.get(indexSelectedRow);
- //copy + paste the description
- Entry newEntry = new EntryImpl();
- newEntry.setFinancialTransaction(entry.getFinancialTransaction());
- newEntry.setVoucher(entry.getVoucher());
- newEntry.setDescription(entry.getDescription());
+ Entry entry = tableModel.get(indexSelectedRow);
+ //copy + paste the description
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(entry.getFinancialTransaction());
+ newEntry.setVoucher(entry.getVoucher());
+ newEntry.setDescription(entry.getDescription());
- tableModel.addEntry(newEntry);
- //select the new line
- int row = tableModel.indexOf(newEntry.getFinancialTransaction()) + newEntry.getFinancialTransaction().sizeEntry() - 1;
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(
- row, row);
- table.changeSelection(row, 1, false, false);
- table.editCellAt(row, 1);
+ tableModel.addEntry(newEntry);
+ //select the new line
+ int row = tableModel.indexOf(newEntry.getFinancialTransaction()) + newEntry.getFinancialTransaction().sizeEntry() - 1;
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ row, row);
+ table.changeSelection(row, 1, false, false);
+ table.editCellAt(row, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
} else {
if (log.isWarnEnabled()) {
log.warn("Call addentry selected transaction without selection");
@@ -192,19 +203,22 @@
t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
+ try {
+ tableModel.removeEntry(indexSelectedRow);
- tableModel.removeEntry(indexSelectedRow);
-
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
} else {
@@ -238,18 +252,22 @@
t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
- tableModel.removeTransaction(indexSelectedRow);
- //select the upper line
- if (tableModel.size() > 0) {
- if (indexSelectedRow >= tableModel.size()) {
- indexSelectedRow = tableModel.size() - 1;
+ try {
+ tableModel.removeTransaction(indexSelectedRow);
+ //select the upper line
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
- ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(
- indexSelectedRow, indexSelectedRow);
- table.changeSelection(indexSelectedRow, 1, false, false);
- table.editCellAt(indexSelectedRow, 1);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
} else {
@@ -286,31 +304,34 @@
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
+ try {
+ Entry entry = tableModel.get(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
- Entry entry = tableModel.get(rowSelected);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (entry.isDebit()) {
- debit = debit.subtract(entry.getAmount());
- } else {
- credit = credit.subtract(entry.getAmount());
+ BigDecimal balance = credit.subtract(debit);
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ tableModel.updateEntry(entry);
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ view.setBalance(true);
+
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(rowSelected, rowSelected);
+ table.changeSelection(rowSelected, 1, false, false);
+ table.editCellAt(rowSelected, 1);
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
- BigDecimal balance = credit.subtract(debit);
- entry.setAmount(balance.abs());
- entry.setDebit(balance.signum() > 0);
- tableModel.updateEntry(entry);
- int firstRow = tableModel.indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- tableModel.fireTableRowsUpdated(firstRow, lastRow);
- view.setBalance(true);
-
- ListSelectionModel selectionModel = table.getSelectionModel();
- selectionModel.setSelectionInterval(rowSelected, rowSelected);
- table.changeSelection(rowSelected, 1, false, false);
- table.editCellAt(rowSelected, 1);
-
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -29,7 +29,8 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.FiscalPeriodException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
@@ -39,9 +40,17 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodImpl;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
import org.nuiton.util.DateUtil;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
+import javax.swing.SwingWorker;
import javax.swing.event.ListSelectionEvent;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -71,6 +80,8 @@
protected FinancialTransactionService financialTransactionService;
+ protected ErrorHelper errorHelper;
+
/**
* Constructor.
*
@@ -83,6 +94,7 @@
financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
public void init() {
@@ -154,18 +166,10 @@
// set begin date picker
Date beginDate = null;
Date endDate;
- try {
- FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
- if (result != null){
- beginDate = DateUtils.addDays(result.getEndDate(), 1);
- }
+ FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
+ if (result != null){
+ beginDate = DateUtils.addDays(result.getEndDate(), 1);
}
- catch (LimaException eee){
- if(log.isDebugEnabled()){
- log.debug("Can't get last fiscal period", eee);
- }
-
- }
if (beginDate == null) {
Calendar calendarBegin = Calendar.getInstance();
// set begindate to JAN 1 - 0:00.000 of this years
@@ -186,11 +190,15 @@
addPeriodDialog.setVisible(true);
if (checkFiscalPeriod(addPeriodDialog)) {
- FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
- fiscalPeriod.setBeginDate(addPeriodDialog.getBeginDatePicker().getDate());
- fiscalPeriod.setEndDate(addPeriodDialog.getEndDatePicker().getDate());
- fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
- tableModel.addValue(fiscalPeriod);
+ try {
+ FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
+ fiscalPeriod.setBeginDate(addPeriodDialog.getBeginDatePicker().getDate());
+ fiscalPeriod.setEndDate(addPeriodDialog.getEndDatePicker().getDate());
+ fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
+ tableModel.addValue(fiscalPeriod);
+ } catch (FiscalPeriodException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
@@ -283,11 +291,15 @@
JOptionPane.WARNING_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
+ try {
+ fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
- tableModel.remove(selectedFiscalPeriod);
- view.setBlockEnabled(false);
- view.setDeleteEnabled(false);
+ tableModel.remove(selectedFiscalPeriod);
+ view.setBlockEnabled(false);
+ view.setDeleteEnabled(false);
+ } catch (FiscalPeriodException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
}
@@ -409,13 +421,15 @@
}
} else {
+ try {
+ FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod);
+ tableModel.setValue(selectedRow, fiscalPeriodBlocked);
- FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod);
- tableModel.setValue(selectedRow, fiscalPeriodBlocked);
-
- view.setBlockEnabled(false);
- view.setDeleteEnabled(false);
-
+ view.setBlockEnabled(false);
+ view.setDeleteEnabled(false);
+ } catch (FiscalPeriodException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,7 +28,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
@@ -84,29 +83,22 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
-
- long accountCount = accountService.getAccountCount();
- if (accountCount > 0) {
- setBackground(GREEN_BACKGROUND);
- String accountsString = t("lima.ui.home.chartaccounts.state1_2") + " "
- + accountCount + " " + t("lima.ui.home.chartaccounts.state2_2")
- + "<br/><br/><a href='#accountschart'>"
- + t("lima.ui.home.chartaccounts.modify") + "</a>";
- //set Text
- setText(htmlBegin + accountsString + htmlEnd);
- } else {
- setBackground(RED_BACKGROUND);
- String accountsString = t("lima.ui.home.chartaccounts.nothing")
- + "<br/><br/><a href='#accountschart'>"
- + t("lima.ui.home.chartaccounts.create") + "</a>";
- //set Text
- setText(htmlBegin + accountsString + htmlEnd);
- }
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't get datas account editor pane home", ex);
- }
+ long accountCount = accountService.getAccountCount();
+ if (accountCount > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String accountsString = t("lima.ui.home.chartaccounts.state1_2") + " "
+ + accountCount + " " + t("lima.ui.home.chartaccounts.state2_2")
+ + "<br/><br/><a href='#accountschart'>"
+ + t("lima.ui.home.chartaccounts.modify") + "</a>";
+ //set Text
+ setText(htmlBegin + accountsString + htmlEnd);
+ } else {
+ setBackground(RED_BACKGROUND);
+ String accountsString = t("lima.ui.home.chartaccounts.nothing")
+ + "<br/><br/><a href='#accountschart'>"
+ + t("lima.ui.home.chartaccounts.create") + "</a>";
+ //set Text
+ setText(htmlBegin + accountsString + htmlEnd);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,16 +25,9 @@
package org.chorem.lima.ui.home;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.event.HyperlinkEvent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.ImportService;
@@ -42,6 +35,11 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
/**
* Home view pane that display entry books statistics.
*
@@ -87,49 +85,43 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
+ List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
+ int ebSize = entryBooks.size();
+ if (ebSize > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String entryBooksString;
+ if (ebSize == 1) {
+ entryBooksString = t("lima.ui.home.entrybooks.state.single")
+ + "<br/>" + entryBooks.get(0).getLabel()
+ + "<br/><br/><a href='#entrybookschart'>"
+ + t("lima.ui.home.entrybooks.modify") + "</a>";
- List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
- int ebSize = entryBooks.size();
- if (ebSize > 0) {
- setBackground(GREEN_BACKGROUND);
- String entryBooksString;
- if (ebSize == 1) {
- entryBooksString = t("lima.ui.home.entrybooks.state.single")
- + "<br/>" + entryBooks.get(0).getLabel()
- + "<br/><br/><a href='#entrybookschart'>"
- + t("lima.ui.home.entrybooks.modify") + "</a>";
-
- } else {
- entryBooksString = t("lima.ui.home.entrybooks.state1_2.plural")
- + " " + entryBooks.size() + " "
- + t("lima.ui.home.entrybooks.state2_2.plural") + "<ul>";
- for (int i = 0; i < ebSize && i < 3; i++) {
+ } else {
+ entryBooksString = t("lima.ui.home.entrybooks.state1_2.plural")
+ + " " + entryBooks.size() + " "
+ + t("lima.ui.home.entrybooks.state2_2.plural") + "<ul>";
+ for (int i = 0; i < ebSize && i < 3; i++) {
// for (EntryBook entryBook : entryBooks) {
- EntryBook entryBook = entryBooks.get(i);
- entryBooksString += "<li>" + entryBook.getCode() +
- " - " + entryBook.getLabel() + "</li>";
- }
- if (ebSize > 3) {
- entryBooksString += "<li> ... </li>";
- }
- entryBooksString += "</ul></p><p horizontal-align:'center'>"
- + "<a href='#entrybookschart'>"
- + t("lima.ui.home.entrybooks.modify") + "</a>";
+ EntryBook entryBook = entryBooks.get(i);
+ entryBooksString += "<li>" + entryBook.getCode() +
+ " - " + entryBook.getLabel() + "</li>";
}
- //set Text
- setText(htmlBegin + entryBooksString + htmlEnd);
- } else {
- setBackground(RED_BACKGROUND);
- //set Text
- setText(htmlBegin
- + t("lima.ui.home.entrybooks.nothing")
- + "<br/><br/><a href='#entrybookschart'>"
- + t("lima.ui.home.entrybooks.create") + "</a>" + htmlEnd);
+ if (ebSize > 3) {
+ entryBooksString += "<li> ... </li>";
+ }
+ entryBooksString += "</ul></p><p horizontal-align:'center'>"
+ + "<a href='#entrybookschart'>"
+ + t("lima.ui.home.entrybooks.modify") + "</a>";
}
-
- } catch (LimaException eee) {
- log.debug("Can't get datas account editor pane home", eee);
+ //set Text
+ setText(htmlBegin + entryBooksString + htmlEnd);
+ } else {
+ setBackground(RED_BACKGROUND);
+ //set Text
+ setText(htmlBegin
+ + t("lima.ui.home.entrybooks.nothing")
+ + "<br/><br/><a href='#entrybookschart'>"
+ + t("lima.ui.home.entrybooks.create") + "</a>" + htmlEnd);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,16 +25,9 @@
package org.chorem.lima.ui.home;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.event.HyperlinkEvent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialTransactionService;
@@ -46,8 +39,11 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
-import com.google.common.collect.Multiset.Entry;
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+import static org.nuiton.i18n.I18n.t;
+
/**
* Home view pane that display statistics about unbalanced transactions.
*
@@ -104,52 +100,46 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
+ List<FiscalPeriod> unblockedFiscalPeriods =
+ fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
- List<FiscalPeriod> unblockedFiscalPeriods =
- fiscalPeriodService.getAllUnblockedFiscalPeriods();
- List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
-
- //Au moins un exercice ouvert et un journal ouvert
- if (unblockedFiscalPeriods.size() != 0 && entryBooks.size() != 0) {
- List<FinancialTransaction> financialTransactionsInexact =
- financialTransactionService.
- getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0));
- if (financialTransactionsInexact.size() > 0) {
- setBackground(RED_BACKGROUND);
- String transactionsString = financialTransactionsInexact.size()
- + " " + t("lima.ui.home.transaction.inexact")
- + "<br/><br/><a href='#financialtransactionunbalanced'>"
- + t("lima.ui.home.transaction.modifiy.inexact") + "</a>";
- //set Text
+ //Au moins un exercice ouvert et un journal ouvert
+ if (unblockedFiscalPeriods.size() != 0 && entryBooks.size() != 0) {
+ List<FinancialTransaction> financialTransactionsInexact =
+ financialTransactionService.
+ getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0));
+ if (financialTransactionsInexact.size() > 0) {
+ setBackground(RED_BACKGROUND);
+ String transactionsString = financialTransactionsInexact.size()
+ + " " + t("lima.ui.home.transaction.inexact")
+ + "<br/><br/><a href='#financialtransactionunbalanced'>"
+ + t("lima.ui.home.transaction.modifiy.inexact") + "</a>";
+ //set Text
+ setText(htmlBegin + transactionsString + htmlEnd);
+ } else {
+ List<FinancialTransaction> financialTransactionsBal =
+ financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0));
+
+ if (financialTransactionsBal.size() > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String transactionsString = financialTransactionsBal.size()
+ + " " + t("lima.ui.home.transaction.balanced")
+ + "<br/><br/><a href='#financialtransactionbalanced'>"
+ + t("lima.ui.home.transaction.modifiy.balanced") + "</a>";
setText(htmlBegin + transactionsString + htmlEnd);
} else {
- List<FinancialTransaction> financialTransactionsBal =
- financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0));
-
- if (financialTransactionsBal.size() > 0) {
- setBackground(GREEN_BACKGROUND);
- String transactionsString = financialTransactionsBal.size()
- + " " + t("lima.ui.home.transaction.balanced")
- + "<br/><br/><a href='#financialtransactionbalanced'>"
- + t("lima.ui.home.transaction.modifiy.balanced") + "</a>";
- setText(htmlBegin + transactionsString + htmlEnd);
- } else {
- setBackground(RED_BACKGROUND);
- String transactionsString = t("lima.ui.home.transaction.nothing")
- + "<br/><br/><a href='#financialtransactionbalanced'>"
- + t("lima.ui.home.transaction.create") + "</a>";
- setText(htmlBegin + transactionsString + htmlEnd);
- }
-
+ setBackground(RED_BACKGROUND);
+ String transactionsString = t("lima.ui.home.transaction.nothing")
+ + "<br/><br/><a href='#financialtransactionbalanced'>"
+ + t("lima.ui.home.transaction.create") + "</a>";
+ setText(htmlBegin + transactionsString + htmlEnd);
}
- }else {
- setBackground(RED_BACKGROUND);
- setText("");
- }
- } catch (LimaException eee) {
- log.debug("Can't get datas account editor pane home", eee);
+ }
+ }else {
+ setBackground(RED_BACKGROUND);
+ setText("");
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,16 +25,9 @@
package org.chorem.lima.ui.home;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.event.HyperlinkEvent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
@@ -42,6 +35,11 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
/**
* Panenl de la home view de lima qui affiche les statistiques de
* l'exercice en cours.
@@ -93,40 +91,35 @@
+ "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
- try {
+ //FISCAL PERIOD
+ List<FiscalPeriod> fiscalPeriods =
+ fiscalPeriodService.getAllFiscalPeriods();
+ List<FiscalPeriod> unblockedFiscalPeriods =
+ fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ if (unblockedFiscalPeriods.size() > 0) {
+ setBackground(GREEN_BACKGROUND);
+ String fiscalString = unblockedFiscalPeriods.size() + " "
+ + t("lima.ui.home.fiscalperiod.opened") + "<br/>"
+ + (fiscalPeriods.size() - unblockedFiscalPeriods.size())
+ + " " + t("lima.ui.home.fiscalperiod.closed")
+ + "<br/><br/><a href='#fiscalperiodschart'>"
+ + t("lima.ui.home.fiscalperiod.modify") + "</a>";
+ //set Text
+ setText(htmlBegin + fiscalString + htmlEnd);
- //FISCAL PERIOD
- List<FiscalPeriod> fiscalPeriods =
- fiscalPeriodService.getAllFiscalPeriods();
- List<FiscalPeriod> unblockedFiscalPeriods =
- fiscalPeriodService.getAllUnblockedFiscalPeriods();
- if (unblockedFiscalPeriods.size() > 0) {
- setBackground(GREEN_BACKGROUND);
- String fiscalString = unblockedFiscalPeriods.size() + " "
- + t("lima.ui.home.fiscalperiod.opened") + "<br/>"
- + (fiscalPeriods.size() - unblockedFiscalPeriods.size())
- + " " + t("lima.ui.home.fiscalperiod.closed")
- + "<br/><br/><a href='#fiscalperiodschart'>"
- + t("lima.ui.home.fiscalperiod.modify") + "</a>";
- //set Text
- setText(htmlBegin + fiscalString + htmlEnd);
-
- } else {
- setBackground(RED_BACKGROUND);
- String fiscalString = t("lima.ui.home.fiscalperiod.noopen");
- if (fiscalPeriods.size() > 0) {
- fiscalString += "<br/>" + fiscalPeriods.size() + " "
- + t("lima.ui.home.fiscalperiod.closed");
- }
- fiscalString += "<br/><br/><a href='#fiscalperiodschart'>"
- + t("lima.ui.home.fiscalperiod.create") + "</a>";
- //set Text
- setText(htmlBegin + fiscalString + htmlEnd);
-
+ } else {
+ setBackground(RED_BACKGROUND);
+ String fiscalString = t("lima.ui.home.fiscalperiod.noopen");
+ if (fiscalPeriods.size() > 0) {
+ fiscalString += "<br/>" + fiscalPeriods.size() + " "
+ + t("lima.ui.home.fiscalperiod.closed");
}
- } catch (LimaException eee) {
- log.debug("Can't get datas home", eee);
+ fiscalString += "<br/><br/><a href='#fiscalperiodschart'>"
+ + t("lima.ui.home.fiscalperiod.create") + "</a>";
+ //set Text
+ setText(htmlBegin + fiscalString + htmlEnd);
+
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.IdentityService;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.IdentityImpl;
@@ -47,14 +46,7 @@
}
public Identity getIdentity() {
- Identity identity = null;
- try {
- identity = identityService.getIdentity();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't get Identity", eee);
- }
- }
+ Identity identity = identityService.getIdentity();
if (identity == null) {
identity = new IdentityImpl();
}
@@ -62,13 +54,6 @@
}
public void updateIdentity(Identity identity) {
-
- try {
- identityService.updateIdentity(identity);
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't update Identity", eee);
- }
- }
+ identityService.updateIdentity(identity);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -25,8 +25,32 @@
package org.chorem.lima.ui.importexport;
-import static org.nuiton.i18n.I18n.t;
+import com.google.common.base.Charsets;
+import com.google.common.base.Strings;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.LimaTechnicalException;
+import org.chorem.lima.business.ImportEbpException;
+import org.chorem.lima.business.api.ExportService;
+import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.api.NewExportService;
+import org.chorem.lima.business.utils.ImportExportEntityEnum;
+import org.chorem.lima.enums.EncodingEnum;
+import org.chorem.lima.enums.ImportExportEnum;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.painter.BusyPainter;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -36,37 +60,14 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.SwingWorker;
+import static org.nuiton.i18n.I18n.t;
-import com.google.common.base.Charsets;
-import com.google.common.base.Strings;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.api.ExportService;
-import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.api.NewExportService;
-import org.chorem.lima.business.utils.ImportExportEntityEnum;
-import org.chorem.lima.enums.EncodingEnum;
-import org.chorem.lima.enums.ImportExportEnum;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.jdesktop.swingx.painter.BusyPainter;
-
/**
* Import export helper.
* Calling service with specified file to import and displaying wait view to user.
@@ -94,6 +95,8 @@
private ImportExportWaitView waitView;
+ protected ErrorHelper errorHelper;
+
public ImportExport(Component view) {
viewComponent = view;
@@ -101,6 +104,7 @@
importService = LimaServiceFactory.getService(ImportService.class);
exportService = LimaServiceFactory.getService(ExportService.class);
newExportService = LimaServiceFactory.getService(NewExportService.class);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
//create the wait dialog panel
waitView = new ImportExportWaitView();
@@ -134,86 +138,90 @@
protected String doInBackground() {
String datas;
String result = "";
- switch (importExportMethodeF) {
- case CSV_ALL_EXPORT:
- datas = newExportService.exportAllAsCSV(charset.name());
- createZipFile(filePath, datas);
- break;
- case CSV_ACCOUNTCHARTS_EXPORT:
- datas = exportService.exportAccountsChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case CSV_ENTRYBOOKS_EXPORT:
- datas = exportService.exportEntryBookChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case CSV_FINANCIALSTATEMENTS_EXPORT:
- datas = exportService.exportFinancialStatementChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case CSV_VAT_EXPORT:
- datas = exportService.exportVatStatementChartAsCSV();
- createFile(filePath, charset.name(), datas);
- break;
- case EBP_ACCOUNTCHARTS_EXPORT:
- //For windows ebp
- datas = exportService.exportAccountsAsEBP();
- createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
- break;
- case EBP_ENTRIES_EXPORT:
- //For windows ebp
- datas = exportService.exportEntriesAsEBP();
- createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
- break;
- case CSV_ALL_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAllAsCSV(datas);
- break;
- case CSV_ACCOUNTCHARTS_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT);
- break;
- case CSV_ENTRYBOOKS_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK);
- break;
- case CSV_FINANCIALSTATEMENTS_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT);
- break;
- case CSV_VAT_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.VATSTATEMENT);
- break;
- case CSV_ENTRIES_IMPORT:
- datas = extractFile(filePath, charset.name());
- result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRY);
- break;
- case PDF_VAT_IMPORT:
- int response = JOptionPane.showConfirmDialog(waitView,
- t("lima.importexport.usevatpdf"),
- t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
- extractFile(filePath, charset.name());
- result = importService.importAsPDF(filePath, ImportExportEntityEnum.VATPDF, response == JOptionPane.YES_OPTION);
- break;
- case EBP_ACCOUNTCHARTS_IMPORT:
- //For windows ebp
- datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
- result = importService.importAccountsChartFromEbp(datas);
- break;
- case EBP_ENTRIES_IMPORT:
- //For windows ebp
- datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
- result = importService.importEntriesFromEbp(datas);
- break;
- case EBP_ENTRYBOOKS_IMPORT:
- datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
- result = importService.importEntryBookFromEbp(datas);
- break;
- case EBP_ENTRYBOOKS_EXPORT:
- datas = exportService.exportEntryBooksAsEBP();
- createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
- break;
+ try {
+ switch (importExportMethodeF) {
+ case CSV_ALL_EXPORT:
+ datas = newExportService.exportAllAsCSV(charset.name());
+ createZipFile(filePath, datas);
+ break;
+ case CSV_ACCOUNTCHARTS_EXPORT:
+ datas = exportService.exportAccountsChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case CSV_ENTRYBOOKS_EXPORT:
+ datas = exportService.exportEntryBookChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case CSV_FINANCIALSTATEMENTS_EXPORT:
+ datas = exportService.exportFinancialStatementChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case CSV_VAT_EXPORT:
+ datas = exportService.exportVatStatementChartAsCSV();
+ createFile(filePath, charset.name(), datas);
+ break;
+ case EBP_ACCOUNTCHARTS_EXPORT:
+ //For windows ebp
+ datas = exportService.exportAccountsAsEBP();
+ createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
+ break;
+ case EBP_ENTRIES_EXPORT:
+ //For windows ebp
+ datas = exportService.exportEntriesAsEBP();
+ createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
+ break;
+ case CSV_ALL_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAllAsCSV(datas);
+ break;
+ case CSV_ACCOUNTCHARTS_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT);
+ break;
+ case CSV_ENTRYBOOKS_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK);
+ break;
+ case CSV_FINANCIALSTATEMENTS_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT);
+ break;
+ case CSV_VAT_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.VATSTATEMENT);
+ break;
+ case CSV_ENTRIES_IMPORT:
+ datas = extractFile(filePath, charset.name());
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRY);
+ break;
+ case PDF_VAT_IMPORT:
+ int response = JOptionPane.showConfirmDialog(waitView,
+ t("lima.importexport.usevatpdf"),
+ t("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
+ extractFile(filePath, charset.name());
+ result = importService.importAsPDF(filePath, ImportExportEntityEnum.VATPDF, response == JOptionPane.YES_OPTION);
+ break;
+ case EBP_ACCOUNTCHARTS_IMPORT:
+ //For windows ebp
+ datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
+ result = importService.importAccountsChartFromEbp(datas);
+ break;
+ case EBP_ENTRIES_IMPORT:
+ //For windows ebp
+ datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
+ result = importService.importEntriesFromEbp(datas);
+ break;
+ case EBP_ENTRYBOOKS_IMPORT:
+ datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding());
+ result = importService.importEntryBookFromEbp(datas);
+ break;
+ case EBP_ENTRYBOOKS_EXPORT:
+ datas = exportService.exportEntryBooksAsEBP();
+ createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas);
+ break;
+ }
+ } catch (ImportEbpException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
return result;
}
@@ -392,13 +400,13 @@
return result;
}
- protected void createZipFile(String path, String zippedBase64Str) throws LimaException {
+ protected void createZipFile(String path, String zippedBase64Str) {
try {
byte[] bytes = Base64.decodeBase64(zippedBase64Str);
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
IOUtils.copy(inputStream, new FileOutputStream(path));
} catch (IOException e) {
- throw new LimaException("could not zip file", e);
+ throw new LimaTechnicalException(e);
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -28,7 +28,10 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.LetteringFilterImpl;
+import org.chorem.lima.business.EntryException;
+import org.chorem.lima.business.FinancialTransactionException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -39,6 +42,7 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -81,6 +85,8 @@
protected LettringSelectionModel lettringSelectionModel;
protected LetteringEditModel editModel;
+ protected ErrorHelper errorHelper;
+
protected enum ButtonMode {DELETTRED, LETTRED, EQUALIZED, ALL}
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
@@ -92,6 +98,7 @@
accountService = LimaServiceFactory.getService(AccountService.class);
financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
entryBookService = LimaServiceFactory.getService(EntryBookService.class);
+ errorHelper = new ErrorHelper(LimaConfig.getInstance());
}
/**
@@ -398,22 +405,26 @@
int[] selectedRows = view.getTable().getSelectedRows();
if (editModel.isEqualized() && selectedRows.length == 2) {
- /*Treatment only if one of values contains decimals*/
- Entry firstSelectedEntry = tableModel.get(selectedRows[0]);
- Entry secondSelectedEntry = tableModel.get(selectedRows[1]);
+ try {
+ /*Treatment only if one of values contains decimals*/
+ Entry firstSelectedEntry = tableModel.get(selectedRows[0]);
+ Entry secondSelectedEntry = tableModel.get(selectedRows[1]);
- Entry[] newEntriesFormEqualizing = financialTransactionService.getEntriesFromEqualizing(firstSelectedEntry, secondSelectedEntry);
+ Entry[] newEntriesFormEqualizing = financialTransactionService.getEntriesFromEqualizing(firstSelectedEntry, secondSelectedEntry);
- /*Add new entries to the model and the table*/
- Entry newSameAccountEntry = newEntriesFormEqualizing[0];
- Entry newCostOrProductEntry = newEntriesFormEqualizing[1];
- tableModel.addValue(newSameAccountEntry);
- tableModel.addValue(newCostOrProductEntry);
+ /*Add new entries to the model and the table*/
+ Entry newSameAccountEntry = newEntriesFormEqualizing[0];
+ Entry newCostOrProductEntry = newEntriesFormEqualizing[1];
+ tableModel.addValue(newSameAccountEntry);
+ tableModel.addValue(newCostOrProductEntry);
- /*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
- * and the new sameAccountEntry
- * */
- view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
+ /*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
+ * and the new sameAccountEntry
+ * */
+ view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
+ } catch (FinancialTransactionException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
+ }
}
}
@@ -470,12 +481,16 @@
LetteringTableModel tableModel = view.getTableModel();
- for (int indexEntry : entrieSelected){
- Entry entry = tableModel.get(indexEntry);
- entry.setLettering(newLetters);
- financialTransactionService.updateEntry(entry);
- tableModel.fireTableRowsUpdated(indexEntry, indexEntry);
+ try {
+ for (int indexEntry : entrieSelected) {
+ Entry entry = tableModel.get(indexEntry);
+ entry.setLettering(newLetters);
+ financialTransactionService.updateEntry(entry);
+ tableModel.fireTableRowsUpdated(indexEntry, indexEntry);
+ }
+ } catch (EntryException e) {
+ errorHelper.showErrorMessage(t(e.getMessage()));
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx 2014-06-30 07:41:22 UTC (rev 3834)
@@ -46,17 +46,10 @@
// set begindate to JAN 1 - 0:00.000 of this years
Date beginDate = calendarBegin.getTime();
beginDate = DateUtils.truncate(beginDate, Calendar.DATE);
- try {
- FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
- if (result != null){
- beginDate = result.getEndDate();
- }
+ FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod();
+ if (result != null){
+ beginDate = result.getEndDate();
}
- catch (LimaException eee){
- if(log.isDebugEnabled()){
- log.debug("Can't get last fiscal period", eee);
- }
- }
beginDate = DateUtils.addDays(beginDate, 1);
getBeginDatePicker().setDate(beginDate);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -24,21 +24,19 @@
*/
package org.chorem.lima.ui.vatchart;
-import static org.nuiton.i18n.I18n.t;
-
-import java.util.List;
-
-import javax.swing.tree.TreePath;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.api.VatStatementService;
import org.chorem.lima.entity.VatStatement;
import org.chorem.lima.entity.VatStatementImpl;
import org.chorem.lima.service.LimaServiceFactory;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+import javax.swing.tree.TreePath;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+
public class VatChartTreeTableModel extends AbstractTreeTableModel {
/** log. */
@@ -81,21 +79,13 @@
public int getChildCount(Object node) {
int result = 0;
if (node == getRoot()) {
- try {
- result = vatStatementService.
- getChildrenVatStatement(null).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = vatStatementService.
+ getChildrenVatStatement(null).size();
} else {
VatStatement parentVatStatementHeader =
(VatStatement) node;
- try {
- result = vatStatementService.getChildrenVatStatement(
- parentVatStatementHeader).size();
- } catch (LimaException eee) {
- log.debug("Can't count child", eee);
- }
+ result = vatStatementService.getChildrenVatStatement(
+ parentVatStatementHeader).size();
}
return result;
}
@@ -104,23 +94,15 @@
public Object getChild(Object parent, int index) {
Object result = null;
if (parent == getRoot()) {
- try {
- List<VatStatement> vatStatements =
- vatStatementService.getChildrenVatStatement(null);
- result = vatStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ List<VatStatement> vatStatements =
+ vatStatementService.getChildrenVatStatement(null);
+ result = vatStatements.get(index);
} else {
VatStatement parentVatStatement =
(VatStatement) parent;
- try {
- List<VatStatement> vatStatements = vatStatementService.
- getChildrenVatStatement(parentVatStatement);
- result = vatStatements.get(index);
- } catch (LimaException eee) {
- log.debug("Can't get child", eee);
- }
+ List<VatStatement> vatStatements = vatStatementService.
+ getChildrenVatStatement(parentVatStatement);
+ result = vatStatements.get(index);
}
return result;
}
@@ -130,23 +112,15 @@
int result = 0;
if (parent == getRoot()) {
- try {
- List<VatStatement> vatStatements =
- vatStatementService.getChildrenVatStatement(null);
- result = vatStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ List<VatStatement> vatStatements =
+ vatStatementService.getChildrenVatStatement(null);
+ result = vatStatements.indexOf(child);
} else {
VatStatement parentVatStatement =
(VatStatement) parent;
- try {
- List<VatStatement> vatStatements = vatStatementService.
- getChildrenVatStatement(parentVatStatement);
- result = vatStatements.indexOf(child);
- } catch (LimaException eee) {
- log.debug("Can't get index child", eee);
- }
+ List<VatStatement> vatStatements = vatStatementService.
+ getChildrenVatStatement(parentVatStatement);
+ result = vatStatements.indexOf(child);
}
return result;
}
@@ -178,7 +152,7 @@
/** Refresh VatStatementChart. */
- public void refreshTree() throws LimaException {
+ public void refreshTree() {
modelSupport.fireNewRoot();
}
@@ -189,9 +163,8 @@
*
* @param path
* @param vatStatement
- * @throws LimaException
*/
- public void addVatStatement(TreePath path, VatStatement vatStatement) throws LimaException {
+ public void addVatStatement(TreePath path, VatStatement vatStatement) {
// Calling account service
//fixed bug when path is null
VatStatement parentVatStatementHeader = null;
@@ -210,9 +183,8 @@
*
* @param path
* @param vatStatement
- * @throws LimaException
*/
- public void updateVatStatement(TreePath path, VatStatement vatStatement) throws LimaException {
+ public void updateVatStatement(TreePath path, VatStatement vatStatement) {
vatStatementService.updateVatStatement(vatStatement);
modelSupport.fireTreeStructureChanged(path);
@@ -223,9 +195,8 @@
*
* @param path
* @param vatStatement
- * @throws LimaException
*/
- public void removeVatStatementObject(TreePath path, VatStatement vatStatement) throws LimaException {
+ public void removeVatStatementObject(TreePath path, VatStatement vatStatement) {
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), vatStatement);
@@ -238,11 +209,7 @@
public void setValueAt(Object value, Object node, int column) {
VatStatement vatStatement = (VatStatement) node;
vatStatement.setAccounts((String) value);
- try {
vatStatementService.updateVatStatement(vatStatement);
- } catch (LimaException eee) {
- log.debug("Can't update vatStatement", eee);
- }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -26,8 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.business.api.VatStatementService;
@@ -37,9 +35,15 @@
import org.chorem.lima.enums.VatStatementsChartEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTreeTable;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -147,27 +151,7 @@
if (newVatChartMovement != null) {
// add it
- try {
- treeTableModel.addVatStatement(treePath, newVatChartMovement);
- } catch (LimaBusinessException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add Vat chart Movement", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- } catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add Vat chart Movement", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- }
+ treeTableModel.addVatStatement(treePath, newVatChartMovement);
refresh();
}
}
@@ -218,19 +202,8 @@
//if action confirmed
if (vatStatement != null) {
// update it
- try {
- treeTableModel.updateVatStatement(
- treePath, vatStatement);
- } catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add update", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- }
+ treeTableModel.updateVatStatement(
+ treePath, vatStatement);
}
}
refresh();
@@ -258,14 +231,7 @@
// if action confirmed
if (value != null) {
if (form.getDeleteVatStatementChart().isSelected()) {
- try {
- vatStatementService.removeAllVatStatement();
-
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't delete financial statement chart", eee);
- }
- }
+ vatStatementService.removeAllVatStatement();
}
VatStatementsChartEnum defaultVatStatementsEnum =
(VatStatementsChartEnum) value;
@@ -302,19 +268,8 @@
t("lima.common.info"),
JOptionPane.INFORMATION_MESSAGE);
} else {
- try {
- treeTableModel.removeVatStatementObject(
- treePath, vatStatement);
- } catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't delete account", eee);
- }
- JOptionPane.showMessageDialog(
- view,
- eee.getMessage(),
- t("lima.common.error"),
- JOptionPane.ERROR_MESSAGE);
- }
+ treeTableModel.removeVatStatementObject(
+ treePath, vatStatement);
}
}
refresh();
@@ -325,13 +280,7 @@
JXTreeTable treeTable = view.getTreeTable();
VatChartTreeTableModel treeTableModel =
(VatChartTreeTableModel) treeTable.getTreeTableModel();
- try {
- treeTableModel.refreshTree();
- } catch (LimaException eee) {
- if (log.isDebugEnabled()) {
- log.debug("Can't refresh model", eee);
- }
- }
+ treeTableModel.refreshTree();
//refresh view
view.repaint();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2014-06-12 16:07:45 UTC (rev 3833)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2014-06-30 07:41:22 UTC (rev 3834)
@@ -99,6 +99,17 @@
* Display a user friendly error frame.
*
* @param message message for user
+ */
+ public void showErrorMessage(String message) {
+ JOptionPane.showMessageDialog(null, message,
+ t("lima.ui.common.error"), JOptionPane.ERROR_MESSAGE);
+ }
+
+
+ /**
+ * Display a user friendly error frame.
+ *
+ * @param message message for user
* @param cause exception cause
*/
public void showErrorDialog(String message, Throwable cause) {
1
0