API v1 Add financial_transaction_type to FinancialTransactions output
This commit is contained in:
parent
be269101f8
commit
88228022e3
4 changed files with 14 additions and 3 deletions
|
@ -14,7 +14,7 @@ class Api::V1::FinancialTransactionsController < Api::V1::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def scope
|
def scope
|
||||||
FinancialTransaction.includes(:user)
|
FinancialTransaction.includes(:user, :financial_transaction_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ransack_auth_object
|
def ransack_auth_object
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Api::V1::User::FinancialTransactionsController < Api::V1::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def scope
|
def scope
|
||||||
current_ordergroup.financial_transactions.includes(:user)
|
current_ordergroup.financial_transactions.includes(:user, :financial_transaction_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,11 +2,16 @@ class FinancialTransactionSerializer < ActiveModel::Serializer
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
attributes :id, :user_id, :user_name, :amount, :note, :created_at
|
attributes :id, :user_id, :user_name, :amount, :note, :created_at
|
||||||
|
attributes :financial_transaction_type_id, :financial_transaction_type_name
|
||||||
|
|
||||||
def user_name
|
def user_name
|
||||||
show_user object.user
|
show_user object.user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def financial_transaction_type_name
|
||||||
|
object.financial_transaction_type.name
|
||||||
|
end
|
||||||
|
|
||||||
def amount
|
def amount
|
||||||
object.amount.to_f
|
object.amount.to_f
|
||||||
end
|
end
|
||||||
|
|
|
@ -383,6 +383,12 @@ definitions:
|
||||||
amount:
|
amount:
|
||||||
type: number
|
type: number
|
||||||
description: amount credited (negative for a debit transaction)
|
description: amount credited (negative for a debit transaction)
|
||||||
|
financial_transaction_type_id:
|
||||||
|
type: integer
|
||||||
|
description: id of the type of the transaction
|
||||||
|
financial_transaction_type_name:
|
||||||
|
type: string
|
||||||
|
description: name of the type of the transaction
|
||||||
note:
|
note:
|
||||||
type: string
|
type: string
|
||||||
description: note entered with the transaction
|
description: note entered with the transaction
|
||||||
|
@ -390,7 +396,7 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
description: when the transaction was entered
|
description: when the transaction was entered
|
||||||
required: ['id', 'user_id', 'user_name', 'amount', 'note', 'created_at']
|
required: ['id', 'user_id', 'user_name', 'amount', 'financial_transaction_type_id', 'financial_transaction_type_name', 'note', 'created_at']
|
||||||
|
|
||||||
FinancialTransactionClass:
|
FinancialTransactionClass:
|
||||||
type: object
|
type: object
|
||||||
|
|
Loading…
Reference in a new issue