How to go about solving this (Design patterns)
<p>I have a billing system in which different type of customers have different type of discount schemes. And for a given bill, a net payable amount should be generated based on the type of the customer and the product.</p>

<p>And there are few rules too. Like :</p>

<p>•If the user is an employee of the store, he gets a 30% discount</p>

<p>•If the user is an affiliate of the store, he gets a 10% discount</p>

<p>•If the user has been a customer for over 2 years, he gets a 5% discount.</p>

<p>•For every $100 on the bill, there would be a $ 5 discount (e.g. for $ 990, you get $ 45 as a discount).</p>

<p>•The percentage based discounts do not apply on groceries
...</p>

<p>I had few Ideas in my mind. 1st bet is to think about a decorator pattern :</p>

<pre><code>Customer &lt;&lt;Interface&gt;&gt;     

|                       
CustomerImpl  



DiscountDecorator &lt;&lt;AbstractClass&gt;&gt; imp Customer

 |             |            |           |
AffiDiscount   StoreEmp   OverTwoYears   AnyOtherDisc
               Discount     Discount       Discount
Items  { 
//? ? :/
}
</code></pre>

<p>But then the <code>Discounts</code> are dependent on <code>Items</code> as well.</p>

<p>What are my options?</p>

<ul>
<li>extend <code>Customer</code> Interface with an <code>Item</code> Interface to keep track on type of item?</li>
<li>Pass <code>List</code> of <code>Items</code> to the discount classes.
...
How to properly have co-relation with <code>Customer</code> and <code>Item</code> classes so that I can decorate them together?</li>
</ul>