Class: FdxV660Api::RegionalTaxWithholding

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

Overview

Regional and/or locality tax withholding. Common names to use for regional withholdings are State, Local, State Unemployment Insurance, Voluntary Plan Disability Insurance, State Disability Insurance, and Temporary Disability Insurance. (Inheriting properties amount, currency, name and yearToDate from PayAmount)

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(amount:, name:, region:, currency: SKIP, year_to_date: SKIP, locality: SKIP, percent: SKIP, additional_properties: nil) ⇒ RegionalTaxWithholding

Returns a new instance of RegionalTaxWithholding.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 73

def initialize(amount:, name:, region:, currency: SKIP, year_to_date: SKIP,
               locality: SKIP, percent: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount = amount
  @currency = currency unless currency == SKIP
  @name = name
  @year_to_date = year_to_date unless year_to_date == SKIP
  @region = region
  @locality = locality unless locality == SKIP
  @percent = percent unless percent == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

The monetary amount

Returns:

  • (Float)


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

def amount
  @amount
end

#currencyIso4217CurrencyCode7

Currency code of the monetary amount



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

def currency
  @currency
end

#localityString

Name of sub-regional locality such as city, if any

Returns:

  • (String)


39
40
41
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 39

def locality
  @locality
end

#nameString

Name of this pay element, earning or deduction, if needed

Returns:

  • (String)


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

def name
  @name
end

#percentFloat

Percentage rate for this regional or local tax withholding, if specified

Returns:

  • (Float)


43
44
45
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 43

def percent
  @percent
end

#regionString

Name or code of state, province, canton, prefecture or sub-national region

Returns:

  • (String)


35
36
37
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 35

def region
  @region
end

#year_to_dateFloat

Year-to-date currency amount for this pay element, earning or deduction, if relevant

Returns:

  • (Float)


31
32
33
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 31

def year_to_date
  @year_to_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 89

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  region = hash.key?('region') ? hash['region'] : nil
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  year_to_date = hash.key?('yearToDate') ? hash['yearToDate'] : SKIP
  locality = hash.key?('locality') ? hash['locality'] : SKIP
  percent = hash.key?('percent') ? hash['percent'] : SKIP

  # 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.
  RegionalTaxWithholding.new(amount: amount,
                             name: name,
                             region: region,
                             currency: currency,
                             year_to_date: year_to_date,
                             locality: locality,
                             percent: percent,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 46

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['name'] = 'name'
  @_hash['year_to_date'] = 'yearToDate'
  @_hash['region'] = 'region'
  @_hash['locality'] = 'locality'
  @_hash['percent'] = 'percent'
  @_hash
end

.nullablesObject

An array for nullable fields



69
70
71
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 69

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 59

def self.optionals
  %w[
    currency
    year_to_date
    locality
    percent
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



128
129
130
131
132
133
134
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 128

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, currency: #{@currency.inspect}, name:"\
  " #{@name.inspect}, year_to_date: #{@year_to_date.inspect}, region: #{@region.inspect},"\
  " locality: #{@locality.inspect}, percent: #{@percent.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



120
121
122
123
124
125
# File 'lib/fdx_v660_api/models/regional_tax_withholding.rb', line 120

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, currency: #{@currency}, name: #{@name}, year_to_date:"\
  " #{@year_to_date}, region: #{@region}, locality: #{@locality}, percent: #{@percent},"\
  " additional_properties: #{@additional_properties}>"
end