manage bookmarks, bugfixes
[smr.git] / gui / app / views / portrait / index.html.erb
blobcd2e2bc2e369f51525dad08869e0a0cc172b0586
2 <h1>
3     Portrait
4     <% if @organization %><em>of <%=@organization %></em>
5     <% elsif @security %><em>of <%=@security %></em><% end %>
6 </h1>
8 <% unless @organization || @security %>
9     Access this via URL to Security or Organization.
10 <% else %>
12   <%=
13     render :partial=>'smart_links',
14         locals: {
15             :item_to_portrait=>(@security ? @security : @organization),
16             :shown_is=>(@security ? :security : :organization),
17         }
18   %>
20   <h2>Overview</h2>
21       <%= if @security
22           render :partial=>'overview_security', :locals=>{ :security=>@security }
23       else
24           render :partial=>'overview_organization', :locals=>{ :organization=>@organization }
25       end %>
26 <% end %>
28 <% unless @positions.blank? %>
29 <h2>Positions</h2>
31 <div id='portrait_positions_summary' class="overview_counters">
32   <ul>
33     <li class="<%= smr_profitloss_status @open_positions_gain, :css=>true %>">Open Positions Gain: <em><%= smr_humanize @open_positions_gain, :shortword=>true %></em></li>
34     <li>Total Gain: <em><%= smr_humanize @all_positions_gain, :shortword=>true %></em></li>
35     <li>Total Dividend: <em><%= smr_humanize @all_positions_dividend  %></em></li>
36   </ul>
37 </div>
39 <table id='portrait_positions'>
40   <thead>
41     <tr>
42         <th></th>
43         <th>Status</th>
44         <th>Average Cost<span>per share</span></th>
45         <th><% if @security %>Size<% else %>Last Trade<% end %></th>
46         <th>Profit / Loss</th>
47         <th>Dividend / Interest</th>
48     </tr>
49   </thead>
50   <tbody>
51   <% @positions.each do |p| %>
52     <tr class="separaterows">
53       <td>
54        <%= link_to '+', p.link.to_url %>
55        <% if @organization %>
56         <%= p.security %>
57        <% else %>
58         <%= p.is_closed? ? smr_humanize(p.time_closed) : '%s shares' % p.shares %>
59        <% end %>
60        <% if not p.comment.blank? %><span class="comment_text"><%= 'at %s:' % p.portfolio if p.is_cash_position? %> <%= p.comment %></span><% end %>
61       </td>
62       <td><span><%= p.status %></span> held at <%= p.portfolio %></td>
63       <td><%= smr_humanize p.cost_price %></td>
64       <td><%= if @security then
65                 smr_humanize( (p.is_closed? ? p.settled_volume : p.market_value ), :shortword=>true)
66               else p.last_quote.last end %>
67       </td>
68       <td class="<%= smr_profitloss_status p.profit_loss, :css=>true %>">
69         <%= smr_humanize p.profit_loss %>
70       </td>
71       <td>
72         <%= smr_humanize p.dividend.received %>
73       </td>
74     </tr>
75   <% end %>
76   </tbody>
77 </table>
78 <% end %>
80 <% unless @cashflow.blank? %>
81 <h2>Upcoming Cashflows</h2>
83 <div id='portrait_cashflow_summary' class="overview_counters">
84   <ul>
85     <li class="profit">Total: <em><%= smr_humanize @cashflow.total, :shortword=>true %></em></li>
86     <li>Number of Payments:   <em><%= @cashflow.count  %></em></li>
87   </ul>
88 </div>
91 <table id='portrait_cashflow'>
92   <thead>
93     <tr>
94         <th/>
95        <% if @organization %>
96         <th>Security</th>
97        <% end %>
98         <th>Type</th>
99         <th colspan="2">Amount</th>
100     </tr>
101     <tr>
102         <th/>
103        <% if @organization %>
104         <th/>
105        <% end %>
106         <th/>
107         <th>per share</th>
108         <th>absolute</th>
109     </tr>
110   </thead>
111   <tbody>
112   <% @cashflow.each do |i|
113      s = Security.find i.link.destination
114      scale = s.has_type_model? ? s.get_type.shares : 0
115   %>
116     <tr class="separaterows">
117       <td><%= smr_humanize i.date %></td>
118      <% if @organization %>
119       <td><%= s %><%= link_to '...', i.link.to_url %></td>
120      <% end %>
121       <td><%= i.describe_type %></td>
122       <td><%= smr_humanize i.total, :shortword=>true %></td>
123       <td><%= smr_humanize i.total * scale, :shortword=>true %></td>
124     </tr>
125   <% end %>
126   </tbody>
127 </table>
128 <% end %>