Package org.zkoss.zss.engine.xel

Examples of org.zkoss.zss.engine.xel.SSErrorXelException


   */
  public static Object financialAccrintm(Object[] args, XelContext ctx) {
    double rate = CommonFns.toNumber(args[2]).doubleValue();
    double par = CommonFns.toNumber(args[3]).doubleValue();
    if(rate <= 0 || par <= 0) {
      throw new SSErrorXelException(SSError.NUM);
    }
    Date issue = UtilFns.stringToDate(args[0].toString());
    Date settle = UtilFns.stringToDate(args[1].toString());
    int basis = 0;
    if(args.length == 5) {
View Full Code Here


  public static Object financialCouppcd(Object[] args, XelContext ctx) {
    Date settle = UtilFns.stringToDate(args[0].toString());
    Date maturi = UtilFns.stringToDate(args[1].toString());
    if(settle.after(maturi))
    {
      throw new SSErrorXelException(SSError.NUM);
    }
    int frequency = frequency(CommonFns.toNumber(args[2]).intValue());
    int basis = 0;
    if(args.length == 4) {
      basis = basis(CommonFns.toNumber(args[3]).intValue());     
View Full Code Here

    double pv = CommonFns.toNumber(args[2]).doubleValue();
    int startPer = (int)Math.floor(CommonFns.toNumber(args[3]).doubleValue());
    int endPer = (int)Math.floor(CommonFns.toNumber(args[4]).doubleValue());
   
    if(rate == 0 || nper == 0 || pv == 0 || startPer < 1 || endPer < 1 || startPer > endPer) {
      throw new SSErrorXelException(SSError.NUM);
    }
    else {
    int type = 0;
    if(args.length > 5)
    {
      type = CommonFns.toNumber(args[5]).intValue();
    }
   
    if( type != 0 && type != 1)
    {
      throw new SSErrorXelException(SSError.NUM);
    }
   
    double cumipmt = 0.0;
    //first calculate PMT for feed into the following magic formula.
    double pmt = pmt(rate, nper, pv, 0.0, type);
View Full Code Here

    double nper = Math.floor(CommonFns.toNumber(args[1]).doubleValue());
    double pv = CommonFns.toNumber(args[2]).doubleValue();
    int startPer = (int)Math.floor(CommonFns.toNumber(args[3]).doubleValue());
    int endPer = (int)Math.floor(CommonFns.toNumber(args[4]).doubleValue());
    if(rate == 0 || nper == 0 || pv == 0 || startPer < 1 || endPer < 1 || startPer > endPer) {
      throw new SSErrorXelException(SSError.NUM);
    }
    else {
    int type = 0;
    if(args.length > 5)
    {
      type = CommonFns.toNumber(args[5]).intValue();
    }
    if(type != 0 && type != 1)
    {
      throw new SSErrorXelException(SSError.NUM);
    }
   
    double cumppmt = 0.0;
    //first calculate PMT for feed into the following magic formula.
    double pmt = pmt(rate, nper, pv, 0.0, type);
View Full Code Here

    double cost = 0;
    double salvage = 0;
    if(args[0] != null) {
      cost = CommonFns.toNumber(args[0]).doubleValue();
      if(cost < 0) {
        throw new SSErrorXelException(SSError.NUM);
      }
    }
    if(args[1] != null) {
      salvage = CommonFns.toNumber(args[1]).doubleValue();
      if(salvage < 0) {
        throw new SSErrorXelException(SSError.NUM);
      }
    }
    if(args[2] == null || args[3] == null) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      double life = CommonFns.toNumber(args[2]).doubleValue();
      double period = CommonFns.toNumber(args[3]).doubleValue();
      if(life < 0 || period < 0) {
        throw new SSErrorXelException(SSError.NUM);
      }
      if(period-1 > life) {
        throw new SSErrorXelException(SSError.NUM);
      } else {
        double month = 12.0;
        if(args.length==5) {
          month = CommonFns.toNumber(args[4]).doubleValue();
        }
View Full Code Here

    double cost = 0;
    double salvage = 0;
    if(args[0] != null) {
      cost = CommonFns.toNumber(args[0]).doubleValue();
      if(cost < 0) {
        throw new SSErrorXelException(SSError.NUM);
      }
    }
    if(args[1] != null) {
      salvage = CommonFns.toNumber(args[1]).doubleValue();
      if(salvage < 0) {
        throw new SSErrorXelException(SSError.NUM);
      }
    }
    if(args[2] == null || args[3] == null) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      double life = CommonFns.toNumber(args[2]).doubleValue();
      double period = CommonFns.toNumber(args[3]).doubleValue();
      if(life < 0 || period < 0) {
        throw new SSErrorXelException(SSError.NUM);
      }
      if(period > life) {
        throw new SSErrorXelException(SSError.NUM);
      } else {
        double factor = 2;
        if(args.length==5) {
          factor = CommonFns.toNumber(args[4]).doubleValue();
        }
View Full Code Here

   */
  public static Object financialDisc(Object[] args, XelContext ctx) {
    double pr = CommonFns.toNumber(args[2]).doubleValue();
    double redemption = CommonFns.toNumber(args[3]).doubleValue();
    if(pr <= 0 || redemption <= 0) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      Date settlement = UtilFns.stringToDate(args[0].toString());
      Date maturity = UtilFns.stringToDate(args[1].toString());
      int basis = 0;
      if(args.length == 5) {
View Full Code Here

  public static Object financialDuration(Object[] args, XelContext ctx) {
    Date settle = UtilFns.stringToDate(args[0].toString());
    Date maturi = UtilFns.stringToDate(args[1].toString());
    if(settle.after(maturi))
    {
      throw new SSErrorXelException(SSError.NUM);
    }
    double coupon = CommonFns.toNumber(args[2]).doubleValue();
    double yld = CommonFns.toNumber(args[3]).doubleValue();
    if(!(yld > 0 || coupon > 0 ))
    {
      throw new SSErrorXelException(SSError.NUM);
    }
    int freq = 1;
    try{
      freq = CommonFns.toNumber(args[4]).intValue();
      }catch(ClassCastException e){
        throw new SSErrorXelException(SSError.NUM);
      }
    if( freq != 1 && freq != 2 && freq != 4 )
    {
      throw new SSErrorXelException(SSError.NUM);
    }
    int basis = 0;
    if(args.length == 6)
    {
      try{
View Full Code Here

   */
  public static Object financialEffect(Object[] args, XelContext ctx) {
    double rate = CommonFns.toNumber(args[0]).doubleValue();
    double npery = Math.floor(CommonFns.toNumber(args[1]).doubleValue());
    if(rate <= 0 || npery < 1) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      double effect = Math.pow(1+rate/npery, npery)-1;
      return new Double(effect);
    }
  }
View Full Code Here

   */
  public static Object financialIntrate(Object[] args, XelContext ctx) {
    double investment = CommonFns.toNumber(args[2]).doubleValue();
    double redemption = CommonFns.toNumber(args[3]).doubleValue();
    if(investment <= 0 || redemption <= 0) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      Date settlement = UtilFns.stringToDate(args[0].toString());
      Date maturity = UtilFns.stringToDate(args[1].toString());
      int basis = 0;
      if(args.length == 5) {
View Full Code Here

TOP

Related Classes of org.zkoss.zss.engine.xel.SSErrorXelException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.