<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/models/charge.rb</filename>
    </added>
    <added>
      <filename>app/models/shipping_charge.rb</filename>
    </added>
    <added>
      <filename>app/models/tax_charge.rb</filename>
    </added>
    <added>
      <filename>db/migrate/20090618203233_create_charges.rb</filename>
    </added>
    <added>
      <filename>db/sample/charges.yml</filename>
    </added>
    <added>
      <filename>test/fixtures/charges.yml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -30,9 +30,9 @@ class CheckoutsController &lt; Spree::BaseController
     end 
 
     success.wants.js do   
-      render :json =&gt; { :order_total =&gt; number_to_currency(@order.total), 
-                        :ship_amount =&gt; number_to_currency(@order.ship_amount), 
-                        :tax_amount =&gt; number_to_currency(@order.tax_amount),
+      @order.reload
+      render :json =&gt; { :order_total =&gt; number_to_currency(@order.total),
+                        :charges =&gt; charge_hash,
                         :available_methods =&gt; rate_hash}.to_json,
              :layout =&gt; false
     end
@@ -74,5 +74,9 @@ class CheckoutsController &lt; Spree::BaseController
         :name =&gt; ship_method.name, 
         :rate =&gt; number_to_currency(ship_method.calculate_shipping(fake_shipment)) }
     end
+  end
+  
+  def charge_hash
+    Hash[*@order.charges.collect { |c| [c.description, number_to_currency(c.amount)] }.flatten]    
   end  
 end
\ No newline at end of file</diff>
      <filename>app/controllers/checkouts_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,10 +31,10 @@ module Spree::BaseHelper
     options.reverse_merge! :format_as_currency =&gt; true, :show_vat_text =&gt; true
     
     # overwrite show_vat_text if show_price_inc_vat is false
-    options[:show_vat_text] = Spree::Tax::Config[:show_price_inc_vat]
+    options[:show_vat_text] = Spree::Config[:show_price_inc_vat]
 
     amount =  order.item_total    
-    amount += Spree::VatCalculator.calculate_tax(order) if Spree::Tax::Config[:show_price_inc_vat]    
+    amount += Spree::VatCalculator.calculate_tax(order) if Spree::Config[:show_price_inc_vat]    
 
     options.delete(:format_as_currency) ? number_to_currency(amount) : amount
   end</diff>
      <filename>app/helpers/spree/base_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
-class Checkout &lt; ActiveRecord::Base
-  after_update :update_order_totals
+class Checkout &lt; ActiveRecord::Base  
   before_save :authorize_creditcard
+  after_save :update_charges
   belongs_to :order
   belongs_to :shipping_method
   belongs_to :bill_address, :foreign_key =&gt; &quot;bill_address_id&quot;, :class_name =&gt; &quot;Address&quot;
@@ -17,7 +17,26 @@ class Checkout &lt; ActiveRecord::Base
     return unless cc.valid? and cc.authorize(order.total)
     order.complete
   end
-  def update_order_totals
+  def update_charges
+    # update shipping (if applicable)
+    if shipping_method
+      ship_charge = order.shipping_charges.first
+      ship_charge ||= order.shipping_charges.build    
+      ship_charge.amount = shipping_method.calculate_shipping(Shipment.new(:order =&gt; order, :address =&gt; ship_address))
+      ship_charge.description = &quot;#{I18n.t(:shipping)} (#{shipping_method.name})&quot; 
+      ship_charge.save
+    end
+    # update tax (if applicable)
+    tax_amount = order.calculate_tax
+    if tax_amount &gt; 0                           
+      tax_charge = order.tax_charges.first
+      tax_charge ||= order.tax_charges.build(:description =&gt; I18n.t(:tax))
+      tax_charge.amount = tax_amount
+      tax_charge.save    
+    end
+
+    order.reload
     order.update_totals
+    order.save 
   end 
 end</diff>
      <filename>app/models/checkout.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 class Order &lt; ActiveRecord::Base  
-  before_save :update_line_items 
   before_create :generate_token
-  before_create :create_checkout
+  before_save :update_line_items, :update_totals
+  after_create :create_checkout
   
   has_many :line_items, :dependent =&gt; :destroy, :attributes =&gt; true
   has_many :inventory_units
@@ -13,14 +13,15 @@ class Order &lt; ActiveRecord::Base
   has_one :checkout
   has_one :bill_address, :through =&gt; :checkout
   has_one :ship_address, :through =&gt; :checkout   
