Examples of MonetaryAmount


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

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

        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

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

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

    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

Examples of common.money.MonetaryAmount

        beneficiary.setName(rs.getString("name"));
       
        Percentage percentage = new Percentage(rs.getDouble("allocation_percentage"));
        beneficiary.setAllocationPercentage(percentage);
       
        MonetaryAmount amount = new MonetaryAmount(rs.getDouble("savings"));
        beneficiary.setSavings(amount);
       
        Account account = new Account();
        account.setEntityId(rs.getLong("account_id"));
        beneficiary.setAccount(account);
View Full Code Here

Examples of common.money.MonetaryAmount

  // TODO 1: Add transactional annotation to identify this method as needing transactional behavior
  // TODO 3: Add non-default propagation level (don't do this until instructed)
  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
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.