Class: AccountsController

Inherits:
AuthorizedController show all
Defined in:
app/controllers/accounts_controller.rb

Direct Known Subclasses

BankAccountsController

Instance Method Summary collapse

Methods inherited from AuthorizedController

#set_locale

Instance Method Details

#csv_bookingsObject



25
26
27
28
29
# File 'app/controllers/accounts_controller.rb', line 25

def csv_bookings
  @account = Account.find(params[:id])
  @bookings = apply_scopes(Booking).(@account)
  send_csv @bookings, :only => [:value_date, :title, :comments, :amount, 'credit_account.code', 'debit_account.code'], :filename => "%s-%s.csv" % [@account.code, @account.title]
end

#indexObject



6
7
8
# File 'app/controllers/accounts_controller.rb', line 6

def index
  @accounts = apply_scopes(Account).includes(:account_type).includes(:credit_bookings, :credit_bookings)
end

#showObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/accounts_controller.rb', line 10

def show
  @account = Account.find(params[:id])
  @bookings = apply_scopes(Booking).includes(:debit_account => :account_type, :credit_account => :account_type).(@account)

  if params[:only_credit_bookings]
    @bookings = @bookings.where(:credit_account_id => @account.id)
  end
  if params[:only_debit_bookings]
    @bookings = @bookings.where(:debit_account_id => @account.id)
  end
  @bookings = @bookings.paginate(:page => params['page'], :per_page => params['per_page'], :order => 'value_date, id')

  show!
end