API v1 financial_transaction_types endpoint
This commit is contained in:
parent
48391f818f
commit
be269101f8
5 changed files with 137 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
class Api::V1::FinancialTransactionTypesController < Api::V1::BaseController
|
||||
include Concerns::CollectionScope
|
||||
|
||||
def index
|
||||
render json: search_scope
|
||||
end
|
||||
|
||||
def show
|
||||
render json: scope.find(params.require(:id))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def max_per_page
|
||||
nil
|
||||
end
|
||||
|
||||
def default_per_page
|
||||
nil
|
||||
end
|
||||
|
||||
def scope
|
||||
FinancialTransactionType.includes(:bank_account, :financial_transaction_class)
|
||||
end
|
||||
|
||||
end
|
||||
17
app/serializers/financial_transaction_type_serializer.rb
Normal file
17
app/serializers/financial_transaction_type_serializer.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class FinancialTransactionTypeSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :name_short
|
||||
attributes :bank_account_id, :bank_account_name, :bank_account_iban
|
||||
attributes :financial_transaction_class_id, :financial_transaction_class_name
|
||||
|
||||
def financial_transaction_class_name
|
||||
object.financial_transaction_class.name
|
||||
end
|
||||
|
||||
def bank_account_name
|
||||
object.bank_account.try(:name)
|
||||
end
|
||||
|
||||
def bank_account_iban
|
||||
object.bank_account.try(:iban)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue