foodsoft/app/controllers/api/v1/user/ordergroup_controller.rb
Philipp Rothmann fb2b4d8a8a chore: rubocop
chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
2023-06-09 17:35:05 +02:00

21 lines
694 B
Ruby

class Api::V1::User::OrdergroupController < Api::V1::BaseController
before_action -> { doorkeeper_authorize! 'finance:user' }, only: [:financial_overview]
def financial_overview
ordergroup = Ordergroup.include_transaction_class_sum.find(current_ordergroup.id)
render json: {
financial_overview: {
account_balance: ordergroup.account_balance.to_f,
available_funds: ordergroup.get_available_funds.to_f,
financial_transaction_class_sums: FinancialTransactionClass.sorted.map do |c|
{
id: c.id,
name: c.display,
amount: ordergroup["sum_of_class_#{c.id}"].to_f
}
end
}
}
end
end