From b1c9706abc4d093daf9b5233a3ece6b0445f96b5 Mon Sep 17 00:00:00 2001
From: Martin Meyerhoff <mamhoff@gmail.com>
Date: Mon, 26 Oct 2015 11:14:48 +0100
Subject: [PATCH] Use gross amount in order for return items

I believe the notion of `pre_tax_amount` is only in the return items because
someone from a sales tax country wanted to use something with additional taxes.

This leads to unfortunate behaviour in VAT stores: While every other price or amount
is entered including VAT, for returns a store admin has to enter the return amount
excluding VAT. For most normal people, that's a complex, error-prone op, and one we
shouldn't make them do.

Unfortunately, this entails a lot of naming changes.
---
 .../admin/return_authorizations_controller.rb |  2 +-
 .../_return_item_decision.html.erb            |  4 +-
 .../_return_item_selection.html.erb           |  8 ++--
 .../spree/admin/reimbursements/edit.html.erb  |  2 +-
 .../spree/admin/reimbursements/show.html.erb  |  4 +-
 .../return_authorizations/_form.html.erb      |  8 ++--
 .../admin/customer_returns_controller_spec.rb |  2 +-
 .../returns/default_refund_amount.rb          | 14 +++----
 core/app/models/spree/customer_return.rb      |  9 ++++-
 core/app/models/spree/order.rb                |  5 +++
 .../spree/reimbursement_tax_calculator.rb     |  2 +-
 core/app/models/spree/return_authorization.rb | 10 +++--
 core/app/models/spree/return_item.rb          | 30 +++++++-------
 core/config/locales/en.yml                    |  2 +-
 ...ge_return_item_pre_tax_amount_to_amount.rb | 27 +++++++++++++
 core/lib/spree/permitted_attributes.rb        |  2 +-
 .../refunds/default_refund_amount_spec.rb     | 18 ++++-----
 .../spec/models/spree/customer_return_spec.rb | 24 ++++++------
 core/spec/models/spree/reimbursement_spec.rb  |  8 ++--
 .../original_payment_spec.rb                  |  2 +-
 .../models/spree/return_authorization_spec.rb | 28 ++++++-------
 core/spec/models/spree/return_item_spec.rb    | 39 ++++++++++---------
 22 files changed, 147 insertions(+), 103 deletions(-)
 create mode 100644 core/db/migrate/20151026093607_change_return_item_pre_tax_amount_to_amount.rb

diff --git a/backend/app/controllers/spree/admin/return_authorizations_controller.rb b/backend/app/controllers/spree/admin/return_authorizations_controller.rb
index f191b3ff0d8..914304da669 100644
--- a/backend/app/controllers/spree/admin/return_authorizations_controller.rb
+++ b/backend/app/controllers/spree/admin/return_authorizations_controller.rb
@@ -30,7 +30,7 @@ def load_return_items
         unassociated_inventory_units = all_inventory_units - associated_inventory_units
 
         new_return_items = unassociated_inventory_units.map do |new_unit|
-          Spree::ReturnItem.new(inventory_unit: new_unit).tap(&:set_default_pre_tax_amount)
+          Spree::ReturnItem.new(inventory_unit: new_unit).tap(&:set_default_amount)
         end
         @form_return_items = (@return_authorization.return_items + new_return_items).sort_by(&:inventory_unit_id)
       end
diff --git a/backend/app/views/spree/admin/customer_returns/_return_item_decision.html.erb b/backend/app/views/spree/admin/customer_returns/_return_item_decision.html.erb
index c1d45383bec..fe4271d8d7c 100644
--- a/backend/app/views/spree/admin/customer_returns/_return_item_decision.html.erb
+++ b/backend/app/views/spree/admin/customer_returns/_return_item_decision.html.erb
@@ -3,7 +3,7 @@
     <tr>
       <th><%= Spree::Product.model_name.human %></th>
       <th><%= Spree::Variant.human_attribute_name(:sku) %></th>
-      <th><%= Spree::ReturnItem.human_attribute_name(:pre_tax_amount) %></th>
+      <th><%= Spree::ReturnItem.human_attribute_name(:amount) %></th>
       <th><%= Spree::ReturnItem.human_attribute_name(:preferred_reimbursement_type) %></th>
       <th><%= Spree::ReturnItem.human_attribute_name(:exchange_variant) %></th>
       <th><%= Spree::ReturnItem.human_attribute_name(:acceptance_status_errors) %></th>
@@ -27,7 +27,7 @@
           <%= return_item.inventory_unit.variant.sku %>
         </td>
         <td class="align-center">
-          <%= return_item.display_pre_tax_amount %>
+          <%= return_item.display_amount %>
         </td>
         <td class="align-center">
           <%= reimbursement_type_name(return_item.preferred_reimbursement_type) %>
diff --git a/backend/app/views/spree/admin/customer_returns/_return_item_selection.html.erb b/backend/app/views/spree/admin/customer_returns/_return_item_selection.html.erb
index 259e0507be5..5091969a429 100644
--- a/backend/app/views/spree/admin/customer_returns/_return_item_selection.html.erb
+++ b/backend/app/views/spree/admin/customer_returns/_return_item_selection.html.erb
@@ -6,7 +6,7 @@
       </th>
       <th><%= Spree::Product.model_name.human %></th>
       <th><%= Spree::Variant.human_attribute_name(:sku) %></th>
-      <th><%= Spree::ReturnItem.human_attribute_name(:pre_tax_amount) %></th>
+      <th><%= Spree::ReturnItem.human_attribute_name(:amount) %></th>
       <th><%= Spree::ReturnItem.human_attribute_name(:inventory_unit_state) %></th>
       <th><%= Spree::ReturnItem.human_attribute_name(:exchange_variant) %></th>
       <th><%= Spree::ReturnItem.human_attribute_name(:resellable) %></th>
@@ -23,9 +23,9 @@
           <div style="display:none">
             <%= item_fields.hidden_field :inventory_unit_id %>
             <%= item_fields.hidden_field :return_authorization_id %>
-            <%= item_fields.hidden_field :pre_tax_amount %>
+            <%= item_fields.hidden_field :amount %>
           </div>
-          <%= item_fields.check_box :returned, {checked: false, class: 'add-item', "data-price" => return_item.pre_tax_amount}, '1', '0' %>
+          <%= item_fields.check_box :returned, {checked: false, class: 'add-item', "data-price" => return_item.amount}, '1', '0' %>
         </td>
         <td>
           <div class="variant-name"><%= return_item.inventory_unit.variant.name %></div>
@@ -35,7 +35,7 @@
           <%= return_item.inventory_unit.variant.sku %>
         </td>
         <td class="align-center">
-          <%= return_item.display_pre_tax_amount %>
+          <%= return_item.display_amount %>
         </td>
         <td class="align-center">
           <%= return_item.inventory_unit.state %>
diff --git a/backend/app/views/spree/admin/reimbursements/edit.html.erb b/backend/app/views/spree/admin/reimbursements/edit.html.erb
index 4db8274783e..bf949354113 100644
--- a/backend/app/views/spree/admin/reimbursements/edit.html.erb
+++ b/backend/app/views/spree/admin/reimbursements/edit.html.erb
@@ -44,7 +44,7 @@
               ) %>
             </td>
             <td class="align-center">
-              <%= item_fields.text_field :pre_tax_amount, { class: 'refund-amount-input' } %>
+              <%= item_fields.text_field :amount, { class: 'refund-amount-input' } %>
             </td>
             <td class="align-center">
               <%= return_item.display_total %>
diff --git a/backend/app/views/spree/admin/reimbursements/show.html.erb b/backend/app/views/spree/admin/reimbursements/show.html.erb
index 7e098dbcd2b..d55b630304e 100644
--- a/backend/app/views/spree/admin/reimbursements/show.html.erb
+++ b/backend/app/views/spree/admin/reimbursements/show.html.erb
@@ -19,7 +19,7 @@
         <th><%= Spree.t(:preferred_reimbursement_type) %></th>
         <th><%= Spree.t(:reimbursement_type_override) %></th>
         <th><%= Spree.t(:exchange_for) %></th>
-        <th><%= Spree.t(:pre_tax_amount) %></th>
+        <th><%= Spree.t(:amount) %></th>
         <th><%= Spree.t(:total) %></th>
       </tr>
     </thead>
@@ -41,7 +41,7 @@
             <%= return_item.exchange_variant.try(:exchange_name) %>
           </td>
           <td class="align-center">
-            <%= return_item.display_pre_tax_amount %>
+            <%= return_item.display_amount %>
           </td>
           <td class="align-center">
             <%= return_item.display_total %>
diff --git a/backend/app/views/spree/admin/return_authorizations/_form.html.erb b/backend/app/views/spree/admin/return_authorizations/_form.html.erb
index b1ea07fff07..584cd1a5ba1 100644
--- a/backend/app/views/spree/admin/return_authorizations/_form.html.erb
+++ b/backend/app/views/spree/admin/return_authorizations/_form.html.erb
@@ -27,7 +27,7 @@
           <td class="return-item-checkbox align-center inventory-unit-checkbox">
             <% if editable %>
               <%= item_fields.hidden_field :inventory_unit_id %>
