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
July 2014
- 3 participants
- 53 discussions
r3847 - in trunk/lima-swing/src/main: java/org/chorem/lima java/org/chorem/lima/ui resources/i18n resources/icons
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 17:28:04 +0200 (Thu, 10 Jul 2014)
New Revision: 3847
Url: http://forge.chorem.org/projects/lima/repository/revisions/3847
Log:
fixes #557 : remove fullscreen option
Removed:
trunk/lima-swing/src/main/resources/icons/action-fullscreen.png
trunk/lima-swing/src/main/resources/icons/action-leave-fullscreen.png
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.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-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2014-07-10 13:16:39 UTC (rev 3846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2014-07-10 15:28:04 UTC (rev 3847)
@@ -309,24 +309,6 @@
}
/**
- * Change full screen mode.
- * Save user file.
- *
- * @param fullscreen new fullscreen mode
- */
- public void setFullscreen(boolean fullscreen) {
- boolean oldValue = isFullScreen();
- setOption(Option.FULL_SCREEN.key, fullscreen + "");
- saveForUser();
- firePropertyChange("fullscreen", oldValue, fullscreen);
- }
-
- public boolean isFullScreen() {
- Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
- return result != null && result;
- }
-
- /**
* Get support email address.
*
* @return support email
@@ -471,12 +453,6 @@
"false",
Boolean.class, false, false),
- FULL_SCREEN("lima.ui.fullscreen",
- t("lima.config.ui.fullscreen.label"),
- n("lima.config.ui.fullscreen.description"),
- "false",
- Boolean.class, false, false),
-
LAUNCH_UI("lima.ui.launchui",
t("lima.config.ui.flaunchui.label"),
n("lima.config.ui.flaunchui.description"),
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2014-07-10 13:16:39 UTC (rev 3846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2014-07-10 15:28:04 UTC (rev 3847)
@@ -137,7 +137,7 @@
// do init ui
MainViewHandler uiHandler = context.getContextValue(MainViewHandler.class);
- final MainView ui = uiHandler.initUI(context, context.getConfig().isFullScreen());
+ final MainView ui = uiHandler.initUI(context);
ui.setLocationRelativeTo(null);
// defaut display home view (not closeable, but might be !)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2014-07-10 13:16:39 UTC (rev 3846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2014-07-10 15:28:04 UTC (rev 3847)
@@ -25,7 +25,6 @@
<JFrame title="lima.ui.mainview.title" onWindowClosing="getHandler().close(this)"
defaultCloseOperation="do_nothing_on_close"
- undecorated='{getConfig().isFullScreen()}'
resizable="true" width="800" height="600"
extendedState='{this.MAXIMIZED_BOTH}'
iconImage='puzzle_icon.png'>
@@ -188,23 +187,6 @@
</JMenu>
- <JMenu text="lima.menu.window" mnemonic="{'W'}">
- <JMenuItem id='menuFileFullscreen'
- text="lima.action.fullscreen"
- toolTipText="lima.action.fullscreen.tip"
- actionIcon="fullscreen"
- mnemonic="P"
- visible="{!isUndecorated()}"
- onActionPerformed="getHandler().changeScreen(this, true)"/>
- <JMenuItem id='menuFileNormalscreen'
- text="lima.action.normalscreen"
- toolTipText="lima.action.normalscreen.tip"
- actionIcon="leave-fullscreen"
- mnemonic="N"
- visible="{isUndecorated()}"
- onActionPerformed="getHandler().changeScreen(this, false)"/>
- </JMenu>
-
<JMenu text="lima.menu.help" mnemonic="{'H'}">
<!--<JMenuItem id="help" text='lima.menu.help.help' actionIcon="help"-->
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2014-07-10 13:16:39 UTC (rev 3846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2014-07-10 15:28:04 UTC (rev 3847)
@@ -95,10 +95,9 @@
* Methode pour initialiser l'ui principale sans l'afficher.
*
* @param rootContext le context applicatif
- * @param fullscreen flag pour indiquer si on doit ouvrir l'ui en model console (pleine ecran).
* @return l'ui instancie et initialisee mais non visible encore
*/
- public MainView initUI(LimaContext rootContext, boolean fullscreen) {
+ public MainView initUI(LimaContext rootContext) {
// show main ui
MainView ui = new MainView(rootContext);
@@ -106,9 +105,6 @@
LimaContext.MAIN_UI_ENTRY_DEF.setContextValue(rootContext, ui);
- // set fullscreen propery on main ui
- ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(fullscreen ? ui : null);
-
return ui;
}
@@ -132,7 +128,7 @@
LimaContext.get().initI18n(config);
// on recharge l'ui
- reloadUI(LimaContext.get(), config.isFullScreen());
+ reloadUI(LimaContext.get());
}
/**
@@ -163,27 +159,6 @@
}
}
- /**
- * Méthode pour changer de mode d'affichage.
- * <p/>
- * Si <code>fullscreen</code> est à <code>true</code> alors on passe en
- * mode console (c'est à dire en mode plein écran exclusif), sinon on
- * passe en mode fenetré normal.
- *
- * @param ui l'ui principale de l'application
- * @param fullscreen le nouvel état requis.
- */
- public void changeScreen(MainView ui, boolean fullscreen) {
- boolean canContinue = ensureModification(ui);
- if (!canContinue) {
- return;
- }
-
- ui.getConfig().setFullscreen(fullscreen);
-
- reloadUI(LimaContext.get(), fullscreen);
- }
-
public void showConfig(JAXXContext context) {
MainView ui = getUI(context);
final LimaConfig config = ui.getConfig();
@@ -255,8 +230,6 @@
helper.addCategory(t("lima.config.category.other"), t("lima.config.category.other.description"));
- helper.addOption(LimaConfig.Option.FULL_SCREEN);
- helper.setOptionShortLabel(LimaConfig.Option.FULL_SCREEN.getLabel());
helper.addOption(LimaConfig.Option.LOCALE);
helper.setOptionShortLabel(LimaConfig.Option.LOCALE.getLabel());
@@ -333,9 +306,8 @@
* Permet de recharger l'ui principale et de changer de le mode d'affichage.
*
* @param rootContext le contexte applicatif
- * @param fullscreen le type de fenetre à reouvrir
*/
- protected void reloadUI(LimaContext rootContext, boolean fullscreen) {
+ protected void reloadUI(LimaContext rootContext) {
// must remove all properties listener on config
LimaContext.CONFIG_DEF.getContextValue(rootContext).removeJaxxPropertyChangeListener();
@@ -351,7 +323,7 @@
ui.setVisible(false);
}
- ui = initUI(rootContext, fullscreen);
+ ui = initUI(rootContext);
// show ui
ui.setVisible(true);
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-10 13:16:39 UTC (rev 3846)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-10 15:28:04 UTC (rev 3847)
@@ -15,10 +15,6 @@
lima.about.translate.content=<h3>How to translate Lima</h3>You can help us to translate or improve label in Lima.<br/><ul><li>Get the <strong>lima-i18n.csv</strong> file in the <strong>i18n</strong> directory</li><li>open it in Libre office (separator caracter is <strong>Tab</strong>)</li><li>Do you work \:)</li><li>At last, send us back the modified file</li></ul><br/>We will apply the patch before next release.
lima.accountsreports.listerror=Can't get entries list
lima.action.commandline.help=Show help in console
-lima.action.fullscreen=Full screen
-lima.action.fullscreen.tip=Open ui in full screen
-lima.action.normalscreen=Normal screen
-lima.action.normalscreen.tip=Open ui in normal screen
lima.balance.documentcreationerror=Enable to create document
lima.balance.documentcreationfiscalerror=Can't create document on an open fiscal year
lima.balance.listerror=Can't get entries list
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-10 13:16:39 UTC (rev 3846)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-10 15:28:04 UTC (rev 3847)
@@ -5,10 +5,6 @@
lima.about.translate.content=<h2>Comment traduire Lima</h2>Vous pouvez nous aider à traduire Lima.<hr/><br/><ul><li>Récupérer le fichier <strong>lima-i18n.csv</strong> dans le répertoire <strong>i18n</strong></li><li>ouvrez le avec un tableur (le caractère séprateur est une Tabultation)</li><li>Traduisez, Améliorer, ...</li><li>Enfin renvoyez-le nous</li></ul><br/>Nous intégrerons vos modifications avant la prochaine version.
lima.accountsreports.listerror=Erreur lors de la récupération des données de la liste
lima.action.commandline.help=Afficher l'aide en console
-lima.action.fullscreen=Plein Ecran
-lima.action.fullscreen.tip=Passer en mode plein écran
-lima.action.normalscreen=Ecran normal
-lima.action.normalscreen.tip=Revenir en écran normal
lima.balance.documentcreationerror=Erreur lors de la création du document
lima.balance.documentcreationfiscalerror=Impossible de créer le document quand la période fiscale est ouverte
lima.balance.listerror=Erreur lors de la récupération des données de la liste
Deleted: trunk/lima-swing/src/main/resources/icons/action-fullscreen.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-leave-fullscreen.png
===================================================================
(Binary files differ)
1
0
r3846 - trunk/lima-business/src/test/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 15:16:39 +0200 (Thu, 10 Jul 2014)
New Revision: 3846
Url: http://forge.chorem.org/projects/lima/repository/revisions/3846
Log:
fixes #557 : fix refactor exception
Modified:
trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-07-10 12:26:56 UTC (rev 3845)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-07-10 13:16:39 UTC (rev 3846)
@@ -23,10 +23,6 @@
package org.chorem.lima.business;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.ParseException;
-
import org.apache.commons.io.IOUtils;
import org.chorem.lima.business.utils.ImportExportEntityEnum;
import org.chorem.lima.entity.Account;
@@ -35,6 +31,10 @@
import org.junit.Assert;
import org.junit.Test;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+
/**
* Test du service d'import en faisant des import/export EBP et xml.
*
@@ -50,10 +50,14 @@
* Import files available in src/test/resources/ebp.
*
* @throws IOException
- * @throws LimaException
- * @throws ParseException
+ * @throws ParseException
+ * @throws BeginAfterEndFiscalPeriodException
+ * @throws NotBeginNextDayOfLastFiscalPeriodException
+ * @throws MoreOneUnlockFiscalPeriodException
+ * @throws ImportEbpException
*/
- protected void importEBPData() throws IOException, LimaException, ParseException {
+ protected void importEBPData() throws IOException, ParseException, BeginAfterEndFiscalPeriodException,
+ NotBeginNextDayOfLastFiscalPeriodException, MoreOneUnlockFiscalPeriodException, ImportEbpException {
// create fiscal period (mandatory for import)
FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
1
0
Author: sbavencoff
Date: 2014-07-10 14:26:56 +0200 (Thu, 10 Jul 2014)
New Revision: 3845
Url: http://forge.chorem.org/projects/lima/repository/revisions/3845
Log:
fixes #557 : fix refactor exception
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java
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/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/ClosedPeriodicEntryBooksException.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/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/FinancialPeriodException.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/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/LimaException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedFinancialPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.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/UnfilledEntriesException.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/WithoutEntryBookFinancialTransactionsException.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/FiscalPeriodService.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/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/LimaExceptionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.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
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -1,61 +0,0 @@
-/*
- * #%L
- * Lima business
- *
- * $Id: LimaBusinessException.java 3290 2011-09-17 12:55:34Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/lima/trunk/lima-business/src/main/java/org/chorem… $
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.business;
-
-/**
- * Lima business exception throw by a business service method
- * that cannot execute successfully.
- *
- * @author chatellier
- * @version $Revision: 3290 $
- * <p/>
- * Last update : $Date: 2011-09-17 14:55:34 +0200 (sam. 17 sept. 2011) $
- * By : $Author: tchemit $
- */
-public class LimaBusinessException extends LimaException {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -6876236663940184462L;
-
- /**
- * Constructs a new exception with the specified detail message.
- *
- * @param message message
- */
- public LimaBusinessException(String message) {
- super(message);
- }
-
- /**
- * Constructs a new exception with the specified detail message and cause.
- *
- * @param message message
- * @param cause cause
- */
- public LimaBusinessException(String message, Throwable cause) {
- super(message, cause);
- }
-}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -96,7 +96,7 @@
// Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.defaultaccountingrules.invalidaccountnumber");
+ throw new InvalidAccountNumberException(account.getAccountNumber());
}
}
@@ -104,7 +104,7 @@
public void updateAccountRules(Account account) throws InvalidAccountNumberException {
// Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.defaultaccountingrules.invalidaccountnumber");
+ throw new InvalidAccountNumberException(account.getAccountNumber());
}
}
@@ -143,7 +143,7 @@
EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao();
// Check if account have entries
if (entryTopiaDao.forAccountEquals(account).exists()) {
- throw new UsedAccountException(account.getAccountNumber(), "lima-business.defaultaccountingrules.deleteaccounterror");
+ throw new UsedAccountException(account.getAccountNumber());
}
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -82,7 +82,7 @@
// Check root account starts with 1 to 8
if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
- throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountstartnumbererror");
+ throw new InvalidAccountNumberException(account.getAccountNumber());
}
}
@@ -95,12 +95,12 @@
// Check if the number account is type numeric
if (!StringUtils.isNumeric(account.getAccountNumber())) {
- throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountnumbernotnumeric");
+ throw new InvalidAccountNumberException(account.getAccountNumber());
}
// Check root account starts with 1 to 8
if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
- throw new InvalidAccountNumberException(account.getAccountNumber(), "lima-business.franceaccountingrules.accountstartnumbererror");
+ throw new InvalidAccountNumberException(account.getAccountNumber());
}
}
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-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -26,7 +26,6 @@
package org.chorem.lima.business.ejb;
import org.apache.commons.lang.StringUtils;
-import org.chorem.lima.business.AccountException;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.AlreadyExistAccountException;
import org.chorem.lima.business.InvalidAccountNumberException;
@@ -76,7 +75,7 @@
* @throws LimaException
*/
@Override
- public Account createAccount(Account account) throws AccountException {
+ public Account createAccount(Account account) throws AlreadyExistAccountException, InvalidAccountNumberException {
// check rules before create the account
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
@@ -89,7 +88,7 @@
AccountTopiaDao AccountTopiaDao = getDaoHelper().getAccountDao();
if (AccountTopiaDao.existByNaturalId(account.getAccountNumber())) {
- throw new AlreadyExistAccountException(account.getAccountNumber(), "lima-business.account.accountalreardyexist");
+ throw new AlreadyExistAccountException(account.getAccountNumber());
}
//create it
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -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.AlreadyExistAccountException;
import org.chorem.lima.business.AlreadyLockedFiscalPeriodException;
import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LastUnlockedFiscalPeriodException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LockedEntryBookException;
@@ -281,12 +282,13 @@
@Override
public FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
boolean retainedEarnings)
- throws AccountException,
- LockedFinancialPeriodException,
+ throws LockedFinancialPeriodException,
LockedEntryBookException,
NoFoundFinancialPeriodException,
LastUnlockedFiscalPeriodException,
- AlreadyLockedFiscalPeriodException {
+ AlreadyLockedFiscalPeriodException,
+ AlreadyExistAccountException,
+ InvalidAccountNumberException {
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -50,9 +50,10 @@
import org.chorem.lima.beans.FinancialTransactionImportImpl;
import org.chorem.lima.beans.VatStatementImport;
import org.chorem.lima.beans.VatStatementImportImpl;
-import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.AlreadyExistAccountException;
import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
import org.chorem.lima.business.ImportEbpException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.LockedFinancialPeriodException;
@@ -329,29 +330,42 @@
"lima-business.import.entrybooknotexist",
entryBook));
}
+ try {
- // create transaction
- if (financialTransaction == null
- || !(dateEcr.equals(financialTransaction
- .getTransactionDate()) && entryBook
- .getCode().equals(
- financialTransaction.getEntryBook()
- .getCode()))) {
- // create financial transaction
- financialTransaction = new FinancialTransactionImpl();
- financialTransaction.setEntryBook(entryBook);
- financialTransaction.setTransactionDate(dateEcr);
- financialTransaction = financialTransactionService
- .createFinancialTransaction(financialTransaction);
- result.append(t(
- "lima-business.import.transactionadded", dateEcr,
- entryBook.getCode()));
+ // create transaction
+ if (financialTransaction == null
+ || !(dateEcr.equals(financialTransaction
+ .getTransactionDate()) && entryBook
+ .getCode().equals(
+ financialTransaction.getEntryBook()
+ .getCode()))) {
+ // create financial transaction
+ financialTransaction = new FinancialTransactionImpl();
+ financialTransaction.setEntryBook(entryBook);
+ financialTransaction.setTransactionDate(dateEcr);
+ financialTransaction = financialTransactionService
+ .createFinancialTransaction(financialTransaction);
+ result.append(t(
+ "lima-business.import.transactionadded", dateEcr,
+ entryBook.getCode()));
+ }
+ // Inside the db, the entries reference the financialTransaction
+ entry.setFinancialTransaction(financialTransaction);
+ entry = financialTransactionService.createEntry(entry);
+ result.append(t("lima-business.import.entryadded",
+ entry.getDescription(), entry.getAmount()));
+
+ } catch (LockedFinancialPeriodException e) {
+ result.append(t("lima-business.import.entries.error.lockedFinancialPeriod",
+ e.getFinancialPeriod().getBeginDate(),
+ e.getFinancialPeriod().getEndDate()));
+ } catch (LockedEntryBookException e) {
+ result.append(t("lima-business.import.entries.error.lockedEntryBook",
+ e.getClosedPeriodicEntryBook().getEntryBook().getCode(),
+ e.getClosedPeriodicEntryBook().getEntryBook().getLabel(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(),
+ e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate()));
}
- // Inside the db, the entries reference the financialTransaction
- entry.setFinancialTransaction(financialTransaction);
- entry = financialTransactionService.createEntry(entry);
- result.append(t("lima-business.import.entryadded",
- entry.getDescription(), entry.getAmount()));
}
}
@@ -365,10 +379,6 @@
throw new ImportEbpException("Can't import ", e);
} catch (IOException 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 {
@@ -422,10 +432,18 @@
account = new AccountImpl();
account.setAccountNumber(accountNumber);
account.setLabel(label);
- accountService.createAccount(account);
- result.append(t("lima-business.import.accountadded",
- accountNumber, label));
- nbAccountCreated++;
+ try {
+ accountService.createAccount(account);
+ result.append(t("lima-business.import.account.added",
+ accountNumber, label));
+ nbAccountCreated++;
+ } catch (AlreadyExistAccountException e) {
+ result.append(t("lima-business.import.account.alreadyExist",
+ accountNumber, label));
+ } catch (InvalidAccountNumberException e) {
+ result.append(t("lima-business.import.account.InvalidAccountNumber",
+ accountNumber, label));
+ }
}
line = csvReader.readNext();
}
@@ -440,8 +458,6 @@
+ (after - before) + " ms");
}
- } catch (AccountException e) {
- throw new ImportEbpException("Can't import", e);
} catch (IOException e) {
throw new ImportEbpException("Can't import", e);
} finally {
@@ -826,8 +842,10 @@
try {
accountService.createAccount(account);
- } catch (AccountException e) {
- result.append(t("lima-business.import.accountalreadyexist", accountNumber));
+ } catch (AlreadyExistAccountException e) {
+ result.append(t("lima-business.import.account.alreadyexist", accountNumber));
+ } catch (InvalidAccountNumberException e) {
+ result.append(t("lima-business.import.account.InvalidAccountNumber", accountNumber));
}
result.append(t("lima-business.import.accountadded",
account.getAccountNumber(),
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-07-10 12:26:56 UTC (rev 3845)
@@ -90,12 +90,21 @@
lima-business.import.FiscalPeriod.error.beginAfterEndFiscalPeriod=
lima-business.import.FiscalPeriod.error.moreOneUnlockFiscalPeriod=
lima-business.import.FiscalPeriod.error.notBeginNextDayOfLastFiscalPeriod=
+lima-business.import.account.InvalidAccountNumber=
+lima-business.import.account.added=
+lima-business.import.account.alreadyExist=
+lima-business.import.account.alreadyexist=
+lima-business.import.accountInvalidAccountNumber=
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
lima-business.import.ebpmissingaccount=FAILED \: Account %s already exist, import aborted. \nCreate all accounts before import entries.
lima-business.import.ebpnoentry=FAILED \: This file contains no entries.
lima-business.import.ebpnoheader=FAILED \: This file has no header datas.
+lima-business.import.entries.error.FinancialPeriod=
+lima-business.import.entries.error.LockedEntryBook=
+lima-business.import.entries.error.lockedEntryBook=
+lima-business.import.entries.error.lockedFinancialPeriod=
lima-business.import.entriesoutofdatesrange=WARNING \: %s entries is out of range of opened fiscal periods. Entry was skip \!\n
lima-business.import.entryadded=SUCCES \: Entry %s %s added\n"
lima-business.import.entrybookalreadyexist=FAILED \: The entrybook %s already exists \!\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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-07-10 12:26:56 UTC (rev 3845)
@@ -87,6 +87,10 @@
lima-business.import.FiscalPeriod.error.beginAfterEndFiscalPeriod=La date de début doit être avant la date de fin
lima-business.import.FiscalPeriod.error.moreOneUnlockFiscalPeriod=Seul deux exercices non clôturés sont autorisés
lima-business.import.FiscalPeriod.error.notBeginNextDayOfLastFiscalPeriod=la date de début doit suivre la date de fin du précédent exercice
+lima-business.import.account.InvalidAccountNumber=Le numéro de compt %1$s n'est pas valide\n
+lima-business.import.account.added=Succès \: Compte %s - %s ajouté\n
+lima-business.import.account.alreadyExist=Le compte %1$s - existe déjà \n
+lima-business.import.account.alreadyexist=
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
@@ -97,6 +101,8 @@
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.
lima-business.import.ebpnoheader=Échec \: Ce fichier ne contient aucun entête.
+lima-business.import.entries.error.lockedEntryBook=
+lima-business.import.entries.error.lockedFinancialPeriod=
lima-business.import.entriesoutofdatesrange=Attention \: Cette entrée %s ne fait partie d'aucune période ouverte. Entrée non importée \!\n
lima-business.import.entryadded=Succès \: Entrée %s %s ajoutée \n
lima-business.import.entrybookalreadyexist=Échec \: Le journal %s exist déjà \!\n
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AccountException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -29,13 +29,12 @@
protected String accountNumber;
- public AccountException(String accountNumber, String message) {
- super(message);
+ public AccountException(String accountNumber) {
this.accountNumber = accountNumber;
}
- public AccountException(String accountNumber, String message, Throwable cause) {
- super(message, cause);
+ public AccountException(String accountNumber, Throwable cause) {
+ super(cause);
this.accountNumber = accountNumber;
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyExistAccountException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -26,11 +26,12 @@
* @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) {
+ super(accountNumber);
}
- public AlreadyExistAccountException(String accountNumber, String message, Throwable cause) {
- super(accountNumber, message, cause);
+ public AlreadyExistAccountException(String accountNumber, Throwable cause) {
+ super(accountNumber, 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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBookException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -31,21 +31,12 @@
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);
+ public ClosedPeriodicEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook) {
this.closedPeriodicEntryBook = closedPeriodicEntryBook;
}
- public ClosedPeriodicEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, String message, Throwable cause) {
- super(message, cause);
+ public ClosedPeriodicEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, Throwable cause) {
+ super(cause);
this.closedPeriodicEntryBook = closedPeriodicEntryBook;
}
Modified: 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 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ClosedPeriodicEntryBooksException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -12,12 +12,11 @@
protected Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks;
public ClosedPeriodicEntryBooksException(Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks) {
- super("");
this.closedPeriodicEntryBooks = closedPeriodicEntryBooks;
}
public ClosedPeriodicEntryBooksException(Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks, Throwable cause) {
- super("", cause);
+ super(cause);
this.closedPeriodicEntryBooks = closedPeriodicEntryBooks;
}
Modified: 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 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/DateException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -10,12 +10,11 @@
protected Date date;
public DateException(Date date) {
- super("");
this.date = date;
}
public DateException(Date date, Throwable cause) {
- super("", cause);
+ super(cause);
this.date = 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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntriesException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -12,12 +12,11 @@
protected Collection<Entry> entries;
public EntriesException(Collection<Entry> entries) {
- super("");
this.entries = entries;
}
public EntriesException(Collection<Entry> entries, Throwable cause) {
- super("", cause);
+ super(cause);
this.entries = 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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -31,13 +31,12 @@
protected EntryBook entryBook;
- public EntryBookException(EntryBook entryBook, String message) {
- super(message);
+ public EntryBookException(EntryBook entryBook) {
this.entryBook = entryBook;
}
- public EntryBookException(EntryBook entryBook, String message, Throwable cause) {
- super(message, cause);
+ public EntryBookException(EntryBook entryBook, Throwable cause) {
+ super(cause);
this.entryBook = entryBook;
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialPeriodException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -10,12 +10,11 @@
protected FinancialPeriod financialPeriod;
public FinancialPeriodException(FinancialPeriod financialPeriod) {
- super("");
this.financialPeriod = financialPeriod;
}
public FinancialPeriodException(FinancialPeriod financialPeriod, Throwable cause) {
- super("", cause);
+ super(cause);
this.financialPeriod = financialPeriod;
}
Modified: 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 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FinancialTransactionsException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -12,12 +12,11 @@
protected Collection<FinancialTransaction> financialTransactions;
public FinancialTransactionsException(Collection<FinancialTransaction> financialTransactions) {
- super("");
this.financialTransactions = financialTransactions;
}
public FinancialTransactionsException(Collection<FinancialTransaction> financialTransactions, Throwable cause) {
- super("", cause);
+ super(cause);
this.financialTransactions = financialTransactions;
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -32,12 +32,11 @@
protected FiscalPeriod fiscalPeriod;
public FiscalPeriodException(FiscalPeriod fiscalPeriod) {
- super("");
this.fiscalPeriod = fiscalPeriod;
}
public FiscalPeriodException(FiscalPeriod fiscalPeriod, Throwable cause) {
- super("", cause);
+ super(cause);
this.fiscalPeriod = 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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportEbpException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -25,7 +25,8 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class ImportEbpException extends LimaException {
+public class ImportEbpException extends Exception {
+
public ImportEbpException(String message) {
super(message);
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -26,11 +26,12 @@
* @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) {
+ super(accountNumber);
}
- public InvalidAccountNumberException(String accountNumber, String message, Throwable cause) {
- super(accountNumber, message, cause);
+ public InvalidAccountNumberException(String accountNumber, Throwable cause) {
+ super(accountNumber, 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-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -37,7 +37,7 @@
* By : $Author$
*/
@ApplicationException
-public class LimaException extends Exception {
+public abstract class LimaException extends Exception {
/**
* serialVersionUID.
@@ -45,21 +45,19 @@
private static final long serialVersionUID = -6876236663940184462L;
/**
- * Constructs a new exception with the specified detail message.
+ * Constructs a new exception
*
- * @param message message
*/
- public LimaException(String message) {
- super(message);
+ public LimaException() {
+ super();
}
/**
- * Constructs a new exception with the specified detail message and cause.
+ * Constructs a new exception with the specified cause.
*
- * @param message message
* @param cause cause
*/
- public LimaException(String message, Throwable cause) {
- super(message, cause);
+ public LimaException(Throwable cause) {
+ super(cause);
}
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedEntryBookException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -8,10 +8,10 @@
public class LockedEntryBookException extends ClosedPeriodicEntryBookException {
public LockedEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook) {
- super(closedPeriodicEntryBook, "");
+ super(closedPeriodicEntryBook);
}
public LockedEntryBookException(ClosedPeriodicEntryBook closedPeriodicEntryBook, Throwable cause) {
- super(closedPeriodicEntryBook, "", cause);
+ super(closedPeriodicEntryBook, cause);
}
}
Modified: 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 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LockedFinancialPeriodException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -6,6 +6,7 @@
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
public class LockedFinancialPeriodException extends FinancialPeriodException{
+
public LockedFinancialPeriodException(FinancialPeriod financialPeriod) {
super(financialPeriod);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -8,12 +8,11 @@
int countUnlockFiscalPeriod;
public MoreOneUnlockFiscalPeriodException(int countUnlockFiscalPeriod) {
- super("");
this.countUnlockFiscalPeriod = countUnlockFiscalPeriod;
}
public MoreOneUnlockFiscalPeriodException(int countUnlockFiscalPeriod, Throwable cause) {
- super("", cause);
+ super(cause);
this.countUnlockFiscalPeriod = countUnlockFiscalPeriod;
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -8,6 +8,7 @@
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
public class NoEmptyFiscalPeriodException extends FinancialTransactionsException {
+
public NoEmptyFiscalPeriodException(Collection<FinancialTransaction> financialTransactions) {
super(financialTransactions);
}
Modified: 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 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotLockedClosedPeriodicEntryBooksException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -8,6 +8,7 @@
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
public class NotLockedClosedPeriodicEntryBooksException extends ClosedPeriodicEntryBooksException {
+
public NotLockedClosedPeriodicEntryBooksException(Collection<ClosedPeriodicEntryBook> closedPeriodicEntryBooks) {
super(closedPeriodicEntryBooks);
}
Modified: 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 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UnfilledEntriesException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -8,6 +8,7 @@
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
public class UnfilledEntriesException extends EntriesException {
+
public UnfilledEntriesException(Collection<Entry> entries) {
super(entries);
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedAccountException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -26,11 +26,12 @@
* @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) {
+ super(accountNumber);
}
- public UsedAccountException(String accountNumber, String message, Throwable cause) {
- super(accountNumber, message, cause);
+ public UsedAccountException(String accountNumber, Throwable cause) {
+ super(accountNumber, cause);
}
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -30,10 +30,10 @@
public class UsedEntryBookException extends EntryBookException {
public UsedEntryBookException(EntryBook entryBook) {
- super(entryBook, "");
+ super(entryBook);
}
public UsedEntryBookException(EntryBook entryBook, Throwable cause) {
- super(entryBook, "", cause);
+ super(entryBook, cause);
}
}
Modified: 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 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/WithoutEntryBookFinancialTransactionsException.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -8,6 +8,7 @@
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
public class WithoutEntryBookFinancialTransactionsException extends FinancialTransactionsException {
+
public WithoutEntryBookFinancialTransactionsException(Collection<FinancialTransaction> financialTransactions) {
super(financialTransactions);
}
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-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -25,7 +25,7 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.AlreadyExistAccountException;
import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.UsedAccountException;
@@ -93,7 +93,7 @@
* @param account account
* @throws LimaException
*/
- Account createAccount(Account account) throws AccountException;
+ Account createAccount(Account account) throws AlreadyExistAccountException, InvalidAccountNumberException;
Account updateAccount(Account account) throws InvalidAccountNumberException;
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -25,9 +25,10 @@
package org.chorem.lima.business.api;
-import org.chorem.lima.business.AccountException;
+import org.chorem.lima.business.AlreadyExistAccountException;
import org.chorem.lima.business.AlreadyLockedFiscalPeriodException;
import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
+import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.LastUnlockedFiscalPeriodException;
import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.LockedFinancialPeriodException;
@@ -79,7 +80,13 @@
* */
FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
boolean retainedEarnings)
- throws AccountException, LockedFinancialPeriodException, LockedEntryBookException, NoFoundFinancialPeriodException, LastUnlockedFiscalPeriodException, AlreadyLockedFiscalPeriodException;
+ throws LockedFinancialPeriodException,
+ LockedEntryBookException,
+ NoFoundFinancialPeriodException,
+ LastUnlockedFiscalPeriodException,
+ AlreadyLockedFiscalPeriodException,
+ AlreadyExistAccountException,
+ InvalidAccountNumberException;
/**
* Test if we have retained earnings on a fiscal period
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java 2014-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaExceptionHandler.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -25,13 +25,8 @@
package org.chorem.lima;
-import static org.nuiton.i18n.I18n.t;
-
-import javax.swing.JOptionPane;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.util.ErrorHelper;
/**
@@ -64,18 +59,8 @@
log.error("Global application exception", ex);
}
- Throwable cause = ex;
- while (cause != null && !(cause instanceof LimaBusinessException)) {
- cause = cause.getCause();
- }
-
- if (cause instanceof LimaBusinessException) {
- JOptionPane.showMessageDialog(null, cause.getMessage(),
- t("lima.ui.common.error"), JOptionPane.ERROR_MESSAGE);
- } else {
- ErrorHelper errorHelper = new ErrorHelper(LimaConfig.getInstance());
- errorHelper.showErrorDialog(null, ex.getMessage(), ex);
- }
+ ErrorHelper errorHelper = new ErrorHelper(LimaConfig.getInstance());
+ errorHelper.showErrorDialog(null, ex.getMessage(), ex);
}
}
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-07-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2014-07-10 12:26:56 UTC (rev 3845)
@@ -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.AccountException;
+import org.chorem.lima.business.AlreadyExistAccountException;
import org.chorem.lima.business.InvalidAccountNumberException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.UsedAccountException;
@@ -46,7 +46,12 @@
import org.jdesktop.swingx.treetable.MutableTreeTableNode;
import org.jdesktop.swingx.treetable.TreeTableNode;
-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.InputEvent;
@@ -271,8 +276,10 @@
model.insertNodeInto(newNode, node, node.getChildCount());
treeTable.expandPath(new TreePath(model.getPathToRoot(node)));
- } catch (AccountException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (AlreadyExistAccountException e) {
+ errorHelper.showErrorMessage(t("lima.ui.account.add.error.alreadyExist", e.getAccountNumber()));
+ } catch (InvalidAccountNumberException e) {
+ errorHelper.showErrorMessage(t("lima.ui.account.add.error.InvalidAccountNumber", e.getAccountNumber()));
} finally {
dialog.dispose();
}
@@ -378,7 +385,7 @@
model.valueForPathChanged(treePath, account);
} catch (InvalidAccountNumberException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ errorHelper.showErrorMessage(t("lima.ui.account.update.error.invalidAccountNumber", e.getAccountNumber()));
} finally {
// close dialog
dialog.dispose();
@@ -417,7 +424,7 @@
// remove node
model.removeNodeFromParent(lastNode);
} catch (UsedAccountException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ errorHelper.showErrorMessage(t("lima.ui.account.remove.error.usedAccount", e.getAccountNumber()));
}
}
}
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-10 12:26:56 UTC (rev 3845)
@@ -337,6 +337,8 @@
lima.tooltip.Filter=
lima.tooltip.filter=<html>Regular expression \:<br/>- accounts interval i..j <br/>- accounts list i,j,k <br/>- Exclude an account -i</html>
lima.tooltip.lettering=<html>Add a letter on many entries <br/>Select many rows with combination ctrl + click</html>
+lima.ui.account.add.error.InvalidAccountNumber=
+lima.ui.account.add.error.alreadyExist=
lima.ui.account.addaccount=
lima.ui.account.addaccounttitle=
lima.ui.account.base=
@@ -346,9 +348,11 @@
lima.ui.account.importtitle=
lima.ui.account.label=
lima.ui.account.number=
+lima.ui.account.remove.error.usedAccount=
lima.ui.account.removeaccountconfirm=
lima.ui.account.removeaccounttitle=
lima.ui.account.shortened=
+lima.ui.account.update.error.invalidAccountNumber=
lima.ui.account.updateaccounttitle=
lima.ui.common.amountcredit=
lima.ui.common.amountdebit=
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-10 09:15:31 UTC (rev 3844)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-10 12:26:56 UTC (rev 3845)
@@ -319,6 +319,8 @@
lima.tooltip.Filter=
lima.tooltip.filter=<html>Expression régulière \:<br/>- intervalle de compte i..j <br/>- liste de compte i,j,k <br/>- Exclure un compte -i</html>
lima.tooltip.lettering=<html>Pour ajouter une lettre à plusieurs écritures <br/>Sélectionner plusieurs lignes avec la combinaison ctrl + click</html>
+lima.ui.account.add.error.InvalidAccountNumber=Le numéro du compt %1$s n'est pas valide
+lima.ui.account.add.error.alreadyExist=Le compt %1$s existe déjà
lima.ui.account.addaccount=Nouveau compte
lima.ui.account.addaccounttitle=Ajout d'un compte
lima.ui.account.base=Plan comptable de base
@@ -328,9 +330,11 @@
lima.ui.account.importtitle=Importer
lima.ui.account.label=Libellé
lima.ui.account.number=Numéro de compte
+lima.ui.account.remove.error.usedAccount=Il exist des transactions sur ce compte
lima.ui.account.removeaccountconfirm=Voulez-vous supprimer le compte %s ?
lima.ui.account.removeaccounttitle=Suppression d'un compte
lima.ui.account.shortened=Plan comptable abrégé
+lima.ui.account.update.error.invalidAccountNumber=Le numéro du compt %1$s n'est pas valide
lima.ui.account.updateaccounttitle=Modification d'un compte
lima.ui.common.amountcredit=Total Crédit
lima.ui.common.amountdebit=Total Débit
1
0
Author: sbavencoff
Date: 2014-07-10 11:15:31 +0200 (Thu, 10 Jul 2014)
New Revision: 3844
Url: http://forge.chorem.org/projects/lima/repository/revisions/3844
Log:
refs #557 : fix fiscal period exception
Added:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyLockedFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeginAfterEndFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/LastUnlockedFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFoundFinancialPeriodException.java
trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotBeginNextDayOfLastFiscalPeriodException.java
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/DateException.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/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/accountingrules/FranceAccountingRules.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-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -68,11 +68,14 @@
* @param fiscalPeriod
* @throws LimaException
*/
- List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
+ List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod)
+ throws BeginAfterEndFiscalPeriodException,
+ NotBeginNextDayOfLastFiscalPeriodException,
+ MoreOneUnlockFiscalPeriodException;
- void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
+ void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LastUnlockedFiscalPeriodException;
- void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
+ void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws NoEmptyFiscalPeriodException;
/**
* Entry 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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -31,11 +31,15 @@
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.AfterLastFiscalPeriodException;
import org.chorem.lima.business.BeforeFirstFiscalPeriodException;
-import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
import org.chorem.lima.business.InvalidAccountNumberException;
+import org.chorem.lima.business.LastUnlockedFiscalPeriodException;
import org.chorem.lima.business.LimaInterceptor;
import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.LockedFinancialPeriodException;
+import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException;
+import org.chorem.lima.business.NoEmptyFiscalPeriodException;
+import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException;
import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
import org.chorem.lima.business.UnfilledEntriesException;
@@ -106,24 +110,27 @@
/** Rules to check before create fiscals periods */
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod)
+ throws BeginAfterEndFiscalPeriodException,
+ NotBeginNextDayOfLastFiscalPeriodException,
+ MoreOneUnlockFiscalPeriodException {
//check if the enddate period is after the begindate period
if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())) {
- throw new FiscalPeriodException(fiscalPeriod, "lima-business.defaultaccountingrules.enddateerror");
+ throw new BeginAfterEndFiscalPeriodException(fiscalPeriod);
}
return null;
}
/** Rules to check before block fiscals periods */
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException{
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LastUnlockedFiscalPeriodException {
}
/** Rules to check before delete fiscals periods */
@Override
public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod)
- throws FiscalPeriodException {
+ throws NoEmptyFiscalPeriodException {
}
/**
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -29,8 +29,12 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
import org.chorem.lima.business.InvalidAccountNumberException;
+import org.chorem.lima.business.LastUnlockedFiscalPeriodException;
+import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException;
+import org.chorem.lima.business.NoEmptyFiscalPeriodException;
+import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException;
import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
import org.chorem.lima.business.UnfilledEntriesException;
@@ -40,6 +44,7 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionTopiaDao;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
@@ -113,7 +118,11 @@
* Pas plus de deux exercices fiscaux ne peuvent-être ouvert en même temps
*/
@Override
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod)
+ throws NotBeginNextDayOfLastFiscalPeriodException,
+ MoreOneUnlockFiscalPeriodException,
+ BeginAfterEndFiscalPeriodException {
+
super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
@@ -132,15 +141,14 @@
Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
- throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.newfiscalperiodadjoiningerror");
+ throw new NotBeginNextDayOfLastFiscalPeriodException(lastFiscalPeriod);
}
//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();
+ int unblockedFiscalPeriod = (int) fiscalPeriodTopiaDao.forLockedEquals(false).count();
if (unblockedFiscalPeriod > 1) {
- throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.antefiscalperiodnotblocked");
+ throw new MoreOneUnlockFiscalPeriodException(unblockedFiscalPeriod);
}
}
@@ -175,7 +183,7 @@
* On ne peut pas clore la dernière periode comptable ouverte.
*/
@Override
- public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LastUnlockedFiscalPeriodException {
FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
FiscalPeriod oldestUnBlockedFiscalPeriod =
@@ -183,7 +191,7 @@
//Check if the fiscal period to block is the oldest
if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) {
- throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.lastFiscalPeriodCantBlocked");
+ throw new LastUnlockedFiscalPeriodException(fiscalPeriod);
}
}
@@ -193,13 +201,14 @@
* On ne peut supprimer qu'une periode comptable ouverte vide.
*/
@Override
- public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws NoEmptyFiscalPeriodException {
FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao();
//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");
+ List<FinancialTransaction> financialTransactions = financialTransactionTopiaDao.findAllByDates(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate());
+ if (!financialTransactions.isEmpty()) {
+ throw new NoEmptyFiscalPeriodException(financialTransactions);
}
}
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -31,17 +31,22 @@
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.AccountException;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.AlreadyLockedFiscalPeriodException;
+import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
+import org.chorem.lima.business.LastUnlockedFiscalPeriodException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.LockedFinancialPeriodException;
+import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException;
+import org.chorem.lima.business.NoEmptyFiscalPeriodException;
+import org.chorem.lima.business.NoFoundFinancialPeriodException;
+import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.EntryBookService;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ReportService;
-import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
@@ -57,16 +62,15 @@
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodTopiaDao;
+import org.nuiton.topia.persistence.TopiaNoResultException;
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.Calendar;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -100,7 +104,10 @@
protected FinancialTransactionService financialTransactionService;
@Override
- public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod)
+ throws BeginAfterEndFiscalPeriodException,
+ NotBeginNextDayOfLastFiscalPeriodException,
+ MoreOneUnlockFiscalPeriodException {
FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao();
FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao();
@@ -201,12 +208,13 @@
* check localized rules before block it
*/
@Override
- public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod)
+ throws AlreadyLockedFiscalPeriodException, LastUnlockedFiscalPeriodException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
if (fiscalPeriod.isLocked()) {
- throw new FiscalPeriodException(fiscalPeriod, "lima-business.fiscalperiod.fiscalperiodalreadyblocked");
+ throw new AlreadyLockedFiscalPeriodException(fiscalPeriod);
}
//check rules
accountingRules.blockFiscalPeriodRules(fiscalPeriod);
@@ -273,7 +281,12 @@
@Override
public FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
boolean retainedEarnings)
- throws AccountException, LockedFinancialPeriodException, LockedEntryBookException, FiscalPeriodException {
+ throws AccountException,
+ LockedFinancialPeriodException,
+ LockedEntryBookException,
+ NoFoundFinancialPeriodException,
+ LastUnlockedFiscalPeriodException,
+ AlreadyLockedFiscalPeriodException {
if (entryBook != null && retainedEarnings) {
@@ -330,34 +343,28 @@
lastFPeriod = itr.next();
}
- FinancialPeriod beginfinancialPeriod = null;
- //look for the first financial period on the new fiscal year which is unlocked
- List<ClosedPeriodicEntryBook> resultsArray =
- new ArrayList<ClosedPeriodicEntryBook>();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBook =
- financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- Collections.sort(closedPeriodicEntryBook, new FinancialPeriodComparator());
- resultsArray.addAll(closedPeriodicEntryBook);
- for (ClosedPeriodicEntryBook cPeriodicEntryBook : resultsArray) {
+ Date beginDateNextFiscalPeriod = DateUtils.addDays(localFiscalPeriod.getEndDate(), 1);
- //check for - unlocked financial period
- // - date after the closing fiscal year
- // - unlocked entrybook
- // - right code and label
- if (!cPeriodicEntryBook.getFinancialPeriod().isLocked()
- && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(localFiscalPeriod.getEndDate())
- && !cPeriodicEntryBook.isLocked()
- && cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode())
- && cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) {
- beginfinancialPeriod = cPeriodicEntryBook.getFinancialPeriod();
- break;
- }
+ FinancialPeriodTopiaDao financialPeriodDao = getDaoHelper().getFinancialPeriodDao();
+ FinancialPeriod beginfinancialPeriod = null;
+ try {
+ beginfinancialPeriod = financialPeriodDao.findByDate(beginDateNextFiscalPeriod);
+ } catch (TopiaNoResultException e) {
+ throw new NoFoundFinancialPeriodException(beginDateNextFiscalPeriod, e);
}
- if (beginfinancialPeriod == null) {
- throw new FiscalPeriodException(fiscalPeriod, "lima-business.fiscalperiod.newfinancialperioderror");
+
+ if (beginfinancialPeriod.isLocked()) {
+ throw new LockedFinancialPeriodException(beginfinancialPeriod);
}
+ ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookDao = getDaoHelper().getClosedPeriodicEntryBookDao();
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookDao.findByEntryBookAndFinancialPeriod(entryBook, beginfinancialPeriod);
+
+ if (closedPeriodicEntryBook.isLocked()) {
+ throw new LockedEntryBookException(closedPeriodicEntryBook);
+ }
+
//holds entries of all closing transactions
FinancialTransaction endfinancialTransaction = new FinancialTransactionImpl();
if (lastFPeriod != null) {
@@ -445,7 +452,7 @@
* check localized rules before delete it
*/
@Override
- public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws NoEmptyFiscalPeriodException {
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
//get entities with TopiaDao
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -51,11 +51,13 @@
import org.chorem.lima.beans.VatStatementImport;
import org.chorem.lima.beans.VatStatementImportImpl;
import org.chorem.lima.business.AccountException;
-import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
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.MoreOneUnlockFiscalPeriodException;
+import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException;
import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException;
import org.chorem.lima.business.UnbalancedFinancialTransactionsException;
import org.chorem.lima.business.UnfilledEntriesException;
@@ -1228,8 +1230,12 @@
result.append(t("lima-business.import.fiscalperiodadded",
fiscalPeriod.getBeginDate(),
fiscalPeriod.getEndDate()));
- } catch (FiscalPeriodException e) {
- result.append(t("lima-business.common.failed", e.getMessage()));
+ } catch (BeginAfterEndFiscalPeriodException e) {
+ result.append("Can't import " + t("lima-business.import.FiscalPeriod.error.beginAfterEndFiscalPeriod"));
+ } catch (MoreOneUnlockFiscalPeriodException e) {
+ result.append("Can't import " + t("lima-business.import.FiscalPeriod.error.moreOneUnlockFiscalPeriod"));
+ } catch (NotBeginNextDayOfLastFiscalPeriodException e) {
+ result.append("Can't import " + t("lima-business.import.FiscalPeriod.error.notBeginNextDayOfLastFiscalPeriod"));
}
}
return result.toString();
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2014-07-10 09:15:31 UTC (rev 3844)
@@ -87,6 +87,9 @@
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.FiscalPeriod.error.beginAfterEndFiscalPeriod=
+lima-business.import.FiscalPeriod.error.moreOneUnlockFiscalPeriod=
+lima-business.import.FiscalPeriod.error.notBeginNextDayOfLastFiscalPeriod=
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2014-07-10 09:15:31 UTC (rev 3844)
@@ -84,6 +84,9 @@
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.FiscalPeriod.error.beginAfterEndFiscalPeriod=La date de début doit être avant la date de fin
+lima-business.import.FiscalPeriod.error.moreOneUnlockFiscalPeriod=Seul deux exercices non clôturés sont autorisés
+lima-business.import.FiscalPeriod.error.notBeginNextDayOfLastFiscalPeriod=la date de début doit suivre la date de fin du précédent exercice
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
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-07-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -24,7 +24,9 @@
package org.chorem.lima.business.accountingrules;
import org.apache.commons.lang3.time.DateUtils;
-import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
+import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException;
+import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
@@ -59,7 +61,10 @@
* Copier/coller de la methode france.
* Le probleme ici est que le default n'en creer aucune.
*/
- public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws FiscalPeriodException {
+ public List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod)
+ throws MoreOneUnlockFiscalPeriodException,
+ NotBeginNextDayOfLastFiscalPeriodException,
+ BeginAfterEndFiscalPeriodException {
super.createFiscalPeriodRules(fiscalPeriod);
List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>();
FiscalPeriodTopiaDao fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDao();
@@ -75,14 +80,14 @@
dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE);
Date dateFiscalPeriod = fiscalPeriod.getBeginDate();
if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) {
- throw new FiscalPeriodException(fiscalPeriod, "lima-business.franceaccountingrules.newfiscalperiodadjoiningerror");
+ throw new NotBeginNextDayOfLastFiscalPeriodException(lastFiscalPeriod);
}
//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");
+ throw new MoreOneUnlockFiscalPeriodException(unblockedFiscalPeriod);
}
}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyLockedFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyLockedFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/AlreadyLockedFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FiscalPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class AlreadyLockedFiscalPeriodException extends FiscalPeriodException {
+
+ public AlreadyLockedFiscalPeriodException(FiscalPeriod fiscalPeriod) {
+ super(fiscalPeriod);
+ }
+
+ public AlreadyLockedFiscalPeriodException(FiscalPeriod fiscalPeriod, Throwable cause) {
+ super(fiscalPeriod, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeginAfterEndFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeginAfterEndFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/BeginAfterEndFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FiscalPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class BeginAfterEndFiscalPeriodException extends FiscalPeriodException {
+
+ public BeginAfterEndFiscalPeriodException(FiscalPeriod fiscalPeriod) {
+ super(fiscalPeriod);
+ }
+
+ public BeginAfterEndFiscalPeriodException(FiscalPeriod fiscalPeriod, Throwable cause) {
+ super(fiscalPeriod, cause);
+ }
+}
Modified: 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 2014-07-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/DateException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -5,7 +5,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class DateException extends LimaException {
+public abstract class DateException extends LimaException {
protected Date date;
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/FiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -27,25 +27,17 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class FiscalPeriodException extends LimaException {
+public abstract 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);
+ public FiscalPeriodException(FiscalPeriod fiscalPeriod) {
+ super("");
this.fiscalPeriod = fiscalPeriod;
}
- public FiscalPeriodException(FiscalPeriod fiscalPeriod, String message, Throwable cause) {
- super(message, cause);
+ public FiscalPeriodException(FiscalPeriod fiscalPeriod, Throwable cause) {
+ super("", cause);
this.fiscalPeriod = fiscalPeriod;
}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LastUnlockedFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/LastUnlockedFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LastUnlockedFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FiscalPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LastUnlockedFiscalPeriodException extends FiscalPeriodException {
+
+ public LastUnlockedFiscalPeriodException(FiscalPeriod fiscalPeriod) {
+ super(fiscalPeriod);
+ }
+
+ public LastUnlockedFiscalPeriodException(FiscalPeriod fiscalPeriod, Throwable cause) {
+ super(fiscalPeriod, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -0,0 +1,23 @@
+package org.chorem.lima.business;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class MoreOneUnlockFiscalPeriodException extends LimaException {
+
+ int countUnlockFiscalPeriod;
+
+ public MoreOneUnlockFiscalPeriodException(int countUnlockFiscalPeriod) {
+ super("");
+ this.countUnlockFiscalPeriod = countUnlockFiscalPeriod;
+ }
+
+ public MoreOneUnlockFiscalPeriodException(int countUnlockFiscalPeriod, Throwable cause) {
+ super("", cause);
+ this.countUnlockFiscalPeriod = countUnlockFiscalPeriod;
+ }
+
+ public int getCountUnlockFiscalPeriod() {
+ return countUnlockFiscalPeriod;
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoEmptyFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -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 NoEmptyFiscalPeriodException extends FinancialTransactionsException {
+ public NoEmptyFiscalPeriodException(Collection<FinancialTransaction> financialTransactions) {
+ super(financialTransactions);
+ }
+
+ public NoEmptyFiscalPeriodException(Collection<FinancialTransaction> financialTransactions, Throwable cause) {
+ super(financialTransactions, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFoundFinancialPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFoundFinancialPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFoundFinancialPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import java.util.Date;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class NoFoundFinancialPeriodException extends DateException {
+
+ public NoFoundFinancialPeriodException(Date date) {
+ super(date);
+ }
+
+ public NoFoundFinancialPeriodException(Date date, Throwable cause) {
+ super(date, cause);
+ }
+}
Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotBeginNextDayOfLastFiscalPeriodException.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotBeginNextDayOfLastFiscalPeriodException.java (rev 0)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotBeginNextDayOfLastFiscalPeriodException.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -0,0 +1,17 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.entity.FiscalPeriod;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class NotBeginNextDayOfLastFiscalPeriodException extends FiscalPeriodException {
+
+ public NotBeginNextDayOfLastFiscalPeriodException(FiscalPeriod fiscalPeriod) {
+ super(fiscalPeriod);
+ }
+
+ public NotBeginNextDayOfLastFiscalPeriodException(FiscalPeriod fiscalPeriod, Throwable cause) {
+ super(fiscalPeriod, cause);
+ }
+}
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -26,9 +26,15 @@
package org.chorem.lima.business.api;
import org.chorem.lima.business.AccountException;
-import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.AlreadyLockedFiscalPeriodException;
+import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
+import org.chorem.lima.business.LastUnlockedFiscalPeriodException;
import org.chorem.lima.business.LockedEntryBookException;
import org.chorem.lima.business.LockedFinancialPeriodException;
+import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException;
+import org.chorem.lima.business.NoEmptyFiscalPeriodException;
+import org.chorem.lima.business.NoFoundFinancialPeriodException;
+import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FiscalPeriod;
@@ -53,11 +59,15 @@
FiscalPeriod getLastFiscalPeriod();
- FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
+ FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod)
+ throws BeginAfterEndFiscalPeriodException,
+ NotBeginNextDayOfLastFiscalPeriodException,
+ MoreOneUnlockFiscalPeriodException;
- FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
+ FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod)
+ throws AlreadyLockedFiscalPeriodException, LastUnlockedFiscalPeriodException;
- void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws FiscalPeriodException;
+ void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws NoEmptyFiscalPeriodException;
/**
* Eventually add retained earnings on last unclosed fiscal period,
@@ -69,7 +79,7 @@
* */
FiscalPeriod retainedEarningsAndBlockFiscalPeriod(FiscalPeriod fiscalPeriod, EntryBook entryBook,
boolean retainedEarnings)
- throws AccountException, FiscalPeriodException, LockedFinancialPeriodException, LockedEntryBookException;
+ throws AccountException, LockedFinancialPeriodException, LockedEntryBookException, NoFoundFinancialPeriodException, LastUnlockedFiscalPeriodException, AlreadyLockedFiscalPeriodException;
/**
* Test if we have retained earnings on a fiscal period
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-07-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2014-07-10 09:15:31 UTC (rev 3844)
@@ -30,7 +30,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
-import org.chorem.lima.business.FiscalPeriodException;
+import org.chorem.lima.business.AlreadyLockedFiscalPeriodException;
+import org.chorem.lima.business.BeginAfterEndFiscalPeriodException;
+import org.chorem.lima.business.LastUnlockedFiscalPeriodException;
+import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException;
+import org.chorem.lima.business.NoEmptyFiscalPeriodException;
+import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
@@ -196,8 +201,16 @@
fiscalPeriod.setEndDate(addPeriodDialog.getEndDatePicker().getDate());
fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
tableModel.addValue(fiscalPeriod);
- } catch (FiscalPeriodException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (BeginAfterEndFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.fiscalPeriod.add.error.beginAfterEndFiscalPeriod",
+ e.getFiscalPeriod().getBeginDate(),
+ e.getFiscalPeriod().getEndDate()));
+ } catch (MoreOneUnlockFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.fiscalPeriod.add.error.moreOneUnlockFiscalPeriod",
+ e.getCountUnlockFiscalPeriod()));
+ } catch (NotBeginNextDayOfLastFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.fiscalPeriod.add.error.notBeginNextDayOfLastFiscalPeriod",
+ e.getFiscalPeriod().getEndDate()));
}
}
}
@@ -211,10 +224,9 @@
if (!addPeriodDialog.isValidate()) {
return false;
} else if (endDate.before(beginDate)) {
- JOptionPane.showMessageDialog(view,
- t("lima.ui.fiscalperiod.addfiscalperiod.endAfterBegin"),
- title,
- JOptionPane.ERROR_MESSAGE);
+ errorHelper.showErrorMessage(t("lima.ui.fiscalPeriod.add.error.beginAfterEndFiscalPeriod",
+ beginDate,
+ endDate));
return false;
} else {
//check if fiscalperiod have 12 months, ask a confirmation
@@ -297,8 +309,9 @@
tableModel.remove(selectedFiscalPeriod);
view.setBlockEnabled(false);
view.setDeleteEnabled(false);
- } catch (FiscalPeriodException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (NoEmptyFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.fiscalPeriod.delete.error.noEmptyFiscalPeriod",
+ e.getFinancialTransactions().size()));
}
}
}
@@ -427,8 +440,12 @@
view.setBlockEnabled(false);
view.setDeleteEnabled(false);
- } catch (FiscalPeriodException e) {
- errorHelper.showErrorMessage(t(e.getMessage()));
+ } catch (LastUnlockedFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.fiscalPeriod.block.error.lastUnlockedFiscalPeriod",
+ e.getFiscalPeriod().getBeginDate(),
+ e.getFiscalPeriod().getEndDate()));
+ } catch (AlreadyLockedFiscalPeriodException e) {
+ errorHelper.showErrorMessage(t("lima.ui.fiscalPeriod.block.error.AlreadyLockedFiscalPeriod"));
}
}
}
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-10 09:15:31 UTC (rev 3844)
@@ -440,8 +440,17 @@
lima.ui.financialtransaction.titleremoveentry=
lima.ui.financialtransaction.titleremovetransaction=
lima.ui.financialtransaction.voucher=
+lima.ui.fiscalPeriod.add.beginAfterEndFiscalPeriod=
+lima.ui.fiscalPeriod.add.error.beginAfterEndFiscalPeriod=
+lima.ui.fiscalPeriod.add.error.moreOneUnlockFiscalPeriod=
+lima.ui.fiscalPeriod.add.error.notBeginNextDayOfLastFiscalPeriod=
+lima.ui.fiscalPeriod.add.moreOneUnlockFiscalPeriod=
+lima.ui.fiscalPeriod.add.notBeginNextDayOfLastFiscalPeriod=
+lima.ui.fiscalPeriod.block.error.AlreadyLockedFiscalPeriod=
+lima.ui.fiscalPeriod.block.error.lastUnlockedFiscalPeriod=
lima.ui.fiscalPeriod.buttonback=
lima.ui.fiscalPeriod.buttonnext=
+lima.ui.fiscalPeriod.delete.error.noEmptyFiscalPeriod=
lima.ui.fiscalperiod.addfiscalperiod.addfiscalperiodtitle=
lima.ui.fiscalperiod.addfiscalperiod.endAfterBegin=
lima.ui.fiscalperiod.addfiscalperiod.morethan12=
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-10 06:31:00 UTC (rev 3843)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-10 09:15:31 UTC (rev 3844)
@@ -419,9 +419,14 @@
lima.ui.financialtransaction.titleremoveentry=Suppression
lima.ui.financialtransaction.titleremovetransaction=Suppression
lima.ui.financialtransaction.voucher=Pièce comptable
+lima.ui.fiscalPeriod.add.error.beginAfterEndFiscalPeriod=Le date de fin de l'exercice (%2$te/%2$tm/%2$tY) doit être postérieur à la date de début (%1$te/%1$tm/%1$tY)
+lima.ui.fiscalPeriod.add.error.moreOneUnlockFiscalPeriod=Il existe déjà %1s exercices non clôturés.
+lima.ui.fiscalPeriod.add.error.notBeginNextDayOfLastFiscalPeriod=La date de début de l'exercice doit suivre la date de fin de l'exercice précédent le %1$te/%1$tm/%1$tY
+lima.ui.fiscalPeriod.block.error.AlreadyLockedFiscalPeriod=L'exercice est déjà clôturés
+lima.ui.fiscalPeriod.block.error.lastUnlockedFiscalPeriod=L'exercice prédent doit être clôturé
lima.ui.fiscalPeriod.buttonback=
lima.ui.fiscalPeriod.buttonnext=
-lima.ui.fiscalperiod.addfiscalperiod.endAfterBegin=Le date de fin de l'exercice doit être postérieur à la date de début
+lima.ui.fiscalPeriod.delete.error.noEmptyFiscalPeriod=Impossible de supprimer un exercice avec des transactions (%1$s).
lima.ui.fiscalperiod.addfiscalperiod.morethan12=La période sélectionnée n'est pas de 12 mois, voulez-vous continuer ?
lima.ui.fiscalperiod.addfiscalperiodtitle=Nouvel exercice
lima.ui.fiscalperiod.begin=Début
1
0
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