Add model and views for bank accounts
This commit is contained in:
parent
4b1e9a6f53
commit
f0a55fb951
24 changed files with 351 additions and 1 deletions
8
app/controllers/finance/bank_accounts_controller.rb
Normal file
8
app/controllers/finance/bank_accounts_controller.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class Finance::BankAccountsController < Finance::BaseController
|
||||
|
||||
def index
|
||||
@bank_accounts = BankAccount.order('name')
|
||||
redirect_to finance_bank_account_transactions_url(@bank_accounts.first) if @bank_accounts.count == 1
|
||||
end
|
||||
|
||||
end
|
||||
28
app/controllers/finance/bank_transactions_controller.rb
Normal file
28
app/controllers/finance/bank_transactions_controller.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
class Finance::BankTransactionsController < ApplicationController
|
||||
before_filter :authenticate_finance
|
||||
inherit_resources
|
||||
|
||||
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
|
||||
|
||||
def show
|
||||
@bank_transaction = BankTransaction.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
|
@ -3,7 +3,16 @@ class Finance::FinancialLinksController < Finance::BaseController
|
|||
def show
|
||||
@financial_link = FinancialLink.find(params[:id])
|
||||
|
||||
@items = @financial_link.financial_transactions.map do |ft|
|
||||
@items = @financial_link.bank_transactions.map do |bt|
|
||||
{
|
||||
date: bt.date,
|
||||
type: t('activerecord.models.bank_transaction'),
|
||||
description: bt.text,
|
||||
amount: bt.amount,
|
||||
link_to: finance_bank_transaction_path(bt)
|
||||
}
|
||||
end
|
||||
@items += @financial_link.financial_transactions.map do |ft|
|
||||
{
|
||||
date: ft.created_on,
|
||||
type: t('activerecord.models.financial_transaction'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue