Class: HrLite::Admin::StatutoryRateCardsController
- Inherits:
-
SuperadminController
- Object
- HrLite::ApplicationController
- BaseController
- LeadershipController
- SuperadminController
- HrLite::Admin::StatutoryRateCardsController
- Defined in:
- app/controllers/hr_lite/admin/statutory_rate_cards_controller.rb
Overview
Adding a financial year, and recording who checked it. Money tier: these figures decide what lands in a bank account.
New years are created by COPYING the newest card — a year's PF and ESI figures usually carry over untouched and only the slabs move, so a blank form would be an invitation to mistype eight numbers that were already right.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/hr_lite/admin/statutory_rate_cards_controller.rb', line 25 def create @card = StatutoryRateCardRecord.new(card_params) if @card.save redirect_to admin_statutory_rate_cards_path, notice: "FY #{@card.financial_year} card saved. Payroll will use it " \ "from #{@card.effective_from.strftime('%d %b %Y')}." else @copied_from = nil render :new, status: :unprocessable_entity end end |
#edit ⇒ Object
37 38 39 |
# File 'app/controllers/hr_lite/admin/statutory_rate_cards_controller.rb', line 37 def edit @card = StatutoryRateCardRecord.find(params[:id]) end |
#index ⇒ Object
11 12 13 14 |
# File 'app/controllers/hr_lite/admin/statutory_rate_cards_controller.rb', line 11 def index @cards = StatutoryRateCardRecord.chronological.reverse @states = ProfessionalTaxSlab.distinct.order(:state).pluck(:state) end |
#new ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/hr_lite/admin/statutory_rate_cards_controller.rb', line 16 def new newest = StatutoryRateCardRecord.chronological.last @card = StatutoryRateCardRecord.new( effective_from: next_financial_year(newest), pf: newest&.pf || {}, esi: newest&.esi || {}, income_tax: newest&.income_tax || {} ) @copied_from = newest end |
#update ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'app/controllers/hr_lite/admin/statutory_rate_cards_controller.rb', line 41 def update @card = StatutoryRateCardRecord.find(params[:id]) if @card.update(card_params) redirect_to admin_statutory_rate_cards_path, notice: "FY #{@card.financial_year} card updated." else render :edit, status: :unprocessable_entity end end |