Add CSV downloads for BankTransaction and Invoice
This commit is contained in:
parent
e0c0834690
commit
9f2e630266
6 changed files with 96 additions and 6 deletions
|
|
@ -17,9 +17,16 @@ class Finance::BankTransactionsController < ApplicationController
|
|||
end
|
||||
|
||||
@bank_account = BankAccount.find(params[:bank_account_id])
|
||||
@bank_transactions = @bank_account.bank_transactions.order(sort).includes(:financial_link)
|
||||
@bank_transactions = @bank_transactions.where('reference LIKE ? OR text LIKE ?', "%#{params[:query]}%", "%#{params[:query]}%") unless params[:query].nil?
|
||||
@bank_transactions = @bank_transactions.page(params[:page]).per(@per_page)
|
||||
@bank_transactions_all = @bank_account.bank_transactions.order(sort).includes(:financial_link)
|
||||
@bank_transactions_all = @bank_transactions_all.where('reference LIKE ? OR text LIKE ?', "%#{params[:query]}%", "%#{params[:query]}%") unless params[:query].nil?
|
||||
@bank_transactions = @bank_transactions_all.page(params[:page]).per(@per_page)
|
||||
|
||||
respond_to do |format|
|
||||
format.js; format.html { render }
|
||||
format.csv do
|
||||
send_data BankTransactionsCsv.new(@bank_transactions_all).to_csv, filename: 'transactions.csv', type: 'text/csv'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -5,7 +5,15 @@ class Finance::InvoicesController < ApplicationController
|
|||
before_action :ensure_can_edit, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@invoices = Invoice.includes(:supplier, :deliveries, :orders).order('date DESC').page(params[:page]).per(@per_page)
|
||||
@invoices_all = Invoice.includes(:supplier, :deliveries, :orders).order('date DESC')
|
||||
@invoices = @invoices_all.page(params[:page]).per(@per_page)
|
||||
|
||||
respond_to do |format|
|
||||
format.js; format.html { render }
|
||||
format.csv do
|
||||
send_data InvoicesCsv.new(@invoices_all).to_csv, filename: 'invoices.csv', type: 'text/csv'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def unpaid
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
.pull-right
|
||||
.btn-group
|
||||
= link_to url_for(query: params[:query], format: :csv), class: 'btn' do
|
||||
= glyph :download
|
||||
CSV
|
||||
- if @bank_transactions.total_pages > 1
|
||||
.btn-group= items_per_page wrap: false
|
||||
= pagination_links_remote @bank_transactions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
- if Invoice.count > 20
|
||||
= items_per_page
|
||||
.pull-right
|
||||
.btn-group
|
||||
= link_to url_for(query: params[:query], format: :csv), class: 'btn' do
|
||||
= glyph :download
|
||||
CSV
|
||||
- if @invoices.total_pages > 1
|
||||
= items_per_page
|
||||
= pagination_links_remote @invoices
|
||||
|
||||
%table.table.table-striped
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue