Class: FdxV660Api::FederalTaxWithholding

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

Overview

National / federal tax withholding. Common names to use for federal withholdings are Federal, Social Security, and Medicare. (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:, currency: SKIP, year_to_date: SKIP, percent: SKIP, additional_properties: nil) ⇒ FederalTaxWithholding

Returns a new instance of FederalTaxWithholding.



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 60

def initialize(amount:, name:, currency: SKIP, year_to_date: 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
  @percent = percent unless percent == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

The monetary amount

Returns:

  • (Float)


16
17
18
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 16

def amount
  @amount
end

#currencyIso4217CurrencyCode7

Currency code of the monetary amount



20
21
22
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 20

def currency
  @currency
end

#nameString

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

Returns:

  • (String)


24
25
26
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 24

def name
  @name
end

#percentFloat

Percentage rate for this federal tax withholding, if specified

Returns:

  • (Float)


33
34
35
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 33

def percent
  @percent
end

#year_to_dateFloat

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

Returns:

  • (Float)


29
30
31
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 29

def year_to_date
  @year_to_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 74

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
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  year_to_date = hash.key?('yearToDate') ? hash['yearToDate'] : 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.
  FederalTaxWithholding.new(amount: amount,
                            name: name,
                            currency: currency,
                            year_to_date: year_to_date,
                            percent: percent,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 36

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

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



47
48
49
50
51
52
53
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 47

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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}, percent: #{@percent.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



101
102
103
104
105
# File 'lib/fdx_v660_api/models/federal_tax_withholding.rb', line 101

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