Class: XeroRuby::PayrollUk::Payslip

Inherits:
Object
  • Object
show all
Defined in:
lib/xero-ruby/models/payroll_uk/payslip.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Payslip

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 198

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::Payslip` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollUk::Payslip`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'pay_slip_id')
    self.pay_slip_id = attributes[:'pay_slip_id']
  end

  if attributes.key?(:'employee_id')
    self.employee_id = attributes[:'employee_id']
  end

  if attributes.key?(:'pay_run_id')
    self.pay_run_id = attributes[:'pay_run_id']
  end

  if attributes.key?(:'last_edited')
    self.last_edited = attributes[:'last_edited']
  end

  if attributes.key?(:'first_name')
    self.first_name = attributes[:'first_name']
  end

  if attributes.key?(:'last_name')
    self.last_name = attributes[:'last_name']
  end

  if attributes.key?(:'total_earnings')
    self.total_earnings = attributes[:'total_earnings']
  end

  if attributes.key?(:'gross_earnings')
    self.gross_earnings = attributes[:'gross_earnings']
  end

  if attributes.key?(:'total_pay')
    self.total_pay = attributes[:'total_pay']
  end

  if attributes.key?(:'total_employer_taxes')
    self.total_employer_taxes = attributes[:'total_employer_taxes']
  end

  if attributes.key?(:'total_employee_taxes')
    self.total_employee_taxes = attributes[:'total_employee_taxes']
  end

  if attributes.key?(:'total_deductions')
    self.total_deductions = attributes[:'total_deductions']
  end

  if attributes.key?(:'total_reimbursements')
    self.total_reimbursements = attributes[:'total_reimbursements']
  end

  if attributes.key?(:'total_court_orders')
    self.total_court_orders = attributes[:'total_court_orders']
  end

  if attributes.key?(:'total_benefits')
    self.total_benefits = attributes[:'total_benefits']
  end

  if attributes.key?(:'bacs_hash')
    self.bacs_hash = attributes[:'bacs_hash']
  end

  if attributes.key?(:'payment_method')
    self.payment_method = attributes[:'payment_method']
  end

  if attributes.key?(:'earnings_lines')
    if (value = attributes[:'earnings_lines']).is_a?(Array)
      self.earnings_lines = value
    end
  end

  if attributes.key?(:'leave_earnings_lines')
    if (value = attributes[:'leave_earnings_lines']).is_a?(Array)
      self.leave_earnings_lines = value
    end
  end

  if attributes.key?(:'timesheet_earnings_lines')
    if (value = attributes[:'timesheet_earnings_lines']).is_a?(Array)
      self.timesheet_earnings_lines = value
    end
  end

  if attributes.key?(:'deduction_lines')
    if (value = attributes[:'deduction_lines']).is_a?(Array)
      self.deduction_lines = value
    end
  end

  if attributes.key?(:'reimbursement_lines')
    if (value = attributes[:'reimbursement_lines']).is_a?(Array)
      self.reimbursement_lines = value
    end
  end

  if attributes.key?(:'leave_accrual_lines')
    if (value = attributes[:'leave_accrual_lines']).is_a?(Array)
      self.leave_accrual_lines = value
    end
  end

  if attributes.key?(:'benefit_lines')
    if (value = attributes[:'benefit_lines']).is_a?(Array)
      self.benefit_lines = value
    end
  end

  if attributes.key?(:'payment_lines')
    if (value = attributes[:'payment_lines']).is_a?(Array)
      self.payment_lines = value
    end
  end

  if attributes.key?(:'employee_tax_lines')
    if (value = attributes[:'employee_tax_lines']).is_a?(Array)
      self.employee_tax_lines = value
    end
  end

  if attributes.key?(:'employer_tax_lines')
    if (value = attributes[:'employer_tax_lines']).is_a?(Array)
      self.employer_tax_lines = value
    end
  end

  if attributes.key?(:'court_order_lines')
    if (value = attributes[:'court_order_lines']).is_a?(Array)
      self.court_order_lines = value
    end
  end
end

Instance Attribute Details

#bacs_hashObject

BACS Service User Number



65
66
67
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 65

def bacs_hash
  @bacs_hash
end

#benefit_linesObject

Returns the value of attribute benefit_lines.



92
93
94
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 92

def benefit_lines
  @benefit_lines
end

#court_order_linesObject

Returns the value of attribute court_order_lines.



104
105
106
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 104

def court_order_lines
  @court_order_lines
end

#deduction_linesObject

Returns the value of attribute deduction_lines.



83
84
85
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 83

def deduction_lines
  @deduction_lines
end

#earnings_linesObject

Returns the value of attribute earnings_lines.



74
75
76
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 74

def earnings_lines
  @earnings_lines
end

#employee_idObject

The Xero identifier for payroll employee



23
24
25
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 23

def employee_id
  @employee_id
end

#employee_tax_linesObject

Returns the value of attribute employee_tax_lines.



