Class: DaysController

Inherits:
AuthorizedController
  • Object
show all
Defined in:
app/controllers/days_controller.rb

Instance Method Summary collapse

Instance Method Details

#calculate_cashObject

AJAX methods



8
9
10
11
12
13
14
# File 'app/controllers/days_controller.rb', line 8

def calculate_cash
  bills = params[:cash_register].select { |key, value| key.to_f > 5 }
  mint = params[:cash_register].select { |key, value| key.to_f <= 5 }

  @cash = bills.map { |a| a[0].to_f * a[1].to_f }.sum
  @cash += mint.map { |a| a[1].to_f }.sum
end

#createObject



2
3
4
5
# File 'app/controllers/days_controller.rb', line 2

def create
  # Create and redirect to index
  create! {days_path}
end