diff --git a/app/controllers/invoice_items_controller.rb b/app/controllers/invoice_items_controller.rb index 0e866d3d..fd830a19 100644 --- a/app/controllers/invoice_items_controller.rb +++ b/app/controllers/invoice_items_controller.rb @@ -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 diff --git a/app/javascript/src/invoices.coffee b/app/javascript/src/invoices.coffee index a9e2c175..76f70d90 100644 --- a/app/javascript/src/invoices.coffee +++ b/app/javascript/src/invoices.coffee @@ -17,8 +17,11 @@ $ -> 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 + "_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')) $("#invoice_invoice_lines_attributes_" + id + "_quantity").val("1") $("#invoice_invoice_lines_attributes_" + id + "_price").val(selected.data('price')) @@ -32,6 +35,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)) @@ -46,4 +56,4 @@ $ -> $("a.replace_field").click -> new_id = new Date().getTime() regexp = new RegExp("new_" + $(this).data("association"), "g") - $("#" + $(this).data("repid")).html($(this).data("content").replace(regexp, new_id)) \ No newline at end of file + $("#" + $(this).data("repid")).html($(this).data("content").replace(regexp, new_id)) diff --git a/app/views/invoice_items/_form.html.erb b/app/views/invoice_items/_form.html.erb index 53b0f880..5735a164 100644 --- a/app/views/invoice_items/_form.html.erb +++ b/app/views/invoice_items/_form.html.erb @@ -23,6 +23,10 @@ <%= f.label :price %>: <%= f.text_field :price %> + + <%= f.label :notes %>: + <%= f.text_area :notes, :size => "35x3" %> + <%= f.submit %> diff --git a/app/views/invoice_items/index.html.erb b/app/views/invoice_items/index.html.erb index e1531101..e87f0860 100644 --- a/app/views/invoice_items/index.html.erb +++ b/app/views/invoice_items/index.html.erb @@ -5,6 +5,7 @@ Memo Category Price + Notes <% if can? :update, InvoiceItem %> <% end %> @@ -18,6 +19,7 @@ <%= item.memo %> <%= item.category %> <%= number_to_currency item.price %> + <%= simple_format item.notes %> <% if can? :update, item %> <%= link_to 'Edit', edit_invoice_item_url(item) %> <% end %> diff --git a/app/views/invoices/_invoice_line_fields.html.erb b/app/views/invoices/_invoice_line_fields.html.erb index 1a21ea50..ef84cef7 100644 --- a/app/views/invoices/_invoice_line_fields.html.erb +++ b/app/views/invoices/_invoice_line_fields.html.erb @@ -8,7 +8,7 @@ <% InvoiceItem.all.each do |item| %> - + <% end %> diff --git a/db/migrate/20250923064313_add_notes_to_invoice_items.rb b/db/migrate/20250923064313_add_notes_to_invoice_items.rb new file mode 100644 index 00000000..41a77438 --- /dev/null +++ b/db/migrate/20250923064313_add_notes_to_invoice_items.rb @@ -0,0 +1,5 @@ +class AddNotesToInvoiceItems < ActiveRecord::Migration[6.1] + def change + add_column :invoice_items, :notes, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index f768eef3..a658eb45 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2025_09_08_184017) do +ActiveRecord::Schema.define(version: 2025_09_23_064313) do create_table "accounts", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t| t.string "name", limit: 255, null: false @@ -220,6 +220,7 @@ t.integer "price", null: false t.datetime "created_at" t.datetime "updated_at" + t.text "notes" end create_table "invoice_lines", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|