-              <%= item_fields.check_box :_destroy, {checked: return_item.persisted?, class: 'add-item', "data-price" => return_item.pre_tax_amount}, '0', '1' %>
+              <%= item_fields.check_box :_destroy, {checked: return_item.persisted?, class: 'add-item', "data-price" => return_item.amount}, '0', '1' %>
             <% end %>
           </td>
           <td class="return-item-product">
@@ -36,13 +36,13 @@
           </td>
           <td class="return-item-state align-center"><%= inventory_unit.state.humanize %></td>
           <td class="return-item-charged align-center">
-            <%= return_item.display_pre_tax_amount %>
+            <%= return_item.display_amount %>
           </td>
           <td class="return-item-pre-tax-refund-amount align-center">
             <% if editable %>
-              <%= item_fields.text_field :pre_tax_amount, { class: 'refund-amount-input' } %>
+              <%= item_fields.text_field :amount, { class: 'refund-amount-input' } %>
             <% else %>
-              <%= return_item.display_pre_tax_amount %>
+              <%= return_item.display_amount %>
             <% end %>
           </td>
           <td class="return-item-reimbursement-type">
diff --git a/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb b/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb
index 63efb005f8f..c97f2815b65 100644
--- a/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb
+++ b/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb
@@ -193,7 +193,7 @@ module Admin
               return_items_attributes: {
                 "0" => {
                   returned: "1",
-                  "pre_tax_amount" => "15.99",
+                  amount: "15.99",
                   inventory_unit_id: order.inventory_units.shipped.last.id,
                   reception_status_event: reception_status_event
                 }
diff --git a/core/app/models/spree/calculator/returns/default_refund_amount.rb b/core/app/models/spree/calculator/returns/default_refund_amount.rb
index 96cf2563a53..013ff4c9e10 100644
--- a/core/app/models/spree/calculator/returns/default_refund_amount.rb
+++ b/core/app/models/spree/calculator/returns/default_refund_amount.rb
@@ -9,7 +9,7 @@ def self.description
 
       def compute(return_item)
         return 0.0.to_d if return_item.part_of_exchange?
-        weighted_order_adjustment_amount(return_item.inventory_unit) + weighted_line_item_pre_tax_amount(return_item.inventory_unit)
+        weighted_order_adjustment_amount(return_item.inventory_unit) + weighted_line_item_amount(return_item.inventory_unit)
       end
 
       private
@@ -18,18 +18,18 @@ def weighted_order_adjustment_amount(inventory_unit)
         inventory_unit.order.adjustments.eligible.non_tax.sum(:amount) * percentage_of_order_total(inventory_unit)
       end
 
-      def weighted_line_item_pre_tax_amount(inventory_unit)
-        inventory_unit.line_item.pre_tax_amount * percentage_of_line_item(inventory_unit)
+      def weighted_line_item_amount(inventory_unit)
+        inventory_unit.line_item.discounted_amount * percentage_of_line_item(inventory_unit)
       end
 
       def percentage_of_order_total(inventory_unit)
-        return 0.0 if inventory_unit.order.pre_tax_item_amount.zero?
-        weighted_line_item_pre_tax_amount(inventory_unit) / inventory_unit.order.pre_tax_item_amount
+        return 0.0 if inventory_unit.order.discounted_item_amount.zero?
+        weighted_line_item_amount(inventory_unit) / inventory_unit.order.discounted_item_amount
       end
 
       def percentage_of_line_item(inventory_unit)
         1 / BigDecimal.new(inventory_unit.line_item.quantity)
       end
-   end
- end
+    end
+  end
 end
diff --git a/core/app/models/spree/customer_return.rb b/core/app/models/spree/customer_return.rb
index 7f32a6ec96a..fcdb7d8c3fa 100644
--- a/core/app/models/spree/customer_return.rb
+++ b/core/app/models/spree/customer_return.rb
@@ -17,7 +17,8 @@ class CustomerReturn < Spree::Base
 
     extend DisplayMoney
     money_methods pre_tax_total: { currency: Spree::Config[:currency] },
-                  total: { currency: Spree::Config[:currency] }
+                  total: { currency: Spree::Config[:currency] },
+                  amount: { currency: Spree::Config[:currency] }
 
     delegate :id, to: :order, prefix: true, allow_nil: true
 
@@ -26,7 +27,11 @@ def total
     end
 
     def pre_tax_total
-      return_items.sum(:pre_tax_amount)
+      return_items.map(&:pre_tax_amount).sum
+    end
+
+    def amount
+      return_items.sum(:amount)
     end
 
     # Temporarily tie a customer_return to one order
diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb
index 958aa7bfd4f..540f7a07412 100644
--- a/core/app/models/spree/order.rb
+++ b/core/app/models/spree/order.rb
@@ -162,6 +162,11 @@ def pre_tax_item_amount
       line_items.to_a.sum(&:pre_tax_amount)
     end
 
+    # Sum of all line item amounts after promotions, before added tax
+    def discounted_item_amount
+      line_items.to_a.sum(&:discounted_amount)
+    end
+
     def currency
       self[:currency] || Spree::Config[:currency]
     end
diff --git a/core/app/models/spree/reimbursement_tax_calculator.rb b/core/app/models/spree/reimbursement_tax_calculator.rb
index 0a42a3e31df..0f5ae1c1577 100644
--- a/core/app/models/spree/reimbursement_tax_calculator.rb
+++ b/core/app/models/spree/reimbursement_tax_calculator.rb
@@ -18,7 +18,7 @@ def call(reimbursement)
       private
 
       def set_tax!(return_item)
-        percent_of_tax = (return_item.pre_tax_amount <= 0) ? 0 : return_item.pre_tax_amount / Spree::ReturnItem.refund_amount_calculator.new.compute(return_item)
+        percent_of_tax = (return_item.amount <= 0) ? 0 : return_item.amount / Spree::ReturnItem.refund_amount_calculator.new.compute(return_item)
 
         additional_tax_total = percent_of_tax * return_item.inventory_unit.additional_tax_total
         included_tax_total   = percent_of_tax * return_item.inventory_unit.included_tax_total
diff --git a/core/app/models/spree/return_authorization.rb b/core/app/models/spree/return_authorization.rb
index b8195b2b794..ce1e83eb524 100644
--- a/core/app/models/spree/return_authorization.rb
+++ b/core/app/models/spree/return_authorization.rb
@@ -34,12 +34,16 @@ class ReturnAuthorization < Spree::Base
     end
 
     extend DisplayMoney
-    money_methods :pre_tax_total
+    money_methods :pre_tax_total, :amount
 
     self.whitelisted_ransackable_attributes = ['memo']
 
     def pre_tax_total
-      return_items.sum(:pre_tax_amount)
+      return_items.map(&:pre_tax_amount).sum
+    end
+
+    def amount
+      return_item.sum(:amount)
     end
 
     def currency
@@ -47,7 +51,7 @@ def currency
     end
 
     def refundable_amount
-      order.pre_tax_item_amount + order.promo_total
+      order.discounted_item_amount + order.promo_total
     end
 
     def customer_returned_items?
diff --git a/core/app/models/spree/return_item.rb b/core/app/models/spree/return_item.rb
index 6d9d7ffd0a0..986a79d84a8 100644
--- a/core/app/models/spree/return_item.rb
+++ b/core/app/models/spree/return_item.rb
@@ -72,8 +72,8 @@ class ReturnItem < Spree::Base
     delegate :variant, to: :inventory_unit
     delegate :shipment, to: :inventory_unit
 
-    before_create :set_default_pre_tax_amount, unless: :pre_tax_amount_changed?
-    before_save :set_exchange_pre_tax_amount
+    before_create :set_default_amount, unless: :amount_changed?
+    before_save :set_exchange_amount
 
     state_machine :reception_status, initial: :awaiting do
       after_transition to: COMPLETED_RECEPTION_STATUSES,  do: :attempt_accept
@@ -93,7 +93,7 @@ class ReturnItem < Spree::Base
     end
 
     extend DisplayMoney
-    money_methods :pre_tax_amount, :total
+    money_methods :pre_tax_amount, :amount, :total
 
     # @return [Boolean] true when this retur item is in a complete reception
     #   state
@@ -133,7 +133,7 @@ def reception_completed?
     #   unit if one exists, or a new one if one does not
     def self.from_inventory_unit(inventory_unit)
       valid.find_by(inventory_unit: inventory_unit) ||
-        new(inventory_unit: inventory_unit).tap(&:set_default_pre_tax_amount)
+        new(inventory_unit: inventory_unit).tap(&:set_default_amount)
     end
 
     # @return [Boolean] true when an exchange has been requested on this return
@@ -154,10 +154,14 @@ def exchange_required?
       exchange_requested? && !exchange_processed?
     end
 
-    # @return [BigDecimal] the cost of the item before tax, plus the included
-    #   and additional taxes
+    # @return [BigDecimal] the cost of the item after tax
     def total
-      pre_tax_amount + included_tax_total + additional_tax_total
+      amount + additional_tax_total
+    end
+
+    # @return [BigDecimal] the cost of the item before tax
+    def pre_tax_amount
+      amount - included_tax_total
     end
 
     # @note This uses the exchange_variant_engine configured on the class.
@@ -185,12 +189,12 @@ def exchange_shipment
       exchange_inventory_unit.try(:shipment)
     end
 
-    # Calculates and sets the default pre-tax amount to be refunded.
+    # Calculates and sets the default amount to be refunded.
     #
     # @note This uses the configured refund_amount_calculator configured on the
     #   class.
-    def set_default_pre_tax_amount
-      self.pre_tax_amount = refund_amount_calculator.new.compute(self)
+    def set_default_amount
+      self.amount = refund_amount_calculator.new.compute(self)
     end
 
     def potential_reception_transitions
@@ -240,7 +244,7 @@ def check_unexchange
       original_ri = sibling_intended_for_exchange('awaiting')
       if original_ri
         original_ri.unexchange!
-        set_default_pre_tax_amount
+        set_default_amount
         save!
       end
     end
@@ -276,8 +280,8 @@ def validate_acceptance_status_for_reimbursement
       end
     end
 
-    def set_exchange_pre_tax_amount
-      self.pre_tax_amount = 0.0.to_d if exchange_requested?
+    def set_exchange_amount
+      self.amount = 0.0.to_d if exchange_requested?
     end
 
     def validate_no_other_completed_return_items
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 2d7f1465e7b..32f91f6183d 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -184,7 +184,7 @@ en:
         exchange_variant: Exchange for
         inventory_unit_state: State
         item_received?: "Item Received?"
-        pre_tax_amount: Pre-Tax Amount
+        pre_tax_amount: Amount before sales tax
         preferred_reimbursement_type_id: Preferred Reimbursement Type
         reception_status: Reception Status
         resellable: "Resellable?"
diff --git a/core/db/migrate/20151026093607_change_return_item_pre_tax_amount_to_amount.rb b/core/db/migrate/20151026093607_change_return_item_pre_tax_amount_to_amount.rb
new file mode 100644
index 00000000000..8e328195f1a
--- /dev/null
+++ b/core/db/migrate/20151026093607_change_return_item_pre_tax_amount_to_amount.rb
@@ -0,0 +1,27 @@
+class ChangeReturnItemPreTaxAmountToAmount < ActiveRecord::Migration
+  def up
+    execute(<<-SQL)
+      UPDATE spree_return_items
+      SET included_tax_total = 0
+      WHERE included_tax_total IS NULL;
+
+      UPDATE spree_return_items
+      SET pre_tax_amount = pre_tax_amount + included_tax_total;
+    SQL
+
+    rename_column :spree_return_items, :pre_tax_amount, :amount
+  end
+
+  def down
+    execute(<<-SQL)
+      UPDATE spree_return_items
+      SET included_tax_total = 0
+      WHERE included_tax_total IS NULL;
+
+      UPDATE spree_return_items
+      SET amount = amount - included_tax_total;
+    SQL
+
+    rename_column :spree_return_items, :amount, :pre_tax_amount
+  end
+end
diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb
index 53e0147e7cf..d0b59be1e8d 100644
--- a/core/lib/spree/permitted_attributes.rb
+++ b/core/lib/spree/permitted_attributes.rb
@@ -52,7 +52,7 @@ module PermittedAttributes
       :month, :year, :expiry, :first_name, :last_name, :name
     ]
 
