Package common.money

Examples of common.money.MonetaryAmount


  @Override
  public Object getResult(ResultSet rs, String columnName)
      throws SQLException {
   
        double amount = rs.getDouble(columnName);
        return new MonetaryAmount(amount);
  }
View Full Code Here


  @Override
  public Object getResult(CallableStatement cs, int columnIndex)
      throws SQLException {
    double amount = cs.getDouble(columnIndex);
        return new MonetaryAmount(amount);
  }
View Full Code Here

    }

    public RewardConfirmation rewardAccountFor(Dining dining) {
        Account account = accountRepository.findByCreditCard(dining.getCreditCardNumber());
        Restaurant restaurant = restaurantRepository.findByMerchantNumber(dining.getMerchantNumber());
        MonetaryAmount amount = restaurant.calculateBenefitFor(account, dining);
        AccountContribution contribution = account.makeContribution(amount);
        accountRepository.updateBeneficiaries(account);
        return rewardRepository.confirmReward(contribution, dining);
    }
View Full Code Here

   * @return the individual beneficiary distributions
   */
  private Set<Distribution> distribute(MonetaryAmount amount) {
    Set<Distribution> distributions = new HashSet<Distribution>(beneficiaries.size());
    for (Beneficiary beneficiary : beneficiaries) {
      MonetaryAmount distributionAmount = amount.multiplyBy(beneficiary.getAllocationPercentage());
      beneficiary.credit(distributionAmount);
      Distribution distribution = new Distribution(beneficiary.getName(), distributionAmount, beneficiary
          .getAllocationPercentage(), beneficiary.getSavings());
      distributions.add(distribution);
    }
View Full Code Here

        String name = rs.getString("BENEFICIARY_NAME");
        if (name == null) {
            // apparently no beneficiary for this
            return null;
        }
        MonetaryAmount savings = MonetaryAmount.valueOf(rs.getString("BENEFICIARY_SAVINGS"));
        Percentage allocationPercentage = Percentage.valueOf(rs.getString("BENEFICIARY_ALLOCATION_PERCENTAGE"));
        return new Beneficiary(name, allocationPercentage, savings);
    }
View Full Code Here

   * @return the individual beneficiary distributions
   */
  private Set<Distribution> distribute(MonetaryAmount amount) {
    Set<Distribution> distributions = new HashSet<Distribution>(beneficiaries.size());
    for (Beneficiary beneficiary : beneficiaries) {
      MonetaryAmount distributionAmount = amount.multiplyBy(beneficiary.getAllocationPercentage());
      beneficiary.credit(distributionAmount);
      Distribution distribution = new Distribution(beneficiary.getName(), distributionAmount, beneficiary
          .getAllocationPercentage(), beneficiary.getSavings());
      distributions.add(distribution);
    }
View Full Code Here

   * @return an allocated beneficiary
   * @throws SQLException an exception occurred extracting data from the result set
   */
  private Beneficiary mapBeneficiary(ResultSet rs) throws SQLException {
    String name = rs.getString("BENEFICIARY_NAME");
    MonetaryAmount savings = MonetaryAmount.valueOf(rs.getString("BENEFICIARY_SAVINGS"));
    Percentage allocationPercentage = Percentage.valueOf(rs.getString("BENEFICIARY_ALLOCATION_PERCENTAGE"));
    return new Beneficiary(name, allocationPercentage, savings);
  }
View Full Code Here

    account.addBeneficiary("Annabelle");
    dining = Dining.createDining("100.00", "1234123412341234", "1234567890");
  }

  public void testCalcuateBenefitFor() {
    MonetaryAmount benefit = restaurant.calculateBenefitFor(account, dining);
    // assert 8.00 eligible for reward
    assertEquals(MonetaryAmount.valueOf("8.00"), benefit);
  }
View Full Code Here

  }

  public void testNoBenefitAvailable() {
    // configure stub that always returns false
    restaurant.setBenefitAvailabilityPolicy(new StubBenefitAvailibilityPolicy(false));
    MonetaryAmount benefit = restaurant.calculateBenefitFor(account, dining);
    // assert zero eligible for reward
    assertEquals(MonetaryAmount.valueOf("0.00"), benefit);
  }
View Full Code Here

    Map<String, Object> values = jdbcTemplate.queryForMap(sql, confirmation.getConfirmationNumber());
    verifyInsertedValues(confirmation, dining, values);
  }

  private void verifyInsertedValues(RewardConfirmation confirmation, Dining dining, Map<String, Object> values) {
    assertEquals(confirmation.getAccountContribution().getAmount(), new MonetaryAmount((Double) values
        .get("REWARD_AMOUNT")));
    assertEquals(SimpleDate.today().asDate(), values.get("REWARD_DATE"));
    assertEquals(confirmation.getAccountContribution().getAccountNumber(), values.get("ACCOUNT_NUMBER"));
    assertEquals(dining.getAmount(), new MonetaryAmount((Double) values.get("DINING_AMOUNT")));
    assertEquals(dining.getMerchantNumber(), values.get("DINING_MERCHANT_NUMBER"));
    assertEquals(SimpleDate.today().asDate(), values.get("DINING_DATE"));
  }
View Full Code Here

TOP

Related Classes of common.money.MonetaryAmount

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.