Author: mallon Date: 2012-06-19 14:14:39 +0200 (Tue, 19 Jun 2012) New Revision: 3456 Url: http://chorem.org/repositories/revision/lima/3456 Log: Correction de la gestion des boutons des exercices (Modification, suppression) Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.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 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-19 08:57:25 UTC (rev 3455) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-06-19 12:14:39 UTC (rev 3456) @@ -131,6 +131,7 @@ addDays(dateLastFiscalPeriod, 1); dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE); Date dateFiscalPeriod = fiscalPeriod.getBeginDate(); + if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) { throw new LimaBusinessException(_("lima-business.franceaccountingrules.newfiscalperiodadjoiningerror")); } @@ -216,6 +217,7 @@ } + /** * Check if old financialperiod for a an entrybook are closed before bock the asked closedperiodicentrybook * <p/> 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-19 08:57:25 UTC (rev 3455) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-06-19 12:14:39 UTC (rev 3456) @@ -134,7 +134,7 @@ 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-19 08:57:25 UTC (rev 3455) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2012-06-19 12:14:39 UTC (rev 3456) @@ -47,9 +47,8 @@ <FiscalPeriodTable id="fiscalPeriodTable" sortable="false" rowHeight="24" constructorParams="getFiscalPeriodTableModel()" - selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" + selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" columnControlVisible="true" - onActionPerformed="getHandler().reloadEnablingButton()" /> <ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()" @@ -77,11 +76,4 @@ 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> 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-19 08:57:25 UTC (rev 3455) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-06-19 12:14:39 UTC (rev 3456) @@ -109,19 +109,9 @@ addPeriodDialog.setVisible(true); FiscalPeriod fiscalPeriod = addPeriodDialog.getPeriod(); - // null = cancel - if (fiscalPeriod != null) { - //check if fiscalperiod have 12 months, ask a confirmation - int nbMonth = DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(), - fiscalPeriod.getEndDate()); - int response = JOptionPane.YES_OPTION; - if (nbMonth != 12) { - response = JOptionPane.showConfirmDialog(view, - _("lima.ui.fiscalperiod.addfiscalperiod.morethan12"), - _("lima.ui.fiscalperiod.addfiscalperiodtitle"), - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - } - if (response == JOptionPane.YES_OPTION) { + if (fiscalPeriod != null) { + int response = JOptionPane.YES_OPTION; + if (response == checkTimeFiscalPeriod(fiscalPeriod)) { fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod); model.addFiscalPeriod(fiscalPeriod); } @@ -151,7 +141,7 @@ model.deleteFiscalPeriod(selectedFiscalPeriod); } } - + /** * Init add period view. * @@ -291,9 +281,44 @@ } /** - * manage + * Manage the differents buttons for fiscal period * */ - public void reloadEnablingButton(){ - + public void reloadEnablingButton() + { + System.out.println("reloadEnablingButton"); + + //get the fiscal period selected + JXTable fiscalPeriodeTable = view.getFiscalPeriodTable(); + FiscalPeriodTableModel model = view.getFiscalPeriodTableModel(); + FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(fiscalPeriodeTable.getSelectedRow()); + + if (selectedFiscalPeriod.getLocked()) + { + System.out.println("Fiscal period closed"); + view.getBlockButton().setEnabled(false); + view.getDeleteButton().setEnabled(false); + } + else + { + System.out.println("Fiscal period opened"); + view.getBlockButton().setEnabled(true); + view.getDeleteButton().setEnabled(true); + } } + + private int checkTimeFiscalPeriod(FiscalPeriod fiscalPeriod){ + //check if fiscalperiod have 12 months, ask a confirmation + int nbMonth = DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(), + fiscalPeriod.getEndDate()); + int response = JOptionPane.YES_OPTION; + if (nbMonth != 12) { + response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.addfiscalperiod.morethan12"), + _("lima.ui.fiscalperiod.addfiscalperiodtitle"), + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + } + + return response; + } + }
participants (1)
-
mallon@users.chorem.org