-    @@customer_return_attributes = [:stock_location_id, return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount, :reception_status_event, :acceptance_status, :exchange_variant_id, :resellable]]
+    @@customer_return_attributes = [:stock_location_id, return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :amount, :reception_status_event, :acceptance_status, :exchange_variant_id, :resellable]]
 
     @@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
 
diff --git a/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb b/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb
index f5ae21d4b6c..9431231438d 100644
--- a/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb
+++ b/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb
@@ -1,21 +1,19 @@
 require 'spec_helper'
 
 describe Spree::Calculator::Returns::DefaultRefundAmount, type: :model do
-  let(:order) { create(:order) }
   let(:line_item_quantity) { 2 }
-  let(:pre_tax_amount)  { 100.0 }
-  let(:line_item)       { create(:line_item, price: 100.0, quantity: line_item_quantity, pre_tax_amount: pre_tax_amount) }
+  let(:line_item_price) { 100.0 }
+  let(:line_item) { create(:line_item, price: line_item_price, quantity: line_item_quantity) }
   let(:inventory_unit) { build(:inventory_unit, order: order, line_item: line_item) }
   let(:return_item) { build(:return_item, inventory_unit: inventory_unit ) }
   let(:calculator) { Spree::Calculator::Returns::DefaultRefundAmount.new }
