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

account_lettering_states_crit, accounts_range_crit, amount_range_crit, crit_params, journal_entries_states_crit, journal_letter_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name, #session_controller?

Instance Method Details

#createObject

cancel


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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)

  sale_credit_save_successful = false
  ActiveRecord::Base.transaction do
    @sale_credit.save
    @sale_credit.reload
    @sale_credit.propose!
    @sale_credit.confirm!
    @sale_credit.invoice!
    sale_credit_save_successful = true
  end

  if sale_credit_save_successful
    redirect_to controller: :sales, action: :show, id: @sale_credit
  else
    render :new
  end
  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