Class: ThePlaidApi::W2Override

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/w2_override.rb

Overview

W2 is an object that represents income data taken from a W2 tax document.

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(employer: SKIP, employee: SKIP, tax_year: SKIP, employer_id_number: SKIP, wages_tips_other_comp: SKIP, federal_income_tax_withheld: SKIP, social_security_wages: SKIP, social_security_tax_withheld: SKIP, medicare_wages_and_tips: SKIP, medicare_tax_withheld: SKIP, social_security_tips: SKIP, allocated_tips: SKIP, box_9: SKIP, dependent_care_benefits: SKIP, nonqualified_plans: SKIP, box_12: SKIP, statutory_employee: SKIP, retirement_plan: SKIP, third_party_sick_pay: SKIP, other: SKIP, state_and_local_wages: SKIP, additional_properties: nil) ⇒ W2Override

Returns a new instance of W2Override.



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/the_plaid_api/models/w2_override.rb', line 173

def initialize(employer: SKIP, employee: SKIP, tax_year: SKIP,
               employer_id_number: SKIP, wages_tips_other_comp: SKIP,
               federal_income_tax_withheld: SKIP,
               social_security_wages: SKIP,
               social_security_tax_withheld: SKIP,
               medicare_wages_and_tips: SKIP, medicare_tax_withheld: SKIP,
               social_security_tips: SKIP, allocated_tips: SKIP,
               box_9: SKIP, dependent_care_benefits: SKIP,
               nonqualified_plans: SKIP, box_12: SKIP,
               statutory_employee: SKIP, retirement_plan: SKIP,
               third_party_sick_pay: SKIP, other: SKIP,
               state_and_local_wages: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @employer = employer unless employer == SKIP
  @employee = employee unless employee == SKIP
  @tax_year = tax_year unless tax_year == SKIP
  @employer_id_number = employer_id_number unless employer_id_number == SKIP
  @wages_tips_other_comp = wages_tips_other_comp unless wages_tips_other_comp == SKIP
  unless federal_income_tax_withheld == SKIP
    @federal_income_tax_withheld =
      federal_income_tax_withheld
  end
  @social_security_wages = social_security_wages unless social_security_wages == SKIP
  unless social_security_tax_withheld == SKIP
    @social_security_tax_withheld =
      social_security_tax_withheld
  end
  @medicare_wages_and_tips = medicare_wages_and_tips unless medicare_wages_and_tips == SKIP
  @medicare_tax_withheld = medicare_tax_withheld unless medicare_tax_withheld == SKIP
  @social_security_tips = social_security_tips unless social_security_tips == SKIP
  @allocated_tips = allocated_tips unless allocated_tips == SKIP
  @box_9 = box_9 unless box_9 == SKIP
  @dependent_care_benefits = dependent_care_benefits unless dependent_care_benefits == SKIP
  @nonqualified_plans = nonqualified_plans unless nonqualified_plans == SKIP
  @box_12 = box_12 unless box_12 == SKIP
  @statutory_employee = statutory_employee unless statutory_employee == SKIP
  @retirement_plan = retirement_plan unless retirement_plan == SKIP
  @third_party_sick_pay = third_party_sick_pay unless third_party_sick_pay == SKIP
  @other = other unless other == SKIP
  @state_and_local_wages = state_and_local_wages unless state_and_local_wages == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#allocated_tipsString

Allocated tips.

Returns:

  • (String)


58
59
60
# File 'lib/the_plaid_api/models/w2_override.rb', line 58

def allocated_tips
  @allocated_tips
end

#box_12Array[W2Box12Override]

Nonqualified plans.

Returns:



74
75
76
# File 'lib/the_plaid_api/models/w2_override.rb', line 74

def box_12
  @box_12
end

#box_9String

Contents from box 9 on the W2.

Returns:

  • (String)


62
63
64
# File 'lib/the_plaid_api/models/w2_override.rb', line 62

def box_9
  @box_9
end

#dependent_care_benefitsString

Dependent care benefits.

Returns:

  • (String)


66
67
68
# File 'lib/the_plaid_api/models/w2_override.rb', line 66

def dependent_care_benefits
  @dependent_care_benefits
end

#employeePaystubOverrideEmployee

The employee on the paystub.



18
19
20
# File 'lib/the_plaid_api/models/w2_override.rb', line 18

def employee
  @employee
end

#employerPaystubOverrideEmployer

The employer on the paystub.



14
15
16
# File 'lib/the_plaid_api/models/w2_override.rb', line 14

def employer
  @employer
end

#employer_id_numberString

An employer identification number or EIN.

Returns:

  • (String)


26
27
28
# File 'lib/the_plaid_api/models/w2_override.rb', line 26

def employer_id_number
  @employer_id_number
end

#federal_income_tax_withheldString

Federal income tax withheld for the tax year.

Returns:

  • (String)


34
35
36
# File 'lib/the_plaid_api/models/w2_override.rb', line 34

def federal_income_tax_withheld
  @federal_income_tax_withheld
end

#medicare_tax_withheldString

Medicare tax withheld for the tax year.

Returns:

  • (String)


50
51
52
# File 'lib/the_plaid_api/models/w2_override.rb', line 50

def medicare_tax_withheld
  @medicare_tax_withheld
end

#medicare_wages_and_tipsString

Wages and tips from medicare.

Returns:

  • (String)


46
47
48
# File 'lib/the_plaid_api/models/w2_override.rb', line 46

def medicare_wages_and_tips
  @medicare_wages_and_tips
end

#nonqualified_plansString

Nonqualified plans.

Returns:

  • (String)


70
71
72
# File 'lib/the_plaid_api/models/w2_override.rb', line 70

def nonqualified_plans
  @nonqualified_plans
end

#otherString

Other.

Returns:

  • (String)


90
91
92
# File 'lib/the_plaid_api/models/w2_override.rb', line 90

def other
  @other
end

#retirement_planString

Retirement plan.

Returns:

  • (String)


82
83
84
# File 'lib/the_plaid_api/models/w2_override.rb', line 82

def retirement_plan
  @retirement_plan
end

#social_security_tax_withheldString

Social security tax withheld for the tax year.

Returns:

  • (String)


42
43
44
# File 'lib/the_plaid_api/models/w2_override.rb', line 42

def social_security_tax_withheld
  @social_security_tax_withheld
end

#social_security_tipsString

Tips from social security.

Returns:

  • (String)


54
55
56
# File 'lib/the_plaid_api/models/w2_override.rb', line 54

def social_security_tips
  @social_security_tips
end

#social_security_wagesString

Wages from social security.

Returns:

  • (String)


38
39
40
# File 'lib/the_plaid_api/models/w2_override.rb', line 38

def social_security_wages
  @social_security_wages
end

#state_and_local_wagesArray[W2StateAndLocalWagesOverride]

Other.

Returns:



94
95
96
# File 'lib/the_plaid_api/models/w2_override.rb', line 94

def state_and_local_wages
  @state_and_local_wages
end

#statutory_employeeString

Statutory employee.

Returns:

  • (String)


78
79
80
# File 'lib/the_plaid_api/models/w2_override.rb', line 78

def statutory_employee
  @statutory_employee
end

#tax_yearString

The tax year of the W2 document.

Returns:

  • (String)


22
23
24
# File 'lib/the_plaid_api/models/w2_override.rb', line 22

def tax_year
  @tax_year
end

#third_party_sick_payString

Third party sick pay.

Returns:

  • (String)


86
87
88
# File 'lib/the_plaid_api/models/w2_override.rb', line 86

def third_party_sick_pay
  @third_party_sick_pay
end

#wages_tips_other_compString

Wages from tips and other compensation.

Returns:

  • (String)


30
31
32
# File 'lib/the_plaid_api/models/w2_override.rb', line 30

def wages_tips_other_comp
  @wages_tips_other_comp
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/the_plaid_api/models/w2_override.rb', line 219

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  employer = PaystubOverrideEmployer.from_hash(hash['employer']) if hash['employer']
  employee = PaystubOverrideEmployee.from_hash(hash['employee']) if hash['employee']
  tax_year = hash.key?('tax_year') ? hash['tax_year'] : SKIP
  employer_id_number =
    hash.key?('employer_id_number') ? hash['employer_id_number'] : SKIP
  wages_tips_other_comp =
    hash.key?('wages_tips_other_comp') ? hash['wages_tips_other_comp'] : SKIP
  federal_income_tax_withheld =
    hash.key?('federal_income_tax_withheld') ? hash['federal_income_tax_withheld'] : SKIP
  social_security_wages =
    hash.key?('social_security_wages') ? hash['social_security_wages'] : SKIP
  social_security_tax_withheld =
    hash.key?('social_security_tax_withheld') ? hash['social_security_tax_withheld'] : SKIP
  medicare_wages_and_tips =
    hash.key?('medicare_wages_and_tips') ? hash['medicare_wages_and_tips'] : SKIP
  medicare_tax_withheld =
    hash.key?('medicare_tax_withheld') ? hash['medicare_tax_withheld'] : SKIP
  social_security_tips =
    hash.key?('social_security_tips') ? hash['social_security_tips'] : SKIP
  allocated_tips =
    hash.key?('allocated_tips') ? hash['allocated_tips'] : SKIP
  box_9 = hash.key?('box_9') ? hash['box_9'] : SKIP
  dependent_care_benefits =
    hash.key?('dependent_care_benefits') ? hash['dependent_care_benefits'] : SKIP
  nonqualified_plans =
    hash.key?('nonqualified_plans') ? hash['nonqualified_plans'] : SKIP
  # Parameter is an array, so we need to iterate through it
  box_12 = nil
  unless hash['box_12'].nil?
    box_12 = []
    hash['box_12'].each do |structure|
      box_12 << (W2Box12Override.from_hash(structure) if structure)
    end
  end

  box_12 = SKIP unless hash.key?('box_12')
  statutory_employee =
    hash.key?('statutory_employee') ? hash['statutory_employee'] : SKIP
  retirement_plan =
    hash.key?('retirement_plan') ? hash['retirement_plan'] : SKIP
  third_party_sick_pay =
    hash.key?('third_party_sick_pay') ? hash['third_party_sick_pay'] : SKIP
  other = hash.key?('other') ? hash['other'] : SKIP
  # Parameter is an array, so we need to iterate through it
  state_and_local_wages = nil
  unless hash['state_and_local_wages'].nil?
    state_and_local_wages = []
    hash['state_and_local_wages'].each do |structure|
      state_and_local_wages << (W2StateAndLocalWagesOverride.from_hash(structure) if structure)
    end
  end

  state_and_local_wages = SKIP unless hash.key?('state_and_local_wages')

  # 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.
  W2Override.new(employer: employer,
                 employee: employee,
                 tax_year: tax_year,
                 employer_id_number: employer_id_number,
                 wages_tips_other_comp: wages_tips_other_comp,
                 federal_income_tax_withheld: federal_income_tax_withheld,
                 social_security_wages: social_security_wages,
                 social_security_tax_withheld: social_security_tax_withheld,
                 medicare_wages_and_tips: medicare_wages_and_tips,
                 medicare_tax_withheld: medicare_tax_withheld,
                 social_security_tips: social_security_tips,
                 allocated_tips: allocated_tips,
                 box_9: box_9,
                 dependent_care_benefits: dependent_care_benefits,
                 nonqualified_plans: nonqualified_plans,
                 box_12: box_12,
                 statutory_employee: statutory_employee,
                 retirement_plan: retirement_plan,
                 third_party_sick_pay: third_party_sick_pay,
                 other: other,
                 state_and_local_wages: state_and_local_wages,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/the_plaid_api/models/w2_override.rb', line 97

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['employer'] = 'employer'
  @_hash['employee'] = 'employee'
  @_hash['tax_year'] = 'tax_year'
  @_hash['employer_id_number'] = 'employer_id_number'
  @_hash['wages_tips_other_comp'] = 'wages_tips_other_comp'
  @_hash['federal_income_tax_withheld'] = 'federal_income_tax_withheld'
  @_hash['social_security_wages'] = 'social_security_wages'
  @_hash['social_security_tax_withheld'] = 'social_security_tax_withheld'
  @_hash['medicare_wages_and_tips'] = 'medicare_wages_and_tips'
  @_hash['medicare_tax_withheld'] = 'medicare_tax_withheld'
  @_hash['social_security_tips'] = 'social_security_tips'
  @_hash['allocated_tips'] = 'allocated_tips'
  @_hash['box_9'] = 'box_9'
  @_hash['dependent_care_benefits'] = 'dependent_care_benefits'
  @_hash['nonqualified_plans'] = 'nonqualified_plans'
  @_hash['box_12'] = 'box_12'
  @_hash['statutory_employee'] = 'statutory_employee'
  @_hash['retirement_plan'] = 'retirement_plan'
  @_hash['third_party_sick_pay'] = 'third_party_sick_pay'
  @_hash['other'] = 'other'
  @_hash['state_and_local_wages'] = 'state_and_local_wages'
  @_hash
end

.nullablesObject

An array for nullable fields



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/the_plaid_api/models/w2_override.rb', line 151

def self.nullables
  %w[
    tax_year
    employer_id_number
    wages_tips_other_comp
    federal_income_tax_withheld
    social_security_wages
    social_security_tax_withheld
    medicare_wages_and_tips
    medicare_tax_withheld
    social_security_tips
    allocated_tips
    box_9
    dependent_care_benefits
    nonqualified_plans
    statutory_employee
    retirement_plan
    third_party_sick_pay
    other
  ]
end

.optionalsObject

An array for optional fields



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/the_plaid_api/models/w2_override.rb', line 124

def self.optionals
  %w[
    employer
    employee
    tax_year
    employer_id_number
    wages_tips_other_comp
    federal_income_tax_withheld
    social_security_wages
    social_security_tax_withheld
    medicare_wages_and_tips
    medicare_tax_withheld
    social_security_tips
    allocated_tips
    box_9
    dependent_care_benefits
    nonqualified_plans
    box_12
    statutory_employee
    retirement_plan
    third_party_sick_pay
    other
    state_and_local_wages
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/the_plaid_api/models/w2_override.rb', line 327

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} employer: #{@employer.inspect}, employee: #{@employee.inspect}, tax_year:"\
  " #{@tax_year.inspect}, employer_id_number: #{@employer_id_number.inspect},"\
  " wages_tips_other_comp: #{@wages_tips_other_comp.inspect}, federal_income_tax_withheld:"\
  " #{@federal_income_tax_withheld.inspect}, social_security_wages:"\
  " #{@social_security_wages.inspect}, social_security_tax_withheld:"\
  " #{@social_security_tax_withheld.inspect}, medicare_wages_and_tips:"\
  " #{@medicare_wages_and_tips.inspect}, medicare_tax_withheld:"\
  " #{@medicare_tax_withheld.inspect}, social_security_tips: #{@social_security_tips.inspect},"\
  " allocated_tips: #{@allocated_tips.inspect}, box_9: #{@box_9.inspect},"\
  " dependent_care_benefits: #{@dependent_care_benefits.inspect}, nonqualified_plans:"\
  " #{@nonqualified_plans.inspect}, box_12: #{@box_12.inspect}, statutory_employee:"\
  " #{@statutory_employee.inspect}, retirement_plan: #{@retirement_plan.inspect},"\
  " third_party_sick_pay: #{@third_party_sick_pay.inspect}, other: #{@other.inspect},"\
  " state_and_local_wages: #{@state_and_local_wages.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/the_plaid_api/models/w2_override.rb', line 310

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} employer: #{@employer}, employee: #{@employee}, tax_year: #{@tax_year},"\
  " employer_id_number: #{@employer_id_number}, wages_tips_other_comp:"\
  " #{@wages_tips_other_comp}, federal_income_tax_withheld: #{@federal_income_tax_withheld},"\
  " social_security_wages: #{@social_security_wages}, social_security_tax_withheld:"\
  " #{@social_security_tax_withheld}, medicare_wages_and_tips: #{@medicare_wages_and_tips},"\
  " medicare_tax_withheld: #{@medicare_tax_withheld}, social_security_tips:"\
  " #{@social_security_tips}, allocated_tips: #{@allocated_tips}, box_9: #{@box_9},"\
  " dependent_care_benefits: #{@dependent_care_benefits}, nonqualified_plans:"\
  " #{@nonqualified_plans}, box_12: #{@box_12}, statutory_employee: #{@statutory_employee},"\
  " retirement_plan: #{@retirement_plan}, third_party_sick_pay: #{@third_party_sick_pay},"\
  " other: #{@other}, state_and_local_wages: #{@state_and_local_wages}, additional_properties:"\
  " #{@additional_properties}>"
end