Class: Logistics::Core::ClientContract
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Logistics::Core::ClientContract
- Defined in:
- app/models/logistics/core/client_contract.rb
Class Method Summary collapse
- .get_accepted_contracts ⇒ Object
- .get_active_contracts ⇒ Object
- .get_approved_contracts ⇒ Object
- .get_contracts(contracts) ⇒ Object
- .get_declined_contracts ⇒ Object
- .get_drafted_contracts ⇒ Object
- .get_rejected_contracts ⇒ Object
- .get_submitted_contracts ⇒ Object
Methods inherited from ApplicationRecord
Class Method Details
.get_accepted_contracts ⇒ Object
27 28 29 30 |
# File 'app/models/logistics/core/client_contract.rb', line 27 def get_accepted_contracts accepted=ClientContract.accepted accepted.empty? ? nil : get_contracts(accepted) end |
.get_active_contracts ⇒ Object
31 32 33 34 |
# File 'app/models/logistics/core/client_contract.rb', line 31 def get_active_contracts active=ClientContract.active active.empty? ? nil : get_contracts(active) end |
.get_approved_contracts ⇒ Object
15 16 17 18 |
# File 'app/models/logistics/core/client_contract.rb', line 15 def get_approved_contracts approved=ClientContract.approved approved.empty? ? nil : get_contracts(approved) end |
.get_contracts(contracts) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/logistics/core/client_contract.rb', line 40 def get_contracts(contracts) contract_details=[] contracts.each do|contract| contract_details.push({'id'=>contract.id, 'title'=>contract.title, 'client'=>contract.offer_request.operation.client ? contract.offer_request.operation.client.name : nil, 'contract_type'=>contract.offer_request.is_bulk ? 'Bulk purchase' : 'One time', 'effective_date'=>contract.effective_date, 'expiry_date'=>contract.expiry_date, 'contract_date'=>contract.contract_date, 'offer_request_id'=>contract.offer_request_id, 'request_no'=>contract.offer_request ? contract.offer_request.request_no : nil, 'contract_duration'=>contract.effective_date.to_formatted_s(:long)+'-'+contract.expiry_date.to_formatted_s(:long), # 'article'=>article(contract.id), 'transaction_type'=>contract.offer_request.operation.transaction_type ? contract.offer_request.operation.transaction_type.name : nil, # 'contract_remark'=>get_contract_remark(contract.id) }) end contract_details.empty? ? nil : contract_details end |
.get_declined_contracts ⇒ Object
19 20 21 22 |
# File 'app/models/logistics/core/client_contract.rb', line 19 def get_declined_contracts declined=ClientContract.declined declined.empty? ? nil : get_contracts(declined) end |
.get_drafted_contracts ⇒ Object
11 12 13 14 |
# File 'app/models/logistics/core/client_contract.rb', line 11 def get_drafted_contracts draft=ClientContract.draft draft.empty? ? nil : get_contracts(draft) end |
.get_rejected_contracts ⇒ Object
35 36 37 38 |
# File 'app/models/logistics/core/client_contract.rb', line 35 def get_rejected_contracts rejected=ClientContract.rejected rejected.empty? ? nil : get_contracts(rejected) end |
.get_submitted_contracts ⇒ Object
23 24 25 26 |
# File 'app/models/logistics/core/client_contract.rb', line 23 def get_submitted_contracts submitted=ClientContract.submitted submitted.empty? ? nil : get_contracts(submitted) end |