-
+  has_many :charges, :order =&gt; :position
+  has_many :shipping_charges
+  has_many :tax_charges
+  
   delegate :email, :to =&gt; :checkout
   delegate :ip_address, :to =&gt; :checkout
   delegate :special_instructions, :to =&gt; :checkout 
   
   validates_associated :line_items, :message =&gt; &quot;are not valid&quot;
-  validates_numericality_of :tax_amount
-  validates_numericality_of :ship_amount
   validates_numericality_of :item_total
   validates_numericality_of :total
 
@@ -32,7 +33,7 @@ class Order &lt; ActiveRecord::Base
   make_permalink :field =&gt; :number
   
   # attr_accessible is a nightmare with attachment_fu, so use attr_protected instead.
-  attr_protected :ship_amount, :tax_amount, :item_total, :total, :user, :number, :ip_address, :checkout_complete, :state, :token
+  attr_protected :charge_total, :item_total, :total, :user, :number, :state, :token
 
   def to_param  
     self.number if self.number
@@ -138,10 +139,14 @@ class Order &lt; ActiveRecord::Base
     self.item_total = tot
   end
   
-  def total
-    self.total = self.item_total + self.ship_amount + self.tax_amount
-  end 
- 
+  def ship_total
+    shipping_charges.inject(0) { |sum, charge| charge.amount + 0 }  
+  end
+  
+  def tax_total
+    tax_charges.inject(0) { |sum, charge| charge.amount + 0 }  
+  end
+  
   # convenience method since many stores will not allow user to create multiple shipments
   def shipment
     shipments.last
@@ -172,16 +177,9 @@ class Order &lt; ActiveRecord::Base
     ShippingMethod.all.select { |method| method.zone.include?(ship_address) &amp;&amp; method.available?(self) }
   end
    
-  def update_totals
-    # finalize order totals 
-    tmp_shipment = shipment || Shipment.new(:order =&gt; self, :address =&gt; checkout.ship_address)
-    if checkout.shipping_method
-      self.ship_amount = checkout.shipping_method.calculate_shipping(tmp_shipment) if checkout.ship_address
-    else
-      self.ship_amount = 0
-    end
-    self.tax_amount = calculate_tax
-    save!
+  def update_totals                                 
+    self.charge_total = self.charges.inject(0) { |sum, charge| charge.amount + sum }   
+    self.total = self.item_total + self.charge_total
   end  
 
   def calculate_tax      
@@ -204,14 +202,13 @@ class Order &lt; ActiveRecord::Base
     shipments.build(:address =&gt; ship_address, :shipping_method =&gt; checkout.shipping_method)
     checkout.update_attribute(:completed_at, Time.now)
     InventoryUnit.sell_units(self)
-    #update_totals
     save_result = save! 
     if email 
       OrderMailer.deliver_confirm(self)
     end     
     save_result
-  end   
-  
+  end
+
   def cancel_order
     restock_inventory
     OrderMailer.deliver_cancel(self)
@@ -234,6 +231,6 @@ class Order &lt; ActiveRecord::Base
   end
   
   def create_checkout
-    self.checkout = Checkout.create unless self.checkout
-  end      
+    self.checkout = Checkout.create(:order =&gt; self) unless self.checkout
+  end
 end</diff>
      <filename>app/models/order.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ class Shipment &lt; ActiveRecord::Base
   belongs_to :address
 
   before_create :generate_shipment_number
-  after_save :recalculate_tax
+#  after_save :recalculate_tax
   after_save :transition_order
 
   attr_accessor :special_instructions 
@@ -41,8 +41,8 @@ class Shipment &lt; ActiveRecord::Base
     order.state_events.create(:name =&gt; I18n.t('ship'), :user =&gt; current_user, :previous_state =&gt; order.state_was)
   end
   
-  def recalculate_tax
-    return unless order &amp;&amp; order.respond_to?(:calculate_tax)      
-    order.update_attribute(&quot;tax_amount&quot;, order.calculate_tax)
-  end
+#  def recalculate_tax
+#    return unless order &amp;&amp; order.respond_to?(:calculate_tax)      
+#    order.update_attribute(&quot;tax_amount&quot;, order.calculate_tax)
+#  end
 end</diff>
      <filename>app/models/shipment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
 
 &lt;%= render :partial =&gt; 'admin/shared/order_tabs', :locals =&gt; {:current =&gt; &quot;Order Details&quot;} %&gt;
 
