feat(order): export order to custom csv file

add custom_csv_collection to orders helper

add rute and controller method to orders controller

add custom csv to download dropdown

add functionality to choose column headers + order for custom csv and append order.sum gross&net to custom csv
This commit is contained in:
viehlieb 2023-02-14 16:51:22 +01:00 committed by Philipp Rothmann
parent caa32de30c
commit 895589c03d
13 changed files with 111 additions and 17 deletions

View file

@ -50,7 +50,7 @@ class OrdersController < ApplicationController
send_order_pdf @order, params[:document]
end
format.csv do
send_data OrderCsv.new(@order).to_csv, filename: @order.name + '.csv', type: 'text/csv'
send_data OrderCsv.new(@order, options= {custom_csv: params[:custom_csv]}).to_csv, filename: @order.name + '.csv', type: 'text/csv'
end
format.text do
send_data OrderTxt.new(@order).to_txt, filename: @order.name + '.txt', type: 'text/plain'
@ -58,6 +58,19 @@ class OrdersController < ApplicationController
end
end
def custom_csv
@order = Order.find(params[:id])
@view = (params[:view] || 'default').gsub(/[^-_a-zA-Z0-9]/, '')
@partial = case @view
when 'default' then 'articles'
when 'groups' then 'shared/articles_by/groups'
when 'articles' then 'shared/articles_by/articles'
else 'articles'
end
render :layout => false
end
# Page to create a new order.
def new
if params[:order_id]