Class: EmployeePayrollTransactions::CreateService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_company:, employee_id:, payroll_period_id:, gross_amount:, amount:, tag_sequence:, current_user:) ⇒ CreateService

Returns a new instance of CreateService.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/employee_payroll_transactions/create_service.rb', line 11

def initialize(
  current_company:,
  employee_id:,
  payroll_period_id:,
  gross_amount:,
  amount:,
  tag_sequence:,
  current_user:
)
  @current_company = current_company
  @employee_id = employee_id
  @payroll_period_id = payroll_period_id
  @gross_amount = gross_amount
  @amount = amount
  @tag_sequence = tag_sequence
  @current_user = current_user
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



3
4
5
# File 'app/services/employee_payroll_transactions/create_service.rb', line 3

def amount
  @amount
end

#current_companyObject (readonly)

Returns the value of attribute current_company.



3
4
5
# File 'app/services/employee_payroll_transactions/create_service.rb', line 3

def current_company
  @current_company
end

#current_userObject (readonly)

Returns the value of attribute current_user.



3
4
5
# File 'app/services/employee_payroll_transactions/create_service.rb', line 3

def current_user
  @current_user
end

#employee_idObject (readonly)

Returns the value of attribute employee_id.



3
4
5
# File 'app/services/employee_payroll_transactions/create_service.rb', line 3

def employee_id
  @employee_id
end

#gross_amountObject (readonly)

Returns the value of attribute gross_amount.



3
4
5
# File 'app/services/employee_payroll_transactions/create_service.rb', line 3

def gross_amount
  @gross_amount
end

#payroll_period_idObject (readonly)

Returns the value of attribute payroll_period_id.



3
4
5
# File 'app/services/employee_payroll_transactions/create_service.rb', line 3

def payroll_period_id
  @payroll_period_id
end

#tag_sequenceObject (readonly)

Returns the value of attribute tag_sequence.



3
4
5
# File 'app/services/employee_payroll_transactions/create_service.rb', line 3

def tag_sequence
  @tag_sequence
end

Instance Method Details

#callObject



29
30
31
32
33
34
35
36
37
38
# File 'app/services/employee_payroll_transactions/create_service.rb', line 29

def call
  ActiveRecord::Base.transaction do
    create_or_find_payroll_transaction_header
    create_or_find_payroll_transaction_detail
    create_employee_payroll_transaction
    validate_after_creation

    @employee_payroll_transaction
  end
end