Class: Spree::LineItem
Instance Attribute Summary collapse
Instance Method Summary
collapse
money_methods
Methods inherited from Base
belongs_to_required_by_default, page, spree_base_scopes
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Attribute Details
#target_shipment ⇒ Object
Returns the value of attribute target_shipment.
46
47
48
|
# File 'app/models/spree/line_item.rb', line 46
def target_shipment
@target_shipment
end
|
Instance Method Details
#amount ⇒ Object
Also known as:
subtotal
74
75
76
|
# File 'app/models/spree/line_item.rb', line 74
def amount
price * quantity
end
|
#copy_price ⇒ Object
51
52
53
54
55
56
57
|
# File 'app/models/spree/line_item.rb', line 51
def copy_price
if variant
update_price if price.nil?
self.cost_price = variant.cost_price if cost_price.nil?
self.currency = variant.currency if currency.nil?
end
end
|
#copy_tax_category ⇒ Object
63
64
65
|
# File 'app/models/spree/line_item.rb', line 63
def copy_tax_category
self.tax_category = variant.tax_category if variant
end
|
#final_amount ⇒ Object
Also known as:
total
87
88
89
|
# File 'app/models/spree/line_item.rb', line 87
def final_amount
amount + adjustment_total
end
|
#insufficient_stock? ⇒ Boolean
98
99
100
|
# File 'app/models/spree/line_item.rb', line 98
def insufficient_stock?
!sufficient_stock?
end
|
#options=(options = {}) ⇒ Object
102
103
104
105
106
107
108
109
110
111
|
# File 'app/models/spree/line_item.rb', line 102
def options=(options = {})
return unless options.present?
opts = options.dup
currency = opts.delete(:currency) || order.try(:currency)
update_price_from_modifier(currency, opts)
assign_attributes opts
end
|
#sufficient_stock? ⇒ Boolean
#taxable_amount ⇒ Object
Also known as:
discounted_amount
80
81
82
|
# File 'app/models/spree/line_item.rb', line 80
def taxable_amount
amount + taxable_adjustment_total
end
|
#update_price ⇒ Object
59
60
61
|
# File 'app/models/spree/line_item.rb', line 59
def update_price
self.price = variant.price_including_vat_for(tax_zone: tax_zone)
end
|
#variant ⇒ Object
Remove variant default_scope ‘deleted_at: nil`
114
115
116
|
# File 'app/models/spree/line_item.rb', line 114
def variant
Spree::Variant.unscoped { super }
end
|