-
-  before { order.line_items << line_item }
+  let(:order) { line_item.order }
 
   subject { calculator.compute(return_item) }
 
   context "not an exchange" do
     context "no promotions or taxes" do
-      it { is_expected.to eq pre_tax_amount / line_item_quantity }
+      it { is_expected.to eq line_item_price }
     end
 
     context "order adjustments" do
@@ -35,7 +33,7 @@
         order.adjustments.first.update_attributes(amount: adjustment_amount)
       end
 
-      it { is_expected.to eq((pre_tax_amount - adjustment_amount.abs) / line_item_quantity) }
+      it { is_expected.to eq line_item_price - (adjustment_amount.abs / line_item_quantity) }
     end
 
     context "shipping adjustments" do
@@ -43,7 +41,7 @@
 
       before { order.shipments << Spree::Shipment.new(adjustment_total: adjustment_total) }
 
-      it { is_expected.to eq pre_tax_amount / line_item_quantity }
+      it { is_expected.to eq line_item_price }
     end
   end
 
@@ -53,8 +51,8 @@
     it { is_expected.to eq 0.0 }
   end
 
-  context "pre_tax_amount is zero" do
-    let(:pre_tax_amount)  { 0.0 }
+  context "line item amount is zero" do
+    let(:line_item_price) { 0 }
     it { is_expected.to eq 0.0 }
   end
 end
