Class: Comee::Core::SalesOrderItemsController
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
#application_code, #authenticate, #current_application, #current_user, #render_content, #render_error, #skip_bullet
Instance Method Details
#activate ⇒ Object
82
83
84
85
86
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 82
def activate
item = set_object
item.update(canceled: false)
render_content(item)
end
|
#cancel ⇒ Object
64
65
66
67
68
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 64
def cancel
item = set_object
item.update!(canceled: true, quantity: 0)
render_content(item)
end
|
#cancel_quantity ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 70
def cancel_quantity
item = set_object
to_cancel = cancel_quantity_params[:quantity]
raise(StandardError, "Quantity to cancel is greater than available quantity.") if to_cancel > item.quantity_remaining
item.quantity_canceled += to_cancel
item.save!
render_content(item)
rescue StandardError => e
render_error(e)
end
|
#destroy ⇒ Object
88
89
90
91
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 88
def destroy
Comee::Core::SalesOrderItem.destroy(params[:id])
render json: {success: true}
end
|
#filter ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 18
def filter
data = SalesOrderItem.includes(
:sales_order,
:purchase_order_item,
:customer_order_item,
:source,
:product,
:unit
).ransack(params[:q]).result
render_content(data)
end
|
#index ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 6
def index
super do
SalesOrderItem.includes(
:sales_order,
:customer_order_item,
:source,
:product,
:unit
).where(sales_order_id: params[:id])
end
end
|
#shipment_details ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 30
def shipment_details
details = SalesOrderItem.includes(
shipment_items: [
{shipment_instruction_items: :pod},
:item_statuses
],
purchase_order_item: [{purchase_order: :supplier}]
).find(params[:id])
render_content(
details,
{
include: [
"shipment_items.shipment_instruction_items.pod",
"shipment_items.item_statuses",
"purchase_order_item.purchase_order.supplier",
"sales_order.fulfillment_center"
],
serializer: SalesOrderItemDetailSerializer
}
)
end
|
#suggest_values ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/comee/core/sales_order_items_controller.rb', line 53
def suggest_values
service = CustomerOrderService.new
result = service.suggest_values(
params[:id],
suggest_params[:from_id],
suggest_params[:to_id],
suggest_params[:quantity]
)
render json: {success: true, data: result}
end
|