Class: Comable::OrderDetail
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comable::OrderDetail
- Includes:
- Decoratable
- Defined in:
- app/models/comable/order_detail.rb
Instance Method Summary collapse
- #before_complete ⇒ Object
-
#current_price ⇒ Object
時価を取得.
-
#current_subtotal_price ⇒ Object
時価小計を取得.
- #decrement_stock ⇒ Object
- #save_price ⇒ Object
-
#subtotal_price ⇒ Object
売価小計を取得.
Methods included from Decoratable
Instance Method Details
#before_complete ⇒ Object
14 15 16 17 |
# File 'app/models/comable/order_detail.rb', line 14 def before_complete save_price decrement_stock end |
#current_price ⇒ Object
時価を取得
20 21 22 |
# File 'app/models/comable/order_detail.rb', line 20 def current_price stock.price end |
#current_subtotal_price ⇒ Object
時価小計を取得
25 26 27 |
# File 'app/models/comable/order_detail.rb', line 25 def current_subtotal_price current_price * quantity end |
#decrement_stock ⇒ Object
34 35 36 |
# File 'app/models/comable/order_detail.rb', line 34 def decrement_stock stock.decrement!(quantity: quantity) end |
#save_price ⇒ Object
38 39 40 |
# File 'app/models/comable/order_detail.rb', line 38 def save_price self.price = stock.price end |
#subtotal_price ⇒ Object
売価小計を取得
30 31 32 |
# File 'app/models/comable/order_detail.rb', line 30 def subtotal_price price * quantity end |