r3454 - 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-business/src/main/resources/i18n lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod lima-swing/src/main/resources/i18n
Author: mallon Date: 2012-06-18 18:31:34 +0200 (Mon, 18 Jun 2012) New Revision: 3454 Url: http://chorem.org/repositories/revision/lima/3454 Log: La suppression des exercices(Ceux ouverts et vides) est d?\195?\169sormais possible, via un bouton de suppression, ajout?\195?\169 au panneau des gestion des exercices. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.out.xml Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.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/FiscalPeriodServiceImpl.java trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.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/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -73,6 +73,8 @@ List<FinancialPeriod> createFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException; void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException; + + void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaException; /** * Entry rules 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-07 14:14:32 UTC (rev 3453) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -116,6 +116,12 @@ } + /** Rules to check before delete fiscals periods */ + @Override + public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) + throws LimaException { + } + /** * Rules to check if an account and all his subaccount is not used * Recursive function @@ -401,4 +407,5 @@ throw new LimaException("Can't check financial transaction", ex); } } + } 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 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -37,6 +37,7 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodImpl; +import org.chorem.lima.entity.FinancialTransactionDAO; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.FiscalPeriodDAO; import org.nuiton.topia.TopiaException; @@ -194,6 +195,28 @@ } /** + * Règles de vérification de supression d'un exercice, appliquées à la comptabilité française. + * + * On ne peut supprimer qu'une periode comptable ouverte vide. + */ + @Override + public void deleteFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LimaBusinessException { + + try { + + FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO(); + + //Check if the fiscal period to delete is empty + if (financialTransactionDAO.findAllByDates(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()).size() != 0) { + throw new LimaBusinessException(_("lima-business.franceaccountingrules.fiscalperiodnotempty")); + } + } catch (TopiaException ex) { + throw new LimaException("Can't check rule", ex); + } + + } + + /** * Check if old financialperiod for a an entrybook are closed before bock the asked closedperiodicentrybook * <p/> * get all closedperiodicentrybook between the first financial period of fiscalperiod 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-07 14:14:32 UTC (rev 3453) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -58,6 +58,8 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; 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.EntryImpl; @@ -447,4 +449,49 @@ } } + @Override + /** + * to delete a fiscal period + * <p/> + * check localized rules before delete it + */ + public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) + throws LimaException { + + AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules(); + + try { + try { + //get entities with DAO + FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO(); + + // re-attach entities to current session + FiscalPeriod localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId()); + + //check rules + accountingRules.deleteFiscalPeriodRules(localFiscalPeriod); + + //all "ClosedPeriodicEntryBooks" for the fiscal period + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO(); + List<ClosedPeriodicEntryBook> closedPeriodicEntryBookDAOList = closedPeriodicEntryBookDAO.findAllClosedPeriodicEntryBooksFromFiscalPeriod(localFiscalPeriod); + + //delete closedPeriodicEntryBook before fiscal period + for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookDAOList) { + // fix : ObjectDeletedException: deleted object would be re-saved by cascade (Need to delete association between entryBook and financial period via closedPeriodEntityBook) + closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook); + closedPeriodicEntryBookDAO.delete(closedPeriodicEntryBook); + } + + fiscalPeriodDAO.delete(localFiscalPeriod); + + } catch (TopiaException ex) { + throw new LimaException("Can't find fiscal period", ex); + } + + } catch (Exception ex) { + throw new LimaException("Can't delete period", ex); + } + + } + } Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2012-06-18 16:31:34 UTC (rev 3454) @@ -68,6 +68,7 @@ lima-business.franceaccountingrules.accountstartnumbererror=Master account is not a digit between 1 to 8 \: %d lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=The previous financial periods for this entrybook must be blocked before this lima-business.franceaccountingrules.antefiscalperiodnotblocked=The ante fiscal period is not locked +lima-business.franceaccountingrules.fiscalperiodnotempty=The fiscal period is not empty \! lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=The new fiscal period must adjoining the last lima-business.import.accountadded=SUCCES \: Account %s - %s added\n lima-business.import.accountalreadyexist=FAILED \: Account %s already exist \n Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-18 16:31:34 UTC (rev 3454) @@ -67,8 +67,9 @@ lima-business.franceaccountingrules.accountnumbernotnumeric=Le numéro de copte n'est pas numéric \: %s lima-business.franceaccountingrules.accountstartnumbererror=Le numéro du copte général n'est pas compris entre 1 et 8 \: %d lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=Les périodes financières précédentes pour ce journal doivent être bloquées avant -lima-business.franceaccountingrules.antefiscalperiodnotblocked=La période fiscale précédante n'est pas bloquée -lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=La nouvelle période fiscale doit suivre la précédante +lima-business.franceaccountingrules.antefiscalperiodnotblocked=La période fiscale précédente n'est pas bloquée +lima-business.franceaccountingrules.fiscalperiodnotempty=La période fiscale à supprimer n'est pas vide \! +lima-business.franceaccountingrules.newfiscalperiodadjoiningerror=La nouvelle période fiscale doit suivre la précédente lima-business.import.accountadded=Succès \: Compte %s - %s ajouté\n lima-business.import.accountalreadyexist=Échec \: Le compte %s existe déjà \n lima-business.import.closedperiodicentrybookupdated=Succès \: La période financière %s - %s - %s est ajoutée \! \n Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -53,6 +53,8 @@ FiscalPeriod createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException; FiscalPeriod blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException; + + void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException; void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear, Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -175,5 +175,23 @@ List<ClosedPeriodicEntryBook> result = context.find(query); return result; } + + /** + * Retourne les ClosedPeriodicEntryBook d'un exercice ouvert. + * + * @return les ClosedPeriodicEntryBook + * @throws TopiaException + */ + public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromFiscalPeriod(FiscalPeriod fiscalPeriod) throws TopiaException { + String query = "SELECT C FROM " + ClosedPeriodicEntryBook.class.getName() + " C" + + ", " + FiscalPeriod.class.getName() + " F" + + " WHERE C.financialPeriod IN ELEMENTS (F.financialPeriod)" + + " AND F = :fiscalPeriod" + + " ORDER BY C.financialPeriod.beginDate"; + + List<ClosedPeriodicEntryBook> result = context.find(query, "fiscalPeriod", fiscalPeriod); + return result; + } + } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodDAOImpl.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -112,5 +112,5 @@ } return result; - } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -129,6 +129,12 @@ fireTableRowsInserted(row, row); } + public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) { + int row = fiscalPeriods.indexOf(fiscalPeriod); + fiscalPeriods.remove(fiscalPeriod); + fireTableRowsDeleted(row, row); + } + public void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException { /*List<FinancialTransaction> financialTransactionsUnbal = financialTransactionService.getAllInexactFinancialTransactions(fiscalPeriod); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2012-06-18 16:31:34 UTC (rev 3454) @@ -48,7 +48,9 @@ id="fiscalPeriodTable" sortable="false" rowHeight="24" constructorParams="getFiscalPeriodTableModel()" selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" - columnControlVisible="true"/> + columnControlVisible="true" + onActionPerformed="getHandler().reloadEnablingButton()" + /> <ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()" onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/> @@ -68,4 +70,18 @@ onActionPerformed="getHandler().blockFiscalPeriod()"/> </cell> </row> + <row> + <cell fill="horizontal"> + <JButton id="deleteButton" text="lima.charts.fiscalperiod.delete" + enabled="{isSelectedPeriod()}" + onActionPerformed="getHandler().deleteFiscalPeriod()"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JButton id="modifyButton" text="lima.charts.fiscalperiod.delete" + enabled="{isSelectedPeriod()}" + onActionPerformed="getHandler().deleteFiscalPeriod()"/> + </cell> + </row> </Table> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.out.xml =================================================================== 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 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-06-18 16:31:34 UTC (rev 3454) @@ -129,6 +129,30 @@ } /** + * Undisplay period and perform delete. + */ + public void deleteFiscalPeriod() { + + JXTable fiscalPeriodeTable = view.getFiscalPeriodTable(); + FiscalPeriodTableModel model = (FiscalPeriodTableModel) view.getFiscalPeriodTable().getModel(); + + //check if the user want to delete the fiscal year + int response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.delete.confirmation"), + _("lima.ui.fiscalperiod.delete.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.WARNING_MESSAGE); + + int selectedRow = fiscalPeriodeTable.getSelectedRow(); + FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow); + + if (response == JOptionPane.YES_OPTION) { + fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod); + + model.deleteFiscalPeriod(selectedFiscalPeriod); + } + } + + /** * Init add period view. * * @param addPeriod view to init @@ -265,4 +289,11 @@ loadAllFiscalPeriod(); } } + + /** + * manage + * */ + public void reloadEnablingButton(){ + + } } 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 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-06-18 16:31:34 UTC (rev 3454) @@ -25,6 +25,7 @@ lima.charts.fiscalperiod.add=Add fiscalperiod lima.charts.fiscalperiod.block=Block fiscalperiod lima.charts.fiscalperiod.create=Create fiscalperiod +lima.charts.fiscalperiod.delete=Delete fiscalperiod lima.charts.fiscalyear=Fiscal Years lima.charts.vatpdf=PDF structure lima.charts.vatstatement=VAT statement chart @@ -263,6 +264,8 @@ lima.ui.fiscalperiod.block.title= lima.ui.fiscalperiod.closed= lima.ui.fiscalperiod.closure= +lima.ui.fiscalperiod.delete.confirmation= +lima.ui.fiscalperiod.delete.title= lima.ui.fiscalperiod.fiscalperiod= lima.ui.fiscalperiod.open= lima.ui.home.account= 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 2012-06-07 14:14:32 UTC (rev 3453) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-18 16:31:34 UTC (rev 3454) @@ -25,6 +25,7 @@ lima.charts.fiscalperiod.add=Nouvel exercice lima.charts.fiscalperiod.block=Cloturer un exercice lima.charts.fiscalperiod.create=Choisissez la date de début et de fin du nouvel exercice +lima.charts.fiscalperiod.delete=Supprimer un exercice lima.charts.fiscalyear=Exercices lima.charts.vatpdf=Structure du pdf lima.charts.vatstatement=Plan TVA @@ -263,6 +264,8 @@ lima.ui.fiscalperiod.block.title=Cloture de l'exercice lima.ui.fiscalperiod.closed=Cloturé lima.ui.fiscalperiod.closure=Cloture +lima.ui.fiscalperiod.delete.confirmation=Ètes vous sûre de vouloir supprimer cette période ? Cette action est irréversible \! +lima.ui.fiscalperiod.delete.title=Suppression de l'exercice lima.ui.fiscalperiod.fiscalperiod=Exercice lima.ui.fiscalperiod.open=Ouvert lima.ui.home.account=Plan comptable
participants (1)
-
mallon@users.chorem.org