Sha256: 8e4b6d30fd98986ef5b929b4904016625192f426102c141db58f819b90541391

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module Trade
  class Admin::PayoutsController < Admin::BaseController
    before_action :set_payout, only: [:show, :edit, :update, :do_pay, :destroy]

    def index
      q_params = {}
      q_params.merge! params.permit(:id, :cash_id, :payout_uuid)

      @payouts = Payout.default_where(q_params).page(params[:page])
    end

    def new
      @payout = Payout.new
    end

    def create
      @payout = Payout.new(payout_params)

      if @payout.save
        render 'create'
      else
        render :new, locals: { model: @payout }, status: :unprocessable_entity
      end
    end

    def show
    end

    def edit
    end

    def update
      @payout.assign_attributes(payout_params)

      unless @payout.save
        render :edit, locals: { model: @payout }, status: :unprocessable_entity
      end
    end

    def do_pay
      @payout.do_pay
    end

    def destroy
      @payout.destroy
    end

    private
    def set_payout
      @payout = Payout.find(params[:id])
    end

    def payout_params
      p = params.fetch(:payout, {}).permit(
        :actual_amount,
        :payout_uuid,
        :to_bank,
        :to_name,
        :to_identifier,
        :proof
      )
      p.merge! operator_id: current_member.id
      p
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_trade-0.0.3 app/controllers/trade/admin/payouts_controller.rb