Documentation Index
Fetch the complete documentation index at: https://docs.ledgerbox.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The W2 model extracts and structures information from W2 tax forms, including employee and employer information, wage data, and tax withholdings.
Schema Structure
| Field | Type | Description |
|---|
W2FormVariant | string? | Type of W2 form |
TaxYear | string? | Tax year of the form |
W2Copy | string? | Copy type of the W2 |
ControlNumber | string? | Form control number |
| Field | Type | Description |
|---|
Employee.SocialSecurityNumber | string? | Employee SSN |
Employee.Name | string? | Employee’s full name |
Employee.Address | string? | Employee’s address |
| Field | Type | Description |
|---|
Employer.IdNumber | string? | Employer’s identification number |
Employer.Name | string? | Employer’s name |
Employer.Address | string? | Employer’s address |
| Field | Type | Description |
|---|
WagesTipsAndOtherCompensation | number? | Total wages, tips, and compensation |
FederalIncomeTaxWithheld | number? | Federal income tax withheld |
SocialSecurityWages | number? | Social security wages |
SocialSecurityTaxWithheld | number? | Social security tax withheld |
MedicareWagesAndTips | number? | Medicare wages and tips |
MedicareTaxWithheld | number? | Medicare tax withheld |
SocialSecurityTips | number? | Social security tips |
AllocatedTips | number? | Allocated tips |
DependentCareBenefits | number? | Dependent care benefits |
NonQualifiedPlans | number? | Non-qualified plans |
VerificationCode | string? | W2 form verification code |
Status Flags
| Field | Type | Description |
|---|
IsStatutoryEmployee | boolean? | Statutory employee status |
IsRetirementPlan | boolean? | Retirement plan status |
IsThirdPartySickPay | boolean? | Third party sick pay status |
Other | string? | Other information |
Each entry in the AdditionalInfo array contains:
| Field | Type | Description |
|---|
LetterCode | string? | IRS W2 box 12 letter code |
Amount | number? | Code amount |
Each entry in the StateTaxInfos array contains:
| Field | Type | Description |
|---|
State | string? | Two letter state code |
EmployerStateIdNumber | string? | Employer state ID number |
StateWagesTipsEtc | number? | State wages and tips |
StateIncomeTax | number? | State income tax |
Each entry in the LocalTaxInfos array contains:
| Field | Type | Description |
|---|
LocalWagesTipsEtc | number? | Local wages and tips |
LocalIncomeTax | number? | Local income tax |
LocalityName | string? | Locality name |
Type Definitions
import type {
W2Employee,
W2Employer,
W2AdditionalInfo,
W2StateTaxInfo,
W2LocalTaxInfo,
W2,
W2Response,
StrictW2Response
} from '@your-package/models';
Validation Rules
Basic Validation
- All fields are optional by default
- Arrays (AdditionalInfo, StateTaxInfos, LocalTaxInfos) default to empty arrays if not specified
Strict Validation
The following fields are required in strict mode:
- TaxYear
- Employee.Name
- Employee.SocialSecurityNumber
- Employer.Name
- Employer.IdNumber
- WagesTipsAndOtherCompensation
- FederalIncomeTaxWithheld
Example Usage
import { validateW2 } from '@your-package/models';
// Example W2 data
const w2Data = {
TaxYear: "2024",
Employee: {
Name: "John A. Doe",
SocialSecurityNumber: "123-45-6789",
Address: "123 Main St, Springfield, IL 62701"
},
Employer: {
Name: "Contoso Corporation",
IdNumber: "12-3456789",
Address: "456 Business Ave, Chicago, IL 60601"
},
WagesTipsAndOtherCompensation: 50000.00,
FederalIncomeTaxWithheld: 7500.00,
SocialSecurityWages: 50000.00,
SocialSecurityTaxWithheld: 3100.00
};
// Validate the W2
const validatedW2 = validateW2(w2Data);
// Access validated data through result property
console.log(validatedW2.result.WagesTipsAndOtherCompensation);
Best Practices
- Always validate W2 forms:
const w2 = validateW2(w2Data);
- Access data through the result property:
const wages = w2.result.WagesTipsAndOtherCompensation;
- Handle optional fields appropriately:
const tips = w2.result.SocialSecurityTips || 0;
- Check arrays before processing:
const stateTaxes = w2.result.StateTaxInfos || [];
const localTaxes = w2.result.LocalTaxInfos || [];
- Verify required fields in strict mode:
if (!w2.result.Employee?.Name || !w2.result.TaxYear) {
// Handle missing required fields
}