Explorar el Código

Added Suppliers by Spend table to service view

pull/3/head
Adrian Short hace 14 años
padre
commit
d94fac495d
Se han modificado 3 ficheros con 39 adiciones y 8 borrados
  1. +8
    -0
      app.rb
  2. +1
    -0
      public/style.css
  3. +30
    -8
      views/service.haml

+ 8
- 0
app.rb Ver fichero

@@ -74,6 +74,14 @@ get '/services/:slug' do
@avg = @service.payments.avg(:amount)
@max = @service.payments.max(:amount)
@min = @service.payments.min(:amount)
@results = repository(:default).adapter.query("
SELECT s.id, s.name AS supplier_name, s.slug AS supplier_slug, SUM(p.amount) AS total
FROM payments p, suppliers s
WHERE p.supplier_id = s.id
AND p.service_id = #{@service.id}
GROUP BY s.id
ORDER BY total DESC")

haml :service
end


+ 1
- 0
public/style.css Ver fichero

@@ -93,6 +93,7 @@ strong
table
{
border-collapse: collapse;
margin-bottom: 30px 0;
}

td, th


+ 30
- 8
views/service.haml Ver fichero

@@ -19,24 +19,46 @@
%p.noprint.download
%a{ :href => "/services/#{@service.slug}.csv" }
Download data as CSV
%p

%h3 Summary

%table
%tr
%th.right Payments
%th.right Total £
%th.right Max £
%th.right Min £
%th.right Average £
%th.right Total
%th.right Max
%th.right Min
%th.right Average

%tr
%td.right= @count
%td.right= sprintf("%0d", @total)
%td.right= sprintf("%0d", @max)
%td.right= sprintf("%0d", @min)
%td.right= sprintf("%0d", @avg)
%td.right= sprintf("£%0d", @total)
%td.right= sprintf("£%0d", @max)
%td.right= sprintf("£%0d", @min)
%td.right= sprintf("£%0d", @avg)

%p
%h3 Suppliers by Spend
%table
%tr
%th Supplier
%th Total £
%th Total %
- for row in @results
%tr
%td
%a{ :href => "/suppliers/#{row['supplier_slug']}" }
= row['supplier_name']
%td.right= sprintf("%0d", row['total'])
%td.right= sprintf("%0.1f", row['total'] / @total * 100)

%p
%h3 Payments to Suppliers

%table


Cargando…
Cancelar
Guardar