Class: Api::V1::User::OrdergroupController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/v1/user/ordergroup_controller.rb

Instance Method Summary collapse

Instance Method Details

#financial_overviewObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/api/v1/user/ordergroup_controller.rb', line 4

def financial_overview
  ordergroup = Ordergroup.include_transaction_class_sum.find(current_ordergroup.id)

  render json: {
    financial_overview: {
      account_balance: ordergroup..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