Class: Comee::Core::CustomerOrdersController
Instance Method Summary
collapse
Methods included from Common
#create, #update
Methods included from Pagination
#default_per_page, #order_by, #order_direction, #page_no, #paginate, #paginate_offset, #per_page
#application_code, #authenticate, #current_application, #current_user, #render_content, #render_error, #skip_bullet
Instance Method Details
#accept ⇒ Object
45
46
47
48
49
50
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 45
def accept
order = @service.accept(params[:id], current_user.name)
render json: {success: true, data: serialize(order)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#cancel ⇒ Object
52
53
54
55
56
57
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 52
def cancel
order = @service.cancel(params[:id])
render json: {success: true, data: serialize(order)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#create_with_items ⇒ Object
26
27
28
29
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 26
def create_with_items
order = @service.create(create_with_item_params)
render json: {success: true, data: serialize(order)}
end
|
#filter ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 59
def filter
orders = CustomerOrder.includes(
:shipment_address,
:delivery_address,
:invoice_address,
:customer_order_items,
:file_attachment,
client: %i[user currency]
).ransack(params[:q]).result
render_content(orders, include: ["client", "customer_order_items.unit"])
end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 8
def index
super do
[
CustomerOrder.includes(:client, customer_order_items: :unit).order(:created_at),
include: ["client", "customer_order_items.unit"]
]
end
end
|
#show ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 17
def show
super do
[
CustomerOrder.includes(:client, customer_order_items: :unit).find(params[:id]),
include: ["client", "customer_order_items.unit"]
]
end
end
|
#submit ⇒ Object
31
32
33
34
35
36
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 31
def submit
order = @service.submit(params[:id])
render json: {success: true, data: serialize(order)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#submit_for_confirmation ⇒ Object
38
39
40
41
42
43
|
# File 'app/controllers/comee/core/customer_orders_controller.rb', line 38
def submit_for_confirmation
order = @service.submit_for_confirmation(params[:id])
render json: {success: true, data: serialize(order)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|