Skip to content

Commit

Permalink
Make currency public in Spree::ReturnItem
Browse files Browse the repository at this point in the history
  • Loading branch information
btolarz committed Sep 25, 2018
1 parent 7f7e228 commit d1e4a61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Expand Up @@ -29,7 +29,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, return_authorization: @return_authorization).tap(&:set_default_pre_tax_amount)
end

@form_return_items = (@return_authorization.return_items + new_return_items).sort_by(&:inventory_unit_id)
Expand Down
8 changes: 4 additions & 4 deletions core/app/models/spree/return_item.rb
Expand Up @@ -163,6 +163,10 @@ def set_default_pre_tax_amount
self.pre_tax_amount = refund_amount_calculator.new.compute(self)
end

def currency
return_authorization.try(:currency) || Spree::Config[:currency]
end

private

def persist_acceptance_status_errors
Expand All @@ -176,10 +180,6 @@ def stock_item
stock_location_id: customer_return.stock_location_id)
end

def currency
return_authorization.try(:currency) || Spree::Config[:currency]
end

def process_inventory_unit!
inventory_unit.return!
if should_restock?
Expand Down
8 changes: 8 additions & 0 deletions core/spec/models/spree/return_item_spec.rb
Expand Up @@ -733,5 +733,13 @@
it { expect { subject }.not_to change { stock_item.reload.count_on_hand } }
end
end

describe '#currency' do
subject { return_item }

it 'responds to currency method' do
expect { subject.respond_to?(:currency) }.to eq true
end
end
end
end

0 comments on commit d1e4a61

Please sign in to comment.