Class: Backend::DepositsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/deposits_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


84
85
86
87
88
89
90
91
# File 'app/controllers/backend/deposits_controller.rb', line 84

def create
  return unless find_mode
  @deposit = Deposit.new(permitted_params)
  unless @deposit.nil?
    return if save_and_redirect(@deposit)
    t3e mode: @deposit.mode.name
  end
end

#editObject


93
94
95
96
# File 'app/controllers/backend/deposits_controller.rb', line 93

def edit
  return unless @deposit = find_and_check
  t3e @deposit
end

#indexObject

Displays the main page with the list of deposits


42
43
44
45
46
# File 'app/controllers/backend/deposits_controller.rb', line 42

def index
  unless IncomingPayment.depositables.any?
    notify_now(:no_depositable_payments)
  end
end

#newObject


78
79
80
81
82
# File 'app/controllers/backend/deposits_controller.rb', line 78

def new
  return unless mode = find_mode
  @deposit = Deposit.new(created_at: Time.zone.today, mode: mode, responsible: current_user.person)
  t3e mode: @deposit.mode.name
end

#showObject

Displays details of one deposit selected with params


59
60
61
62
63
64
# File 'app/controllers/backend/deposits_controller.rb', line 59

def show
  return unless @deposit = find_and_check
  t3e @deposit
  respond_with(@deposit, include: [:responsible, :journal_entry, :mode, :cash,
                                   { payments: { include: :payer } }])
end

#unvalidatedsObject


112
113
114
115
116
117
118
119
120
121
# File 'app/controllers/backend/deposits_controller.rb', line 112

def unvalidateds
  @deposits = Deposit.unvalidateds
  if request.post?
    for id, values in params[:unvalidateds] || {}
      return unless deposit = find_and_check(id: id)
      deposit.update_attributes!(locked: true) if deposit && values[:validated].to_i == 1
    end
    redirect_to action: :unvalidateds
  end
end

#updateObject


98
99
100
101
102
# File 'app/controllers/backend/deposits_controller.rb', line 98

def update
  return unless @deposit = find_and_check
  return if save_and_redirect(@deposit, attributes: permitted_params, url: { action: :index })
  t3e @deposit
end