added security type models, improved cashflow, bug- and layout fixes along the way
[smr.git] / gui / app / views / position / _overview_gain.html.erb
blob24376f1a1a71ccc12ee7702b7505c1ceb0b4ef32
1 <div class="overview_container">
2 <table id="overview_gain">
3   <thead>
4     <tr><th colspan="2">Gain</th></tr>
5   </thead>
6   <tbody>
7 <% if position.is_closed? and not position.is_viewed_before_closure? %>
8     <tr><td>Purchased Volume</td><td><%= smr_humanize(position.purchase_volume) %></td></tr>
9     <tr><td>Settled Volume</td><td><%= smr_humanize(position.settled_volume) %></td></tr>
10     <tr>
11         <td>= <%= smr_profitloss_status(position.profit_loss) %></td>
12         <td class="<%= smr_profitloss_status(position.profit_loss, :css=>true) %>">
13             <%= smr_humanize(position.profit_loss) %>
14             <span><%= percentage_change(position.purchase_volume, position.settled_volume) %></span>
15         </td>
16     </tr>
17 <% else %>
18     <tr><td>Invested Money</td><td><%= smr_humanize(position.invested) %></td></tr>
19     <tr><td>Market Value</td><td><%= smr_humanize(position.market_value) %></td></tr>
20     <tr>
21         <td>= <%= smr_profitloss_status(position.profit_loss) %></td>
22         <td class="<%= smr_profitloss_status(position.profit_loss, :css=>true) %>">
23             <%= smr_humanize(position.profit_loss) %>
24             <span><%= percentage_change(position.invested, position.market_value)%></span>
25         </td>
26     </tr>
27 <% end %>
28     <tr>
29         <td>Charges</td>
30         <td><%= smr_humanize(position.charges*-1) %>
31             <span><%= if position.is_closed? then
32                     percentage_of(position.purchase_volume, position.charges)
33                 else percentage_of(position.invested, position.charges) end%></span>
34         </td>
35     </tr>
36     <tr>
37         <td><%= case position.security.type.to_sym
38                     when :stock then 'Dividend Received'
39                     when :bond then 'Coupons Received'
40                     when :fund then 'Distributions Received'
41                     else 'Proceeds'
42                 end %></td>
43         <td><%= smr_humanize(position.dividend.received) %>
44 <% if position.is_closed? and not position.is_viewed_before_closure? %>
45             <span><%= percentage_of(position.purchase_volume, position.dividend.received) %>b</span>
46 <% else %>
47             <span><%= percentage_of(position.invested, position.dividend.received)%></span>
48 <% end %>
49         </td>
50     </tr>
51     <tr><td>Accrued Interest Balance</td><td><%= smr_humanize(position.accrued_interest) %></td></tr>
52     <tr>
53         <td>= Gain</td>
54         <td class="<%= smr_profitloss_status(position.gain, :css=>true) %>">
55             <%= smr_humanize(position.gain) %>
56 <% if position.is_closed? and not position.is_viewed_before_closure? %>
57             <span><%= percentage_of(position.purchase_volume, position.gain) %></span>
58 <% else %>
59             <span><%= percentage_change(position.invested, position.dirty_value) %></span>
60 <% end %>
61         </td>
62     </tr>
63   </tbody>
64 </table>
65 </div>