Class: Finance::BankTransactionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/finance/bank_transactions_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/finance/bank_transactions_controller.rb', line 5

def index
  if params["sort"]
    sort = case params["sort"]
             when "date" then "date"
             when "amount" then "amount"
             when "financial_link" then "financial_link_id"
             when "date_reverse" then "date DESC"
             when "amount_reverse" then "amount DESC"
             when "financial_link_reverse" then "financial_link_id DESC"
           end
  else
    sort = "date DESC"
  end

  @bank_account = BankAccount.find(params[:bank_account_id])
  @bank_transactions = @bank_account.bank_transactions.order(sort)
  @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)
end

#showObject


25
26
27
# File 'app/controllers/finance/bank_transactions_controller.rb', line 25

def show
  @bank_transaction = BankTransaction.find(params[:id])
end