diff --git a/core/spec/models/spree/customer_return_spec.rb b/core/spec/models/spree/customer_return_spec.rb
index 7247eb90eb7..edde017dd32 100644
--- a/core/spec/models/spree/customer_return_spec.rb
+++ b/core/spec/models/spree/customer_return_spec.rb
@@ -72,19 +72,19 @@
   end
 
   describe "#total" do
-    let(:pre_tax_amount) { 15.0 }
+    let(:amount) { 15.0 }
     let(:tax_amount) { 5.0 }
     let(:customer_return) { create(:customer_return, line_items_count: 2) }
 
     before do
-      Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(pre_tax_amount: pre_tax_amount, additional_tax_total: tax_amount)
+      Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(amount: amount, additional_tax_total: tax_amount)
       customer_return.reload
     end
 
     subject { customer_return.total }
 
     it "returns the sum of the return item's total amount" do
-      expect(subject).to eq((pre_tax_amount * 2) + (tax_amount * 2))
+      expect(subject).to eq((amount * 2) + (tax_amount * 2))
     end
   end
 
@@ -97,27 +97,27 @@
     end
   end
 
-  describe "#pre_tax_total" do
-    let(:pre_tax_amount)  { 15.0 }
+  describe "#amount" do
+    let(:amount) { 15.0 }
     let(:customer_return) { create(:customer_return, line_items_count: 2) }
 
     before do
-      Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(pre_tax_amount: pre_tax_amount)
+      Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(amount: amount)
     end
 
-    subject { customer_return.pre_tax_total }
+    subject { customer_return.amount }
 
-    it "returns the sum of the return item's pre_tax_amount" do
-      expect(subject).to eq(pre_tax_amount * 2)
+    it "returns the sum of the return item's amount" do
+      expect(subject).to eq(amount * 2)
     end
   end
 
-  describe "#display_pre_tax_total" do
+  describe "#display_amount" do
     let(:customer_return) { Spree::CustomerReturn.new }
 
     it "returns a Spree::Money" do
-      allow(customer_return).to receive_messages(pre_tax_total: 21.22)
-      expect(customer_return.display_pre_tax_total).to eq(Spree::Money.new(21.22))
+      allow(customer_return).to receive_messages(amount: 21.22)
+      expect(customer_return.display_amount).to eq(Spree::Money.new(21.22))
     end
   end
 
diff --git a/core/spec/models/spree/reimbursement_spec.rb b/core/spec/models/spree/reimbursement_spec.rb
index 828bcfb0967..9adcdc3a64a 100644
--- a/core/spec/models/spree/reimbursement_spec.rb
+++ b/core/spec/models/spree/reimbursement_spec.rb
@@ -106,8 +106,8 @@
         return_item.reload
         expect(return_item.additional_tax_total).to be > 0
         expect(return_item.additional_tax_total).to eq line_item.additional_tax_total
