Update of /cvsroot/tcotool/TCO-Tool/plugins/ch.softenvironment.tcotool.finance/source/ch/softenvironment/tcotool/finance In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv16793/plugins/ch.softenvironment.tcotool.finance/source/ch/softenvironment/tcotool/finance Modified Files: ReportDepreciation.java Added Files: SEPlugin.java Removed Files: ReportPlugin.java FinancialCalculator.java Log Message: Calculation enhanced --- FinancialCalculator.java DELETED --- --- ReportPlugin.java DELETED --- --- NEW FILE: SEPlugin.java --- package ch.softenvironment.tcotool.finance; /* * Copyright (C) 2006 Peter Hirzel softEnvironment (http://www.softenvironment.ch). * All rights reserved. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ import javax.swing.JComponent; import javax.swing.JMenuItem; import org.java.plugin.Plugin; import org.tcotool.application.LauncherView; import org.tcotool.core.runtime.ApplicationPlugin; import org.tcotool.model.TcoObject; import org.tcotool.pluginsupport.PluginUtility; import org.tcotool.standard.report.ReportTool; import org.tcotool.tools.ModelUtility; /** * Free <i>soft</i>Environment Plugins (might serve as sample). * PLUGIN_ID = "ch.softenvironment.tcotool.finance"; * @author Peter Hirzel <i>soft</i>Environment * @version $Revision: 1.1 $ $Date: 2008/06/18 15:28:16 $ */ public final class SEPlugin extends Plugin implements org.tcotool.pluginsupport.Menu { protected static final String REPORT_HEADER = "ReportHeader.png"; /** * Constructor. */ public SEPlugin() { super(); } /** * @see org.java.plugin.Plugin#doStart() */ protected void doStart() throws Exception { } /** * @see org.java.plugin.Plugin#doStop() */ protected void doStop() throws Exception { } /** * Menu was clicked -> generate the report. * @see org.tcotool.pluginsupport.Menu#init(javax.swing.JComponent) */ public void actionPerform(final JComponent item, final Object object) { ApplicationPlugin.showBusy(new Runnable() { public void run() { try { String actionCommand = ((JMenuItem)item).getActionCommand(); if (actionCommand.equals("depreciation" /*@see plugin.xml=>id*/)) { reportFinancialTotal(ModelUtility.getTcoPackageOrRoot(object)); } } catch(Throwable e) { LauncherView.getInstance().handleException(e); } } }); } /** * Depreciation-Report. */ private void reportFinancialTotal(TcoObject root) throws Throwable { LauncherView.getInstance().addReport(ReportDepreciation.createBlockDepreciation(root, ReportTool.getDepreciationDuration(), PluginUtility.getClassLoader(this))); } } Index: ReportDepreciation.java =================================================================== RCS file: /cvsroot/tcotool/TCO-Tool/plugins/ch.softenvironment.tcotool.finance/source/ch/softenvironment/tcotool/finance/ReportDepreciation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReportDepreciation.java 13 Jun 2007 20:21:38 -0000 1.1 --- ReportDepreciation.java 18 Jun 2008 15:28:16 -0000 1.2 *************** *** 23,26 **** --- 23,29 ---- import org.tcotool.standard.report.ReportTool; import org.tcotool.tools.Calculator; + import org.tcotool.tools.CalculatorDegressiveDepreciation; + import org.tcotool.tools.CalculatorLinearDepreciation; + import org.tcotool.tools.CalculatorLinearDepreciationCompountInterest; import org.tcotool.application.*; *************** *** 28,31 **** --- 31,35 ---- import ch.softenvironment.jomm.DbObjectServer; import ch.softenvironment.jomm.serialize.AttributeList; + import ch.softenvironment.view.BaseDialog; /** *************** *** 39,42 **** --- 43,47 ---- class ReportDepreciation extends ReportTool { private ClassLoader loader = null; + private long maxDepreciation = 0; protected ReportDepreciation(String title) { *************** *** 44,53 **** } /** ! * Summarize all Depreciation-Costs within given object and subpackages. */ public static ReportTool createBlockDepreciation(TcoObject root, long maxDepreciation, ClassLoader loader) throws java.lang.Throwable { ! ReportDepreciation tool = new ReportDepreciation(ResourceManager.getResource(ReportPlugin.class, "MniReportFinancialTotal_text", loader)); tool.loader = loader; ! tool.calculator = new FinancialCalculator(LauncherView.getInstance().getUtility(), root, maxDepreciation); tool.totalCost(root); return tool; --- 49,59 ---- } /** ! * Summarize all Depreciation-Costs within given object and sub-packages. */ public static ReportTool createBlockDepreciation(TcoObject root, long maxDepreciation, ClassLoader loader) throws java.lang.Throwable { ! ReportDepreciation tool = new ReportDepreciation(ResourceManager.getResource(SEPlugin.class, "MniReportFinancialTotal_text", loader)); tool.loader = loader; ! tool.maxDepreciation = maxDepreciation; ! //tool.calculator = new CalculatorLinearDepreciation(LauncherView.getInstance().getUtility(), root, maxDepreciation); tool.totalCost(root); return tool; *************** *** 58,62 **** public void startBody(AttributeList list) throws IOException { super.startBody(list); ! java.net.URL url = loader.getResource(ReportPlugin.REPORT_HEADER); image(url, "", 0); } --- 64,68 ---- public void startBody(AttributeList list) throws IOException { super.startBody(list); ! java.net.URL url = loader.getResource(SEPlugin.REPORT_HEADER); image(url, "", 0); } *************** *** 65,76 **** */ protected void encodeCodes(DbObjectServer server, TcoObject root) throws Throwable { ! encodeDepreciation(root, ResourceManager.getResource(ReportPlugin.class, "CTLinearDepreciation", loader), FinancialCalculator.DEPRECIATION_LINEAR); ! encodeDepreciation(root, ResourceManager.getResource(ReportPlugin.class, "CTDegressiveDepreciation", loader), FinancialCalculator.DEPRECIATION_GEOMETRIC_DEGRESSIVE); } ! private void encodeDepreciation(TcoObject root, String title, final String type) throws IOException { startParagraph(); ! List totalCosts = ((FinancialCalculator)calculator).getDepreciationCostBlock(root, type); bold(title); ! simpleContent(" " + ResourceManager.getResource(ReportPlugin.class, "CQFactCostIncluded", loader) + ":" /*getRsc("CIFactCostOverAll")*/); breakLine(); --- 71,90 ---- */ protected void encodeCodes(DbObjectServer server, TcoObject root) throws Throwable { ! calculator = new CalculatorLinearDepreciation(LauncherView.getInstance().getUtility(), root, maxDepreciation); ! encodeDepreciation(root, ResourceManager.getResource(SEPlugin.class, "CTLinearDepreciation", loader)); ! calculator = new CalculatorLinearDepreciationCompountInterest(LauncherView.getInstance().getUtility(), root, maxDepreciation); ! if (calculator.isBaseOffsetInvolved()) { ! //TODO NLS ! BaseDialog.showWarning(LauncherView.getInstance(), "Calculation without warranty", "The Base-Offset (de: Basis-Offset) is not yet considered in this report, sorry."); ! } ! encodeDepreciation(root, ResourceManager.getResource(SEPlugin.class, "CTLinearDepreciationCompoundInterest", loader)); ! calculator = new CalculatorDegressiveDepreciation(LauncherView.getInstance().getUtility(), root, maxDepreciation); ! encodeDepreciation(root, ResourceManager.getResource(SEPlugin.class, "CTDegressiveDepreciation", loader)); } ! private void encodeDepreciation(TcoObject root, String title/*, final String type*/) throws IOException { startParagraph(); ! List totalCosts = calculator.getTotalCosts(root, Calculator.KIND_FC); //getDepreciationCostBlock(root, type); bold(title); ! simpleContent(" " + ResourceManager.getResource(SEPlugin.class, "CQFactCostIncluded", loader) + ":" /*getRsc("CIFactCostOverAll")*/); breakLine(); *************** *** 92,96 **** startTableRow(); ! for (int i=0; i<totalCosts.size(); i++) { double amount = Calculator.getValue(totalCosts, i); tableDataAmount(amount, true); --- 106,110 ---- startTableRow(); ! for (int i=0; i<calculator.getDurationYears()+1; i++) { double amount = Calculator.getValue(totalCosts, i); tableDataAmount(amount, true); *************** *** 100,106 **** String tmp = ""; ! if (type.equals(FinancialCalculator.DEPRECIATION_GEOMETRIC_DEGRESSIVE)) { tmp = "; " + ResourceManager.getResourceAsNonLabeled(SystemParameterDetailView.class, "LblDepreciationInterestRate_text") + " = " + LauncherView.getInstance().getUtility().getInterestRate() + "%"; ! } encodeCostUnit(tmp); --- 114,120 ---- String tmp = ""; ! //if (type.equals(Calculator.DEPRECIATION_GEOMETRIC_DEGRESSIVE)) { tmp = "; " + ResourceManager.getResourceAsNonLabeled(SystemParameterDetailView.class, "LblDepreciationInterestRate_text") + " = " + LauncherView.getInstance().getUtility().getInterestRate() + "%"; ! //} encodeCostUnit(tmp); |