@@ -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 | ||||
@@ -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 | ||||
@@ -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 | ||||
@@ -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 | ||||
@@ -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 | ||||