From 735bc7d25b053eaac1dc9047a39d71e8f64d5153 Mon Sep 17 00:00:00 2001 From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com> Date: Tue, 23 Sep 2025 03:14:01 -0400 Subject: [PATCH 1/3] Feat: Allow Invoice Items to have Notes --- app/controllers/invoice_items_controller.rb | 2 +- app/javascript/src/invoices.coffee | 11 +++++++++++ app/views/invoice_items/_form.html.erb | 8 ++++++++ app/views/invoice_items/index.html.erb | 2 ++ app/views/invoices/_invoice_line_fields.html.erb | 2 +- .../20250923064313_add_notes_to_invoice_items.rb | 5 +++++ db/schema.rb | 3 ++- 7 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20250923064313_add_notes_to_invoice_items.rb 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..380ddb22 100644 --- a/app/javascript/src/invoices.coffee +++ b/app/javascript/src/invoices.coffee @@ -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')) $("#invoice_invoice_lines_attributes_" + id + "_quantity").val("1") $("#invoice_invoice_lines_attributes_" + id + "_price").val(selected.data('price')) @@ -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)) diff --git a/app/views/invoice_items/_form.html.erb b/app/views/invoice_items/_form.html.erb index 53b0f880..24cbaff2 100644 --- a/app/views/invoice_items/_form.html.erb +++ b/app/views/invoice_items/_form.html.erb @@ -19,10 +19,18 @@ <%= f.label :category %>: <%= f.select :category, InvoiceLine::Invoice_Categories %> + + <%= f.label :notes %>: + <%= f.text_area :notes, :size => "35x3" %> + <%= 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 5ebbca98..934b8870 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: 2024_10_07_223900) 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| From cd259734d7aba79ebb88bd02384d255e05eafb32 Mon Sep 17 00:00:00 2001 From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com> Date: Thu, 2 Oct 2025 17:59:32 -0400 Subject: [PATCH 2/3] Remove duplicated line from invoices.coffee --- app/javascript/src/invoices.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/javascript/src/invoices.coffee b/app/javascript/src/invoices.coffee index 380ddb22..76f70d90 100644 --- a/app/javascript/src/invoices.coffee +++ b/app/javascript/src/invoices.coffee @@ -19,7 +19,6 @@ window.chooseLinePreset = (id) -> 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')) @@ -57,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)) From 5c744271cf7750d17645e07a39c60ca0b835a412 Mon Sep 17 00:00:00 2001 From: TBG <43731728+tomas-goncalves@users.noreply.github.com> Date: Fri, 21 Nov 2025 17:37:08 -0500 Subject: [PATCH 3/3] Update app/views/invoice_items/_form.html.erb Co-authored-by: Perry Naseck <4472083+DaAwesomeP@users.noreply.github.com> --- app/views/invoice_items/_form.html.erb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/invoice_items/_form.html.erb b/app/views/invoice_items/_form.html.erb index 24cbaff2..5735a164 100644 --- a/app/views/invoice_items/_form.html.erb +++ b/app/views/invoice_items/_form.html.erb @@ -19,10 +19,6 @@ <%= f.label :category %>: <%= f.select :category, InvoiceLine::Invoice_Categories %> - - <%= f.label :notes %>: - <%= f.text_area :notes, :size => "35x3" %> - <%= f.label :price %>: <%= f.text_field :price %>