-&lt;%= render :partial =&gt; 'admin/shared/order_details', :locals =&gt; {:order =&gt; @order} -%&gt;
+&lt;%= render :partial =&gt; 'shared/order_details', :locals =&gt; {:order =&gt; @order} -%&gt;
 
 &lt;% if @order.bill_address %&gt;
   &lt;div class='adr'&gt;</diff>
      <filename>app/views/admin/orders/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@
   &lt;/ul&gt;
   &lt;br class='clear' /&gt;
 &lt;/div&gt;
-&lt;h1&gt;&lt;%=t(&quot;ext_tax_calculator_tax_rates&quot;) %&gt;&lt;/h1&gt;
+&lt;h1&gt;&lt;%=t(&quot;tax_rates&quot;) %&gt;&lt;/h1&gt;
 &lt;table class=&quot;index&quot;&gt;
   &lt;thead&gt;                        
     &lt;th&gt;&lt;%=t(&quot;zone&quot;)%&gt;&lt;/th&gt;</diff>
      <filename>app/views/admin/tax_rates/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -10,6 +10,7 @@ Order Summary [CANCELED]
 &lt;% end -%&gt;      
 ============================================================
 Subtotal: &lt;%= number_to_currency @order.item_total %&gt;
-Tax: &lt;%= number_to_currency @order.tax_amount %&gt;
-Shipping: &lt;%= number_to_currency @order.ship_amount %&gt;
+&lt;% @order.charges.each do |charge| %&gt;
+  &lt;%= &quot;#{charge.description}: #{number_to_currency charge.amount}&quot;%&gt;
+&lt;% end %&gt;
 Order Total: &lt;%= number_to_currency @order.total %&gt;</diff>
      <filename>app/views/order_mailer/cancel.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -10,8 +10,9 @@ Order Summary
 &lt;% end -%&gt;      
 ============================================================
 Subtotal: &lt;%= number_to_currency @order.item_total %&gt;
-Tax: &lt;%= number_to_currency @order.tax_amount %&gt;
-Shipping: &lt;%= number_to_currency @order.ship_amount %&gt;
+&lt;% @order.charges.each do |charge| %&gt;
+  &lt;%= &quot;#{charge.description}: #{number_to_currency charge.amount}&quot;%&gt;
+&lt;% end %&gt;
 Order Total: &lt;%= number_to_currency @order.total %&gt;
 
 </diff>
      <filename>app/views/order_mailer/confirm.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -10,8 +10,8 @@
   &quot;&lt;%= order.number %&gt;&quot;,		//Order Number
   &quot;&quot;,		//Affiliation
   &quot;&lt;%= order.total %&gt;&quot;,		//Order total
-  &quot;&lt;%= order.tax_amount %&gt;&quot;,		//Tax Amount
-  &quot;&lt;%= order.ship_amount %&gt;&quot;,		//Ship Amount
+  &quot;&lt;%= order.tax_charges.sum(:amount).to_s %&gt;&quot;,		//Tax Amount
+  &quot;&lt;%= order.shipping_charges.sum(:amount).to_s %&gt;&quot;,		//Ship Amount
   &quot;&quot;,		//City
   &quot;&quot;,		//State
   &quot;&quot;		//Country</diff>
      <filename>app/views/orders/_google_order.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,36 +1,38 @@
