class Admin::Accounting::Payments::DetailsController < Admin::Accounting::Controller
  def show
    render_success :ok, json: details_props
  end

  private
    def payment
      current_school.accounting_decreases.payment.find_by(id: params[:payment_id])
    end

    def detail
      @detail ||= payment.payment_detail
    end

    def details_props
      {
        id: detail.id,
        payment: detail.payment,
        distribution: JSON.parse(detail.details)['distribution']
      }
    end
end
