Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/invoice_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def destroy

private
def ii_params
params.require(:invoice_item).permit(:memo, :category, :price, :line_no)
params.require(:invoice_item).permit(:memo, :category, :price, :notes, :line_no)
end
end
11 changes: 11 additions & 0 deletions app/javascript/src/invoices.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ $ ->
window.chooseLinePreset = (id) ->
if $("#invoice-line-preset-" + id).val() != ""
selected = $("#invoice-line-preset-" + id + " option:selected").first()
if(selected.data('notes'))
showNotes(id)
$("#invoice_invoice_lines_attributes_" + id + "_notes").val(selected.data('notes'))
$("#invoice_invoice_lines_attributes_" + id + "_category").val(selected.data('category'))
$("#invoice_invoice_lines_attributes_" + id + "_memo").val(selected.data('memo'))
$("#invoice_invoice_lines_attributes_" + id + "_notes").val(selected.data('notes'))
Comment thread
tomas-goncalves marked this conversation as resolved.
$("#invoice_invoice_lines_attributes_" + id + "_quantity").val("1")
$("#invoice_invoice_lines_attributes_" + id + "_price").val(selected.data('price'))

Expand All @@ -32,6 +36,13 @@ window.toggleNotes = (id) ->
note.css("display","none")
link.html("V")

window.showNotes = (id) ->
note = $("#notes" + id)
link = $("#notesToggle" + id)
if note.css("display") == "none"
note.css("display","block")
link.html("^")

window.indexList = () ->
$('input.index').each( (i) ->
$(this).val(i))
Expand Down
8 changes: 8 additions & 0 deletions app/views/invoice_items/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@
<td class="subheading"><%= f.label :category %>:</td>
<td><%= f.select :category, InvoiceLine::Invoice_Categories %></td>
</tr>
<tr>
<td class="subheading"><%= f.label :notes %>:</td>
<td><%= f.text_area :notes, :size => "35x3" %></td>
</tr>
Comment thread
tomas-goncalves marked this conversation as resolved.
Outdated
<tr>
<td class="subheading"><%= f.label :price %>:</td>
<td><%= f.text_field :price %></td>
</tr>
<tr>
<td class="subheading"><%= f.label :notes %>:</td>
<td><%= f.text_area :notes, :size => "35x3" %></td>
</tr>
<tr>
<td></td>
<td><%= f.submit %></td>
Expand Down
2 changes: 2 additions & 0 deletions app/views/invoice_items/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<th>Memo</th>
<th>Category</th>
<th>Price</th>
<th>Notes</th>
<% if can? :update, InvoiceItem %>
<th></th>
<% end %>
Expand All @@ -18,6 +19,7 @@
<td><%= item.memo %></td>
<td><%= item.category %></td>
<td><%= number_to_currency item.price %></td>
<td><%= simple_format item.notes %></td>
<% if can? :update, item %>
<td><%= link_to 'Edit', edit_invoice_item_url(item) %></td>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/invoices/_invoice_line_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<option></option>

<% InvoiceItem.all.each do |item| %>
<option data-memo="<%= item.memo %>" data-category="<%= item.category %>" data-price="<%= item.price %>"><%= item.memo %></option>
<option data-memo="<%= item.memo %>" data-notes="<%= item.notes %>" data-category="<%= item.category %>" data-price="<%= item.price %>"><%= item.memo %></option>
<% end %>
</select>
</td>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20250923064313_add_notes_to_invoice_items.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddNotesToInvoiceItems < ActiveRecord::Migration[6.1]
def change
add_column :invoice_items, :notes, :text
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.