-&lt;table class=&quot;order-summary&quot;&gt;
-  &lt;tr&gt;
-    &lt;th&gt;&lt;%= t('item_description') %&gt;&lt;/th&gt;
-    &lt;th class=&quot;price&quot;&gt;&lt;%= t('price') %&gt;&lt;/th&gt;
-    &lt;th class=&quot;qty&quot;&gt;&lt;%= t('qty') %&gt;&lt;/th&gt;
-    &lt;th class=&quot;total_display&quot;&gt;&lt;span&gt;&lt;%= t('total') %&gt;&lt;/span&gt;&lt;/th&gt;
-  &lt;/tr&gt;
-  &lt;% @order.line_items.each do |item| %&gt;
-  &lt;tr &gt;
-    &lt;td width=&quot;300&quot;&gt;&lt;%=item.variant.product.name-%&gt; &lt;%= &quot;(&quot; + variant_options(item.variant) + &quot;)&quot; unless item.variant .option_values.empty? %&gt;&lt;/td&gt;
-    &lt;td valign=&quot;top&quot;&gt;&lt;%= number_to_currency item.price -%&gt;&lt;/td&gt;
-    &lt;td valign=&quot;top&quot;&gt;&lt;%=item.quantity-%&gt;&lt;/td&gt;
-    &lt;td valign=&quot;top&quot; class=&quot;total_display&quot;&gt;&lt;span&gt;&lt;%= number_to_currency (item.price * item.quantity)-%&gt;&lt;/span&gt;&lt;/td&gt;
-  &lt;/tr&gt;
-  &lt;% end %&gt;      
-  &lt;tr id=&quot;subtotal-row&quot;&gt;
-    &lt;td colspan=&quot;3&quot;&gt;&lt;b&gt;&lt;%= t('subtotal') %&gt;:&lt;/b&gt;&lt;/td&gt;
-    &lt;td class=&quot;total_display&quot;&gt;&lt;span&gt;&lt;%= number_to_currency @order.item_total -%&gt;&lt;/span&gt;&lt;/td&gt;
-  &lt;/tr&gt;
-  &lt;tr&gt;
-    &lt;td colspan=&quot;3&quot;&gt;&lt;b&gt;&lt;%= t('tax') %&gt;:&lt;/b&gt;&lt;/td&gt;
-    &lt;td class=&quot;total_display&quot;&gt;&lt;span id=&quot;tax_amount&quot;&gt;&lt;%= number_to_currency @order.tax_amount -%&gt;&lt;/span&gt;&lt;/td&gt;
-  &lt;/tr&gt;
-  &lt;tr&gt;
-    &lt;td colspan=&quot;3&quot;&gt;&lt;b&gt;&lt;%= t('shipping') %&gt;:&lt;/b&gt; 
-      &lt;% if @order.shipment &amp;&amp; @order.shipment.shipping_method %&gt;
-        &lt;span id=&quot;ship_method&quot;&gt;(&lt;%= @order.shipment.shipping_method.name %&gt;)&lt;/span&gt;
-      &lt;% end %&gt;
-    &lt;/td&gt;
-    &lt;td class=&quot;total_display&quot;&gt;&lt;span id=&quot;ship_amount&quot;&gt;&lt;%= number_to_currency @order.ship_amount -%&gt;&lt;/span&gt;&lt;/td&gt;
-  &lt;/tr&gt;
-  &lt;tr&gt;
-    &lt;td colspan=&quot;3&quot;&gt;&lt;b&gt;&lt;%= t('order_total') %&gt;:&lt;/b&gt;&lt;/td&gt;
-    &lt;td class=&quot;total_display&quot;&gt;&lt;span id=&quot;order_total&quot;&gt;&lt;%= number_to_currency @order.total -%&gt;&lt;/span&gt;&lt;/td&gt;
-  &lt;/tr&gt;
-&lt;/table&gt;
+&lt;table class=&quot;index&quot;&gt;
+  &lt;tbody id='line-items'&gt;
+    &lt;tr&gt;
+      &lt;th&gt;&lt;%= t('item_description') %&gt;&lt;/th&gt;
+      &lt;th class=&quot;price&quot;&gt;&lt;%= t('price') %&gt;&lt;/th&gt;
+      &lt;th class=&quot;qty&quot;&gt;&lt;%= t('qty') %&gt;&lt;/th&gt;
+      &lt;th class=&quot;total_display&quot;&gt;&lt;span&gt;&lt;%= t('total') %&gt;&lt;/span&gt;&lt;/th&gt;
+    &lt;/tr&gt;
+    &lt;% @order.line_items.each do |item| %&gt;
+      &lt;tr &gt;
+        &lt;td width=&quot;300&quot;&gt;&lt;%=item.variant.product.name-%&gt; &lt;%= &quot;(&quot; + variant_options(item.variant) + &quot;)&quot; unless item.variant .option_values.empty? %&gt;&lt;/td&gt;
+        &lt;td valign=&quot;top&quot;&gt;&lt;%= number_to_currency item.price -%&gt;&lt;/td&gt;
+        &lt;td valign=&quot;top&quot;&gt;&lt;%=item.quantity-%&gt;&lt;/td&gt;
+        &lt;td valign=&quot;top&quot; class=&quot;total_display&quot;&gt;&lt;span&gt;&lt;%= number_to_currency (item.price * item.quantity)-%&gt;&lt;/span&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;% end %&gt;      
+  &lt;/tbody&gt;
+  &lt;tbody id='subtotal'&gt;
+    &lt;tr class=&quot;total&quot; id=&quot;subtotal-row&quot;&gt;
+      &lt;td colspan=&quot;3&quot;&gt;&lt;b&gt;&lt;%= t('subtotal') %&gt;:&lt;/b&gt;&lt;/td&gt;
+      &lt;td class=&quot;total_display&quot;&gt;&lt;span&gt;&lt;%= number_to_currency @order.item_total -%&gt;&lt;/span&gt;&lt;/td&gt;
+    &lt;/tr&gt;
+  &lt;/tbody&gt;
+  &lt;tbody id=&quot;order-charges&quot;&gt;
+    &lt;% order.charges.each do |charge| %&gt;
+      &lt;tr class=&quot;total&quot;&gt;
+        &lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;&lt;%= charge.description %&gt;&lt;/strong&gt;&lt;/td&gt;
+        &lt;td class=&quot;total_display&quot;&gt;&lt;span&gt;&lt;%= number_to_currency charge.amount -%&gt;&lt;/span&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;% end %&gt;
+  &lt;/tbody&gt;
+  &lt;tbody id='order-total'&gt;
+    &lt;tr class=&quot;total&quot;&gt;
+      &lt;td colspan=&quot;3&quot;&gt;&lt;b&gt;&lt;%= t('order_total') %&gt;:&lt;/b&gt;&lt;/td&gt;
+      &lt;td class=&quot;total_display&quot;&gt;&lt;span id=&quot;order_total&quot;&gt;&lt;%= number_to_currency @order.total -%&gt;&lt;/span&gt;&lt;/td&gt;
+    &lt;/tr&gt;
+  &lt;/tbody&gt;
+&lt;/table&gt;
\ No newline at end of file</diff>
      <filename>app/views/shared/_order_details.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -46,10 +46,8 @@ en-US:
         ip_address: &quot;IP Address&quot;
         item_total: &quot;Item Total&quot;
         number: Number
