Class: Cats::Core::ReceiptAuthorizationsController
Instance Method Summary
collapse
Methods included from Common
#show, #update
#authenticate, #current_user, #skip_bullet
Instance Method Details
#confirm ⇒ Object
24
25
26
27
28
29
30
|
# File 'app/controllers/cats/core/receipt_authorizations_controller.rb', line 24
def confirm
authorization = ReceiptAuthorization.find(params[:id])
authorization.confirm
render json: {success: true, data: serialize(authorization)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#create ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/cats/core/receipt_authorizations_controller.rb', line 14
def create
authorization = ReceiptAuthorization.new(model_params)
if authorization.save
AuthorizationService.new.send_receipt_notification(authorization)
render json: {success: true, data: serialize(authorization)}, status: :created
else
render json: {success: false, error: authorization.errors.full_messages[0]}, status: :unprocessable_entity
end
end
|
#driver_confirm ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/cats/core/receipt_authorizations_controller.rb', line 32
def driver_confirm
service = AuthorizationService.new
authorization = service.driver_confirm(
params[:id], driver_confirm_params[:pin], driver_confirm_params[:receipt_number]
)
render json: {success: true, data: serialize(authorization)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#filter ⇒ Object
60
61
62
63
64
65
66
67
68
|
# File 'app/controllers/cats/core/receipt_authorizations_controller.rb', line 60
def filter
query = ReceiptAuthorization.includes(
:dispatch,
:store,
:authorized_by,
:unit
).ransack(params[:q])
render json: {success: true, data: serialize(query.result.reverse_order)}
end
|
#index ⇒ Object
8
9
10
11
12
|
# File 'app/controllers/cats/core/receipt_authorizations_controller.rb', line 8
def index
super do
ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit).where(dispatch_id: params[:id]).reverse_order
end
end
|
#stack ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'app/controllers/cats/core/receipt_authorizations_controller.rb', line 42
def stack
service = AuthorizationService.new
authorization = ReceiptAuthorization.find(params[:id])
authorization = service.stack(authorization.id)
render json: {success: true, data: serialize(authorization)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#storekeeper_authorizations ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'app/controllers/cats/core/receipt_authorizations_controller.rb', line 51
def storekeeper_authorizations
storekeeper = User.find(params[:id])
status = params[:status]
stores = storekeeper.stores
authorizations = ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit)
.where(store: stores, status: status)
render json: {success: true, data: serialize(authorizations)}
end
|