Преглед на файлове

Removed Trans No from CSV downloads

pull/3/head
Adrian Short преди 14 години
родител
ревизия
7223e03584
променени са 2 файла, в които са добавени 4 реда и са изтрити 8 реда
  1. +4
    -7
      app.rb
  2. +0
    -1
      lib/models.rb

+ 4
- 7
app.rb Целия файл

@@ -6,8 +6,6 @@ require 'lib/models'

get '/' do
@directorates = Directorate.all( :order => ['name'] )
# @payments_count = Payment.all.size
# @suppliers_count = Supplier.all.size
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM payments")
@payments_count = @results[0]
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM suppliers")
@@ -19,7 +17,6 @@ end

get '/directorates/:slug' do
@directorate = Directorate.first(:slug => params[:slug])
# @total = @directorate.payments.sum(:amount)
haml :directorate
end

@@ -29,10 +26,10 @@ get '/suppliers/:slug.csv' do
headers "Content-Disposition" => "attachment;filename=supplier-#{@supplier.slug}.csv",
"Content-Type" => "application/octet-stream"

result = "Date,Ref.,URL,Trans No,Directorate,Service,Amount ex. VAT\n"
result = "Date,Ref.,URL,Directorate,Service,Amount ex. VAT\n"

for payment in @supplier.payments
result += "#{payment.d.strftime("%d %b %Y")},#{payment.id},#{payment.url},#{payment.trans_no},\"#{payment.directorate.name}\",#{payment.service.name},#{sprintf("%0.2f", payment.amount)}\n"
result += "#{payment.d.strftime("%d %b %Y")},#{payment.id},#{payment.url},\"#{payment.service.directorate.name}\",#{payment.service.name},#{sprintf("%0.2f", payment.amount)}\n"
end

result
@@ -60,10 +57,10 @@ get '/services/:slug.csv' do
headers "Content-Disposition" => "attachment;filename=service-#{@service.slug}.csv",
"Content-Type" => "application/octet-stream"

result = "Date,Ref.,URL,Trans No,Directorate,Supplier,Amount ex. VAT\n"
result = "Date,Ref.,URL,Directorate,Supplier,Amount ex. VAT\n"

for payment in @service.payments
result += "#{payment.d.strftime("%d %b %Y")},#{payment.id},#{payment.url},#{payment.trans_no},\"#{payment.directorate.name}\",#{payment.supplier.name},#{sprintf("%0.2f", payment.amount)}\n"
result += "#{payment.d.strftime("%d %b %Y")},#{payment.id},#{payment.url},\"#{payment.service.directorate.name}\",#{payment.supplier.name},#{sprintf("%0.2f", payment.amount)}\n"
end

result


+ 0
- 1
lib/models.rb Целия файл

@@ -38,7 +38,6 @@ class Directorate
has n, :services, :order => ['name']
has n, :suppliers, { :through => :services, :order => ['name'] }
# has n, :payments, { :through => :services }

before :save, :slugify



Зареждане…
Отказ
Запис