-        ship_amount: &quot;Ship Amount&quot;
         special_instructions: &quot;Special Instructions&quot;
         state: State
-        tax_amount: &quot;Tax Amount&quot;
         total: Total
       product: 
         available_on: &quot;Available On&quot;</diff>
      <filename>config/locales/en-US.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,12 @@
 class Order &lt; ActiveRecord::Base  
   belongs_to :bill_address, :foreign_key =&gt; &quot;bill_address_id&quot;, :class_name =&gt; &quot;Address&quot;
-  belongs_to :ship_address, :foreign_key =&gt; &quot;ship_address_id&quot;, :class_name =&gt; &quot;Address&quot;
+  belongs_to :ship_address, :foreign_key =&gt; &quot;ship_address_id&quot;, :class_name =&gt; &quot;Address&quot;  
+  has_many :shipments
+end
+Checkout.class_eval do
+  # temporarily disable the charge stuff since its interfering with this migration
+  def update_charges
+  end
 end
 
 class CreateCheckouts &lt; ActiveRecord::Migration
@@ -19,13 +25,13 @@ class CreateCheckouts &lt; ActiveRecord::Migration
     change_table :creditcards do |t|
       t.references :checkout
     end                     
-    
+
     Checkout.reset_column_information
     Creditcard.reset_column_information
     
     # move address, etc. from order to checkout
     Order.all.each do |order|             
