Class: HrLite::Admin::TaxDeclarationsController
- Inherits:
-
BaseController
- Object
- HrLite::ApplicationController
- BaseController
- HrLite::Admin::TaxDeclarationsController
- Defined in:
- app/controllers/hr_lite/admin/tax_declarations_controller.rb
Overview
HR checking the proof behind a declaration, line by line. The verified amount is what payroll deducts against once this is done, so it is entered per section rather than accepted wholesale.
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/hr_lite/admin/tax_declarations_controller.rb', line 10 def index @status = params[:status].presence_in(TaxDeclaration::STATUSES) || "submitted" @declarations = paginate( hr_scope(TaxDeclaration.includes(:user, :tax_declaration_items), "tax.view") .where(status: @status).order(created_at: :desc) ) end |
#reject ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'app/controllers/hr_lite/admin/tax_declarations_controller.rb', line 41 def reject declaration = find_manageable declaration.reject!(actor: hr_current_user, note: params[:note].to_s.strip) redirect_to admin_tax_declarations_path, notice: "Sent back to the employee." rescue ArgumentError redirect_to admin_tax_declaration_path(declaration), alert: "Say what is missing — they have to know what to fix." end |
#show ⇒ Object
18 19 20 |
# File 'app/controllers/hr_lite/admin/tax_declarations_controller.rb', line 18 def show @declaration = find_visible end |
#update ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/hr_lite/admin/tax_declarations_controller.rb', line 22 def update @declaration = find_manageable # Recording what the proof supported is a separate act from deciding # — an amount can be corrected while the decision is still pending. if @declaration.update(verification_params) redirect_to admin_tax_declaration_path(@declaration), notice: "Amounts recorded." else render :show, status: :unprocessable_entity end end |
#verify ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/controllers/hr_lite/admin/tax_declarations_controller.rb', line 33 def verify declaration = find_manageable declaration.verify!(actor: hr_current_user, note: params[:note]) redirect_to admin_tax_declarations_path, notice: "Verified — payroll will use the checked amounts." rescue ActiveRecord::RecordInvalid redirect_to admin_tax_declaration_path(declaration), alert: "Only a submitted declaration can be verified." end |