Package com.cedarsoft.business

Examples of com.cedarsoft.business.Money


      double monthYears = getTimeSystem().calculateYears( actualMonthBegin, actualMonthEnd );
      double monthDays = getTimeSystem().calculateDays( actualMonthBegin, actualMonthEnd );
      double monthRate = getInterestRateProvider().getRate( actualMonthBegin );

      //add the rent for the rent
      Money baseForMonth = rentSummer.immutable();

      Money compoundInterest;
      if ( getBackingCalculationSystem().isCompoundSystem() && baseForMonth.getValue() != 0 ) {
        compoundInterest = getBackingCalculationSystem().calculateInterest( baseForMonth, monthYears, monthDays, monthRate );
        rentSummer.plus( compoundInterest );
      } else {
        compoundInterest = Money.ZERO;
      }

      //add the rent for the amount
      Money interest = getBackingCalculationSystem().calculateInterest( amount, monthYears, monthDays, monthRate );
      rentSummer.plus( interest );

      //Build the information object (if expected)
      interestDetails.add( new InterestDetails( actualMonthBegin, actualMonthEnd, monthRate, baseForMonth, interest.plus( compoundInterest ), monthDays ) );

      //Next month --> now we really need the first day of the month
      actualMonthBegin = actualMonthBegin.plusMonths( 1 ).withDayOfMonth( 1 );
    }
View Full Code Here


  @NotNull
  private Rent calculateInterestConstantRate( @NotNull Money amount, @NotNull LocalDate begin, @NotNull LocalDate end ) {
    double years = getTimeSystem().calculateYears( begin, end );
    double days = getTimeSystem().calculateDays( begin, end );
    double rate = getInterestRateProvider().getRate( begin );
    Money interest = getBackingCalculationSystem().calculateInterest( amount, years, days, rate );

    //We need just one interest details since the interest rate is constant
    InterestDetails interestDetails = new InterestDetails( begin, begin.plusDays( 1 ), rate, amount, interest, days );//todo check end date
    return new Rent( amount, begin, end, Collections.singletonList( interestDetails ) );
  }
View Full Code Here

      actualGuess = INITIAL_RATE_GUESS;
    }

    int counter = 0;

    Money actualValue = Money.BIG;
    while ( actualValue.abs().isGreaterThan( TARGET_DELTA ) ) {
      double change = INITIAL_RATE_GUESS / Math.pow( 2, counter );

      if ( change < MIN_CHANGE ) {
        return new PangV( actualGuess, actualValue, counter, sum.immutable() );
      }

      //modify guess
      if ( !sumPositive ^ actualValue.isGreaterThan( Money.ZERO ) ) {
        actualGuess += change;
      } else {
        actualGuess -= change;
      }
View Full Code Here

      actualGuess = INITIAL_RATE_GUESS;
    }

    int counter = 0;

    Money actualValue = Money.BIG;
    while ( actualValue.abs().isGreaterThan( TARGET_DELTA ) ) {
      double change = INITIAL_RATE_GUESS / Math.pow( 2, counter );

      if ( change < MIN_CHANGE ) {
        return new PangV( actualGuess, actualValue, counter, sum.immutable() );
      }

      //modify guess
      if ( !sumPositive ^ actualValue.isGreaterThan( Money.ZERO ) ) {
        actualGuess += change;
      } else {
        actualGuess -= change;
      }
View Full Code Here

      double monthYears = getTimeSystem().calculateYears( actualMonthBegin, actualMonthEnd );
      double monthDays = getTimeSystem().calculateDays( actualMonthBegin, actualMonthEnd );
      double monthRate = getInterestRateProvider().getRate( actualMonthBegin );

      //add the rent for the rent
      Money baseForMonth = rentSummer.immutable();

      Money compoundInterest;
      if ( getBackingCalculationSystem().isCompoundSystem() && baseForMonth.getValue() != 0 ) {
        compoundInterest = getBackingCalculationSystem().calculateInterest( baseForMonth, monthYears, monthDays, monthRate );
        rentSummer.plus( compoundInterest );
      } else {
        compoundInterest = Money.ZERO;
      }

      //add the rent for the amount
      Money interest = getBackingCalculationSystem().calculateInterest( amount, monthYears, monthDays, monthRate );
      rentSummer.plus( interest );

      //Build the information object (if expected)
      interestDetails.add( new InterestDetails( actualMonthBegin, actualMonthEnd, monthRate, baseForMonth, interest.plus( compoundInterest ), monthDays ) );

      //Next month --> now we really need the first day of the month
      actualMonthBegin = actualMonthBegin.plusMonths( 1 ).withDayOfMonth( 1 );
    }
View Full Code Here

  @Nonnull
  private Rent calculateInterestConstantRate( @Nonnull Money amount, @Nonnull LocalDate begin, @Nonnull LocalDate end ) {
    double years = getTimeSystem().calculateYears( begin, end );
    double days = getTimeSystem().calculateDays( begin, end );
    double rate = getInterestRateProvider().getRate( begin );
    Money interest = getBackingCalculationSystem().calculateInterest( amount, years, days, rate );

    //We need just one interest details since the interest rate is constant
    InterestDetails interestDetails = new InterestDetails( begin, begin.plusDays( 1 ), rate, amount, interest, days );//todo check end date
    return new Rent( amount, begin, end, Collections.singletonList( interestDetails ) );
  }
View Full Code Here

      actualGuess = INITIAL_RATE_GUESS;
    }

    int counter = 0;

    Money actualValue = Money.BIG;
    while ( actualValue.abs().isGreaterThan( TARGET_DELTA ) ) {
      double change = INITIAL_RATE_GUESS / Math.pow( 2, counter );

      if ( change < MIN_CHANGE ) {
        return new PangV( actualGuess, actualValue, counter, sum.immutable() );
      }

      //modify guess
      if ( !sumPositive ^ actualValue.isGreaterThan( Money.ZERO ) ) {
        actualGuess += change;
      } else {
        actualGuess -= change;
      }
View Full Code Here

TOP

Related Classes of com.cedarsoft.business.Money

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.