Class: Comee::Core::BackOrdersController

Inherits:
ApplicationController show all
Includes:
Common
Defined in:
app/controllers/comee/core/back_orders_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

#filterObject



23
24
25
26
# File 'app/controllers/comee/core/back_orders_controller.rb', line 23

def filter
  data = BackOrder.includes(:back_order_items, :supplier).ransack(params[:q]).result
  render_content(data)
end

#indexObject



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

def index
  super do
    Comee::Core::BackOrder.includes(:back_order_items, :supplier)
  end
end

#model_paramsObject



28
29
30
31
# File 'app/controllers/comee/core/back_orders_controller.rb', line 28

def model_params
  params.require(:payload).permit(:order_number, :order_date, :delivery_date, :supplier_id, :terms,
                                  :delivery_address, :invoice_address, :status, :remark)
end

#submitObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/comee/core/back_orders_controller.rb', line 13

def submit
  ActiveRecord::Base.transaction do
    @obj.submit
    Comee::Core::BackOrderNotification.with(back_order: @obj).deliver(@obj.supplier.user)
    render json: {success: true, data: serialize(@obj.reload)}
  end
rescue StandardError => e
  render json: {success: false, error: e.message}
end