organized code into Smr module
[smr.git] / gui / app / views / assets / index.html.erb
blob15c4cb1b8d7a44aebd68d0c580a5fac44282d8ba
2 <h1>Assets</h1>
4 <% if @quote %>
5     <%= form_for @quote, :url=>{action: :create}, :method=>:POST do |f| %>
6      <fieldset id='quote'>
7       <legend><% if @quote.id %>Update<% else %>Add New<% end %> Quote Data</legend>
8         <%= f.hidden_field :id %>
9         <%= f.select :id_stock, options_from_collection_for_select(@securities, :id, :name, @quote.id), :prompt=>'-- Select Security --' %><br/>
10         <%= date_field_tag :time, @quote.time, :placeholder=>'Date payment received'  %><br/>
11         <%= f.number_field :quote, :placeholder=>'Quote Traded', :step=>0.0001 %><br/>
12         <%= f.number_field :low, :placeholder=>'Day Low', :step=>0.0001 %><br/>
13         <%= f.number_field :high, :placeholder=>'Day High', :step=>0.0001 %><br/>
14         <%= f.number_field :volume, :placeholder=>'Volume Traded', :step=>1 %><br/>
15         <%= f.text_field :exchange, :placeholder=>'Exchange' %><br/>
16         <br/>
17         <%= f.submit 'Save Quotation' %>
18       </div>
19      </fieldset>
20     <% end %>
21 <% end %>
23 <ul id='assets_invested'>
24     <li>Invested: <em><%= smr_humanize(@assets.invested) %></em></li>
25     <li>Market Value:  <em><%= smr_humanize(@assets.market_value) %></em></li>
26     <li><%= if @assets.profit_loss>=0 then 'Profit' else 'Loss' end %>: <em><%= smr_humanize(@assets.profit_loss) %> (<%= percentage_change(@assets.invested, @assets.market_value) %>)</em></li>
27 </ul>
29 <h2>Open Positions</h2>
30 <table id='assets'>
31   <thead>
32     <tr>
33     <th></th>
34     <th>Shares</th>
35     <th>Cost Price</th>
36     <th>Last Quote</th>
37     <th>Market Value</th>
38     <th>Profit/Loss</th>
39     <th>Weight</th>
40     </tr>
41   </thead>
42   <tbody>
43   <% @open_positions.each do |p| %>
44     <tr>
45       <td>
46         <%= link_to "+", controller: 'positions', action: 'show', id: p.id %><%=p.stock.name%>
47         <span><%=p.stock.symbol%> <%= link_to 'IR', p.stock.url%></span>
48       </td>
49       <td><%= smr_humanize(p.shares) %></td>
50       <td><%= smr_humanize(p.cost_price) %></td>
51       <td><%= p.last_quote %></td>
52       <td><%= smr_humanize(p.market_value) %></td>
53       <td><%= smr_humanize(p.profit_loss) %> <span><%= percentage_change(p.invested, p.market_value) %></span></td>
54       <td><%= percentage_of(@assets.market_value, p.market_value) %></td>
55     </tr>
56   <% end %>
57   </tbody>
58 </table>