-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
prebuilt-tax.us.w2.ts
497 lines (483 loc) · 15.1 KB
/
prebuilt-tax.us.w2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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
217
218
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* @azsdk-util
* @azsdk-skip-javascript
*/
// Model: prebuilt-tax.us.w2
// Description: Extract key information from IRS US W2 tax forms (year 2018-current).
// API Version: 2023-07-31
// Created: Wed Aug 02 2023
import * as fr from "@azure/ai-form-recognizer";
/**
* Extract key information from IRS US W2 tax forms (year 2018-current).
*/
export const PrebuiltTaxUsW2Model = fr.createModelFromSchema(
modelInfo()
) as fr.DocumentModel<PrebuiltTaxUsW2Result>;
export interface PrebuiltTaxUsW2Result extends fr.AnalyzeResultCommon {
/**
* Extracted pages.
*/
pages?: fr.DocumentPage[];
/**
* Extracted document paragraphs.
*/
paragraphs?: fr.DocumentParagraph[];
/**
* Extracted font styles.
*/
styles?: fr.DocumentStyle[];
/**
* Extracted key-value pairs.
*/
keyValuePairs?: fr.DocumentKeyValuePair[];
/**
* Extracted documents.
*/
documents: PrebuiltTaxUsW2Document[];
}
export type PrebuiltTaxUsW2Document = TaxUsW2;
export interface TaxUsW2 {
/**
* Document type: "tax.us.w2".
*/
docType: "tax.us.w2";
/**
* Document fields.
*/
fields: TaxUsW2Fields;
/**
* Bounding regions covering the document.
*/
boundingRegions?: fr.BoundingRegion[];
/**
* Locations of the document's elements in the `content` text (reading-order-concatenated content).
*/
spans: fr.DocumentSpan[];
/**
* The service's confidence that it has correctly extracted the document.
*/
confidence: number;
}
/**
* Describes the fields of `TaxUsW2Fields`.
*/
export interface TaxUsW2Fields {
/**
* IRS W2 Form variant. This field can have the one of the following values: 'W-2', 'W-2AS', 'W-2CM', 'W-2GU' or 'W-2VI'
*/
w2FormVariant?: fr.DocumentStringField;
/**
* Form tax year
*/
taxYear?: fr.DocumentStringField;
/**
* W2 form copy version along with printed instruction realted to this copy
*/
w2Copy?: fr.DocumentStringField;
/**
* `TaxUsW2` "Employee" field
*/
employee?: fr.DocumentObjectField<TaxUsW2Employee>;
/**
* W2 Form control number. IRS W2 form field d
*/
controlNumber?: fr.DocumentStringField;
/**
* `TaxUsW2` "Employer" field
*/
employer?: fr.DocumentObjectField<TaxUsW2Employer>;
/**
* Wages, tips, and other compensation amount in USD. IRS W2 form field 1
*/
wagesTipsAndOtherCompensation?: fr.DocumentNumberField;
/**
* Federal income tax withheld amount in USD. IRS W2 form field 2
*/
federalIncomeTaxWithheld?: fr.DocumentNumberField;
/**
* Social security wages amount in USD. IRS W2 form field 3
*/
socialSecurityWages?: fr.DocumentNumberField;
/**
* Social security tax withheld amount in USD. IRS W2 form field 4
*/
socialSecurityTaxWithheld?: fr.DocumentNumberField;
/**
* Medicare wages and tips amount in USD. IRS W2 form field 5
*/
medicareWagesAndTips?: fr.DocumentNumberField;
/**
* Medicare tax withheld amount in USD. IRS W2 form field 6
*/
medicareTaxWithheld?: fr.DocumentNumberField;
/**
* Social security tips amount in USD. IRS W2 form field 7
*/
socialSecurityTips?: fr.DocumentNumberField;
/**
* Allocated tips in USD. IRS W2 form field 8
*/
allocatedTips?: fr.DocumentNumberField;
/**
* W2 form verification code. IRS W2 form field 9
*/
verificationCode?: fr.DocumentStringField;
/**
* Dependent care benefits amount in USD. IRS W2 form field 10
*/
dependentCareBenefits?: fr.DocumentNumberField;
/**
* Non-qualified plans amount in USD. IRS W2 form field 11
*/
nonQualifiedPlans?: fr.DocumentNumberField;
/**
* Array holding W2 Codes. IRS W2 form field 12
*/
additionalInfo?: fr.DocumentArrayField<fr.DocumentObjectField<TaxUsW2AdditionalInfoElement>>;
/**
* Part of IRS W2 form field 13. Can be 'true' or 'false'
*/
isStatutoryEmployee?: fr.DocumentStringField;
/**
* Part of IRS W2 form field 13. Can be 'true' or 'false'
*/
isRetirementPlan?: fr.DocumentStringField;
/**
* Part of IRS W2 form field 13. Can be 'true' or 'false'
*/
isThirdPartySickPay?: fr.DocumentStringField;
/**
* Content of IRS W2 form field 14
*/
other?: fr.DocumentStringField;
/**
* State tax-related information. content of IRS W2 form field 15 to 17
*/
stateTaxInfos?: fr.DocumentArrayField<fr.DocumentObjectField<TaxUsW2StateTaxInfosElement>>;
/**
* Local tax-related information. Content of IRS W2 form field 18 to 20
*/
localTaxInfos?: fr.DocumentArrayField<fr.DocumentObjectField<TaxUsW2LocalTaxInfosElement>>;
}
/**
* Describes the fields of `TaxUsW2Employee`.
*/
export interface TaxUsW2Employee {
/**
* Employee social security number. IRS W2 form field a. eg: '123-45-6789'
*/
socialSecurityNumber?: fr.DocumentStringField;
/**
* Employee's first name, middle full/initials name, last name and suffix. IRS W2 form field e
*/
name?: fr.DocumentStringField;
/**
* Employee's address. Part of IRS W2 form field f
*/
address?: fr.DocumentAddressField;
}
/**
* Describes the fields of `TaxUsW2Employer`.
*/
export interface TaxUsW2Employer {
/**
* Employer's identification number. IRS W2 form field b
*/
idNumber?: fr.DocumentStringField;
/**
* Employer's name. Part of IRS W2 form field c
*/
name?: fr.DocumentStringField;
/**
* Employer's address. Part of IRS W2 form field c
*/
address?: fr.DocumentAddressField;
}
/**
* Describes the fields of `TaxUsW2AdditionalInfoElement`.
*
* Array holding W2 Codes. IRS W2 form field 12
*/
export interface TaxUsW2AdditionalInfoElement {
/**
* Please refer to https://www.irs.gov/pub/irs-pdf/iw2w3.pdf for more details on IRS W2 box 12's letter code
*/
letterCode?: fr.DocumentStringField;
/**
* Code amount in USD
*/
amount?: fr.DocumentNumberField;
}
/**
* Describes the fields of `TaxUsW2StateTaxInfosElement`.
*
* State tax-related information. content of IRS W2 form field 15 to 17
*/
export interface TaxUsW2StateTaxInfosElement {
/**
* Two letter state code. Part of IRS W2 form field 15
*/
state?: fr.DocumentStringField;
/**
* Employer state ID number. Part of IRS W2 form field 15
*/
employerStateIdNumber?: fr.DocumentStringField;
/**
* State wages, tips, etc amount in USD. IRS W2 form field 16
*/
stateWagesTipsEtc?: fr.DocumentNumberField;
/**
* State income tax amount in USD. IRS W2 form field 17
*/
stateIncomeTax?: fr.DocumentNumberField;
}
/**
* Describes the fields of `TaxUsW2LocalTaxInfosElement`.
*
* Local tax-related information. Content of IRS W2 form field 18 to 20
*/
export interface TaxUsW2LocalTaxInfosElement {
/**
* Local wages, tips, etc amount in USD. Part of IRS W2 form field 18
*/
localWagesTipsEtc?: fr.DocumentNumberField;
/**
* Local income tax amount in USD. Part of IRS W2 form field 19
*/
localIncomeTax?: fr.DocumentNumberField;
/**
* Locality name. Part of IRS W2 form field 20
*/
localityName?: fr.DocumentStringField;
}
/**
* The raw model schema.
*/
function modelInfo() {
return {
modelId: "prebuilt-tax.us.w2",
description: "Extract key information from IRS US W2 tax forms (year 2018-current).",
createdOn: "2023-07-31T00:00:00.000Z",
apiVersion: "2023-07-31",
docTypes: {
"tax.us.w2": {
buildMode: "template",
fieldSchema: {
W2FormVariant: {
type: "string",
description:
"IRS W2 Form variant. This field can have the one of the following values: 'W-2', 'W-2AS', 'W-2CM', 'W-2GU' or 'W-2VI'",
example: "W-2",
},
TaxYear: {
type: "string",
description: "Form tax year",
example: "2021",
},
W2Copy: {
type: "string",
description: "W2 form copy version along with printed instruction realted to this copy",
example: "Copy A—For Social Security Administration",
},
Employee: {
type: "object",
properties: {
SocialSecurityNumber: {
type: "string",
description:
"Employee social security number. IRS W2 form field a. eg: '123-45-6789'",
example: "123-45-6789",
},
Name: {
type: "string",
description:
"Employee's first name, middle full/initials name, last name and suffix. IRS W2 form field e",
example: "John Contonso",
},
Address: {
type: "address",
description: "Employee's address. Part of IRS W2 form field f",
example: "123 Microsoft way, Redmond WA, 98123",
},
},
},
ControlNumber: {
type: "string",
description: "W2 Form control number. IRS W2 form field d",
example: "0AB12 D345 7890",
},
Employer: {
type: "object",
properties: {
IdNumber: {
type: "string",
description: "Employer's identification number. IRS W2 form field b",
example: "12-3456789",
},
Name: {
type: "string",
description: "Employer's name. Part of IRS W2 form field c",
example: "Fabrikam",
},
Address: {
type: "address",
description: "Employer's address. Part of IRS W2 form field c",
example: "321 Microsoft way, Redmond WA, 98123",
},
},
},
WagesTipsAndOtherCompensation: {
type: "number",
description: "Wages, tips, and other compensation amount in USD. IRS W2 form field 1",
example: "1234567.89",
},
FederalIncomeTaxWithheld: {
type: "number",
description: "Federal income tax withheld amount in USD. IRS W2 form field 2",
example: "1234567.89",
},
SocialSecurityWages: {
type: "number",
description: "Social security wages amount in USD. IRS W2 form field 3",
example: "1234567.89",
},
SocialSecurityTaxWithheld: {
type: "number",
description: "Social security tax withheld amount in USD. IRS W2 form field 4",
example: "1234567.89",
},
MedicareWagesAndTips: {
type: "number",
description: "Medicare wages and tips amount in USD. IRS W2 form field 5",
example: "1234567.89",
},
MedicareTaxWithheld: {
type: "number",
description: "Medicare tax withheld amount in USD. IRS W2 form field 6",
example: "1234567.89",
},
SocialSecurityTips: {
type: "number",
description: "Social security tips amount in USD. IRS W2 form field 7",
example: "1234567.89",
},
AllocatedTips: {
type: "number",
description: "Allocated tips in USD. IRS W2 form field 8",
example: "1234567.89",
},
VerificationCode: {
type: "string",
description: "W2 form verification code. IRS W2 form field 9",
example: "AB123456",
},
DependentCareBenefits: {
type: "number",
description: "Dependent care benefits amount in USD. IRS W2 form field 10",
example: "1234567.89",
},
NonQualifiedPlans: {
type: "number",
description: "Non-qualified plans amount in USD. IRS W2 form field 11",
example: "1234567.89",
},
AdditionalInfo: {
type: "array",
description: "Array holding W2 Codes. IRS W2 form field 12",
items: {
type: "object",
properties: {
LetterCode: {
type: "string",
description:
"Please refer to https://www.irs.gov/pub/irs-pdf/iw2w3.pdf for more details on IRS W2 box 12's letter code",
example: "A",
},
Amount: {
type: "number",
description: "Code amount in USD",
example: "1234567.89",
},
},
},
},
IsStatutoryEmployee: {
type: "string",
description: "Part of IRS W2 form field 13. Can be 'true' or 'false'",
example: "true",
},
IsRetirementPlan: {
type: "string",
description: "Part of IRS W2 form field 13. Can be 'true' or 'false'",
example: "true",
},
IsThirdPartySickPay: {
type: "string",
description: "Part of IRS W2 form field 13. Can be 'true' or 'false'",
example: "true",
},
Other: {
type: "string",
description: "Content of IRS W2 form field 14",
example: "SICK LV WAGES SBJT TO $511/DAY LIMIT 1356",
},
StateTaxInfos: {
type: "array",
description: "State tax-related information. content of IRS W2 form field 15 to 17",
items: {
type: "object",
properties: {
State: {
type: "string",
description: "Two letter state code. Part of IRS W2 form field 15",
example: "WA",
},
EmployerStateIdNumber: {
type: "string",
description: "Employer state ID number. Part of IRS W2 form field 15",
example: "1234567",
},
StateWagesTipsEtc: {
type: "number",
description: "State wages, tips, etc amount in USD. IRS W2 form field 16",
example: "1234567.89",
},
StateIncomeTax: {
type: "number",
description: "State income tax amount in USD. IRS W2 form field 17",
example: "1234567.89",
},
},
},
},
LocalTaxInfos: {
type: "array",
description: "Local tax-related information. Content of IRS W2 form field 18 to 20",
items: {
type: "object",
properties: {
LocalWagesTipsEtc: {
type: "number",
description: "Local wages, tips, etc amount in USD. Part of IRS W2 form field 18",
example: "1234567.89",
},
LocalIncomeTax: {
type: "number",
description: "Local income tax amount in USD. Part of IRS W2 form field 19",
example: "1234567.89",
},
LocalityName: {
type: "string",
description: "Locality name. Part of IRS W2 form field 20",
example: "Redmond",
},
},
},
},
},
},
},
} as const;
}