r3750 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/fiscalperiod resources/i18n
Author: sbavencoff Date: 2014-02-28 16:18:09 +0100 (Fri, 28 Feb 2014) New Revision: 3750 Url: http://chorem.org/projects/lima/repository/revisions/3750 Log: fixes #768 : Report ?\195?\160 nouveau impossible ?\195?\160 ?\195?\169tablir Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsWait.jaxx Modified: 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-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2014-02-28 10:04:45 UTC (rev 3749) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2014-02-28 15:18:09 UTC (rev 3750) @@ -25,6 +25,7 @@ package org.chorem.lima.ui.fiscalperiod; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -299,13 +300,13 @@ */ public void blockFiscalPeriod() { FiscalPeriodTable table = view.getFiscalPeriodTable(); - FiscalPeriodTableModel tableModel = view.getFiscalPeriodTableModel(); + final FiscalPeriodTableModel tableModel = view.getFiscalPeriodTableModel(); - int selectedRow = table.getSelectedRow(); + final int selectedRow = table.getSelectedRow(); if (selectedRow >= 0) { - FiscalPeriod selectedFiscalPeriod = tableModel.get(selectedRow); + final FiscalPeriod selectedFiscalPeriod = tableModel.get(selectedRow); if (!selectedFiscalPeriod.isLocked()) { @@ -316,31 +317,38 @@ JOptionPane.WARNING_MESSAGE); if (answerBlock == JOptionPane.YES_OPTION) { - boolean retainedEarnings = false; - EntryBook entryBook = null; - // find next fiscal year - FiscalPeriod lastFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); - if (selectedFiscalPeriod.equals(lastFiscalPeriod)) { + //report if they are at least one transaction to be report + if (fiscalPeriodService.isRetainedEarnings(selectedFiscalPeriod)) { - //check if the user wants to create a new fiscal year - int answerCreate = JOptionPane.showConfirmDialog(view, - _("lima.ui.fiscalperiod.block.newyear"), - _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + // find next fiscal year + FiscalPeriod lastFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); + if (selectedFiscalPeriod.equals(lastFiscalPeriod)) { - // create a new fiscal year - if (answerCreate == JOptionPane.YES_OPTION) { - addFiscalPeriod(); + //check if the user wants to create a new fiscal year + int answerCreate = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.block.newyear"), + _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + + // create a new fiscal year + if (answerCreate == JOptionPane.YES_OPTION) { + addFiscalPeriod(); + } } - } - // if next fiscal year exist - if (selectedFiscalPeriod.equals(lastFiscalPeriod)) { - //report if they are at least one transaction to be report - if (fiscalPeriodService.isRetainedEarnings(selectedFiscalPeriod)) { + lastFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); + // check if next fiscal year don't exist + if (selectedFiscalPeriod.equals(lastFiscalPeriod)) { + JOptionPane.showMessageDialog(view, + _("lima.ui.fiscalperiod.block.cantBalanceIfNextPeriodNotExist"), + _("lima.ui.fiscalperiod.block.title"), + JOptionPane.ERROR_MESSAGE); + + } else { + //check if the user wants to report datas int answerRetainedEarnings = JOptionPane.showConfirmDialog(view, _("lima.ui.fiscalperiod.block.addretainedearnings"), @@ -348,8 +356,6 @@ JOptionPane.QUESTION_MESSAGE); if (answerRetainedEarnings == JOptionPane.YES_OPTION) { - retainedEarnings = true; - //Sets EntryBook EntryBook newEntryBook = new EntryBookImpl(); RetainedEarningsEntryBookForm entryBookForm = @@ -359,16 +365,58 @@ // jaxx constructor don't call super() ? entryBookForm.setLocationRelativeTo(view); entryBookForm.setVisible(true); - entryBook = entryBookForm.getEntryBook(); + final EntryBook entryBook = entryBookForm.getEntryBook(); + + if (entryBook != null && StringUtils.isNotBlank(entryBook.getCode())) { + + final RetainedEarningsWait retainedEarningsWait = new RetainedEarningsWait(view); + retainedEarningsWait.setLocationRelativeTo(view); + + new SwingWorker<FiscalPeriod, Void>() { + @Override + protected FiscalPeriod doInBackground() throws Exception { + FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, true); + tableModel.setValue(selectedRow, fiscalPeriodBlocked); + + view.setBlockEnabled(false); + view.setDeleteEnabled(false); + + return fiscalPeriodBlocked; + } + + @Override + protected void done() { + retainedEarningsWait.setVisible(false); + } + }.execute(); + retainedEarningsWait.setVisible(true); + + } else { + + JOptionPane.showMessageDialog(view, + _("lima.ui.fiscalperiod.block.cantBalanceNotBook"), + _("lima.ui.fiscalperiod.block.title"), + JOptionPane.ERROR_MESSAGE); + } + + } else { + + JOptionPane.showMessageDialog(view, + _("lima.ui.fiscalperiod.block.cantBlockNotBalance"), + _("lima.ui.fiscalperiod.block.title"), + JOptionPane.ERROR_MESSAGE); } } - } - FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, retainedEarnings); - tableModel.setValue(selectedRow, fiscalPeriodBlocked); + } else { - view.setBlockEnabled(false); - view.setDeleteEnabled(false); + FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod); + tableModel.setValue(selectedRow, fiscalPeriodBlocked); + + view.setBlockEnabled(false); + view.setDeleteEnabled(false); + + } } } } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsWait.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsWait.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsWait.jaxx 2014-02-28 15:18:09 UTC (rev 3750) @@ -0,0 +1,12 @@ +<JDialog modal="true" id="waitDialog" title="lima.ui.importexport.waittitle"> + <Table> + <row> + <cell> + <org.jdesktop.swingx.JXBusyLabel id='busylabel' busy='true'/> + </cell> + <cell> + <JLabel text='lima.ui.retainedEarnings.wait'/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file 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 2014-02-28 10:04:45 UTC (rev 3749) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-02-28 15:18:09 UTC (rev 3750) @@ -353,6 +353,9 @@ lima.ui.fiscalperiod.addfiscalperiodtitle= lima.ui.fiscalperiod.begin= lima.ui.fiscalperiod.block.addretainedearnings= +lima.ui.fiscalperiod.block.cantBalanceIfNextPeriodNotExist= +lima.ui.fiscalperiod.block.cantBalanceNotBook= +lima.ui.fiscalperiod.block.cantBlockNotBalance= lima.ui.fiscalperiod.block.confirmation= lima.ui.fiscalperiod.block.newyear= lima.ui.fiscalperiod.block.retainedearningstitle= @@ -452,6 +455,7 @@ lima.ui.opening.next=Next lima.ui.opening.title= lima.ui.opening.welcome=<html><center>Welcome to Lima<br/>this assistant help you to start your business accounting in the blink of an eye<br/>OR import instantanly your already existing save in CSV format<br/><br/><br/><br/></center></html> +lima.ui.retainedEarnings.wait= lima.ui.table.cell.colorSelectionFocus= lima.ui.table.cell.comportmentEditingCell= lima.ui.table.cell.selectAllEditingCell= 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 2014-02-28 10:04:45 UTC (rev 3749) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-02-28 15:18:09 UTC (rev 3750) @@ -335,6 +335,9 @@ lima.ui.fiscalperiod.addfiscalperiodtitle=Nouvel exercice lima.ui.fiscalperiod.begin=Début lima.ui.fiscalperiod.block.addretainedearnings=Reporter à nouveau? +lima.ui.fiscalperiod.block.cantBalanceIfNextPeriodNotExist=Impossible de créer le report à nouveaux. L'exercice fiscal suivant n'existe pas +lima.ui.fiscalperiod.block.cantBalanceNotBook=Impossible de créer le report à nouveaux. aucun journal n'est selectioné. +lima.ui.fiscalperiod.block.cantBlockNotBalance=Impossible de clôturer un exercice non equilibré lima.ui.fiscalperiod.block.confirmation=Ètes vous sûre de vouloir clôturer cette période ? Cette action est irréversible \! lima.ui.fiscalperiod.block.newyear=Voulez vous créer un nouvel exercice? lima.ui.fiscalperiod.block.retainedearningstitle=Report à nouveau @@ -429,6 +432,7 @@ lima.ui.opening.next=Suivant lima.ui.opening.title=Initialisation lima.ui.opening.welcome=<html><center>Bienvenue dans Lima<br/>Laissez vous guider par cet assistant pour démarrer votre comptabilité en quelques instants <br/>Ou bien importer directement une ancienne sauvegarde de LIMA au format CSV<br/><br/><br/><br/></center></html> +lima.ui.retainedEarnings.wait=Report à nouveaux... lima.vatreport.listerror=Erreur lors de la récupération des données de la liste lima.vatstatement.accounts=Liste des comptes lima.vatstatement.boxname=PDF BoxName
participants (1)
-
sbavencoff@users.chorem.org