From: Ira W. Snyder Date: Tue, 27 Nov 2007 00:22:37 +0000 (-0800) Subject: Add Reciept to the Purchase System X-Git-Tag: turned-in~16 X-Git-Url: https://www.irasnyder.com/gitweb/?a=commitdiff_plain;h=3675868d3ed4abc289309694772c385d529e35fa;p=cs356-p2-videostore.git Add Reciept to the Purchase System Signed-off-by: Ira W. Snyder --- diff --git a/app/controllers/purchase_controller.rb b/app/controllers/purchase_controller.rb index 6be4254..4492862 100644 --- a/app/controllers/purchase_controller.rb +++ b/app/controllers/purchase_controller.rb @@ -76,17 +76,26 @@ class PurchaseController < ApplicationController 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 @@ -174,7 +183,7 @@ class PurchaseController < ApplicationController purchase.rentable = @rentable purchase.save! - # Add te session variables + # Add to session variables session[:total] += @rentable.calculated_price session[:items].push @rentable diff --git a/app/views/purchase/menu.rhtml b/app/views/purchase/menu.rhtml index e2e01b5..5fc8814 100644 --- a/app/views/purchase/menu.rhtml +++ b/app/views/purchase/menu.rhtml @@ -27,6 +27,6 @@


-
  • <%=link_to 'End Purchase', :action => 'success_end' %>
  • +
  • <%=link_to 'End Purchase', :action => 'reciept' %>
  • diff --git a/app/views/purchase/reciept.rhtml b/app/views/purchase/reciept.rhtml new file mode 100644 index 0000000..2c4918a --- /dev/null +++ b/app/views/purchase/reciept.rhtml @@ -0,0 +1,49 @@ +

    Reciept

    + +

    Customer ID: <%= @customer.id.to_s %>

    +

    Customer Name: <%= @customer.name.to_s %>

    +
    +

    Transaction Date: <%= @time %>

    +
    + +

    Purchases:

    + + + + + + + + + + <% if @debt %> + + + + + + <% end %> +<% for item in @items %> + + + <% if item.class == Video or item.class == Game %> + + + <% else %> + + + <% end %> + +<% end %> + + + + + +
    ItemDue DatePrice
    Overdue Item Fees<%= number_to_currency(@debt) %>
    <%=h item.title %><%=h item.due_date %><%=h number_to_currency(item.calculated_price) %><%=h number_to_currency(item.price) %>
    Total<%= number_to_currency(@total) %>
    + +
    + +<%= link_to 'Start a new Purchase', :action => 'begin' %> + + diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 68cbfbe..74a0b45 100644 Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