-        expect(reimbursement.total).to eq line_item.pre_tax_amount + line_item.additional_tax_total
-        expect(Spree::Refund.last.amount).to eq line_item.pre_tax_amount + line_item.additional_tax_total
+        expect(reimbursement.total).to eq line_item.amount + line_item.additional_tax_total
+        expect(Spree::Refund.last.amount).to eq line_item.amount + line_item.additional_tax_total
       end
     end
 
@@ -192,8 +192,8 @@
       subject { reimbursement.calculated_total }
 
       before do
-        reimbursement.return_items << Spree::ReturnItem.new(pre_tax_amount: 10.003)
-        reimbursement.return_items << Spree::ReturnItem.new(pre_tax_amount: 10.003)
+        reimbursement.return_items << Spree::ReturnItem.new(amount: 10.003)
+        reimbursement.return_items << Spree::ReturnItem.new(amount: 10.003)
       end
 
       it 'rounds down' do
diff --git a/core/spec/models/spree/reimbursement_type/original_payment_spec.rb b/core/spec/models/spree/reimbursement_type/original_payment_spec.rb
index 550c12078c1..e0a3d901667 100644
--- a/core/spec/models/spree/reimbursement_type/original_payment_spec.rb
+++ b/core/spec/models/spree/reimbursement_type/original_payment_spec.rb
@@ -61,7 +61,7 @@ module Spree
 
         before do
           reimbursement.order.payments.first.update_attributes!(amount: 5.0)
-          return_item.update_attributes!(pre_tax_amount: refund_amount)
+          return_item.update_attributes!(amount: refund_amount)
         end
 
         it "includes refunds all payment type" do
diff --git a/core/spec/models/spree/return_authorization_spec.rb b/core/spec/models/spree/return_authorization_spec.rb
index 8ac9797f19c..3f9bc0325a7 100644
--- a/core/spec/models/spree/return_authorization_spec.rb
+++ b/core/spec/models/spree/return_authorization_spec.rb
@@ -137,19 +137,19 @@
   end
 
   describe "#pre_tax_total" do
-    let(:pre_tax_amount_1) { 15.0 }
-    let!(:return_item_1) { create(:return_item, return_authorization: return_authorization, pre_tax_amount: pre_tax_amount_1) }
+    let(:amount_1) { 15.0 }
+    let!(:return_item_1) { create(:return_item, return_authorization: return_authorization, amount: amount_1) }
 
-    let(:pre_tax_amount_2) { 50.0 }
-    let!(:return_item_2) { create(:return_item, return_authorization: return_authorization, pre_tax_amount: pre_tax_amount_2) }
+    let(:amount_2) { 50.0 }
+    let!(:return_item_2) { create(:return_item, return_authorization: return_authorization, amount: amount_2) }
 
-    let(:pre_tax_amount_3) { 5.0 }
-    let!(:return_item_3) { create(:return_item, return_authorization: return_authorization, pre_tax_amount: pre_tax_amount_3) }
+    let(:amount_3) { 5.0 }
+    let!(:return_item_3) { create(:return_item, return_authorization: return_authorization, amount: amount_3) }
 
-    subject { return_authorization.pre_tax_total }
+    subject { return_authorization.reload.pre_tax_total }
 
-    it "sums it's associated return_item's pre-tax amounts" do
-      expect(subject).to eq(pre_tax_amount_1 + pre_tax_amount_2 + pre_tax_amount_3)
+    it "sums it's associated return_item's amounts" do
+      expect(subject).to eq(amount_1 + amount_2 + amount_3)
     end
   end
 
@@ -177,27 +177,27 @@
   end
 
   describe "#refundable_amount" do
-    let(:weighted_line_item_pre_tax_amount) { 5.0 }
-    let(:line_item_count)                   { return_authorization.order.line_items.count }
+    let(:line_item_price) { 5.0 }
+    let(:line_item_count) { return_authorization.order.line_items.count }
 
     subject { return_authorization.refundable_amount }
 
     before do
-      return_authorization.order.line_items.update_all(pre_tax_amount: weighted_line_item_pre_tax_amount)
+      return_authorization.order.line_items.update_all(price: line_item_price)
       return_authorization.order.update_attribute(:promo_total, promo_total)
     end
 
     context "no promotions" do
       let(:promo_total) { 0.0 }
       it "returns the pre-tax line item total" do
