Class: Comable::OrderItem

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Csvable, SkuChoice, SkuItem
Defined in:
app/models/comable/order_item.rb,
app/models/comable/order_item/csvable.rb

Defined Under Namespace

Modules: Csvable

Instance Method Summary collapse

Methods included from SkuChoice

#name_with_sku, #sku_name

Methods included from SkuItem

#sku_h?, #sku_v?

Instance Method Details

#completeObject



22
23
24
# File 'app/models/comable/order_item.rb', line 22

def complete
  unstock
end

#copy_attributesObject

TODO: カート投入時との差額表示



35
36
37
# File 'app/models/comable/order_item.rb', line 35

def copy_attributes
  self.attributes = current_attributes
end

#current_priceObject

時価を取得



40
41
42
# File 'app/models/comable/order_item.rb', line 40

def current_price
  stock.price
end

#current_subtotal_priceObject

時価小計を取得



45
46
47
# File 'app/models/comable/order_item.rb', line 45

def current_subtotal_price
  current_price * quantity
end

#restockObject



30
31
32
# File 'app/models/comable/order_item.rb', line 30

def restock
  increment_stock
end

#subtotal_priceObject

売価小計を取得



50
51
52
# File 'app/models/comable/order_item.rb', line 50

def subtotal_price
  price * quantity
end

#unstockObject



26
27
28
# File 'app/models/comable/order_item.rb', line 26

def unstock
  decrement_stock
end

#unstocked?Boolean

Returns:

  • (Boolean)


54
55
56
57
58
# File 'app/models/comable/order_item.rb', line 54

def unstocked?
  stock_with_clean_quantity do |stock|
    stock.unstocked?(quantity: quantity)
  end
end