-      shipping_method = order.shipment.shipping_method if order.shipment  
+      shipping_method = order.shipments.last.shipping_method if order.shipments.present?  
       completed_at = order.attributes[&quot;created_at&quot;] if order.attributes[&quot;checkout_complete&quot;] 
       creditcard = Creditcard.find_by_order_id(order.id)
       checkout = Checkout.create(:order =&gt; order, </diff>
      <filename>db/migrate/20090603153927_create_checkouts.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ checkout_&lt;%= i %&gt;:
   ship_address: frank_ship_address_&lt;%= i %&gt;
   bill_address: frank_bill_address_&lt;%= i %&gt;
   email: frank.foo@example.com 
-  order: order_&lt;%= i %&gt; 
-  ip_address: 127.0.0.1 
-  completed_at: &lt;%= Time.now %&gt;
+  order: order_&lt;%= i %&gt;
+  completed_at: &lt;%=Time.now%&gt;
+  ip_address: 127.0.0.1
 &lt;% end %&gt;
\ No newline at end of file</diff>
      <filename>db/sample/checkouts.yml</filename>
    </modified>
    <modified>
      <diff>@@ -3,8 +3,6 @@ order_&lt;%= i %&gt;:
   user: frank
   number: &lt;%= &quot;R#{Array.new(9){rand(9)}.join}&quot; %&gt;
   state: new
-  ship_amount: 5.00
-  tax_amount: 2.78
   item_total: 37.97
   total: 45.75
 &lt;% end %&gt;
\ No newline at end of file</diff>
      <filename>db/sample/orders.yml</filename>
    </modified>
    <modified>
      <diff>@@ -301,10 +301,12 @@ var update_shipping_methods = function(methods) {
 };                                     
 
 var update_confirmation = function(order) {
+  var textToInsert = '';
+  for (var key in order.charges) {
+    textToInsert  += '&lt;tr&gt;&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;' + key + '&lt;/strong&gt;&lt;/td&gt;&lt;td class=&quot;total_display&quot;&gt;&lt;span&gt;' + order.charges[key] + '&lt;/span&gt;&lt;/td&gt;';
+  }
+  $('tbody#order-charges').html(textToInsert); 
   $('span#order_total').html(order.order_total);
-  $('span#ship_amount').html(order.ship_amount);
-  $('span#tax_amount').html(order.tax_amount);                                  
-  $('span#ship_method').html(order.ship_method);                                    
 };      
 
 var submit_registration = function() {</diff>
      <filename>public/javascripts/checkout.js</filename>
    </modified>
    <modified>
      <diff>@@ -147,3 +147,6 @@ div#order
         :display block
         :text-align right
         :padding-right 150px
+                                 
+tbody#subtotal
+  border-bottom:1px solid #DDDDDD;
\ No newline at end of file</diff>
      <filename>public/stylesheets/sass/_checkout.sass</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 Factory.define :order do |f| 
-  f.line_items { [Factory(:line_item)] }
   f.charges { [Factory(:ship_charge), Factory(:tax_charge)] } 
 end
 
@@ -116,4 +115,14 @@ end
 Factory.define :creditcard_txn do |f|
   f.amount 45.75
   f.response_code 12345
+end
+
+Factory.define :ship_charge, :class =&gt; ShippingCharge do |f|
+  f.amount 8.99
+  f.description &quot;Shipping&quot;
+end
+
+Factory.define :tax_charge, :class =&gt; TaxCharge do |f|
+  f.amount 3.17
+  f.description &quot;Sales Tax&quot;
 end
\ No newline at end of file</diff>
      <filename>test/factories.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,16 +5,17 @@ class ChargeTest &lt; ActiveSupport::TestCase
   should_validate_presence_of :description
   context &quot;order instance with charges&quot; do
     setup do
-      @charge = Factory(:tax_charge, :amount =&gt; 3.00)
+      @charge = Factory(:tax_charge, :amount =&gt; 3.17)
       @order = Factory(:order, :charges =&gt; [@charge])
     end
     context &quot;when adding another charge&quot; do
       setup do 
         @order.charges &lt;&lt; Factory(:ship_charge, :amount =&gt; 8.99)
         @order.save
-      end                                          
-      should_change &quot;@order.total&quot;, :by =&gt; 8.99
-      should_change &quot;@order.charge_total&quot;, :by =&gt; 8.99
+      end
+      
+      should_change &quot;@order.total.to_f&quot;, :by =&gt; 8.99
+      should_change &quot;@order.charge_total.to_f&quot;, :by =&gt; 8.99
       should_not_change &quot;@order.item_total&quot;
     end
     context &quot;when destroying a charge&quot; do
@@ -22,8 +23,8 @@ class ChargeTest &lt; ActiveSupport::TestCase
         @order.charges.clear
         @order.save
       end
-      should_change &quot;@order.total.to_f&quot;, :by =&gt; -3.00
-      should_change &quot;@order.charge_total&quot;, :by =&gt; -3.00
+      should_change &quot;@order.total.to_f&quot;, :by =&gt; -3.17
+      should_change &quot;@order.charge_total.to_f&quot;, :by =&gt; -3.17
       should_not_change &quot;@order.item_total&quot;
     end
   end</diff>
      <filename>test/unit/charge_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,62 @@ class CheckoutTest &lt; ActiveSupport::TestCase
       should_not_change &quot;Creditcard.count&quot;
       should_not_change &quot;CreditcardPayment.count&quot;
       should_not_change &quot;CreditcardTxn.count&quot;
+    end
+  end
+
+  context &quot;belonging to an order&quot; do
+    setup do 
+      @checkout = Checkout.new(:order =&gt; Order.create, :ship_address =&gt; Factory(:address), :bill_address =&gt; Factory(:address))
+    end
+    context &quot;with no shipping method&quot; do
+      setup { @checkout.save }
+      should_not_change &quot;@checkout.order.shipping_charges&quot;
     end  
+    context &quot;with shipping method&quot; do
+      setup do
+        @shipping_method = ShippingMethod.new  
+        @checkout.shipping_method = @shipping_method
+        @shipping_method.stub!(:available?, :return =&gt; true)
+        @shipping_method.stub!(:calculate_shipping, :return =&gt; 10)
+        @checkout.save 
+      end
+      should &quot;increase shipping_charges by 1&quot; do
+        assert_equal 1, @checkout.order.shipping_charges.size
+      end
+      should &quot;have the correct value for the new shipping charge&quot; do
+        assert_equal 10, @checkout.order.shipping_charges.first.amount
+      end
+      should_change &quot;@checkout.order.total&quot;, :by =&gt; 10
+      context &quot;and shipping amount changes&quot; do
+        setup do
+          @shipping_method.stub!(:calculate_shipping, :return =&gt; 20)
+          @checkout.save
+        end
+        should_not_change &quot;@checkout.order.shipping_charges.count&quot;
+        should_change &quot;@checkout.order.shipping_charges.first.amount&quot;, :from =&gt; 10, :to =&gt; 20
+      end      
+    end 
+    context &quot;with taxable items&quot; do
+      setup do
+        @checkout.order.stub!(:calculate_tax, :return =&gt; 15)
+        @checkout.save
+      end
+      should &quot;increase tax_charges by 1&quot; do
+        assert_equal 1, @checkout.order.tax_charges.size
+      end
+      should &quot;have the correct value for the newly created tax charge&quot; do
+        assert_equal 15, @checkout.order.tax_charges.first.amount
+      end
+      should_change &quot;@checkout.order.total&quot;, :by =&gt; 15
+      context &quot;and tax amount changes&quot; do
+        setup do
+          @checkout.order.stub!(:calculate_tax, :return =&gt; 8)
+          @checkout.save
+        end
+        should_not_change &quot;@checkout.order.tax_charges.count&quot;
+        should_change &quot;@checkout.order.tax_charges.first.amount&quot;, :from =&gt; 15, :to =&gt; 8
+      end
+    end 
   end
+
 end</diff>
      <filename>test/unit/checkout_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -85,8 +85,8 @@ module Spree
        :customer =&gt; checkout.email, 
        :ip =&gt; checkout.ip_address, 
        :order_id =&gt; checkout.order.number,
-       :shipping =&gt; checkout.order.ship_amount * 100,
-       :tax =&gt; checkout.order.tax_amount * 100, 
+       :shipping =&gt; checkout.order.ship_total * 100,
+       :tax =&gt; checkout.order.tax_total * 100, 
        :subtotal =&gt; checkout.order.item_total * 100}  
     end
     </diff>
      <filename>vendor/extensions/payment_gateway/lib/spree/payment_gateway.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>app/views/admin/shared/_order_details.html.erb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>0112563ec294c320e2c33ffac144d558b6b743e8</id>
    </parent>
  </parents>
  <author>
    <name>Sean Schofield</name>
    <login>schof</login>
    <email>schof@apache.org</email>
  </author>
  <url>http://github.com/railsdog/spree/commit/0f12041d6412364767d9daec5d5a165f8633053e</url>
  <id>0f12041d6412364767d9daec5d5a165f8633053e</id>
  <committed-date>2009-06-24T19:22:12-07:00</committed-date>
  <authored-date>2009-06-18T13:44:50-07:00</authored-date>
  <message>Replaced ship_amount and tax_amount with a flexible system of charges. [#499 state:resolved milestone:0.8.99]</message>
  <tree>5be2245dc58e9504d351f5f574d827ce3c1479d3</tree>
  <committer>
    <name>Sean Schofield</name>
    <login>schof</login>
    <email>schof@apache.org</email>
  </committer>
</commit>
