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

@@ -1,5 +1,6 @@
module Budgets
class ExecutionsController < ApplicationController
include DownloadSettingsHelper
before_action :load_budget
load_and_authorize_resource :budget
@@ -8,6 +9,19 @@ module Budgets
authorize! :read_executions, @budget
@statuses = Milestone::Status.all
@investments_by_heading = investments_by_heading_ordered_alphabetically.to_h
downloadables = []
investments_by_heading_ordered_alphabetically
.map { |heading| downloadables.concat heading[1] }
respond_to do |format|
format.html
format.csv { send_data to_csv(downloadables,
Budget::Investment,
1),
type: "text/csv",
disposition: "attachment",
filename: "budget_investment_milestones.csv" }
end
end
private

View File

@@ -2,6 +2,7 @@ module Budgets
class ResultsController < ApplicationController
before_action :load_budget
before_action :load_heading
include DownloadSettingsHelper
load_and_authorize_resource :budget
@@ -9,6 +10,14 @@ module Budgets
authorize! :read_results, @budget
@investments = Budget::Result.new(@budget, @heading).investments
@headings = @budget.headings.sort_by_name
respond_to do |format|
format.html
format.csv { send_data to_csv(@investments.compatible, Budget::Investment),
type: "text/csv",
disposition: "attachment",
filename: "budget_investment_results.csv" }
end
end
private