r3156 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod
Author: vsalaun Date: 2011-06-06 11:46:38 +0200 (Mon, 06 Jun 2011) New Revision: 3156 Url: http://chorem.org/repositories/revision/lima/3156 Log: #345 adding trigger button, EntryBook selector 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/FiscalPeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 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 2011-06-06 09:18:53 UTC (rev 3155) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-06-06 09:46:38 UTC (rev 3156) @@ -40,9 +40,11 @@ import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; import org.chorem.lima.business.ImportServiceMonitorable; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.utils.FiscalPeriodComparator; +import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; @@ -242,6 +244,33 @@ refresh(); } } + + /** + * Sets FiscalPeriods and call for performing adding retained earnings + * @param selectedRow + * @param entryBook + * @throws LimaException + */ + public void addRetainedEarnings(int selectedRow, EntryBook entryBook) throws LimaException { + + FiscalPeriod fiscalPeriod = getFiscalPeriodAtRow(selectedRow); + //check if the current fiscal period isn't block + if (fiscalPeriod.getLocked()) { + throw new LimaBusinessException("The fiscal period is blocked"); + } + if (selectedRow == 0) { + throw new LimaBusinessException("Can't find previous fiscal period"); + } + + //check if the previous fiscal period exists, if so check if it is blocked + FiscalPeriod previousFiscalPeriod = getFiscalPeriodAtRow(selectedRow-1); + if (!previousFiscalPeriod.getLocked()) { + throw new LimaBusinessException("The previous fiscal period isn't blocked"); + } + + financialTransactionService.addRetainedEarnings(previousFiscalPeriod, fiscalPeriod, entryBook); + + } @Override public void notifyMethod(String serviceName, String methodeName) { 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 2011-06-06 09:18:53 UTC (rev 3155) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2011-06-06 09:46:38 UTC (rev 3156) @@ -40,7 +40,7 @@ ]]> </script> <row> - <cell fill="both" weightx="1" weighty="1" rows="4"> + <cell fill="both" weightx="1" weighty="1" rows="5"> <JScrollPane> <org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel id="modelFiscalPeriodTable"/> @@ -61,9 +61,15 @@ </cell> </row> <row> - <cell> + <cell fill="horizontal"> <JButton id="blockButton" text="lima.charts.fiscalperiod.block" enabled="{isSelectedPeriod()}" onActionPerformed="getHandler().blockFiscalPeriod()" /> </cell> </row> + <row> + <cell fill="horizontal"> + <JButton id="ranButton" text="lima.charts.fiscalperiod.addretainedearnings" enabled="{isSelectedPeriod()}" + onActionPerformed="getHandler().addRetainedEarnings()" /> + </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 2011-06-06 09:18:53 UTC (rev 3155) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-06-06 09:46:38 UTC (rev 3156) @@ -33,6 +33,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.EntryBookImpl; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.ui.fiscalperiod.AddPeriod; import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; @@ -125,7 +127,42 @@ DialogHelper.showMessageDialog(eee.getMessage()); } } + + /** + * Checks confirmation from user + * Sets EntryBook to use + */ + public void addRetainedEarnings() { + JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); + int selectedRow = fiscalPeriodeTable.getSelectedRow(); + FiscalPeriodTableModel model = + (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); + try { + int response = JOptionPane.showConfirmDialog(view, _("lima.charts.fiscalperiod.addretainedearnings"), + _("lima.common.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + if (response == JOptionPane.YES_OPTION) { + EntryBook newEntryBook = new EntryBookImpl(); + RetainedEarningsEntryBookForm entryBookForm = new RetainedEarningsEntryBookForm(view); + entryBookForm.setEntryBook(newEntryBook); + // jaxx constructor don't call super() ? + entryBookForm.setLocationRelativeTo(view); + entryBookForm.setVisible(true); + // null == cancel action + EntryBook entryBook = entryBookForm.getEntryBook(); + if (entryBook != null) { + model.addRetainedEarnings(selectedRow, entryBook); + } + } + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't set net income", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + + } + } + public FiscalPeriodView getView() { return view; }
participants (1)
-
vsalaun@users.chorem.org