Class: HrLite::TaxDeclarationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- HrLite::TaxDeclarationsController
- Defined in:
- app/controllers/hr_lite/tax_declarations_controller.rb
Overview
The employee's own declaration for a financial year. Replaces an admin typing one lump sum into the profile: the whole year's TDS is projected from this, so the person whose money it is fills it in.
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
6 7 8 9 |
# File 'app/controllers/hr_lite/tax_declarations_controller.rb', line 6 def show @declaration = current_declaration || build_declaration @regime = @declaration.regime end |
#submit ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/hr_lite/tax_declarations_controller.rb', line 35 def submit @declaration = current_declaration return redirect_to tax_declaration_path, alert: "Nothing to submit yet." if @declaration.nil? @declaration.submit!(actor: hr_current_user) redirect_to tax_declaration_path, notice: "Submitted — HR will check the proof." rescue ActiveRecord::RecordInvalid redirect_to tax_declaration_path, alert: "Only a draft can be submitted." end |
#update ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/hr_lite/tax_declarations_controller.rb', line 11 def update # A bare record, not the form's scaffold: `build_declaration` fills in # one blank line per section so the form is a list rather than an empty # box, and saving those blanks fails a NOT NULL amount. @declaration = current_declaration || TaxDeclaration.new(user_id: hr_current_user.id, financial_year: financial_year, regime: employee_regime) # A verified declaration is what payroll is deducting against; changing # it would silently re-open a decision HR has already made. if @declaration.verified? return redirect_to tax_declaration_path, alert: "This year's declaration is verified. Ask HR to reopen it." end if @declaration.update(declaration_params) redirect_to tax_declaration_path, notice: "Saved." else # Re-render needs the full set of lines back, or the form loses the # sections the person had not filled in yet. fill_missing_sections(@declaration) render :show, status: :unprocessable_entity end end |