session[:items] = []
end
- def success_end
- # Set the customer's debt to $0.00. They MUST pay you before
- # checking anything else out, of course
+ def reciept
+ # Save important data, since we're gonna wipe it out now
+ @customer = Customer.find_by_id(session[:customer_id])
+ @debt = @customer.debt
+ @total = session[:total] + @debt
+ @items = session[:items]
+ @time = Time.now
+
+ # Set the customer's debt to $0.00, she paid us
@customer = Customer.find_by_id(session[:customer_id])
@customer.debt = 0.00
@customer.save
+ # Wipe session data
session[:customer_id] = nil
session[:total] = nil
session[:items] = nil
- redirect_to :action => :begin
+
+ # Show the reciept
+ render :action => 'reciept'
end
def customer_ok
purchase.rentable = @rentable
purchase.save!
- # Add te session variables
+ # Add to session variables
session[:total] += @rentable.calculated_price
session[:items].push @rentable
<br/>
<br/>
<br/>
- <li><%=link_to 'End Purchase', :action => 'success_end' %></li>
+ <li><%=link_to 'End Purchase', :action => 'reciept' %></li>
</ul>
--- /dev/null
+<h1>Reciept</h1>
+
+<p><b>Customer ID: </b><%= @customer.id.to_s %></p>
+<p><b>Customer Name: </b><%= @customer.name.to_s %></p>
+<br/>
+<p><b>Transaction Date: </b><%= @time %></p>
+<br/>
+
+<p><b>Purchases:</b></p>
+<table border="1">
+ <!-- Header -->
+ <tr>
+ <th>Item</th>
+ <th>Due Date</th>
+ <th>Price</th>
+ </tr>
+
+ <!-- Debt -->
+ <% if @debt %>
+ <tr>
+ <td><b>Overdue Item Fees</b></td>
+ <td></td>
+ <td><%= number_to_currency(@debt) %></td>
+ </tr>
+ <% end %>
+<% for item in @items %>
+ <tr>
+ <td><%=h item.title %></td>
+ <% if item.class == Video or item.class == Game %>
+ <td><%=h item.due_date %></td>
+ <td><%=h number_to_currency(item.calculated_price) %></td>
+ <% else %>
+ <td></td>
+ <td><%=h number_to_currency(item.price) %></td>
+ <% end %>
+ </tr>
+<% end %>
+ <tr>
+ <td><b>Total</b></td>
+ <td></td>
+ <td><b><%= number_to_currency(@total) %></b></td>
+ </tr>
+</table>
+
+<br/>
+
+<%= link_to 'Start a new Purchase', :action => 'begin' %>
+
+