Class: Comee::Core::SalesOrdersController
Instance Method Summary
collapse
Methods included from Common
#create
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
120
121
122
123
124
125
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 120
def accept
order = @service.accept(params[:id])
render_content(order)
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#cancel ⇒ Object
127
128
129
130
131
132
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 127
def cancel
order = @service.cancel(params[:id])
render_content(order)
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#confirm ⇒ Object
113
114
115
116
117
118
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 113
def confirm
order = @service.confirm(params[:id])
render_content(order)
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#create_back_order ⇒ Object
141
142
143
144
145
146
147
148
149
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 141
def create_back_order
service = SalesOrderService.new
result = service.create_back_orders(back_order_params[:payload])
if result[:success]
render json: {success: true}
else
render json: {success: false, error: result[:error]}
end
end
|
#filter ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 79
def filter
data = SalesOrder.includes(
:customer_order,
:client,
:customs_detail,
shipment_address: :country,
delivery_address: :country,
invoice_address: :country,
sales_order_items: %i[unit customer_order_item]
).ransack(params[:q]).result
render_content(
data,
include: [
"client",
"customer_order",
"sales_order_items.product",
"sales_order_items.unit",
"sales_order_items.customer_order_item",
"shipment_address.country",
"delivery_address.country",
"invoice_address.country",
"customs_detail",
"fulfillment_center"
]
)
end
|
#index ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 7
def index
super do
data = SalesOrder.includes(
:customer_order,
:client,
:customs_detail,
shipment_address: :country,
delivery_address: :country,
invoice_address: :country,
sales_order_items: :unit
).order(created_at: :desc)
[
data,
include: [
"client",
"customer_order",
"sales_order_items",
"sales_order_items.product",
"sales_order_items.unit",
"shipment_address.country",
"delivery_address.country",
"invoice_address.country",
"customs_detail",
"fulfillment_center"
]
]
end
end
|
#revert ⇒ Object
134
135
136
137
138
139
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 134
def revert
order = @service.revert(params[:id])
render_content(order)
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#show ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 36
def show
super do
[
SalesOrder.includes(
:customer_order,
:client,
:customs_detail,
shipment_address: :country,
delivery_address: :country,
invoice_address: :country,
sales_order_items: :unit
).find(params[:id]),
include: [
"client",
"customer_order",
"sales_order_items",
"sales_order_items.product",
"sales_order_items.unit",
"shipment_address.country",
"delivery_address.country",
"invoice_address.country",
"customs_detail",
"fulfillment_center"
]
]
end
end
|
#submit ⇒ Object
106
107
108
109
110
111
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 106
def submit
order = @service.submit(params[:id])
render_content(order)
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#update ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/comee/core/sales_orders_controller.rb', line 64
def update
super do
{
include: [
"client",
"customer_order",
"sales_order_items",
"sales_order_items.product",
"sales_order_items.unit",
"fulfillment_center"
]
}
end
end
|