Class: Comee::Core::PurchaseOrderItem
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Comee::Core::PurchaseOrderItem
- Defined in:
- app/models/comee/core/purchase_order_item.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(_auth_object = nil) ⇒ Object
Instance Method Summary collapse
- #calculate_confirmation_values ⇒ Object
- #calculate_total_price ⇒ Object
- #update_purchase_order ⇒ Object
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
62 63 64 65 66 67 |
# File 'app/models/comee/core/purchase_order_item.rb', line 62 def self.ransackable_associations(_auth_object = nil) %w[ purchase_order unit ] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/comee/core/purchase_order_item.rb', line 47 def self.ransackable_attributes(_auth_object = nil) %w[ id purchase_order_id unit_id quantity confirmed_quantity price confirmed_price delivery_date confirmed_delivery_date status ] end |
Instance Method Details
#calculate_confirmation_values ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/models/comee/core/purchase_order_item.rb', line 29 def calculate_confirmation_values self.confirmed_price = price unless confirmed_price self.confirmed_quantity = quantity unless confirmed_quantity self.confirmed_delivery_date = delivery_date unless confirmed_delivery_date self.confirmed_total_price = (confirmed_price * confirmed_quantity).round(2) end |
#calculate_total_price ⇒ Object
25 26 27 |
# File 'app/models/comee/core/purchase_order_item.rb', line 25 def calculate_total_price self.total_price = (price * quantity).round(2) end |
#update_purchase_order ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/models/comee/core/purchase_order_item.rb', line 39 def update_purchase_order purchase_order.calculate_total_price purchase_order.calculate_vat purchase_order.calculate_confirmed_total_price purchase_order.calculate_confirmed_vat purchase_order.save! end |