Class: Cats::Core::RoundBeneficiariesController
Instance Method Summary
collapse
Methods included from Common
#create, #show, #update
#authenticate, #current_user, #skip_bullet
Instance Method Details
#confirm_receipt ⇒ Object
34
35
36
37
38
39
40
|
# File 'app/controllers/cats/core/round_beneficiaries_controller.rb', line 34
def confirm_receipt
service = BeneficiaryService.new
result = service.confirm_receipt(params[:id], common_params[:ids])
render json: {success: result}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#filter ⇒ Object
21
22
23
24
|
# File 'app/controllers/cats/core/round_beneficiaries_controller.rb', line 21
def filter
query = RoundBeneficiary.includes(:beneficiary, :commodity_category, :unit).ransack(params[:q])
render json: {success: true, data: serialize(query.result)}
end
|
#generate ⇒ Object
13
14
15
16
17
18
19
|
# File 'app/controllers/cats/core/round_beneficiaries_controller.rb', line 13
def generate
service = BeneficiaryService.new
result = service.generate_distribution_list(params[:id])
render json: {success: result}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#index ⇒ Object
6
7
8
9
10
11
|
# File 'app/controllers/cats/core/round_beneficiaries_controller.rb', line 6
def index
beneficiaries = RoundBeneficiary.joins(:round_plan_item)
.where(round_plan_item: {round_plan_id: params[:id]})
.includes(:beneficiary, :commodity_category, :unit)
render json: {success: true, data: serialize(beneficiaries)}
end
|
#remove_beneficiaries ⇒ Object
26
27
28
29
30
31
32
|
# File 'app/controllers/cats/core/round_beneficiaries_controller.rb', line 26
def remove_beneficiaries
service = BeneficiaryService.new
result = service.remove_items(params[:id], common_params[:ids])
render json: {success: result}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|