Author: vsalaun Date: 2011-05-26 14:49:51 +0200 (Thu, 26 May 2011) New Revision: 3146 Url: http://chorem.org/repositories/revision/lima/3146 Log: #356 impossibilite de bloquer une periode comptable si une transaction n'a pas de journal 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-26 10:31:37 UTC (rev 3145) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2011-05-26 12:49:51 UTC (rev 3146) @@ -196,12 +196,15 @@ /** * Check if all financial transactions of closedperiodicentrybook are equilibrate + * Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in + * Check if all financial transactions have EntryBooks */ @Override public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaContext) throws LimaException { List<FinancialTransaction> result = null; + // Check if all financial transactions of closedperiodicentrybook are equilibrate try { FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); @@ -223,6 +226,7 @@ } result = null; + // Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in try { FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); @@ -240,12 +244,36 @@ result = financialTransactionDAO.findAllByQuery(query); if (result.size()>0){ - throw new LimaBusinessException("Can't block financialperiod / missing elements in transactions"); + throw new LimaBusinessException("Can't block financialperiod / missing elements in transactions for this FinancialPeriod/EntryBook"); } } catch (TopiaException ex) { doCatch(topiaContext, ex, log); } + + result = null; + + // Check if all financial transactions have EntryBooks + 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 = ''") + .addNull(FinancialTransaction.ENTRY_BOOK); + result = financialTransactionDAO.findAllByQuery(query); + + if (result.size()>0){ + throw new LimaBusinessException("Can't block financialperiod / missing EntryBook in transactions"); + } + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } } /**
participants (1)
-
vsalaun@users.chorem.org