Class: Comable::OrderDetail

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

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
25
# File 'app/models/comable/order_detail.rb', line 22

def complete
  copy_attributes
  decrement_stock
end

#copy_attributesObject

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



28
29
30
# File 'app/models/comable/order_detail.rb', line 28

def copy_attributes
  self.attributes = current_attributes
end

#current_priceObject

時価を取得



33
34
35
# File 'app/models/comable/order_detail.rb', line 33

def current_price
  stock.price
end

#current_subtotal_priceObject

時価小計を取得



38
39
40
# File 'app/models/comable/order_detail.rb', line 38

def current_subtotal_price
  current_price * quantity
end

#subtotal_priceObject

売価小計を取得



43
44
45
# File 'app/models/comable/order_detail.rb', line 43

def subtotal_price
  price * quantity
end

#unstocked?Boolean Also known as: soldout_stock?

Returns:

  • (Boolean)


47
48
49
50
51
# File 'app/models/comable/order_detail.rb', line 47

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