Sha256: fbcd418cdfb84cd4154833e15095399fbf87f27cd7871c9b08957895160d12f5

Contents?: true

Size: 976 Bytes

Versions: 6

Compression:

Stored size: 976 Bytes

Contents

class Kaui::ChargesController < Kaui::EngineController

  def new
    invoice_id = params[:invoice_id]
    amount = params[:amount]

    if invoice_id.present?
      @invoice = Kaui::Invoice.find_by_id_or_number(invoice_id, true, 'NONE', options_for_klient)
      amount ||= @invoice.balance
      currency = @invoice.currency
    else
      currency = params[:currency] || 'USD'
    end

    @charge = Kaui::InvoiceItem.new(:account_id => params.require(:account_id), :invoice_id => invoice_id, :amount => amount, :currency => currency)
  end

  def create
    charge = Kaui::InvoiceItem.new(params.require(:invoice_item).delete_if { |key, value| value.blank? })
    charge.account_id ||= params.require(:account_id)

    charge = charge.create(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
    redirect_to kaui_engine.account_invoice_path(charge.account_id, charge.invoice_id), :notice => 'Charge was successfully created'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kaui-0.15.5 app/controllers/kaui/charges_controller.rb
kaui-0.15.4 app/controllers/kaui/charges_controller.rb
kaui-0.15.3 app/controllers/kaui/charges_controller.rb
kaui-0.15.2 app/controllers/kaui/charges_controller.rb
kaui-0.15.1 app/controllers/kaui/charges_controller.rb
kaui-0.15.0 app/controllers/kaui/charges_controller.rb