Class: Kaui::InvoiceItemsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/invoice_items_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_user

Methods included from ErrorHelper

#as_string

Instance Method Details

#destroyObject



28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/kaui/invoice_items_controller.rb', line 28

def destroy
  begin
    Kaui::KillbillHelper.delete_cba(params[:account_id], params[:invoice_id], params[:id], current_user, params[:reason], params[:comment])
    flash[:notice] = "CBA deleted"
    redirect_to kaui_engine.invoice_path(params[:invoice_id])
  rescue => e
    flash[:error] = "Error while deleting the CBA: #{as_string(e)}"
    redirect_to kaui_engine.invoice_path(params[:invoice_id])
  end
end

#editObject



12
13
14
# File 'app/controllers/kaui/invoice_items_controller.rb', line 12

def edit
  find_invoice_item
end

#indexObject



2
3
4
5
6
# File 'app/controllers/kaui/invoice_items_controller.rb', line 2

def index
  if params[:invoice_item_id].present? and params[:invoice_id].present?
    redirect_to kaui_engine.invoice_item_path(params[:invoice_item_id], :invoice_id => params[:invoice_id])
  end
end

#showObject



8
9
10
# File 'app/controllers/kaui/invoice_items_controller.rb', line 8

def show
  find_invoice_item
end

#updateObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/kaui/invoice_items_controller.rb', line 16

def update
  @invoice_item = Kaui::InvoiceItem.new(params[:invoice_item])
  begin
    Kaui::KillbillHelper.adjust_invoice(@invoice_item, current_user, params[:reason], params[:comment])
    flash[:notice] = "Adjustment item created"
    redirect_to kaui_engine.invoice_path(@invoice_item.invoice_id)
  rescue => e
    flash[:error] = "Error while updating the invoice item: #{as_string(e)}"
    render :action => "edit"
  end
end