manage bookmarks, bugfixes
[smr.git] / gui / app / views / report / index.html.erb
blob86a6cc7854a762e0b2d41bfcd6a2ce108de8e810
2 <h1>Report</h1>
4 <%= form_tag({:action=>'index'}, :method=>:get, :id=>'controller_filter') do %>
5     <p>
6      <%= select_tag 'timeframe', options_for_select(@timeframes, @timeframe) , prompt: '-- Time Frame --' %>
7      <%= select_tag 'portfolio', options_from_collection_for_select(@portfolios, :id, :name, @portfolio) , prompt: '-- All Portfolios --' %>
8      <%= submit_tag 'Run Report' %>
9     </p>
10 <% end %>
12 <div id='report_statistic_summary'>
13   <ul>
14     <% if  @realized_gain >=0 then %>
15         <li class="profit">Realized Profit: <em><%= smr_humanize @realized_gain, :shortword=>true %></em></li>
16     <% else %>
17         <li class="loss">Realized Loss: <em><%= smr_humanize @realized_gain, :shortword=>true %></em></li>
18     <% end %>
19     <li>Revenue:            <em><%= smr_humanize @revenue, :shortword=>true  %></em></li>
20   </ul>
21 </div>
23 <h2>Asset Development</h2>
24 <table id='asset_totals'>
25   <thead>
26     <tr>
27         <th></th>
28         <th>Invested</th>
29         <th>Market Value</th>
30         <th>Profit / Loss</th>
31     </tr>
32   </thead>
33   <tbody>
34   <%
35     this_market_value = 0
36     prev_market_value = 0
38   @asset_totals.each do |t|
39     this_market_value = t.market_value
40     prev_market_value = this_market_value if prev_market_value == 0
41     change = percentage_change(prev_market_value, this_market_value) || '-'
42   %>
43     <tr class="separaterows">
44       <td>
45         <%= link_to '+', asset_index_path %>
46         <%= smr_humanize t.date, :time_for_humans=>true %>
47       </td>
48       <td><%= smr_humanize t.invested, :shortword=>true %></td>
49       <td>
50         <%= smr_humanize this_market_value, :shortword=>true %>
51         <span class="<%= if change.length == 1 then ''
52                        elsif change.length>2 and change.starts_with?'-' then 'loss'
53                        else 'profit' end %>">
54           <%= change %>
55         </span>
56       </td>
57       <td class="<%= smr_profitloss_status t.profit_loss, :css=>true %>">
58          <%= smr_humanize t.profit_loss, :shortword=>true %>
59       </td>
60     </tr>
61   <%
62     prev_market_value = this_market_value
63   end
64   %>
65   </tbody>
66 </table>
68 <% unless @closed_positions.empty? %>
69 <h2>Closed Positions</h2>
70 <table id='closed_positions'>
71   <thead>
72     <tr>
73         <th></th>
74         <th>Sold At</th>
75         <th>Purchase Volume</th>
76         <th>Settled Volume</th>
77         <th>Charges Paid</th>
78         <th>Dividend / Interest Received</th>
79         <th>Gain</th>
80     </tr>
81   </thead>
82   <tbody>
83   <% @closed_positions.each do |p| %>
84     <tr class="separaterows">
85       <td>
86         <%= link_to '+', p.link.to_url %> <%= p.security %>
87         <span>
88            <span class="symbol"><%=p.security.symbol%></span>
89         </span>
90         <% if not p.comment.blank? %><span class="comment_text"><%= 'at %s:' % p.portfolio if p.is_cash_position? %> <%= p.comment %></span><% end %>
91       </td>
92       <td><%= smr_humanize p.time_closed %></td>
93       <td><%= smr_humanize p.purchase_volume %></td>
94       <td><%= smr_humanize p.settled_volume %></td>
95       <td>
96         <%= smr_humanize p.charges %>
97         <% if p.charges > 0 %><span><%= smr_humanize p.charges_per_kilo, :scale=>2 %>per 1k</span><% end %>
98       </td>
99       <td><%= smr_humanize p.dividend.received %></td>
100       <td class="<%= smr_profitloss_status p.profit_loss, :css=>true %>">
101         <%= smr_humanize p.gain %>
102         <span><%= percentage_of(p.purchase_volume, p.gain) %></span>
103       </td>
104     </tr>
105   <% end %>
106   </tbody>
107 </table>
108 <% end %>