Class: Backend::SaleCreditsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/sale_credits_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Instance Method Summary collapse

Methods inherited from BaseController

accounts_range_crit, crit_params, journal_entries_states_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name

Instance Method Details

#createObject

cancel


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/backend/sale_credits_controller.rb', line 29

def create # cancel
  attributes = permitted_params[:sale]
  attributes[:credit] = true
  attributes[:credited_sale_id] = @credited_sale.id
  @sale_credit = Sale.new(attributes)
  saved = false
  if @sale_credit.save
    @sale_credit.reload
    @sale_credit.propose!
    @sale_credit.confirm!
    @sale_credit.invoice!
    saved = true
  end
  return false if save_and_redirect(@sale_credit, saved: saved, url: { controller: :sales, action: :show, id: 'id'.c })
  t3e @sale_credit.credited_sale
end

#newObject

undo


24
25
26
27
# File 'app/controllers/backend/sale_credits_controller.rb', line 24

def new # undo
  @sale_credit = @credited_sale.build_credit
  t3e @sale_credit.credited_sale
end