| Class | Cart |
| In: |
app/models/cart.rb
|
| Parent: | Object |
Class to hande the cart at checkout process. It stores all reservations and force addons
| items | [R] | |
| total_price | [R] |
Add a new line to the card - also the force addons are included. The total amount is calculated from room price and addons
# File app/models/cart.rb, line 26
26: def add_line(addons, room, total, arrival, departure, adults, children)
27: #item_check = @items.find {|i| i.room.id == room.id and i.arrival arrival}
28: #if !item_check
29: if !check_doubles(room, arrival, departure)
30: item = CartItem.new(@index, addons, room, total, arrival, departure, adults, children)
31: @items << item
32: @total_price += total.to_f
33: @index = @index + 1
34: return true
35: else
36: return false
37: end
38: end
# File app/models/cart.rb, line 55
55: def change_total(amount)
56: @total_price = @total_price - amount.to_f
57: end
# File app/models/cart.rb, line 40
40: def check_doubles(room, arrival, departure)
41: item_check = @items.find {|i| i.room.id == room.id and \
42: ((i.arrival <= arrival and i.departure >= arrival) or \
43: (i.arrival <= departure and i.departure >= departure) or \
44: (arrival <= i.arrival and departure >= i.departure))}
45: end