98
99
100
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 98

def employee_tax_lines
  @employee_tax_lines
end

#employer_tax_linesObject

Returns the value of attribute employer_tax_lines.



101
102
103
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 101

def employer_tax_lines
  @employer_tax_lines
end

#first_nameObject

Employee first name



32
33
34
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 32

def first_name
  @first_name
end

#gross_earningsObject

Total earnings before any deductions. Same as total earnings for UK.



41
42
43
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 41

def gross_earnings
  @gross_earnings
end

#last_editedObject

The date payslip was last updated



29
30
31
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 29

def last_edited
  @last_edited
end

#last_nameObject

Employee last name



35
36
37
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 35

def last_name
  @last_name
end

#leave_accrual_linesObject

Returns the value of attribute leave_accrual_lines.



89
90
91
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 89

def leave_accrual_lines
  @leave_accrual_lines
end

#leave_earnings_linesObject

Returns the value of attribute leave_earnings_lines.



77
78
79
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 77

def leave_earnings_lines
  @leave_earnings_lines
end

#pay_run_idObject

The Xero identifier for the associated payrun



26
27
28
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 26

def pay_run_id
  @pay_run_id
end

#pay_slip_idObject

The Xero identifier for a Payslip



20
21
22
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 20

def pay_slip_id
  @pay_slip_id
end

#payment_linesObject

Returns the value of attribute payment_lines.



95
96
97
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 95

def payment_lines
  @payment_lines
end

#payment_methodObject

The payment method code



68
69
70
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 68

def payment_method
  @payment_method
end

#reimbursement_linesObject

Returns the value of attribute reimbursement_lines.



86
87
88
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 86

def reimbursement_lines
  @reimbursement_lines
end

#timesheet_earnings_linesObject

Returns the value of attribute timesheet_earnings_lines.



80
81
82
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 80

def timesheet_earnings_lines
  @timesheet_earnings_lines
end

#total_benefitsObject

Benefits (also called fringe benefits, perquisites or perks) are various non-earnings compensations provided to employees in addition to their normal earnings or salaries



62
63
64
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 62

def total_benefits
  @total_benefits
end

#total_court_ordersObject

Total amounts required by law to subtract from the employee’s earnings



59
60
61
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 59

def total_court_orders
  @total_court_orders
end

#total_deductionsObject

Total amount subtracted from an employee’s earnings to reach total pay



53
54
55
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 53

def total_deductions
  @total_deductions
end

#total_earningsObject

Total earnings before any deductions. Same as gross earnings for UK.



38
39
40
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 38

def total_earnings
  @total_earnings
end

#total_employee_taxesObject

The part of an employee’s earnings that is deducted for tax purposes



50
51
52
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 50

def total_employee_taxes
  @total_employee_taxes
end

#total_employer_taxesObject

The employer’s tax obligation



47
48
49
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 47

def total_employer_taxes
  @total_employer_taxes
end

#total_payObject

The employee net pay



44
45
46
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 44

def total_pay
  @total_pay
end

#total_reimbursementsObject

Total reimbursements are nontaxable payments to an employee used to repay out-of-pocket expenses when the person incurs those expenses through employment



56
57
58
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 56

def total_reimbursements
  @total_reimbursements
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 129

def self.attribute_map
  {
    :'pay_slip_id' => :'paySlipID',
    :'employee_id' => :'employeeID',
    :'pay_run_id' => :'payRunID',
    :'last_edited' => :'lastEdited',
    :'first_name' => :'firstName',
    :'last_name' => :'lastName',
    :'total_earnings' => :'totalEarnings',
    :'gross_earnings' => :'grossEarnings',
    :'total_pay' => :'totalPay',
    :'total_employer_taxes' => :'totalEmployerTaxes',
    :'total_employee_taxes' => :'totalEmployeeTaxes',
    :'total_deductions' => :'totalDeductions',
    :'total_reimbursements' => :'totalReimbursements',
    :'total_court_orders' => :'totalCourtOrders',
    :'total_benefits' => :'totalBenefits',
    :'bacs_hash' => :'bacsHash',
    :'payment_method' => :'paymentMethod',
    :'earnings_lines' => :'earningsLines',
    :'leave_earnings_lines' => :'leaveEarningsLines',
    :'timesheet_earnings_lines' => :'timesheetEarningsLines',
    :'deduction_lines' => :'deductionLines',
    :'reimbursement_lines' => :'reimbursementLines',
    :'leave_accrual_lines' => :'leaveAccrualLines',
    :'benefit_lines' => :'benefitLines',
    :'payment_lines' => :'paymentLines',
    :'employee_tax_lines' => :'employeeTaxLines',
    :'employer_tax_lines' => :'employerTaxLines',
    :'court_order_lines' => :'courtOrderLines'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



421
422
423
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 421

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 163

def self.openapi_types
  {
    :'pay_slip_id' => :'String',
    :'employee_id' => :'String',
    :'pay_run_id' => :'String',
    :'last_edited' => :'Date',
    :'first_name' => :'String',
    :'last_name' => :'String',
    :'total_earnings' => :'Float',
    :'gross_earnings' => :'Float',
    :'total_pay' => :'Float',
    :'total_employer_taxes' => :'Float',
    :'total_employee_taxes' => :'Float',
    :'total_deductions' => :'Float',
    :'total_reimbursements' => :'Float',
    :'total_court_orders' => :'Float',
    :'total_benefits' => :'Float',
    :'bacs_hash' => :'String',
    :'payment_method' => :'String',
    :'earnings_lines' => :'Array<EarningsLine>',
    :'leave_earnings_lines' => :'Array<LeaveEarningsLine>',
    :'timesheet_earnings_lines' => :'Array<TimesheetEarningsLine>',
    :'deduction_lines' => :'Array<DeductionLine>',
    :'reimbursement_lines' => :'Array<ReimbursementLine>',
    :'leave_accrual_lines' => :'Array<LeaveAccrualLine>',
    :'benefit_lines' => :'Array<BenefitLine>',
    :'payment_lines' => :'Array<PaymentLine>',
    :'employee_tax_lines' => :'Array<TaxLine>',
    :'employer_tax_lines' => :'Array<TaxLine>',
    :'court_order_lines' => :'Array<CourtOrderLine>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 373

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      pay_slip_id == o.pay_slip_id &&
      employee_id == o.employee_id &&
      pay_run_id == o.pay_run_id &&
      last_edited == o.last_edited &&
      first_name == o.first_name &&
      last_name == o.last_name &&
      total_earnings == o.total_earnings &&
      gross_earnings == o.gross_earnings &&
      total_pay == o.total_pay &&
      total_employer_taxes == o.total_employer_taxes &&
      total_employee_taxes == o.total_employee_taxes &&
      total_deductions == o.total_deductions &&
      total_reimbursements == o.total_reimbursements &&
      total_court_orders == o.total_court_orders &&
      total_benefits == o.total_benefits &&
      bacs_hash == o.bacs_hash &&
      payment_method == o.payment_method &&
      earnings_lines == o.earnings_lines &&
      leave_earnings_lines == o.leave_earnings_lines &&
      timesheet_earnings_lines == o.timesheet_earnings_lines &&
      deduction_lines == o.deduction_lines &&
      reimbursement_lines == o.reimbursement_lines &&
      leave_accrual_lines == o.leave_accrual_lines &&
      benefit_lines == o.benefit_lines &&
      payment_lines == o.payment_lines &&
      employee_tax_lines == o.employee_tax_lines &&
      employer_tax_lines == o.employer_tax_lines &&
      court_order_lines == o.court_order_lines
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 449

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(parse_date(value))
  when :Date
    Date.parse(parse_date(value))
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BigDecimal
    BigDecimal(value.to_s)
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    XeroRuby::PayrollUk.const_get(type).build_from_hash(value)
  end
end

#_to_hash(value, downcase: false) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 522

def _to_hash(value, downcase: false)
  if value.is_a?(Array)
    value.map do |v|
      v.to_hash(downcase: downcase)
    end
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash(downcase: downcase)
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 428

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


408
409
410
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 408

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



414
415
416
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 414

def hash
  [pay_slip_id, employee_id, pay_run_id, last_edited, first_name, last_name, total_earnings, gross_earnings, total_pay, total_employer_taxes, total_employee_taxes, total_deductions, total_reimbursements, total_court_orders, total_benefits, bacs_hash, payment_method, earnings_lines, leave_earnings_lines, timesheet_earnings_lines, deduction_lines, reimbursement_lines, leave_accrual_lines, benefit_lines, payment_lines, employee_tax_lines, employer_tax_lines, court_order_lines].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



348
349
350
351
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 348

def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end

#parse_date(datestring) ⇒ Object



538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 538

def parse_date(datestring)
  if datestring.include?('Date')
    date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
    original, date, timezone = *date_pattern.match(datestring)
    date = (date.to_i / 1000)
    Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
  elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
    Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
  else # handle date 'types' for small subset of payroll API's
    Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
  end
end

#to_attributesObject

Returns the object in the form of hash with snake_case



514
515
516
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 514

def to_attributes
  to_hash(downcase: true)
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



496
497
498
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 496

def to_body
  to_hash
end

#to_hash(downcase: false) ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



502
503
504
505
506
507
508
509
510
511
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 502

def to_hash(downcase: false)
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    key = downcase ? attr : param
    hash[key] = _to_hash(value, downcase: downcase)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



490
491
492
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 490

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



355
356
357
358
359
# File 'lib/xero-ruby/models/payroll_uk/payslip.rb', line 355

def valid?
  payment_method_validator = EnumAttributeValidator.new('String', ["Cheque", "Electronically", "Manual"])
  return false unless payment_method_validator.valid?(@payment_method)
  true
end