tab/app/datatables/transaction_datatable.rb

28 lines
612 B
Ruby
Raw Normal View History

2015-09-08 17:30:13 +02:00
class TransactionDatatable < AjaxDatatablesRails::Base
2015-09-08 20:45:32 +02:00
include TransactionsHelper
2015-09-08 17:30:13 +02:00
def sortable_columns
2015-09-09 11:31:34 +02:00
@sortable_columns ||= ['Transaction.created_at']
2015-09-08 17:30:13 +02:00
end
def searchable_columns
@searchable_columns ||= []
end
private
def data
records.map do |record|
2015-09-08 20:45:32 +02:00
[ amount_in_perspective(record, options[:user]),
record.origin,
record.message,
get_transaction_peer(record, options[:user]).name,
record.created_at.strftime('%d/%m/%y %H:%M')
]
2015-09-08 17:30:13 +02:00
end
end
def get_raw_records
2015-09-08 20:45:32 +02:00
options[:user].transactions.eager_load(:debtor, :creditor)
2015-09-08 17:30:13 +02:00
end
end