Permalink
Browse files

Form for LineItems

  • Loading branch information...
danielfone committed Oct 19, 2013
1 parent 5e52fbc commit 257d3f26b95881d384300fc18f6e9645a24d8432
Showing with 33 additions and 6 deletions.
  1. +8 −0 app/models/line_item.rb
  2. +25 −6 app/views/reimbursements/_form.html.erb
View
@@ -0,0 +1,8 @@
+class LineItem
+ include ActiveModel::Model
+
+ attr_accessor :detail, :code, :dept, :amount, :gst
+
+ validates_presence_of :detail, :code, :dept
+ validates_numericality_of :amount
+end
@@ -19,12 +19,31 @@
<%= f.text_area :comments, :class => 'text_field', rows: 5 %>
</div>
</div>
- <div class="control-group">
- <%= f.label :data, :class => 'control-label' %>
- <div class="controls">
- <%= f.text_field :data, :class => 'text_field' %>
- </div>
- </div>
+
+ <fieldset>
+ <legend>Line Items</legend>
+ <table class="table">
+ <thead>
+ <tr>
+ <th>Detail</th>
+ <th>Code</th>
+ <th>Dept/Project</th>
+ <th>Amount</th>
+ <th>GST?</th>
+ </tr>
+ </thead>
+ <%- @reimbursement.line_items << LineItem.new -%>
+ <%= f.fields_for :line_items do |ff| %>
+ <tr>
+ <td><%= ff.text_field :detail %></td>
+ <td><%= ff.select :code, ['Overheads', 'Misc'], prompt: true %></td>
+ <td><%= ff.select :dept, ['Sales', 'Engineering', 'R & D'], prompt: true %></td>
+ <td><%= ff.number_field :amount, step: 0.01 %></td>
+ <td><%= ff.check_box :gst %></td>
+ </tr>
+ <%- end -%>
+ </table>
+ </fieldset>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>

0 comments on commit 257d3f2

Please sign in to comment.