Class: Logistics::Core::OfferRequest
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Logistics::Core::OfferRequest
- Defined in:
- app/models/logistics/core/offer_request.rb
Class Method Summary collapse
Instance Method Summary collapse
- #change_to_hash(items) ⇒ Object
- #get_bill_of_loading_by_status(status) ⇒ Object
- #get_bill_of_loading_by_status_and_user(status, user_id) ⇒ Object
- #get_request_with_additional_service ⇒ Object
- #get_requests_by_security_status(security_status) ⇒ Object
- #offer_by_ids(ids) ⇒ Object
- #to_json ⇒ Object
Methods inherited from ApplicationRecord
Class Method Details
.fetch_all(bill_of_loading_ids, user, filtering_criteria) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/models/logistics/core/offer_request.rb', line 85 def self.fetch_all(bill_of_loading_ids, user, filtering_criteria) result = [] @bill_of_loadings = nil if filtering_criteria != 'none' if filtering_criteria == 'request' @bill_of_loadings = OfferRequest.where('(user_id =:user_id and status = :status_one)',{user_id:user.id,status_one:'draft'} ) else @bill_of_loadings = OfferRequest.where('(user_id =:user_id and status = :status_one)',{user_id:user.id,status_one:filtering_criteria} ) end else @bill_of_loadings = OfferRequest.where.not(id: bill_of_loading_ids).where(user_id: user.id) end @bill_of_loadings.each do |bill_of_loading| result.push({:id => bill_of_loading.id, :bill_of_loading_number => bill_of_loading.bill_of_loading_number, :transaction_type_id => bill_of_loading.transaction_type_id, :transaction_type_name => bill_of_loading.transaction_type_name, :operation_type_id => bill_of_loading.operation_type_id, :operation_type_name => bill_of_loading.operation_type_name, :user_id => bill_of_loading.user.id, :status => bill_of_loading.status, :entry_status => bill_of_loading.entry_status, :client_id => bill_of_loading.client_id, :client => bill_of_loading.client_name, :communication_channel_id => bill_of_loading.communication_channel_id, :communication_channel_name => bill_of_loading.communication_channel_name, :source_detail => bill_of_loading.source_detail, :point_of_recipient => bill_of_loading.point_of_recipient, :date_of_recipient => bill_of_loading.date_of_recipient, :general_remark => bill_of_loading.general_remark, :freight_forwarding => bill_of_loading.freight_forwarding, :customs_clearing => bill_of_loading.customs_clearing, :transport => bill_of_loading.transport, :rate_level => bill_of_loading.rate_level, :route_id => bill_of_loading.route_id, :route_name => bill_of_loading.route_name, :positioning_route_id => bill_of_loading.positioning_route_id, :positioning_route_name => bill_of_loading.positioning_route_name, :return_fee_route_id => bill_of_loading.return_fee_route_id, :return_fee_route_name => bill_of_loading.return_fee_route_name, :review_count =>bill_of_loading.review_count, :no_of_items => bill_of_loading.no_of_items, :no_of_convoy => bill_of_loading.no_of_convoy}) end return result end |
Instance Method Details
#change_to_hash(items) ⇒ Object
62 63 64 65 66 67 68 |
# File 'app/models/logistics/core/offer_request.rb', line 62 def change_to_hash(items) data = [] items.each { |item| data.push item.to_json } return data end |
#get_bill_of_loading_by_status(status) ⇒ Object
57 58 59 60 |
# File 'app/models/logistics/core/offer_request.rb', line 57 def get_bill_of_loading_by_status(status) bill_of_loadings = OfferRequest.includes(:client, :operation_type, :transaction_type, :communication_channel, :contract).where(status: status).order('id DESC') return bill_of_loadings end |
#get_bill_of_loading_by_status_and_user(status, user_id) ⇒ Object
52 53 54 55 |
# File 'app/models/logistics/core/offer_request.rb', line 52 def get_bill_of_loading_by_status_and_user(status, user_id) bill_of_loadings = OfferRequest.where(status: status, user_id: user_id).order(:id) return bill_of_loadings end |
#get_request_with_additional_service ⇒ Object
70 71 72 73 |
# File 'app/models/logistics/core/offer_request.rb', line 70 def get_request_with_additional_service offer_requests = OfferRequest.where.not(additional_service_status: nil).order(:id) return offer_requests end |
#get_requests_by_security_status(security_status) ⇒ Object
75 76 77 78 79 |
# File 'app/models/logistics/core/offer_request.rb', line 75 def get_requests_by_security_status(security_status) offer_requests = OfferRequest.includes(:transaction_type, :client, :communication_channel, :operation_type, :contract) .where(security_status: security_status) return offer_requests end |
#offer_by_ids(ids) ⇒ Object
81 82 83 |
# File 'app/models/logistics/core/offer_request.rb', line 81 def offer_by_ids(ids) OfferRequest.includes(:transaction_type, :contract, :client, :communication_channel, :operation_type).where(id: ids) end |
#to_json ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/logistics/core/offer_request.rb', line 22 def to_json JSON.parse( Jbuilder.encode do |json| json.id self.id json.request_no self.request_no json.transaction_type_id self.transaction_type.id json.transaction_type_name self.transaction_type.name json.status self.status json.client_id self.client.id json.client self.client.name json.communication_channel_id self.communication_channel_id json.communication_channel_name self.communication_channel.name json.source_detail self.source_detail json.point_of_recipient self.point_of_recipient json.date_of_recipient self.date_of_recipient json.general_remark self.general_remark json.freight_forwarding self.freight_forwarding json.customs_clearing self.customs_clearing json.transport self.transport json.rate_level self.rate_level json.security_status self.security_status json.operation_type_id self.operation_type.id json.operation_type_name self.operation_type.name json.no_of_items self.no_of_items json.no_of_convoy self.no_of_convoy json.is_bulk self.is_bulk end ) end |