Sha256: 5fa108863c7a551b806b348ad14487b33014dc38a6177cd76015764a52d43455

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

class Kaui::ChargesController < Kaui::EngineController

  def new
    @account_id = params[:account_id]
    @invoice_id = params[:invoice_id]
    begin
      @account = Kaui::KillbillHelper::get_account(@account_id, false, false, options_for_klient)

      if @invoice_id.present?
        @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id, true, options_for_klient)
        @charge = Kaui::Charge.new("accountId" => @account_id, "invoiceId" => @invoice_id)
      else
        @charge = Kaui::Charge.new("accountId" => @account_id)
      end
    rescue => e
      flash.now[:error] = "Error while creating a charge: #{as_string(e)}"
    end
  end

  def create
    charge = Kaui::Charge.new(params[:charge])

    if charge.present?
      begin
        Kaui::KillbillHelper::create_charge(charge, params[:requested_date], current_user, params[:reason], params[:comment], options_for_klient)
        flash[:notice] = "Charge created"
        redirect_to kaui_engine.account_timeline_path(:id => charge.account_id)
      rescue => e
        flash.now[:error] = "Error while creating a charge: #{as_string(e)}"
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kaui-0.4.2 app/controllers/kaui/charges_controller.rb
kaui-0.4.1 app/controllers/kaui/charges_controller.rb
kaui-0.4.0 app/controllers/kaui/charges_controller.rb
kaui-0.3.1 app/controllers/kaui/charges_controller.rb