Class: Spree::Calculator::Returns::DefaultRefundAmount

Inherits:
ReturnsCalculator show all
Defined in:
app/models/spree/calculator/returns/default_refund_amount.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Spree::Calculator

#available?, calculators, #description, #to_s

Methods inherited from Base

belongs_to_required_by_default, page, spree_base_scopes

Methods included from Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Attribute Details

#inventory_unitObject (readonly)

Returns the value of attribute inventory_unit


6
7
8
# File 'app/models/spree/calculator/returns/default_refund_amount.rb', line 6

def inventory_unit
  @inventory_unit
end

Class Method Details

.descriptionObject


8
9
10
# File 'app/models/spree/calculator/returns/default_refund_amount.rb', line 8

def self.description
  Spree.t(:default_refund_amount)
end

Instance Method Details

#compute(return_item) ⇒ Object


12
13
14
15
16
# File 'app/models/spree/calculator/returns/default_refund_amount.rb', line 12

def compute(return_item)
  return 0.0.to_d if return_item.exchange_requested?
  @inventory_unit = return_item.inventory_unit
  weighted_order_adjustment_amount(return_item) + weighted_line_item_pre_tax_amount(return_item)
end