Browse Source

Added period start & end dates to service & supplier views, created nicedate() helper

pull/3/head
Adrian Short 14 years ago
parent
commit
864a693b19
5 changed files with 28 additions and 6 deletions
  1. +9
    -0
      app.rb
  2. +1
    -1
      views/payment.haml
  3. +1
    -1
      views/scoreboard.haml
  4. +11
    -2
      views/service.haml
  5. +6
    -2
      views/supplier.haml

+ 9
- 0
app.rb View File

@@ -14,6 +14,11 @@ helpers do
def yesno(boolean) def yesno(boolean)
boolean == true ? 'Yes' : 'No' boolean == true ? 'Yes' : 'No'
end end
def nicedate(d)
d.strftime("%d %b %Y")
end
end end


get '/' do get '/' do
@@ -52,6 +57,8 @@ get '/suppliers/:slug' do
@avg = @supplier.payments.avg(:amount) @avg = @supplier.payments.avg(:amount)
@max = @supplier.payments.max(:amount) @max = @supplier.payments.max(:amount)
@min = @supplier.payments.min(:amount) @min = @supplier.payments.min(:amount)
@d_start = @supplier.payments.min(:d)
@d_end = @supplier.payments.max(:d)
haml :supplier haml :supplier
end end


@@ -89,6 +96,8 @@ get '/services/:slug' do
@avg = @service.payments.avg(:amount) @avg = @service.payments.avg(:amount)
@max = @service.payments.max(:amount) @max = @service.payments.max(:amount)
@min = @service.payments.min(:amount) @min = @service.payments.min(:amount)
@d_start = @service.payments.min(:d)
@d_end = @service.payments.max(:d)
@results = repository(:default).adapter.query(" @results = repository(:default).adapter.query("
SELECT s.name AS supplier_name, s.slug AS supplier_slug, SUM(p.amount) AS total SELECT s.name AS supplier_name, s.slug AS supplier_slug, SUM(p.amount) AS total


+ 1
- 1
views/payment.haml View File

@@ -4,7 +4,7 @@
%table %table
%tr %tr
%td Date %td Date
%td= @payment.d.strftime("%d %b %Y")
%td= nicedate(@payment.d)
%tr %tr
%td Directorate %td Directorate
%td %td


+ 1
- 1
views/scoreboard.haml View File

@@ -29,7 +29,7 @@
%td= yesno(council.machine_readable) %td= yesno(council.machine_readable)
%td= council.start_d.strftime("%b %Y") %td= council.start_d.strftime("%b %Y")
%td= council.end_d.strftime("%b %Y") %td= council.end_d.strftime("%b %Y")
%td= council.updated_at.strftime("%d %b %Y")
%td= nicedate(council.updated_at)
%p.highlight.noprint %p.highlight.noprint
This scoreboard data is free for you to use according to the This scoreboard data is free for you to use according to the


+ 11
- 2
views/service.haml View File

@@ -25,7 +25,11 @@


.grid_9 .grid_9


%h3 Summary
%h3
Summary for
= nicedate(@d_start)
to
= nicedate(@d_end)


%table %table
%tr %tr
@@ -42,7 +46,12 @@
%td.right= commify(sprintf("£%0d", @min)) %td.right= commify(sprintf("£%0d", @min))
%td.right= commify(sprintf("£%0d", @avg)) %td.right= commify(sprintf("£%0d", @avg))
%h3 Suppliers by Spend
%h3
Suppliers by Spend for
= nicedate(@d_start)
to
= nicedate(@d_end)
%table %table
%tr %tr


+ 6
- 2
views/supplier.haml View File

@@ -18,8 +18,12 @@
%a{ :href => "/suppliers/#{@supplier.slug}.csv" } %a{ :href => "/suppliers/#{@supplier.slug}.csv" }
Download data as CSV Download data as CSV


%h3 Summary
%h3
Summary for
= nicedate(@d_start)
to
= nicedate(@d_end)

%table %table
%tr %tr
%th.right Payments %th.right Payments


Loading…
Cancel
Save