Report generation. Download csv

This commit is contained in:
German Galia
2019-06-12 10:17:31 +02:00
parent 139b2720d8
commit 9d1ca3bfd4
63 changed files with 1528 additions and 40 deletions

View File

@@ -0,0 +1,28 @@
module DownloadSettings
module BudgetInvestmentCsv
extend ActiveSupport::Concern
def get_association_attribute_names
["author_name", "author_email"]
end
def get_downloadables_names(config)
DownloadSetting.where(name_model: "Budget::Investment",
downloadable: true,
config: config).pluck(:name_field)
end
def to_csv(budgets, admin_attr, options = {})
attributes = admin_attr.nil? ? [] : admin_attr
CSV.generate(options) do |csv|
csv << attributes
budgets.each do |budget|
csv << attributes.map{ |attr| budget.send(attr)}
end
end
end
end
end