r2894 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/financialperiod lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model lima-swing/src/main/resources/i18n
Author: jpepin Date: 2010-05-12 12:52:17 +0200 (Wed, 12 May 2010) New Revision: 2894 Url: http://chorem.org/repositories/revision/lima/2894 Log: Ajout ?\195?\169tat de cloture ouvert/ferm?\195?\169 pour chaque p?\195?\169riode financi?\195?\168re de chaque journaux Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.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/EntryBookServiceImpl.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/FiscalPeriodServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.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/FinancialPeriodService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -22,6 +22,8 @@ import java.util.Date; import java.util.List; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; /** @@ -42,5 +44,9 @@ void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException; FinancialPeriod getFinancialPeriodWithDate(Date date) throws LimaException; + + /** Methode for closedperiodicentrybook */ + ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook, + FinancialPeriod financialPeriod) throws LimaException; } 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 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -86,7 +86,6 @@ //get the last fiscal period FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.findByQuery(query); - log.debug("lastFiscalPeriod : "+lastFiscalPeriod); //check the new fiscal period adjoining the last Date dateLastFiscalPeriod=lastFiscalPeriod.getEndDate(); @@ -102,7 +101,6 @@ //But not the ante periodfiscal int unblockedFiscalPeriod = fiscalPeriodDAO.findAllByLocked(false).size(); - log.debug(unblockedFiscalPeriod); if (unblockedFiscalPeriod>1){ throw new LimaBusinessException( "The ante fiscal period is not locked"); @@ -122,7 +120,6 @@ financialPeriod.setEndDate(periodEndDate); fiscalPeriod.addFinancialPeriod(financialPeriod); loopDate = loopUpperDate; - log.debug("financialPeriod : "+financialPeriod); financialPeriodService.createFinancialPeriod(financialPeriod); } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -33,9 +33,13 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; +import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookDAO; +import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransactionDAO; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.entity.FinancialTransaction; @@ -60,6 +64,8 @@ protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl(); + protected FinancialPeriodServiceImpl financialPeriodService = new FinancialPeriodServiceImpl(); + protected AccountingRules accountingRules; @@ -102,6 +108,28 @@ // creation du EntryBook entryBookDAO.create(entryBook); + + //create ClosedPeriodicEntryBook for all unblocked financial period + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); + for (FinancialPeriod financialPeriod : financialPeriodService.getUnblockedFinancialPeriods()) { + //new closedperiodentrybook + + //set financial + + //set entrybook + + //create it + + //new closed periodic entrybook + ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); + // set entrybook + closedPeriodicEntryBook.setEntryBook(entryBook); + // set financial period + closedPeriodicEntryBook.setFinancialPeriod(financialPeriod); + // create it + closedPeriodicEntryBookDAO.create(closedPeriodicEntryBook); + } // commit transaction.commitTransaction(); 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 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -30,6 +30,11 @@ import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountDAO; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; +import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.EntryBookDAO; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodDAO; import org.chorem.lima.entity.FinancialPeriodImpl; @@ -83,8 +88,25 @@ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction); + //create financial period financialPeriodDAO.create(financialPeriod); + //create ClosedPeriodicEntryBook for all entrybook + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); + EntryBookDAO entryBookDAO = + LimaCallaoDAOHelper.getEntryBookDAO(transaction); + for (EntryBook entryBook : entryBookDAO.findAll()) { + //new closed periodic entrybook + ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); + // set entrybook + closedPeriodicEntryBook.setEntryBook(entryBook); + // set financial period + closedPeriodicEntryBook.setFinancialPeriod(financialPeriod); + // create it + closedPeriodicEntryBookDAO.create(closedPeriodicEntryBook); + } + // commit transaction.commitTransaction(); } @@ -185,6 +207,37 @@ return financialPeriod; } + + @Override + public ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException { + ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); + + TopiaContext topiaContext = null; + try { + topiaContext = rootContext.beginTransaction(); + + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext); + + TopiaQuery query = closedPeriodicEntryBookDAO.createQuery(); + if (entryBook != null){ + query.add(ClosedPeriodicEntryBook.ENTRY_BOOK, entryBook); + } + if (financialPeriod != null){ + query.add(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, financialPeriod); + } + closedPeriodicEntryBook=closedPeriodicEntryBookDAO.findByQuery(query); + + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + + return closedPeriodicEntryBook; + } } 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 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -34,6 +34,7 @@ import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodDAO; import org.chorem.lima.entity.FiscalPeriod; Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -88,7 +88,7 @@ */ @Override public int getRowCount() { - cacheDataList=getDataList(); + //cacheDataList=getDataList(); return cacheDataList.size(); } @@ -110,13 +110,13 @@ switch(columnIndex) { case 0 : - result = _("lima.tab.financialperiod"); + result = _("lima.model.period"); break; case 1: result = _("lima.entrybook"); break; case 2: - result = _("Bloquée"); + result = _("lima.closure"); break; } @@ -147,42 +147,52 @@ public Object getValueAt(int rowIndex, int columnIndex) { Object result = null; - FinancialPeriodEntryBook financialPeriodEntryBook = cacheDataList.get(rowIndex); - - String[] monthName = {_("lima.date.january"), _("lima.date.february"), - _("lima.date.march"), _("lima.date.april"), _("lima.date.may"), - _("lima.date.june"), _("lima.date.july"), _("lima.date.august"), - _("lima.date.september"), _("lima.date.october"), - _("lima.date.november"), _("lima.date.december")}; - - if (financialPeriodEntryBook != null){ - /* Date date = fiscalPeriod.getBeginDate(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - String formatBeginDate = monthName[calendar.get(Calendar.MONTH)] - +" "+String.valueOf(calendar.get(Calendar.YEAR)); - date = fiscalPeriod.getEndDate(); - calendar.setTime(date); - String formatEndDate = monthName[calendar.get(Calendar.MONTH)] - +" "+String.valueOf(calendar.get(Calendar.YEAR)); - date = fiscalPeriod.getEndDate();*/ + try { + FinancialPeriodEntryBook financialPeriodEntryBook = cacheDataList.get(rowIndex); + + String[] monthName = {_("lima.date.january"), _("lima.date.february"), + _("lima.date.march"), _("lima.date.april"), _("lima.date.may"), + _("lima.date.june"), _("lima.date.july"), _("lima.date.august"), + _("lima.date.september"), _("lima.date.october"), + _("lima.date.november"), _("lima.date.december")}; - switch (columnIndex) { - case 0: - result = financialPeriodEntryBook.financialPeriod;//formatBeginDate + " - " + formatEndDate; - break; - case 1: - result = financialPeriodEntryBook.entryBook; - break; - case 2: - result=null; //get boolean financialperiod/entrybook blocked + if (financialPeriodEntryBook != null){ + FinancialPeriod financialPeriod = financialPeriodEntryBook.financialPeriod; + EntryBook entryBook = financialPeriodEntryBook.entryBook; + + Date date = financialPeriod.getBeginDate(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + String formatBeginDate = monthName[calendar.get(Calendar.MONTH)] + +" "+String.valueOf(calendar.get(Calendar.YEAR)); + + switch (columnIndex) { + case 0: + result = formatBeginDate; + break; + case 1: + result = entryBook.getCode()+" - "+entryBook.getLabel(); + break; + case 2: + if(financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod).getLocked()){ + result = _("lima.close"); + } + else{ + result = _("lima.open"); + } + break; + } } } - + catch (LimaException eee){ + if (log.isDebugEnabled()){ + log.debug("Can't get value at row", eee ); + } + } return result; } - public List<FinancialPeriodEntryBook> getDataList(){ + public void getDataList(){ List<FinancialPeriodEntryBook> results = new ArrayList<FinancialPeriodEntryBook>(); List<FinancialPeriod> periods = new ArrayList<FinancialPeriod>(); @@ -212,7 +222,7 @@ } ErrorHelper.showErrorDialog("Can't get entrybook and financial period list"); } - return results; + cacheDataList=results; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx 2010-05-12 10:52:17 UTC (rev 2894) @@ -23,10 +23,7 @@ <Boolean id="selectedPeriod" javaBean="false" /> <script> <![CDATA[ - - void $afterCompleteSetup() { - //getModelFinancialPeriodTable().getDataList(); - } + getModelFinancialPeriodTable().getDataList(); ]]> </script> 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 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -63,7 +63,8 @@ public void addFiscalPeriod() { - FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); + FiscalPeriodTableModel model = + (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); AddPeriod addPeriodDialog = new AddPeriod(view); // jaxx don't call super() ? @@ -73,9 +74,10 @@ FiscalPeriod fiscalPeriod = addPeriodDialog.getPeriod(); // null = cancel if (fiscalPeriod!= null) { - System.out.println("begin : "+fiscalPeriod.getBeginDate()+" end :"+fiscalPeriod.getEndDate()); //check if fiscalperiod have 12 months, ask a confirmation - int nbMonth = DateUtils.getDifferenceInMonths(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); + int nbMonth = + DateUtils.getDifferenceInMonths(fiscalPeriod.getBeginDate(), + fiscalPeriod.getEndDate()); int n = 0; if(nbMonth !=12){ n = JOptionPane.showConfirmDialog(view, @@ -100,13 +102,18 @@ public void blockFiscalPeriod() { JXTable fiscalPeriodeTable = view.getFiscalPeriodTable(); int selectedRow = fiscalPeriodeTable.getSelectedRow(); - FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); + FiscalPeriodTableModel model = + (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); // blocked it try { - FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAtRow(selectedRow); - int response = JOptionPane.showConfirmDialog(view, _("lima.question.fiscalperiod.blocked"), - _("lima.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + FiscalPeriod selectedFiscalPeriod = + model.getFiscalPeriodAtRow(selectedRow); + int response = + JOptionPane.showConfirmDialog(view, + _("lima.question.fiscalperiod.blocked"), + _("lima.question"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { model.blockFiscalPeriod(selectedFiscalPeriod); @@ -119,16 +126,17 @@ } } - + /** just for debug, no release version */ public void removeAllFiscalPeriods(){ - FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); + FiscalPeriodTableModel model = + (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); try { model.removeAllFiscalPeriods(); } catch (LimaException ex) { if (log.isErrorEnabled()) { log.error("Can't delete all fiscal period", ex); } - ErrorHelper.showErrorDialog(_("Can't delete all fiscal period"), ex); + ErrorHelper.showErrorDialog(_("Can't delete all fiscal period")); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-05-12 10:52:17 UTC (rev 2894) @@ -93,7 +93,7 @@ result = _("lima.tab.fiscalperiod"); break; case 1: - result = _("Bloquée"); + result = _("lima.closure"); break; } @@ -155,7 +155,12 @@ + " - " + formatEndDate; break; case 1: - result = fiscalPeriod.getLocked(); + if(fiscalPeriod.getLocked()){ + result = _("lima.close"); + } + else{ + result = _("lima.open"); + } break; } } 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 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-05-12 10:52:17 UTC (rev 2894) @@ -61,6 +61,8 @@ lima.chartofaccounts.journal= lima.chartofaccounts.management= lima.chartofaccounts.subledgers= +lima.close=Closed +lima.closure=Closure lima.closure.period.begin=Period from lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period. lima.common.add= @@ -241,6 +243,7 @@ lima.not.lettered=Not lettered lima.number=Number lima.ok=OK +lima.open=Open lima.openejb.remotemode.description= lima.passif=Liability lima.period=Period @@ -314,6 +317,7 @@ lima.tab.balance=Balance lima.tab.bilan=Results lima.tab.closure=Closure +lima.tab.financialperiod= lima.tab.fiscalperiod= lima.tab.home=Home lima.tab.journal=Journal 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 2010-05-11 15:39:50 UTC (rev 2893) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-12 10:52:17 UTC (rev 2894) @@ -59,6 +59,8 @@ lima.chartofaccounts.journal=Journaux lima.chartofaccounts.management=Plan comptable lima.chartofaccounts.subledgers=Plan tiers +lima.close=Ferm\uFFFD +lima.closure=Cloture lima.closure.period.begin=P\u00E9riode de lima.closure.timespan.warning=Attention \: lorsque la p\u00E9riode est bloqu\u00E9e, il n'est plus possible d'ajouter, modifier et supprimer les entr\u00E9es comptables sur cette p\u00E9riode. lima.common.add=Ajout Compte G\u00E9n\u00E9ral @@ -231,6 +233,7 @@ lima.non.valids.transactions=Ecritures non valides lima.not.lettered=Non lettr\u00E9 lima.number=Num\u00E9ro +lima.open=Ouvert lima.openejb.remotemode.description= lima.passif=Passif lima.period= @@ -298,6 +301,7 @@ lima.tab.balance=Balance lima.tab.bilan=Bilan lima.tab.blocked=Block\u00E9 +lima.tab.financialperiod= lima.tab.fiscalperiod=Exercice lima.tab.home=Accueil lima.tab.lettering=Lettrage
participants (1)
-
jpepin@users.chorem.org