Author: vsalaun Date: 2011-05-26 12:31:37 +0200 (Thu, 26 May 2011) New Revision: 3145 Url: http://chorem.org/repositories/revision/lima/3145 Log: #356 empeche la cloture d'une periode comptable liee a un journal lorsqu'une transaction de ce journal a cette date n'est pas complete Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2011-05-25 12:19:36 UTC (rev 3144) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2011-05-26 10:31:37 UTC (rev 3145) @@ -202,7 +202,7 @@ throws LimaException { List<FinancialTransaction> result = null; - try { + try { FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); @@ -220,7 +220,32 @@ } catch (TopiaException ex) { doCatch(topiaContext, ex, log); - } + } + result = null; + + try { + FinancialTransactionDAO financialTransactionDAO = + LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); + + TopiaQuery query = financialTransactionDAO.createQuery("T"); + query.addDistinct() + .addOrder("T."+FinancialTransaction.TOPIA_CREATE_DATE) + .addFrom(FiscalPeriod.class, "F") + .addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true) + .addWhere("T.amountCredit != T.amountDebit OR E.account = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''") + .addEquals(FinancialTransaction.ENTRY_BOOK, + closedPeriodicEntryBook.getEntryBook()) + .addEquals(FinancialTransaction.FINANCIAL_PERIOD, + closedPeriodicEntryBook.getFinancialPeriod()); + result = financialTransactionDAO.findAllByQuery(query); + + if (result.size()>0){ + throw new LimaBusinessException("Can't block financialperiod / missing elements in transactions"); + } + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } } /** @@ -246,7 +271,7 @@ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod( entryOld.getFinancialTransaction().getEntryBook(), financialPeriod); if (closedPeriodicEntryBook.getLocked()){ - throw new LimaBusinessException("2 - Can't update entry : financialperiod of this entrybook is closed"); + throw new LimaBusinessException("Can't update entry : financialperiod of this entrybook is closed"); } //third case @@ -256,7 +281,7 @@ // Check 2 & 3 cases if (closedPeriodicEntryBook2.getLocked()){ - throw new LimaBusinessException("3 - Can't update entry : financialperiod of this entrybook is closed"); + throw new LimaBusinessException("Can't update entry : financialperiod of this entrybook is closed"); } }
participants (1)
-
vsalaun@users.chorem.org