Author: echatellier Date: 2012-06-05 17:08:46 +0200 (Tue, 05 Jun 2012) New Revision: 3443 Url: http://chorem.org/repositories/revision/lima/3443 Log: Corrige l'operation de cloture d'un exercice Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.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 2012-06-05 14:51:55 UTC (rev 3442) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-05 15:08:46 UTC (rev 3443) @@ -208,7 +208,7 @@ closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findByTopiaId(closedPeriodicEntryBook.getTopiaId()); // Check if all financial transactions of closedperiodicentrybook are equilibrate - // FIMXE echatellier 20120504 unutile de recuperer une liste + // FIXME echatellier 20120504 unutile de recuperer une liste // entiere juste pour tester l'existence FinancialPeriod period = closedPeriodicEntryBook.getFinancialPeriod(); List<FinancialTransaction> result = financialTransactionDAO.getAllUnbalancedTransaction(period.getBeginDate(), @@ -220,18 +220,16 @@ // Check if all financial transactions of this closedperiodicentrybook/financialPeriod are well filled in result = financialTransactionDAO.getAllUnfilledTransaction(period.getBeginDate(), period.getEndDate(), closedPeriodicEntryBook.getEntryBook()); - // FIMXE echatellier 20120504 unutile de recuperer une liste + // FIXME echatellier 20120504 unutile de recuperer une liste // entiere juste pour tester l'existence if (result.size() > 0) { throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingelements")); } // Check if all financial transactions have EntryBooks - // FIXME echatellier 20120605 only check in interval defined - // by period to block (not all database) result = financialTransactionDAO.getAllTransactionWithoutEntryBook(period.getBeginDate(), period.getEndDate()); - // FIMXE echatellier 20120504 unutile de recuperer une liste + // FIXME echatellier 20120504 unutile de recuperer une liste // entiere juste pour tester l'existence if (result.size() > 0) { FinancialTransaction transaction = result.get(0); 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 2012-06-05 14:51:55 UTC (rev 3442) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-05 15:08:46 UTC (rev 3443) @@ -263,7 +263,7 @@ } catch (TopiaException ex) { throw new LimaException("Can't find fiscal period", ex); } - + //sets dates // - endRetainedEarnings: last day of the closing year // - beginRetainedEarnings: first open day of the following year @@ -280,6 +280,7 @@ found = true; } } + //if entrybook isn't found //then create it if (!found) { @@ -305,8 +306,7 @@ accountMaster = new AccountImpl(); accountMaster.setAccountNumber("89"); accountMaster.setLabel("BILAN"); - accountService.createAccount(accountMaster); - accountMaster = accountService.getAccountByNumber("89"); + accountMaster = accountService.createAccount(accountMaster); } //890 Bilan d'ouverture @@ -315,8 +315,7 @@ beginRetainedAccount = new AccountImpl(); beginRetainedAccount.setAccountNumber("890"); beginRetainedAccount.setLabel("Bilan d'ouverture"); - accountService.createAccount(beginRetainedAccount); - beginRetainedAccount = accountService.getAccountByNumber("890"); + beginRetainedAccount = accountService.createAccount(beginRetainedAccount); } //891 Bilan de cloture @@ -325,19 +324,18 @@ endRetainedAccount = new AccountImpl(); endRetainedAccount.setAccountNumber("891"); endRetainedAccount.setLabel("Bilan de clôture"); - accountService.createAccount(endRetainedAccount); - endRetainedAccount = accountService.getAccountByNumber("891"); + endRetainedAccount = accountService.createAccount(endRetainedAccount); } //look for the last financial period from the previous fiscal year + //check if the last financial period isn't blocked Collection<FinancialPeriod> fperiod = localFiscalPeriod.getFinancialPeriod(); - Iterator<FinancialPeriod> itr = fperiod.iterator(); FinancialPeriod lastFPeriod = null; while (itr.hasNext()) { lastFPeriod = itr.next(); } - //check if the last financial period isn't blocked + if (lastFPeriod.getLocked()) { throw new LimaBusinessException(_("lima-business.fiscalperiod.previousfiscalperiodalreadyblocked")); } @@ -378,7 +376,7 @@ //Sets the endfinancialTransaction endfinancialTransaction.setEntryBook(entryBook); endfinancialTransaction.setTransactionDate(localFiscalPeriod.getEndDate()); - financialTransactionService.createFinancialTransaction(endfinancialTransaction); + endfinancialTransaction = financialTransactionService.createFinancialTransaction(endfinancialTransaction); } //holds entries of all opening transactions @@ -388,7 +386,7 @@ //Sets the endfinancialTransaction beginfinancialTransaction.setEntryBook(entryBook); beginfinancialTransaction.setTransactionDate(beginfinancialPeriod.getBeginDate()); - financialTransactionService.createFinancialTransaction(beginfinancialTransaction); + beginfinancialTransaction = financialTransactionService.createFinancialTransaction(beginfinancialTransaction); } } @@ -397,9 +395,6 @@ calendar.setTime(fiscalPeriod.getEndDate()); //Sets entries - Entry beginEntry; - - BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(), localFiscalPeriod.getEndDate(), null, false, false); @@ -410,7 +405,7 @@ if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6 && !report.getAmountSolde().equals(BigDecimal.ZERO)) { //close accounts by removing amounts from all class 1 to 5 accounts - beginEntry = new EntryImpl(); + Entry beginEntry = new EntryImpl(); beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")"); beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher")); beginEntry.setFinancialTransaction(endfinancialTransaction);