From cb14b99f897ead2543dcc9578f1c83b3b98222d4 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 7 Feb 2014 21:22:20 +0100 Subject: [PATCH 1/3] Sort invoices in descending order by number by default --- stoptime.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/stoptime.rb b/stoptime.rb index 278dd3d..56d2381 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -376,6 +376,7 @@ module StopTime::Models has_many :time_entries, :through => :tasks belongs_to :customer belongs_to :company_info + default_scope order('number DESC') # Returns a time and cost summary of the contained tasks (Hash of # Task to Array). From fd6b853154d98cd25106ee363bc70cb09b647705 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 7 Feb 2014 21:36:09 +0100 Subject: [PATCH 2/3] Move the 'Create a new invoice' button to a more consistent location --- stoptime.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 56d2381..3376e9c 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1918,10 +1918,14 @@ module StopTime::Views end end - h2 "Invoices" + h2 do + text! "Invoices" + div.btn_group.pull_right do + a.btn.btn_small "» Create a new invoice", + :href => R(CustomersNInvoicesNew, @customer.id) + end + end _invoice_list(@invoices) - a.btn "» Create a new invoice", - :href => R(CustomersNInvoicesNew, @customer.id) end end end From acd2ab46e4c9eed533a45da6abcd3986af36c1ca Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sun, 9 Feb 2014 14:40:28 +0100 Subject: [PATCH 3/3] Reorder the invoices when retrieving the last invoice --- stoptime.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stoptime.rb b/stoptime.rb index 3376e9c..b84d684 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1052,7 +1052,7 @@ module StopTime::Controllers return redirect R(CustomersN, customer_id) if @input.cancel # Create the invoice. - last = Invoice.last + last = Invoice.reorder('number ASC').last number = if last last_year = last.number.to_s[0..3].to_i if Time.now.year > last_year