@@ -57,7 +57,7 @@ get '/suppliers/?' do | |||||
haml :suppliers | haml :suppliers | ||||
end | end | ||||
get '/services/:slug.csv' do | |||||
get '/services/:slug/payments.csv' do | |||||
@service = Service.first(:slug => params[:slug]) | @service = Service.first(:slug => params[:slug]) | ||||
headers "Content-Disposition" => "attachment;filename=service-#{@service.slug}.csv", | headers "Content-Disposition" => "attachment;filename=service-#{@service.slug}.csv", | ||||
@@ -98,6 +98,14 @@ get '/services/:slug' do | |||||
haml :service | haml :service | ||||
end | end | ||||
get '/services/:slug/payments' do | |||||
@service = Service.first(:slug => params[:slug]) | |||||
@total = @service.payments.sum(:amount) | |||||
haml :servicepayments | |||||
end | |||||
get '/services/?' do | get '/services/?' do | ||||
@services = Service.all( :order => ['name'] ) | @services = Service.all( :order => ['name'] ) | ||||
haml :services | haml :services | ||||
@@ -10,6 +10,7 @@ body | |||||
p | p | ||||
{ | { | ||||
font-size: 110%; | font-size: 110%; | ||||
margin: 30px 0; | |||||
} | } | ||||
input | input | ||||
@@ -15,13 +15,15 @@ | |||||
= @service.directorate.name | = @service.directorate.name | ||||
Directorate | Directorate | ||||
%p.noprint.download | |||||
%a{ :href => "/services/#{@service.slug}.csv" } | |||||
Download data as CSV | |||||
%p | |||||
%p.noprint | |||||
%a{ :href => "/services/#{@service.slug}/payments" } | |||||
Payments to Suppliers details for | |||||
= @service.name | |||||
» | |||||
.clear | |||||
.grid_9 | |||||
%h3 Summary | %h3 Summary | ||||
@@ -39,8 +41,6 @@ | |||||
%td.right= commify(sprintf("£%0d", @max)) | %td.right= commify(sprintf("£%0d", @max)) | ||||
%td.right= commify(sprintf("£%0d", @min)) | %td.right= commify(sprintf("£%0d", @min)) | ||||
%td.right= commify(sprintf("£%0d", @avg)) | %td.right= commify(sprintf("£%0d", @avg)) | ||||
%p | |||||
%h3 Suppliers by Spend | %h3 Suppliers by Spend | ||||
@@ -56,35 +56,6 @@ | |||||
= row['supplier_name'] | = row['supplier_name'] | ||||
%td.right= commify(sprintf("%0d", row['total'])) | %td.right= commify(sprintf("%0d", row['total'])) | ||||
%td.right= sprintf("%0.1f", row['total'] / @total * 100) | %td.right= sprintf("%0.1f", row['total'] / @total * 100) | ||||
%p | |||||
%h3 Payments to Suppliers | |||||
%table | |||||
%tr | |||||
%th Date | |||||
%th Ref. | |||||
%th Supplier | |||||
%th.right £ | |||||
- for payment in @service.payments | |||||
%tr | |||||
%td= payment.d.strftime("%d %b %Y") | |||||
%td.right | |||||
%a{ :href => "/payments/#{payment.id}" } | |||||
= payment.id | |||||
%td | |||||
%a{ :href => '/suppliers/' + payment.supplier.slug } | |||||
= payment.supplier.name | |||||
%td.right= commify(sprintf("%0d", payment.amount)) | |||||
%tr | |||||
%td | |||||
%td | |||||
%td | |||||
%strong TOTAL | |||||
%td.right= commify(sprintf("%0d", @total)) | |||||
.clear | .clear | ||||
<div class="grid_9 noprint"> | <div class="grid_9 noprint"> | ||||
@@ -0,0 +1,75 @@ | |||||
.grid_12 | |||||
%ul#breadcrumb | |||||
%li.home | |||||
%a{ :href => '/'} Home | |||||
%li | |||||
%a{ :href => '/services' } Services | |||||
%li | |||||
%a{ :href => "/services/#{@service.slug}" } | |||||
= @service.name | |||||
%li Payments to Suppliers | |||||
%h2= @page_title = @service.name | |||||
%p | |||||
A service in the | |||||
%a{ :href => '/directorates/' + @service.directorate.slug } | |||||
= @service.directorate.name | |||||
Directorate | |||||
%p.noprint | |||||
%a{ :href => "/services/#{@service.slug}" } | |||||
« Suppliers by Spend summary for | |||||
= @service.name | |||||
%p.noprint.download | |||||
%a{ :href => "/services/#{@service.slug}/payments.csv" } | |||||
Download data as CSV | |||||
.clear | |||||
.grid_9 | |||||
%h3 Payments to Suppliers | |||||
%table | |||||
%tr | |||||
%th Date | |||||
%th Ref. | |||||
%th Supplier | |||||
%th.right £ | |||||
- for payment in @service.payments | |||||
%tr | |||||
%td= payment.d.strftime("%d %b %Y") | |||||
%td.right | |||||
%a{ :href => "/payments/#{payment.id}" } | |||||
= payment.id | |||||
%td | |||||
%a{ :href => '/suppliers/' + payment.supplier.slug } | |||||
= payment.supplier.name | |||||
%td.right= commify(sprintf("%0d", payment.amount)) | |||||
%tr | |||||
%td | |||||
%td | |||||
%td | |||||
%strong TOTAL | |||||
%td.right= commify(sprintf("%0d", @total)) | |||||
.clear | |||||
<div class="grid_9 noprint"> | |||||
= haml_partial "comment_header" | |||||
<div id="disqus_thread" class="noprint"></div> | |||||
<script type="text/javascript"> | |||||
var disqus_developer = 1; | |||||
(function() { | |||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; | |||||
dsq.src = 'http://armchairauditor.disqus.com/embed.js'; | |||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); | |||||
})(); | |||||
</script> | |||||
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=armchairauditor">comments powered by Disqus.</a></noscript> | |||||
<a href="http://disqus.com" class="dsq-brlink noprint">Comments powered by <span class="logo-disqus">Disqus</span></a> | |||||
</div> | |||||