Class: CurrenciesController
Instance Method Summary
collapse
#accessible_company_ids_from_tenant_and_user, #application_mode_from_hostname, #current_company_id_from_accessible_company_ids, #current_tenant_from_user, #current_user_and_locale_from_token
Instance Method Details
#create ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/currencies_controller.rb', line 39
def create
currency_id = params[:currency_id] || 0
code = params[:code]
description_english = params[:description_english]
description_french = params[:description_french]
exchange_rate = params[:exchange_rate]
user = params[:user] || 'Admin'
Currency.create_or_update_procedure(
currency_id: currency_id,
code: code,
description_english: description_english,
description_french: description_french,
exchange_rate: exchange_rate,
user: user
)
render json: { message: 'Currency inserted/updated successfully' }
end
|
#index ⇒ Object
6
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
|
# File 'app/controllers/currencies_controller.rb', line 6
def index
display_length = params[:limit] || 10
search_value = params[:query] || ''
display_start_from_page_no = params[:offset] || 1
order_by = params[:order_by] || 'currency_id'
order_direction = params[:order_direction] || 'DESC'
grouping = "#{order_by} #{order_direction}"
result = Currency.where_procedure(
display_length: display_length,
search_value: search_value,
display_start_from_page_no: display_start_from_page_no,
grouping: grouping
)
result[:data] = result[:data].map do |row|
row.merge(
'type_description' => I18n.locale == :fr ? row['description_french'] : row['description_english']
)
end
render json: {
data: result[:data],
metadata: result[:metadata]
}
end
|
#options ⇒ Object
59
60
61
62
63
|
# File 'app/controllers/currencies_controller.rb', line 59
def options
render json: {
data: Currency.options
}
end
|
#show ⇒ Object
33
34
35
36
37
|
# File 'app/controllers/currencies_controller.rb', line 33
def show
currency_id = params[:id]
result = Currency.find_procedure(currency_id)
render json: result
end
|