From 0a22a6333b7795d515afd0778ee5763e5971746f Mon Sep 17 00:00:00 2001 From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com> Date: Mon, 22 Sep 2025 21:17:43 -0400 Subject: [PATCH 1/3] Feat: Invoice Labor notes default --- app/models/invoice_line.rb | 10 ++++++++++ app/views/invoices/prettyView.html.erb | 4 ++-- app/views/invoices/show.html.erb | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) mode change 100755 => 100644 app/views/invoices/show.html.erb diff --git a/app/models/invoice_line.rb b/app/models/invoice_line.rb index e10686f4..b5a8b2f1 100644 --- a/app/models/invoice_line.rb +++ b/app/models/invoice_line.rb @@ -21,4 +21,14 @@ def <=> (il) return -1 if Invoice_Categories.find_index(il.category).nil? return Invoice_Categories.find_index(category) <=> Invoice_Categories.find_index(il.category) end + + def get_notes_with_defaults + if not self.notes.empty? + self.notes + else + if category == "Labor" + "Labor hours are estimates; Actual hours will be billed." + end + end + end end diff --git a/app/views/invoices/prettyView.html.erb b/app/views/invoices/prettyView.html.erb index 739eaa33..99bccb85 100644 --- a/app/views/invoices/prettyView.html.erb +++ b/app/views/invoices/prettyView.html.erb @@ -159,10 +159,10 @@ <%=line.category %> <%=line.memo %> - <% if line.notes.to_s.length > 0 then %> + <% if line.get_notes_with_defaults.to_s.length > 0 then %>
- <%= simple_format line.notes %> + <%= simple_format line.get_notes_with_defaults %>
<% end %> diff --git a/app/views/invoices/show.html.erb b/app/views/invoices/show.html.erb old mode 100755 new mode 100644 index df36a562..04a6527b --- a/app/views/invoices/show.html.erb +++ b/app/views/invoices/show.html.erb @@ -57,8 +57,8 @@ <%= line.category %> <%= line.memo %> - <% if line.notes and not line.notes.empty? %> - <%= simple_format line.notes %> + <% if line.get_notes_with_defaults and not line.get_notes_with_defaults.empty? %> + <%= simple_format line.get_notes_with_defaults %> <% end %> <% if can? :readprice, @invoice %> From 94df67b419050c686feea84f7396665d70c8f8f6 Mon Sep 17 00:00:00 2001 From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com> Date: Mon, 22 Sep 2025 21:21:17 -0400 Subject: [PATCH 2/3] Make sure this only happens with quotes --- app/models/invoice_line.rb | 6 ++++-- app/views/invoices/prettyView.html.erb | 4 ++-- app/views/invoices/show.html.erb | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/invoice_line.rb b/app/models/invoice_line.rb index b5a8b2f1..32f85569 100644 --- a/app/models/invoice_line.rb +++ b/app/models/invoice_line.rb @@ -22,12 +22,14 @@ def <=> (il) return Invoice_Categories.find_index(category) <=> Invoice_Categories.find_index(il.category) end - def get_notes_with_defaults + def get_notes_with_defaults(status) if not self.notes.empty? self.notes else - if category == "Labor" + if category == "Labor" and status == "Quote" "Labor hours are estimates; Actual hours will be billed." + else + nil end end end diff --git a/app/views/invoices/prettyView.html.erb b/app/views/invoices/prettyView.html.erb index 99bccb85..66104918 100644 --- a/app/views/invoices/prettyView.html.erb +++ b/app/views/invoices/prettyView.html.erb @@ -159,10 +159,10 @@ <%=line.category %> <%=line.memo %> - <% if line.get_notes_with_defaults.to_s.length > 0 then %> + <% if line.get_notes_with_defaults(@invoice.status).to_s.length > 0 then %>
- <%= simple_format line.get_notes_with_defaults %> + <%= simple_format line.get_notes_with_defaults(@invoice.status) %>
<% end %> diff --git a/app/views/invoices/show.html.erb b/app/views/invoices/show.html.erb index 04a6527b..7b320328 100644 --- a/app/views/invoices/show.html.erb +++ b/app/views/invoices/show.html.erb @@ -57,8 +57,8 @@ <%= line.category %> <%= line.memo %> - <% if line.get_notes_with_defaults and not line.get_notes_with_defaults.empty? %> - <%= simple_format line.get_notes_with_defaults %> + <% if line.get_notes_with_defaults(@invoice.status) and not line.get_notes_with_defaults(@invoice.status).empty? %> + <%= simple_format line.get_notes_with_defaults(@invoice.status) %> <% end %> <% if can? :readprice, @invoice %> From 9a202588b5518dc36c338b0f236438bc47bd6c88 Mon Sep 17 00:00:00 2001 From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com> Date: Tue, 23 Sep 2025 03:21:32 -0400 Subject: [PATCH 3/3] improve functions names and parameters --- app/models/invoice_line.rb | 4 ++-- app/views/invoices/prettyView.html.erb | 4 ++-- app/views/invoices/show.html.erb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/invoice_line.rb b/app/models/invoice_line.rb index 32f85569..f25b4501 100644 --- a/app/models/invoice_line.rb +++ b/app/models/invoice_line.rb @@ -22,11 +22,11 @@ def <=> (il) return Invoice_Categories.find_index(category) <=> Invoice_Categories.find_index(il.category) end - def get_notes_with_defaults(status) + def notes_with_defaults if not self.notes.empty? self.notes else - if category == "Labor" and status == "Quote" + if category == "Labor" and self.invoice.status == "Quote" "Labor hours are estimates; Actual hours will be billed." else nil diff --git a/app/views/invoices/prettyView.html.erb b/app/views/invoices/prettyView.html.erb index 66104918..72a76097 100644 --- a/app/views/invoices/prettyView.html.erb +++ b/app/views/invoices/prettyView.html.erb @@ -159,10 +159,10 @@ <%=line.category %> <%=line.memo %> - <% if line.get_notes_with_defaults(@invoice.status).to_s.length > 0 then %> + <% if line.notes_with_defaults.to_s.length > 0 then %>
- <%= simple_format line.get_notes_with_defaults(@invoice.status) %> + <%= simple_format line.notes_with_defaults %>
<% end %> diff --git a/app/views/invoices/show.html.erb b/app/views/invoices/show.html.erb index 7b320328..40eb9c0d 100644 --- a/app/views/invoices/show.html.erb +++ b/app/views/invoices/show.html.erb @@ -57,8 +57,8 @@ <%= line.category %> <%= line.memo %> - <% if line.get_notes_with_defaults(@invoice.status) and not line.get_notes_with_defaults(@invoice.status).empty? %> - <%= simple_format line.get_notes_with_defaults(@invoice.status) %> + <% if line.notes_with_defaults and not line.notes_with_defaults.empty? %> + <%= simple_format line.notes_with_defaults %> <% end %> <% if can? :readprice, @invoice %>