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

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


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

def create
  return unless find_mode
  @deposit = Deposit.new(permitted_params)
  unless @deposit.nil?
    return if save_and_redirect(@deposit, url: { action: :index })
    t3e mode: @deposit.mode.name
  end
end

#editObject


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

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
83
84
85
86
87
# 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,
    cash: mode.cash,
    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


117
118
119
120
121
122
123
124
125
126
# File 'app/controllers/backend/deposits_controller.rb', line 117

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


103
104
105
106
107
# File 'app/controllers/backend/deposits_controller.rb', line 103

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