mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 08:43:37 +02:00
117702653-csv_fix
This commit is contained in:
parent
8e1ce32143
commit
b8df59d2ff
1 changed files with 4 additions and 4 deletions
|
@ -6,7 +6,6 @@ class AccountActivity < ActiveRecord::Base
|
||||||
belongs_to :bank_transaction
|
belongs_to :bank_transaction
|
||||||
belongs_to :invoice
|
belongs_to :invoice
|
||||||
|
|
||||||
attr_accessor :registrar
|
|
||||||
|
|
||||||
CREATE = 'create'
|
CREATE = 'create'
|
||||||
RENEW = 'renew'
|
RENEW = 'renew'
|
||||||
|
@ -24,14 +23,15 @@ class AccountActivity < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_csv
|
def to_csv
|
||||||
attributes = %w(registrar description activity_type created_at sum)
|
attributes = %w(description activity_type created_at sum)
|
||||||
|
|
||||||
CSV.generate(headers: true) do |csv|
|
CSV.generate(headers: true) do |csv|
|
||||||
csv << %w(registrar description activity_type receipt_date sum)
|
csv << %w(registrar description activity_type receipt_date sum)
|
||||||
|
|
||||||
all.each do |x| # rubocop:disable Rails/FindEach
|
all.each do |x| # rubocop:disable Rails/FindEach
|
||||||
x.registrar = Registrar.find(x.account_id).try(:code)
|
attrs = [x.account.registrar.try(:code)]
|
||||||
csv << attributes.map { |attr| x.send(attr) }
|
attrs += attributes.map { |attr| x.send(attr) }
|
||||||
|
csv << attrs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue