This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 8f3fbd5dfa2219ed181c487786dbd780fb396f79 Author: David Cossé <cosse@codelutin.com> Date: Fri Jul 8 10:33:23 2016 +0200 refs #1174 ajout d'une exception pour gérer le cas ou l'on essaye de supprimer un compte qui 'existe pas --- .../business/exceptions/UnexistingAccount.java | 26 +++++++++++++++++++++- .../accountingrules/DefaultAccountingRules.java | 6 ++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java b/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java index f8c7528..34bc826 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java @@ -1,10 +1,34 @@ package org.chorem.lima.business.exceptions; +/* + * #%L + * Lima :: business API + * %% + * Copyright (C) 2008 - 2014 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + /** - * Created by davidcosse on 08/07/16. + * @author David Cossé */ public class UnexistingAccount extends AccountException { + private static final long serialVersionUID = 1L; + public UnexistingAccount(String accountNumber, String message) { super(accountNumber, message); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java index 9c2fafb..182b557 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java +++ b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java @@ -39,6 +39,7 @@ import org.chorem.lima.business.exceptions.NoEmptyFiscalPeriodException; import org.chorem.lima.business.exceptions.NotBeginNextDayOfLastFiscalPeriodException; import org.chorem.lima.business.exceptions.NotLockedClosedPeriodicEntryBooksException; import org.chorem.lima.business.exceptions.NotNumberAccountNumberException; +import org.chorem.lima.business.exceptions.UnexistingAccount; import org.chorem.lima.business.exceptions.UnbalancedEntriesException; import org.chorem.lima.business.exceptions.UnbalancedFinancialTransactionsException; import org.chorem.lima.business.exceptions.UnfilledEntriesException; @@ -175,10 +176,13 @@ public class DefaultAccountingRules implements AccountingRules { * Recursive function */ @Override - public void removeAccountRules(Account account) throws UsedAccountException { + public void removeAccountRules(Account account) throws UsedAccountException, UnexistingAccount { EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); // Check if account have entries + if (!account.isPersisted()) { + throw new UnexistingAccount(account.getAccountNumber(), "Unsaved Account, this account can not be removed"); + } if (entryTopiaDao.forAccountEquals(account).exists()) { throw new UsedAccountException(account.getAccountNumber()); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.