Class: Comee::Core::QuotationRequestItemsController

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

Instance Method Summary collapse

Methods included from Common

#create, #index, #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

#cancelObject



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

def cancel
  QuotationRequestItem.where(id: params[:ids]).update_all(canceled: true)
  render json: {success: true}
end

#destroyObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/comee/core/quotation_request_items_controller.rb', line 16

def destroy
  item = QuotationRequestItem.find(params[:id])
  rfq = item.quotation_request
  if QuotationRequest.statuses[rfq.status] == QuotationRequest.statuses[:draft]
    item.destroy
    render json: {success: true}
  else
    render json: {success: false, error: "RFQ should be in draft state first."}, status: :forbidden
  end
end

#filterObject



11
12
13
14
# File 'app/controllers/comee/core/quotation_request_items_controller.rb', line 11

def filter
  data = QuotationRequestItem.includes(:product, :quotation_request, :unit).ransack(params[:q]).result
  render_content(data)
end