-        expect(subject).to eq(weighted_line_item_pre_tax_amount * line_item_count)
+        expect(subject).to eq(line_item_price * line_item_count)
       end
     end
 
     context "promotions" do
       let(:promo_total) { -10.0 }
       it "returns the pre-tax line item total minus the order level promotion value" do
-        expect(subject).to eq((weighted_line_item_pre_tax_amount * line_item_count) + promo_total)
+        expect(subject).to eq((line_item_price * line_item_count) + promo_total)
       end
     end
   end
diff --git a/core/spec/models/spree/return_item_spec.rb b/core/spec/models/spree/return_item_spec.rb
index 3525d2ef2ef..98b04894508 100644
--- a/core/spec/models/spree/return_item_spec.rb
+++ b/core/spec/models/spree/return_item_spec.rb
@@ -69,7 +69,7 @@
         return_item_in_lieu.reload
         expect(return_item_with_exchange.reception_status).to eq 'unexchanged'
         expect(return_item_in_lieu.reception_status).to eq 'received'
-        expect(return_item_in_lieu.pre_tax_amount).to eq 0
+        expect(return_item_in_lieu.amount).to eq 0
         expect(inventory_unit.reload.state).to eq 'shipped'
         expect(exchange_inventory_unit.reload.state).to eq 'returned'
       end
@@ -141,11 +141,12 @@
   end
 
   describe "#display_pre_tax_amount" do
-    let(:pre_tax_amount) { 21.22 }
-    let(:return_item) { build(:return_item, pre_tax_amount: pre_tax_amount) }
+    let(:amount) { 21.22 }
+    let(:included_tax_total) { 1.22 }
+    let(:return_item) { build(:return_item, amount: amount, included_tax_total: included_tax_total) }
 
     it "returns a Spree::Money" do
-      expect(return_item.display_pre_tax_amount).to eq Spree::Money.new(pre_tax_amount)
+      expect(return_item.display_pre_tax_amount).to eq Spree::Money.new(amount - included_tax_total)
     end
   end
 
@@ -155,28 +156,28 @@
     end
   end
 
-  describe "pre_tax_amount calculations on create" do
+  describe "amount calculations on create" do
     let(:inventory_unit) { build(:inventory_unit) }
     before { subject.save! }
 
-    context "pre tax amount is not specified" do
+    context "amount is not specified" do
       subject { build(:return_item, inventory_unit: inventory_unit) }
 
       context "not an exchange" do
-        it { expect(subject.pre_tax_amount).to eq Spree::Calculator::Returns::DefaultRefundAmount.new.compute(subject) }
+        it { expect(subject.amount).to eq Spree::Calculator::Returns::DefaultRefundAmount.new.compute(subject) }
       end
 
       context "an exchange" do
         subject { build(:exchange_return_item) }
 
-        it { expect(subject.pre_tax_amount).to eq 0.0 }
+        it { expect(subject.amount).to eq 0.0 }
       end
     end
 
-    context "pre tax amount is specified" do
-      subject { build(:return_item, inventory_unit: inventory_unit, pre_tax_amount: 100) }
+    context "amount is specified" do
+      subject { build(:return_item, inventory_unit: inventory_unit, amount: 100) }
 
-      it { expect(subject.pre_tax_amount).to eq 100 }
+      it { expect(subject.amount).to eq 100 }
     end
   end
 
@@ -567,17 +568,17 @@
       end
 
       it do
-        return_item.pre_tax_amount = 5.0
+        return_item.amount = 5.0
         return_item.save!
-        expect(return_item.reload.pre_tax_amount).to eq 0.0
+        expect(return_item.reload.amount).to eq 0.0
       end
     end
 
     context "the return item is not intended to be exchanged" do
       it do
-        return_item.pre_tax_amount = 5.0
+        return_item.amount = 5.0
         return_item.save!
-        expect(return_item.reload.pre_tax_amount).to eq 5.0
+        expect(return_item.reload.amount).to eq 5.0
       end
     end
   end
@@ -686,14 +687,14 @@
       create(
         :return_item,
         inventory_unit: inventory_unit,
-        included_tax_total: 10
+        included_tax_total: 5
       )
     end
 
     it 'includes included tax total' do
-      expect(return_item.pre_tax_amount).to eq 10
-      expect(return_item.included_tax_total).to eq 10
-      expect(return_item.total).to eq 20
+      expect(return_item.amount).to eq 10
+      expect(return_item.included_tax_total).to eq 5
+      expect(return_item.total).to eq 10
     end
   end