Class: Comable::OrderDetail

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

Instance Method Summary collapse

Methods included from Decoratable

included

Instance Method Details

#before_completeObject



14
15
16
17
# File 'app/models/comable/order_detail.rb', line 14

def before_complete
  save_price
  decrement_stock
end

#current_priceObject

時価を取得



20
21
22
# File 'app/models/comable/order_detail.rb', line 20

def current_price
  stock.price
end

#current_subtotal_priceObject

時価小計を取得



25
26
27
# File 'app/models/comable/order_detail.rb', line 25

def current_subtotal_price
  current_price * quantity
end

#decrement_stockObject



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

def decrement_stock
  stock.decrement!(quantity: quantity)
end

#save_priceObject



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

def save_price
  self.price = stock.price
end

#subtotal_priceObject

売価小計を取得



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

def subtotal_price
  price * quantity
end