Class: Comee::Core::QuotationRequestsController

Inherits:
ApplicationController show all
Includes:
Common
Defined in:
app/controllers/comee/core/quotation_requests_controller.rb

Instance Method Summary collapse

Methods included from Common

#create, #show, #update

Methods included from Pagination

#default_per_page, #order_by, #order_direction, #page_no, #paginate, #paginate_offset, #per_page

Methods inherited from ApplicationController

#application_code, #authenticate, #current_application, #current_user, #render_content, #render_error, #skip_bullet

Instance Method Details

#confirmObject



48
49
50
51
52
53
54
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 48

def confirm
  service = QuotationRequestService.new
  rfq = service.confirm(params[:id])
  render_content(rfq)
rescue StandardError => e
  render json: {success: false, error: e.message}
end

#convertObject



56
57
58
59
60
61
62
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 56

def convert
  service = QuotationRequestService.new
  order = service.convert_to_order(params[:id])
  render_content(order)
rescue StandardError => e
  render json: {success: false, error: e.message}
end

#create_request_with_itemsObject



25
26
27
28
29
30
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 25

def create_request_with_items
  service = QuotationRequestService.new
  parameters = rfq_params.to_h.deep_symbolize_keys
  result = service.create_request_with_items(parameters)
  render_content(result)
end

#filterObject



12
13
14
15
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 12

def filter
  data = QuotationRequest.includes(:client).ransack(params[:q]).result
  render_content(data)
end

#indexObject



6
7
8
9
10
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 6

def index
  super do
    QuotationRequest.includes(:client).all
  end
end

#rfq_products_for_clientObject



17
18
19
20
21
22
23
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 17

def rfq_products_for_client
  client_products = ClientPrice.includes(:product).where(client_id: params[:id]).map(&:product_id)
  root = Product.roots.first
  ids = root.indirect_ids - client_products
  products = Product.where(id: ids)
  render_content(products)
end

#submitObject



32
33
34
35
36
37
38
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 32

def submit
  service = QuotationRequestService.new
  rfq = service.submit(params[:id])
  render_content(rfq)
rescue StandardError => e
  render json: {success: false, error: e.message}
end

#submit_for_confirmationObject



40
41
42
43
44
45
46
# File 'app/controllers/comee/core/quotation_requests_controller.rb', line 40

def submit_for_confirmation
  service = QuotationRequestService.new
  rfq = service.submit_for_confirmation(params[:id])
  render_content(rfq)
rescue StandardError => e
  render json: {success: false, error: e.message}
end