From c40f1b73be4a0009ca782784b8b6640f58d221d2 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Tue, 15 Jun 2010 10:03:56 +0100 Subject: [PATCH] Separated payments to suppliers details onto a separate view from supplier --- app.rb | 10 ++++- public/style.css | 1 + views/service.haml | 47 +++++------------------- views/servicepayments.haml | 75 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 39 deletions(-) create mode 100644 views/servicepayments.haml diff --git a/app.rb b/app.rb index 8169206..ca2c6c7 100644 --- a/app.rb +++ b/app.rb @@ -57,7 +57,7 @@ get '/suppliers/?' do haml :suppliers end -get '/services/:slug.csv' do +get '/services/:slug/payments.csv' do @service = Service.first(:slug => params[:slug]) headers "Content-Disposition" => "attachment;filename=service-#{@service.slug}.csv", @@ -98,6 +98,14 @@ get '/services/:slug' do haml :service end +get '/services/:slug/payments' do + @service = Service.first(:slug => params[:slug]) + @total = @service.payments.sum(:amount) + haml :servicepayments +end + + + get '/services/?' do @services = Service.all( :order => ['name'] ) haml :services diff --git a/public/style.css b/public/style.css index 7e701a2..06d9169 100644 --- a/public/style.css +++ b/public/style.css @@ -10,6 +10,7 @@ body p { font-size: 110%; + margin: 30px 0; } input diff --git a/views/service.haml b/views/service.haml index 0b2d8c7..18667cc 100644 --- a/views/service.haml +++ b/views/service.haml @@ -15,13 +15,15 @@ = @service.directorate.name 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 @@ -39,8 +41,6 @@ %td.right= commify(sprintf("£%0d", @max)) %td.right= commify(sprintf("£%0d", @min)) %td.right= commify(sprintf("£%0d", @avg)) - - %p %h3 Suppliers by Spend @@ -56,35 +56,6 @@ = row['supplier_name'] %td.right= commify(sprintf("%0d", row['total'])) %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
diff --git a/views/servicepayments.haml b/views/servicepayments.haml new file mode 100644 index 0000000..2f532a1 --- /dev/null +++ b/views/servicepayments.haml @@ -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 +
+= haml_partial "comment_header" +
+ + +Comments powered by Disqus +
+ \ No newline at end of file