Sha256: e0a5b66540a2d10eca50752416c43c20df6afd3fd3fe218a8a04747d6ddd67fd

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

class Kaui::InvoicesController < Kaui::EngineController
  def index
    if params[:id].present?
      redirect_to invoice_path(params[:id])
    end
  end

  def show
    @invoice_id = params[:id]
    if @invoice_id.present?
      @invoice = Kaui::KillbillHelper.get_invoice(@invoice_id)
      if @invoice.present?
        @account = Kaui::KillbillHelper.get_account(@invoice.account_id)
        @payments = Kaui::KillbillHelper.get_payments(@invoice_id)
        @subscriptions = {}
        @bundles = {}
        if @invoice.items.present?
          @invoice.items.each do |item|
            unless item.subscription_id.nil? || @subscriptions.has_key?(item.subscription_id)
              @subscriptions[item.subscription_id] = Kaui::KillbillHelper.get_subscription(item.subscription_id)
            end
            unless item.bundle_id.nil? || @bundles.has_key?(item.bundle_id)
              @bundles[item.bundle_id] = Kaui::KillbillHelper.get_bundle(item.bundle_id)
            end
        end
        else
          flash[:error] = "Invoice items for #{@invoice_id} not found"
        end
      else
        flash[:error] = "Invoice #{@invoice_id} not found"
        redirect_to :action => :index
      end
    else
      flash[:error] = "No id given"
    end
  end

  def show_html
    render :text => Kaui::KillbillHelper.get_invoice_html(params[:id])
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kaui-0.1.0 app/controllers/kaui/invoices_controller.rb
kaui-0.0.9 app/controllers/kaui/invoices_controller.rb
kaui-0.0.8 app/controllers/kaui/invoices_controller.rb
kaui-0.0.7 app/controllers/kaui/invoices_controller.rb
kaui-0.0.6 app/controllers/kaui/invoices_controller.rb
kaui-0.0.5 app/controllers/kaui/invoices_controller.rb
kaui-0.0.4 app/controllers/kaui/invoices_controller.rb