Class: Comee::Core::PurchaseRequisitionItem
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Comee::Core::PurchaseRequisitionItem
- Defined in:
- app/models/comee/core/purchase_requisition_item.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(_auth_object = nil) ⇒ Object
Instance Method Summary collapse
- #calculate_requisition_price ⇒ Object
- #calculate_total_price ⇒ Object
- #update_requisition_purchase_status ⇒ Object
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
53 54 55 |
# File 'app/models/comee/core/purchase_requisition_item.rb', line 53 def self.ransackable_associations(_auth_object = nil) [] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/comee/core/purchase_requisition_item.rb', line 35 def self.ransackable_attributes(_auth_object = nil) %w[ delivery_date id price processing_status product_id purchase_order_item_id purchase_requisition_id quantity supplier_id total_price unit_id created_at updated_at ] end |
Instance Method Details
#calculate_requisition_price ⇒ Object
23 24 25 26 |
# File 'app/models/comee/core/purchase_requisition_item.rb', line 23 def calculate_requisition_price purchase_requisition.total_price = purchase_requisition.calculate_total_price purchase_requisition.save! end |
#calculate_total_price ⇒ Object
19 20 21 |
# File 'app/models/comee/core/purchase_requisition_item.rb', line 19 def calculate_total_price self.total_price = price * quantity end |
#update_requisition_purchase_status ⇒ Object
28 29 30 31 32 33 |
# File 'app/models/comee/core/purchase_requisition_item.rb', line 28 def update_requisition_purchase_status return unless purchase_requisition.purchase_requisition_items.all.all?(&:fully_processed?) purchase_requisition.purchase_status = PurchaseRequisition.purchase_statuses[:processed] purchase_requisition.save! end |