Java Reference
In-Depth Information
value="update ticker set currentPrice = :price where ticker = :ticker"/>
<beans:property name="itemSqlParameterSourceProvider">
With the tickers updated, the data import is complete. From here, you can apply the business rules
as required and finally output your customers' statements. The first step of applying business logic for
this job is determining the pricing tier to which each of your customers belongs. The next section looks
at how to apply that logic to your customers' accounts.
Calculating Pricing Tiers
The Apress Investment Company charges for each transaction a customer chooses to make through it.
However, Apress Investments gives discounts based on how many transactions a customer makes in a
month. The more transactions the customer makes, the less the company charges. The pricing is divided
into four tiers. The number of transactions a customer performed in a month indicates each tier. Pricing
for a customer is based on the tier they fall into. In this section you create an ItemProcessor that
calculates the tier each customer falls into for the month.
Before you get into the technical aspects of the calculation, Table 10-1 shows how each tier is
defined and the related price that each transaction is charged based on the tier.
Table 10-1. Pricing Tiers
Fee per Transaction
$9 + .1% of the purchase price
1,001: 100,000
100,001: 1,000,000
> 1,000,000
You may wonder why you need to calculate the tiers prior to calculating the fees and why you can't
just do it all in one step. The reasons are twofold. First, processing the tiers requires only the number of
transactions a customer performed in a month and not the transactions themselves. Because of this, you
don't need to load all the transactions to make this calculation. Second, because knowing the tier is a
prerequisite for calculating the fees, it would require a lot of state management to pull off this type of
calculation in a single step, and with large numbers of transactions doing so would be impractical.
Finally, this approach also provides you with a safer implementation because this step can fail without
impacting the pricing of the transactions.
To implement this piece of functionality, you use a JDBC-based ItemReader to read in the data
required to determine the pricing tier. Once the data for each account has been read in, it's passed to the
ItemProcessor to calculate what tier the customer's account falls into. Finally, a JDBC-based ItemWriter
Search WWH ::

Custom Search