Class: Kaui::InvoiceItemsController
Instance Method Summary
collapse
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient
Instance Method Details
#destroy ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/kaui/invoice_items_controller.rb', line 29
def destroy
@invoice_item = Kaui::InvoiceItem.new(:invoice_item_id => params[:id],
:invoice_id => params[:invoice_id],
:account_id => params[:account_id])
begin
@invoice_item.delete(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
redirect_to kaui_engine.invoice_path(@invoice_item.invoice_id), :notice => 'CBA item was successfully deleted'
rescue => e
flash.now[:error] = "Error while deleting CBA item: #{as_string(e)}"
render :action => :edit
end
end
|
#edit ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/kaui/invoice_items_controller.rb', line 3
def edit
invoice_item_id = params[:id]
invoice_id = params[:invoice_id]
begin
invoice = Kaui::Invoice.find_by_id_or_number(invoice_id, true, 'NONE', options_for_klient)
rescue => e
flash[:error] = "Error while getting information for invoice #{invoice_id}: #{as_string(e)}"
redirect_to :back
end
@invoice_item = invoice.items.find { |ii| ii.invoice_item_id == invoice_item_id }
end
|
#update ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/kaui/invoice_items_controller.rb', line 17
def update
@invoice_item = Kaui::InvoiceItem.new(params[:invoice_item])
begin
invoice = @invoice_item.update(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
redirect_to kaui_engine.invoice_path(invoice.invoice_id), :notice => 'Adjustment item was successfully created'
rescue => e
flash.now[:error] = "Error while adjusting invoice item: #{as_string(e)}"
render :action => :edit
end
end
|