mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 01:33:36 +02:00
Add csv export to activities #2691
This commit is contained in:
parent
af40038160
commit
f7556f48c8
4 changed files with 25 additions and 4 deletions
|
@ -18,6 +18,18 @@ class AccountActivity < ActiveRecord::Base
|
|||
def types_for_select
|
||||
[CREATE, RENEW, ADD_CREDIT].map { |x| [I18n.t(x), x] }
|
||||
end
|
||||
|
||||
def to_csv
|
||||
attributes = %w(description activity_type created_at sum)
|
||||
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << %w(description activity_type receipt_date sum)
|
||||
|
||||
all.each do |x|
|
||||
csv << attributes.map{ |attr| x.send(attr) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue