Class: FdxV660Api::PaystubEntity

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/paystub_entity.rb

Overview

An employee's paystub

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(employee:, employer:, pay_period:, payroll_frequency:, gross_pay:, net_pay:, withholding:, paystub_id: SKIP, data_as_of: SKIP, source: SKIP, other_frequency: SKIP, earnings: SKIP, deductions: SKIP, payment_details: SKIP, disclaimers: SKIP, links: SKIP, additional_properties: nil) ⇒ PaystubEntity

Returns a new instance of PaystubEntity.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 126

def initialize(employee:, employer:, pay_period:, payroll_frequency:,
               gross_pay:, net_pay:, withholding:, paystub_id: SKIP,
               data_as_of: SKIP, source: SKIP, other_frequency: SKIP,
               earnings: SKIP, deductions: SKIP, payment_details: SKIP,
               disclaimers: SKIP, links: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @paystub_id = paystub_id unless paystub_id == SKIP
  @data_as_of = data_as_of unless data_as_of == SKIP
  @source = source unless source == SKIP
  @employee = employee
  @employer = employer
  @pay_period = pay_period
  @payroll_frequency = payroll_frequency
  @other_frequency = other_frequency unless other_frequency == SKIP
  @gross_pay = gross_pay
  @net_pay = net_pay
  @withholding = withholding
  @earnings = earnings unless earnings == SKIP
  @deductions = deductions unless deductions == SKIP
  @payment_details = payment_details unless payment_details == SKIP
  @disclaimers = disclaimers unless disclaimers == SKIP
  @links = links unless links == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#data_as_ofDate

The data on the paystub is as of this date

Returns:

  • (Date)


22
23
24
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 22

def data_as_of
  @data_as_of
end

#deductionsArray[PayAmount]

All the named deductions for this pay period, with pay period and year-to-date amounts and currency. Common names to use for deductions are Retirement, Medical, Dental, Vision, Garnishment, and Other Miscellaneous

Returns:



70
71
72
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 70

def deductions
  @deductions
end

#disclaimersArray[String]

All the disclaimer notes for this pay period

Returns:

  • (Array[String])


78
79
80
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 78

def disclaimers
  @disclaimers
end

#earningsArray[EarningComponent]

All the earning components for this pay period

Returns:



64
65
66
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 64

def earnings
  @earnings
end

#employeeEmployeeEntity1

The employee

Returns:



30
31
32
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 30

def employee
  @employee
end

#employerEmployerEntity1

The employer for the job/position

Returns:



34
35
36
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 34

def employer
  @employer
end

#gross_payPayAmount1

Gross pay and year-to-date amounts and currency for this paystub

Returns:



52
53
54
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 52

def gross_pay
  @gross_pay
end

Links to retrieve the PDF for this paystub, or to invoke related APIs

Returns:



82
83
84
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 82

def links
  @links
end

#net_payPayAmount2

Net pay and year-to-date amounts and currency for this paystub

Returns:



56
57
58
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 56

def net_pay
  @net_pay
end

#other_frequencyString

Description of the frequency, required if specified as OTHER

Returns:

  • (String)


48
49
50
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 48

def other_frequency
  @other_frequency
end

#pay_periodPayPeriod

The date range and payment date for this paystub

Returns:



38
39
40
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 38

def pay_period
  @pay_period
end

#payment_detailsArray[PaymentDetail]

The detailed splits of this payment between checks/cheques and/or deposits

Returns:



74
75
76
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 74

def payment_details
  @payment_details
end

#payroll_frequencyPayrollFrequencyType1

The frequency of payments. In pay period length order, one of DAILY, WEEKLY, BI-WEEKLY, SEMI-MONTHLY, EVERY 2.6 WEEKS, EVERY 4 WEEKS, MONTHLY, EVERY 5.2 WEEKS, QUARTERLY, SEMI-ANNUALLY, ANNUALLY, OTHER



44
45
46
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 44

def payroll_frequency
  @payroll_frequency
end

#paystub_idString

The paystub identification number, if any. This can be any ID which the data provider creates specific to the consenting person's paystub, perhaps simply the pay date as a string optionally followed by a sequence number: "2024-09-30-01". Need only be unique within the current employee's consent / token, according to data provider's preference

Returns:

  • (String)


18
19
20
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 18

def paystub_id
  @paystub_id
end

#sourcePaystubSource2

The original source of the paystub data

Returns:



26
27
28
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 26

def source
  @source
end

#withholdingPayPeriodWithholding

National, regional and local tax withholdings



60
61
62
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 60

def withholding
  @withholding
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 154

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  employee = EmployeeEntity1.from_hash(hash['employee']) if hash['employee']
  employer = EmployerEntity1.from_hash(hash['employer']) if hash['employer']
  pay_period = PayPeriod.from_hash(hash['payPeriod']) if hash['payPeriod']
  payroll_frequency =
    hash.key?('payrollFrequency') ? hash['payrollFrequency'] : nil
  gross_pay = PayAmount1.from_hash(hash['grossPay']) if hash['grossPay']
  net_pay = PayAmount2.from_hash(hash['netPay']) if hash['netPay']
  withholding = PayPeriodWithholding.from_hash(hash['withholding']) if hash['withholding']
  paystub_id = hash.key?('paystubId') ? hash['paystubId'] : SKIP
  data_as_of = hash.key?('dataAsOf') ? hash['dataAsOf'] : SKIP
  source = hash.key?('source') ? hash['source'] : SKIP
  other_frequency =
    hash.key?('otherFrequency') ? hash['otherFrequency'] : SKIP
  # Parameter is an array, so we need to iterate through it
  earnings = nil
  unless hash['earnings'].nil?
    earnings = []
    hash['earnings'].each do |structure|
      earnings << (EarningComponent.from_hash(structure) if structure)
    end
  end

  earnings = SKIP unless hash.key?('earnings')
  # Parameter is an array, so we need to iterate through it
  deductions = nil
  unless hash['deductions'].nil?
    deductions = []
    hash['deductions'].each do |structure|
      deductions << (PayAmount.from_hash(structure) if structure)
    end
  end

  deductions = SKIP unless hash.key?('deductions')
  # Parameter is an array, so we need to iterate through it
  payment_details = nil
  unless hash['paymentDetails'].nil?
    payment_details = []
    hash['paymentDetails'].each do |structure|
      payment_details << (PaymentDetail.from_hash(structure) if structure)
    end
  end

  payment_details = SKIP unless hash.key?('paymentDetails')
  disclaimers = hash.key?('disclaimers') ? hash['disclaimers'] : SKIP
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (HateoasLink.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  PaystubEntity.new(employee: employee,
                    employer: employer,
                    pay_period: pay_period,
                    payroll_frequency: payroll_frequency,
                    gross_pay: gross_pay,
                    net_pay: net_pay,
                    withholding: withholding,
                    paystub_id: paystub_id,
                    data_as_of: data_as_of,
                    source: source,
                    other_frequency: other_frequency,
                    earnings: earnings,
                    deductions: deductions,
                    payment_details: payment_details,
                    disclaimers: disclaimers,
                    links: links,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 85

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['paystub_id'] = 'paystubId'
  @_hash['data_as_of'] = 'dataAsOf'
  @_hash['source'] = 'source'
  @_hash['employee'] = 'employee'
  @_hash['employer'] = 'employer'
  @_hash['pay_period'] = 'payPeriod'
  @_hash['payroll_frequency'] = 'payrollFrequency'
  @_hash['other_frequency'] = 'otherFrequency'
  @_hash['gross_pay'] = 'grossPay'
  @_hash['net_pay'] = 'netPay'
  @_hash['withholding'] = 'withholding'
  @_hash['earnings'] = 'earnings'
  @_hash['deductions'] = 'deductions'
  @_hash['payment_details'] = 'paymentDetails'
  @_hash['disclaimers'] = 'disclaimers'
  @_hash['links'] = 'links'
  @_hash
end

.nullablesObject

An array for nullable fields



122
123
124
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 122

def self.nullables
  []
end

.optionalsObject

An array for optional fields



107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 107

def self.optionals
  %w[
    paystub_id
    data_as_of
    source
    other_frequency
    earnings
    deductions
    payment_details
    disclaimers
    links
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



252
253
254
255
256
257
258
259
260
261
262
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 252

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} paystub_id: #{@paystub_id.inspect}, data_as_of: #{@data_as_of.inspect},"\
  " source: #{@source.inspect}, employee: #{@employee.inspect}, employer:"\
  " #{@employer.inspect}, pay_period: #{@pay_period.inspect}, payroll_frequency:"\
  " #{@payroll_frequency.inspect}, other_frequency: #{@other_frequency.inspect}, gross_pay:"\
  " #{@gross_pay.inspect}, net_pay: #{@net_pay.inspect}, withholding: #{@withholding.inspect},"\
  " earnings: #{@earnings.inspect}, deductions: #{@deductions.inspect}, payment_details:"\
  " #{@payment_details.inspect}, disclaimers: #{@disclaimers.inspect}, links:"\
  " #{@links.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



241
242
243
244
245
246
247
248
249
# File 'lib/fdx_v660_api/models/paystub_entity.rb', line 241

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} paystub_id: #{@paystub_id}, data_as_of: #{@data_as_of}, source: #{@source},"\
  " employee: #{@employee}, employer: #{@employer}, pay_period: #{@pay_period},"\
  " payroll_frequency: #{@payroll_frequency}, other_frequency: #{@other_frequency}, gross_pay:"\
  " #{@gross_pay}, net_pay: #{@net_pay}, withholding: #{@withholding}, earnings: #{@earnings},"\
  " deductions: #{@deductions}, payment_details: #{@payment_details}, disclaimers:"\
  " #{@disclaimers}, links: #{@links}, additional_properties: #{@additional_properties}>"
end