Class: PayrollRunService

Inherits:
Object
  • Object
show all
Defined in:
app/services/payroll_run_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(company_id:) ⇒ PayrollRunService

Returns a new instance of PayrollRunService.



4
5
6
# File 'app/services/payroll_run_service.rb', line 4

def initialize(company_id:)
  @company_id = company_id
end

Instance Attribute Details

#company_idObject (readonly)

Returns the value of attribute company_id.



2
3
4
# File 'app/services/payroll_run_service.rb', line 2

def company_id
  @company_id
end

Instance Method Details

#create_or_find_transaction_header_idObject



43
44
# File 'app/services/payroll_run_service.rb', line 43

def create_or_find_transaction_header_id
end

#period_optionsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/services/payroll_run_service.rb', line 8

def period_options
  result = ActiveRecord::Base.execute_procedure(
    'pr_run_and_schedule_payroll_step_1',
    company.company_id
  )[0]
  open_period_id = result['CurrentOpenPayrollPeriodId']
  next_period_id = result['Next_Payroll_Period_Id']

  open_period
  next_period
  grouped_payroll_periods
  default_payroll_period
  company_name
  default_hours_per_week

  period_id = [open_period_id, next_period_id, company.current_payroll_period_id].find { |id| id != 0 }
  period_option = open_period_id == 0 ? 'next_period' : 'open_period'
  period_info = PayrollPeriod
                .find_by(payroll_period_id: period_id)
                &.wizard_info(option: period_option)

  periods_with_timesheets = company.payroll_periods_data(must_have_timesheet: true, no_future: true)
  grouped_payroll_periods = Company.group_payroll_periods_by_year(periods_with_timesheets)
  default_payroll_period = periods_with_timesheets.first

  result.merge(
    grouped_payroll_periods: grouped_payroll_periods,
    default_payroll_period: default_payroll_period,
    company_name: company.company_name_e,
    default_hours_per_week: company.default_hours_per_week,

    period_option => period_info
  )
end

#recompute_transaction_headerObject



49
50
# File 'app/services/payroll_run_service.rb', line 49

def recompute_transaction_header
end

#reopen_transaction_header_for_reviewObject



61
62
# File 'app/services/payroll_run_service.rb', line 61

def reopen_transaction_header_for_review
end

#review_transaction_headerObject



58
59
# File 'app/services/payroll_run_service.rb', line 58

def review_transaction_header
end


46
47
# File 'app/services/payroll_run_service.rb', line 46

def transaction_header_related_records
end

#transaction_header_summaryObject



52
53
# File 'app/services/payroll_run_service.rb', line 52

def transaction_header_summary
end

#unlock_transaction_detailObject



55
56
# File 'app/services/payroll_run_service.rb', line 55

def unlock_transaction_detail
end