Class: PayrollFederalProvincialDeduction::View

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/payroll_federal_provincial_deduction.rb

Constant Summary collapse

FEDERAL_PAYROLL_SOURCE =
'01'
PROVINCIAL_PAYROLL_SOURCE =
'02'

Class Method Summary collapse

Methods inherited from ApplicationRecord

define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection

Class Method Details

.federal_deduction_code_exists?(payroll_frequency:, code:) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
# File 'app/models/payroll_federal_provincial_deduction.rb', line 41

def federal_deduction_code_exists?(payroll_frequency:, code:)
  exists?(
    payroll_frequency: payroll_frequency,
    payroll_source: FEDERAL_PAYROLL_SOURCE,
    province_id: Province::NO_PROVINCE_ID,
    deduction_code: code
  )
end

.federal_deduction_codes(payroll_frequency:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/payroll_federal_provincial_deduction.rb', line 13

def federal_deduction_codes(payroll_frequency:)
  select(
    :deduction_code,
    :deduction_code_display_english
  )
    .distinct
    .where(
      payroll_frequency: payroll_frequency,
      payroll_source: FEDERAL_PAYROLL_SOURCE,
      province_id: -1
    )
    .order(:deduction_code)
end

.provincial_deduction_code_exists?(payroll_frequency:, code:) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
# File 'app/models/payroll_federal_provincial_deduction.rb', line 50

def provincial_deduction_code_exists?(payroll_frequency:, code:)
  exists?(
    payroll_frequency: payroll_frequency,
    payroll_source: PROVINCIAL_PAYROLL_SOURCE,
    province_id: Province::QUEBEC_PROVINCE_ID,
    deduction_code: code
  )
end

.provincial_deduction_codes(payroll_frequency:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/payroll_federal_provincial_deduction.rb', line 27

def provincial_deduction_codes(payroll_frequency:)
  select(
    :deduction_code,
    :deduction_code_display_english
  )
    .distinct
    .where(
      payroll_frequency: payroll_frequency,
      payroll_source: PROVINCIAL_PAYROLL_SOURCE,
      province_id: Province::QUEBEC_PROVINCE_ID
    )
    .order(:deduction_code)
end