Class: FdxV660Api::PayPeriodWithholding

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

Overview

National, regional and local tax withholdings

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(tax_filing_status:, country:, federal_withholdings: SKIP, regional_withholdings: SKIP, additional_properties: nil) ⇒ PayPeriodWithholding

Returns a new instance of PayPeriodWithholding.



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 52

def initialize(tax_filing_status:, country:, federal_withholdings: SKIP,
               regional_withholdings: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @tax_filing_status = tax_filing_status
  @country = country
  @federal_withholdings = federal_withholdings unless federal_withholdings == SKIP
  @regional_withholdings = regional_withholdings unless regional_withholdings == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#countryIso3166CountryCode5

The country for the federal withholding amount

Returns:



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

def country
  @country
end

#federal_withholdingsArray[FederalTaxWithholding]

All the various named national / federal withholdings for this pay period

Returns:



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

def federal_withholdings
  @federal_withholdings
end

#regional_withholdingsArray[RegionalTaxWithholding]

All the various named regional and/or local withholdings for this pay period

Returns:



27
28
29
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 27

def regional_withholdings
  @regional_withholdings
end

#tax_filing_statusString

Tax filing status of the employee for this pay period

Returns:

  • (String)


14
15
16
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 14

def tax_filing_status
  @tax_filing_status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 65

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  tax_filing_status =
    hash.key?('taxFilingStatus') ? hash['taxFilingStatus'] : nil
  country = hash.key?('country') ? hash['country'] : nil
  # Parameter is an array, so we need to iterate through it
  federal_withholdings = nil
  unless hash['federalWithholdings'].nil?
    federal_withholdings = []
    hash['federalWithholdings'].each do |structure|
      federal_withholdings << (FederalTaxWithholding.from_hash(structure) if structure)
    end
  end

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

  regional_withholdings = SKIP unless hash.key?('regionalWithholdings')

  # 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.
  PayPeriodWithholding.new(tax_filing_status: tax_filing_status,
                           country: country,
                           federal_withholdings: federal_withholdings,
                           regional_withholdings: regional_withholdings,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['tax_filing_status'] = 'taxFilingStatus'
  @_hash['country'] = 'country'
  @_hash['federal_withholdings'] = 'federalWithholdings'
  @_hash['regional_withholdings'] = 'regionalWithholdings'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 40

def self.optionals
  %w[
    federal_withholdings
    regional_withholdings
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



117
118
119
120
121
122
123
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 117

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} tax_filing_status: #{@tax_filing_status.inspect}, country:"\
  " #{@country.inspect}, federal_withholdings: #{@federal_withholdings.inspect},"\
  " regional_withholdings: #{@regional_withholdings.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



109
110
111
112
113
114
# File 'lib/fdx_v660_api/models/pay_period_withholding.rb', line 109

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} tax_filing_status: #{@tax_filing_status}, country: #{@country},"\
  " federal_withholdings: #{@federal_withholdings}, regional_withholdings:"\
  " #{@regional_withholdings}, additional_properties: #{@additional_properties}>"
end