Sha256: 0fdde6990e6447190d4830625f0c0532693caa9b9c4dd14a4a3d70aa85293ab0

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 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, nil, 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

1 entries across 1 versions & 1 rubygems

Version Path
kaui-0.3.0 app/controllers/kaui/charges_controller.rb