portrait Security and Organization records
[smr.git] / gui / app / views / asset / index.html.erb
blob38cea079dcef157c2dae53af4e27f85181564313
2 <h1>Assets</h1>
4 <% if @quote %>
5     <%= render :partial=>'quote_form', locals: { :quote=>@quote, :securities=>@securities  } %>
6 <% end %>
8 <div id='assets_invested' class="overview_counters">
9   <ul>
10     <li>Invested: <span><%= smr_humanize(@assets.invested, :shortword=>true) %></span></li>
11     <li>Market Value:  <span><%= smr_humanize(@assets.market_value, :shortword=>true) %></span></li>
12     <% if @assets.profit_loss>=0 then %>
13         <li class="profit">Profit: <span><%= smr_humanize(@assets.profit_loss, :shortword=>true) %> (<%= percentage_change(@assets.invested, @assets.market_value) %>)</span></li>
14     <% else %>
15         <li class="loss">Loss: <span><%= smr_humanize(@assets.profit_loss, :shortword=>true) %> (<%= percentage_change(@assets.invested, @assets.market_value) %>)</span></li>
16     <% end %>
17     <% if @assets.collateral_coverage_value > 0 then %>
18        <li>Collateral:  <span><%= smr_humanize(@assets.collateral_coverage_value, :shortword=>true) %></span></li>
19     <% end %>
20   </ul>
21 </div>
23 <%= form_tag({:action=>'index'}, :method=>:get, :id=>'controller_filter') do %>
24     <p>
25      <%= select_tag :portfolio, options_from_collection_for_select(@portfolios, :id, :name, @portfolio), prompt: '-- All Portfolios --' %>
26      <%= button_tag :show, :name=>'show', :value=>'this' %>
27     </p>
28 <% end %>
30 <h2>Open Positions</h2>
31 <table id='assets'>
32   <thead>
33     <tr>
34         <th></th>
35         <th>Average Cost<span>per share</span></th>
36         <th>Last Trade</th>
37         <th>Market Value</th>
38         <th>Profit / Loss</th>
39         <th>Weight</th>
40     </tr>
41   </thead>
42   <tbody>
43   <% @open_positions.sort.reverse.each do |p| %>
44     <tr class="separaterows">
45       <td>
46         <%= link_to '+', p.link.to_url %> <%= p.security %>
47         <span><%=p.security.symbol%> <%= link_to 'IR', p.security.url%></span>
48         <% if not p.comment.blank? %><span class="comment_text"><%= 'at %s:' % p.portfolio if p.is_cash_position? %> <%= p.comment %></span><% end %>
49       </td>
50       <td><%= smr_humanize(p.cost_price) %></td>
51       <td><% if not p.last_quote.quote %>-<% else %><%= p.last_quote.quote %> <span class='<%= p.last_quote.css_class(smr_browse_date) %>'>&bull;</span><% end %></td>
52       <td><%= smr_humanize(p.market_value) %></td>
53       <td class="<%= smr_profitloss_status(p.profit_loss, :css=>true) %>">
54         <%= smr_humanize(p.profit_loss) %>
55         <span><%= percentage_change(p.invested, p.market_value) %></span>
56       </td>
57       <td><%= percentage_of(@assets.market_value, p.market_value) %></td>
58     </tr>
59   <% end %>
60   </tbody>
61 </table>