Sha256: c7ceeff35debe9deae791e0584e08887c81c647386aeb5289a28f98564c3a0ca

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 KB

Contents

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

  def show
    @invoice_id = params[:id]
    if @invoice_id.present?
      begin
        @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 = {}
          @cba_items_not_deleteable = []
          if @invoice.items.present?
            @invoice.items.each do |item|
              @cba_items_not_deleteable << item.linked_invoice_item_id if item.description =~ /account credit/ and item.amount < 0

              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"
          render :action => :index
        end
      rescue => e
        flash[:error] = "Error while getting information for invoice #{invoice_id}: #{as_string(e)}"
      end
    else
      flash[:error] = "No id given"
    end
  end

  def show_html
    begin
      render :text => Kaui::KillbillHelper.get_invoice_html(params[:id])
    rescue => e
      flash[:error] = "Error rendering invoice html #{invoice_id}: #{as_string(e)}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kaui-0.1.18 app/controllers/kaui/invoices_controller.rb
kaui-0.1.17 app/controllers/kaui/invoices_controller.rb
kaui-0.1.16 app/controllers/kaui/invoices_controller.rb
kaui-0.1.15 app/controllers/kaui/invoices_controller.rb
kaui-0.1.14 app/controllers/kaui/invoices_controller.rb
kaui-0.1.12 app/controllers/kaui/invoices_controller.rb