Package common.money

Examples of common.money.MonetaryAmount


  }

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

    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

  }

  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

    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

  @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

      FieldSet fields = reader.read();
      if (fields == null) {
        return null;
      }

      MonetaryAmount amount;
      String creditCardNumber;
      String merchantNumber;
      SimpleDate date;
      try {
        amount = MonetaryAmount.valueOf(fields.readString(0));
View Full Code Here

  @Transactional//(propagation= Propagation.REQUIRES_NEW)
  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

  @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

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

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.