Class: FdxV660Api::EarningComponent

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

Overview

A single named pay component earned on this paystub with amount and optional currency and/or year-to-date amount. Common names to use for earned components that would fall under OTHER type (in addition to names for BASE, BONUS, COMMISSION, and OVERTIME types) are Tips, Stock, Workers Compensation, Pension, and Severance. (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:, currency: SKIP, name: SKIP, year_to_date: SKIP, rate: SKIP, rate_type: SKIP, hours: SKIP, type: SKIP, additional_properties: nil) ⇒ EarningComponent

Returns a new instance of EarningComponent.



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

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

Instance Attribute Details

#amountFloat

The monetary amount

Returns:

  • (Float)


19
20
21
# File 'lib/fdx_v660_api/models/earning_component.rb', line 19

def amount
  @amount
end

#currencyIso4217CurrencyCode7

Currency code of the monetary amount



23
24
25
# File 'lib/fdx_v660_api/models/earning_component.rb', line 23

def currency
  @currency
end

#hoursFloat

The number of hours paid for this component amount

Returns:

  • (Float)


46
47
48
# File 'lib/fdx_v660_api/models/earning_component.rb', line 46

def hours
  @hours
end

#nameString

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

Returns:

  • (String)


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

def name
  @name
end

#rateFloat

The rate used to calculate this earned component amount

Returns:

  • (Float)


36
37
38
# File 'lib/fdx_v660_api/models/earning_component.rb', line 36

def rate
  @rate
end

#rate_typePayrollRateType1

The unit for this rate. In time period length order, one of HOURLY, DAILY, WEEKLY, BI-WEEKLY, SEMI-MONTHLY, EVERY 2.6 WEEKS, EVERY 4 WEEKS, MONTHLY, EVERY 5.2 WEEKS, QUARTERLY, SEMI-ANNUALLY, ANNUAL, OTHER

Returns:



42
43
44
# File 'lib/fdx_v660_api/models/earning_component.rb', line 42

def rate_type
  @rate_type
end

#typeEarningType

The GSE Mapping for a specific earning component. For a Government Sponsored Enterprise (GSE), such as Fannie Mae or Freddie Mac. One of BASE, BONUS, COMMISSION, OTHER, OVERTIME

Returns:



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

def type
  @type
end

#year_to_dateFloat

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

Returns:

  • (Float)


32
33
34
# File 'lib/fdx_v660_api/models/earning_component.rb', line 32

def year_to_date
  @year_to_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/fdx_v660_api/models/earning_component.rb', line 104

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  year_to_date = hash.key?('yearToDate') ? hash['yearToDate'] : SKIP
  rate = hash.key?('rate') ? hash['rate'] : SKIP
  rate_type = hash.key?('rateType') ? hash['rateType'] : SKIP
  hours = hash.key?('hours') ? hash['hours'] : SKIP
  type = hash.key?('type') ? hash['type'] : 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.
  EarningComponent.new(amount: amount,
                       currency: currency,
                       name: name,
                       year_to_date: year_to_date,
                       rate: rate,
                       rate_type: rate_type,
                       hours: hours,
                       type: type,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fdx_v660_api/models/earning_component.rb', line 55

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['name'] = 'name'
  @_hash['year_to_date'] = 'yearToDate'
  @_hash['rate'] = 'rate'
  @_hash['rate_type'] = 'rateType'
  @_hash['hours'] = 'hours'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fdx_v660_api/models/earning_component.rb', line 69

def self.optionals
  %w[
    currency
    name
    year_to_date
    rate
    rate_type
    hours
    type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



145
146
147
148
149
150
151
# File 'lib/fdx_v660_api/models/earning_component.rb', line 145

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

#to_sObject

Provides a human-readable string representation of the object.



137
138
139
140
141
142
# File 'lib/fdx_v660_api/models/earning_component.rb', line 137

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