Class: Kaui::InvoiceItemsController
- Inherits:
-
EngineController
- Object
- EngineController
- Kaui::InvoiceItemsController
- Defined in:
- app/controllers/kaui/invoice_items_controller.rb
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/kaui/invoice_items_controller.rb', line 31 def destroy invoice_item = Kaui::InvoiceItem.new(invoice_item_id: params.require(:id), invoice_id: params.require(:invoice_id), account_id: params.require(:account_id)) invoice_item.delete(current_user.kb_username, params[:reason], params[:comment], ) redirect_to kaui_engine.account_invoice_path(invoice_item.account_id, invoice_item.invoice_id), notice: 'CBA item was successfully deleted' end |
#edit ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/kaui/invoice_items_controller.rb', line 5 def edit invoice_item_id = params.require(:id) invoice_id = params.require(:invoice_id) # See https://github.com/killbill/killbill/issues/7 invoice = Kaui::Invoice.find_by_id(invoice_id, false, 'NONE', ) @invoice_item = invoice.items.find { |ii| ii.invoice_item_id == invoice_item_id } return unless @invoice_item.nil? flash[:error] = "Unable to find invoice item #{invoice_item_id}" redirect_to account_invoice_path(params.require(:account_id), invoice_id) end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/kaui/invoice_items_controller.rb', line 19 def update @invoice_item = Kaui::InvoiceItem.new(params.require(:invoice_item)) begin invoice = @invoice_item.update(current_user.kb_username, params[:reason], params[:comment], ) redirect_to kaui_engine.account_invoice_path(invoice.account_id, invoice.invoice_id), notice: 'Adjustment item was successfully created' rescue StandardError => e flash.now[:error] = "Error while adjusting invoice item: #{as_string(e)}" render action: :edit end end |
#update_tags ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/kaui/invoice_items_controller.rb', line 40 def @invoice_item = Kaui::InvoiceItem.new(invoice_item_id: params.require(:id)) invoice_id = params.require(:invoice_id) account_id = params.require(:account_id) @invoice_item.account_id = account_id = [] params.each do |tag| tag_info = tag.split('_') next if (tag_info.size != 2) || (tag_info[0] != 'tag') << tag_info[1] end @invoice_item.(, current_user.kb_username, params[:reason], params[:comment], ) redirect_to account_invoice_path(account_id, invoice_id), notice: 'Invoice Item tags successfully set' end |