Examples of MonetaryAmount


Examples of common.money.MonetaryAmount

   * @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

Examples of common.money.MonetaryAmount

    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

Examples of common.money.MonetaryAmount

  }

  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

Examples of common.money.MonetaryAmount

   * Enapsulates the lgoic to map a row in a ResultSet to a Reward object.
   */
  private static class RewardMapper implements ParameterizedRowMapper<Reward> {
    public Reward mapRow(ResultSet rs, int rowNum) throws SQLException {
      return new Reward(rs.getString(1), rs.getString(2), rs.getString(3), SimpleDate.valueOf(rs.getDate(4)),
          new MonetaryAmount(rs.getDouble(5)));
    }
View Full Code Here

Examples of common.money.MonetaryAmount

   * @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

Examples of common.money.MonetaryAmount

  @Transactional
  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);
    return rewardRepository.confirmReward(contribution, dining);
  }
View Full Code Here

Examples of common.money.MonetaryAmount

   * @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

Examples of common.money.MonetaryAmount

  public RewardConfirmation rewardAccountFor(Dining dining) {

    Account account = accountMapper.findByCreditCard(dining.getCreditCardNumber());
    Restaurant restaurant = restaurantMapper.findByMerchantNumber(dining.getMerchantNumber());
    MonetaryAmount amount = restaurant.calculateBenefitFor(account, dining);
    AccountContribution contribution = account.makeContribution(amount);
    updateBeneficiaries(account);
    return rewardRepository.confirmReward(contribution, dining);
  }
View Full Code Here

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

Examples of common.money.MonetaryAmount

  @Override
  public Object getResult(CallableStatement cs, int columnIndex)
      throws SQLException {
    double amount = cs.getDouble(columnIndex);
        return new MonetaryAmount(amount);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.