From 3675868d3ed4abc289309694772c385d529e35fa Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Mon, 26 Nov 2007 16:22:37 -0800 Subject: [PATCH] Add Reciept to the Purchase System Signed-off-by: Ira W. Snyder --- app/controllers/purchase_controller.rb | 19 +++++++--- app/views/purchase/menu.rhtml | 2 +- app/views/purchase/reciept.rhtml | 49 +++++++++++++++++++++++++ db/development.sqlite3 | Bin 30720 -> 30720 bytes 4 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 app/views/purchase/reciept.rhtml 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 68cbfbea4bbb7321a0643fe135e4412471354711..74a0b4545b532870429c8e474fd017248eae2f69 100644 GIT binary patch delta 825 zcmZuvK~EDw6rT6q7F)V0l`dil7HV<2jBVN0vK57LGsbW*kpqVwB*u^s5W~@UXpILB z9wdA57pMng3Y!>@9{dAF4r|hbR}&A!7%n8}Y zSa8PWhYrkd$yrJ>9h(e);SqkoSNH^5^ctJAN1L=l6;$V-+@K%tVX$7E!S*?7A7Z#SYJ&l?q4+c4thirp@F9oEQ5Q_n+A&8p+L;!vxEJD5zI)PtTK@DXTb_C}G zDC0$4L4IwJBx(UE|HP|dXo6cRbS_G&M6m2b&6Y)nlV6e*G7OBdBEZV}?#9FEyE~5` z?Cd@&Xk#E*gnQfTTU!H`J#+sQW15b1;y;>mbV?`gdF=;by5yeDC3NcoYccYuD<4aX z>ZId${D?2`KGrb~y>OEyxk-<8*&b`{cT5zepgDhwR|m6kF&Ie9s@}O7k{MA{HG&7w r-}e<|6*G~c5E(8d(>(?V5C>8$8#Qins{_2;}ih#BKe?l zj7A0q=DLQ4x<;mOmbnZQRF)GaW?%th8CuA&KxA3?U}8qbFqW~w^V`9*n}ETW7+ zQ6|RV+{Bz5m?%T{=Kt!fEL@Dtzd->e!2El&pvimY&42aTc|u^46( lW*(*oOglC -- 2.25.1