Class: Kaui::RefundsController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kaui::RefundsController
- Defined in:
- app/controllers/kaui/refunds_controller.rb
Constant Summary
Constants included from EngineControllerUtil
EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD
Instance Method Summary collapse
Methods inherited from EngineController
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/kaui/refunds_controller.rb', line 17 def create invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', ) if params[:adjustment_type] == 'invoiceItemAdjustment' items = [] (params.to_unsafe_h[:adjustments] || []).each do |ii| original_item = find_original_item(invoice.items, ii[0]) item = KillBillClient::Model::InvoiceItem.new item.invoice_item_id = ii[0] # If we tried to do a partial item adjustment, we pass the value, if not we don't send any value and let the system # decide what is the maximum amount we can have on that item item.amount = (ii[1].to_f == original_item.amount) ? nil : ii[1] items << item end end KillBillClient::Model::InvoicePayment.refund(params.require(:payment_id), params[:amount], items, current_user.kb_username, params[:reason], params[:comment], ) redirect_to kaui_engine.account_invoice_path(invoice.account_id, invoice.invoice_id), :notice => 'Refund created' end |
#new ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/kaui/refunds_controller.rb', line 3 def new = fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', ) } fetch_payment = promise { Kaui::InvoicePayment::find_by_id(params.require(:payment_id), false, false, ) } fetch_bundles = promise { @account.bundles() } @invoice = wait(fetch_invoice) @payment = wait(fetch_payment) @bundles = wait(fetch_bundles) @refund = KillBillClient::Model::InvoiceItem.new(:invoice_id => @invoice.invoice_id) end |