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 W4 model extracts and structures information from W4 tax forms (Employee’s Withholding Certificate), including taxpayer information, filing status, and withholding adjustments.
Schema Structure
| Field | Type | Description |
|---|
TaxYear | string? | Tax year for W-4 form submission |
| Field | Type | Description |
|---|
TaxPayer.FirstNameAndInitials | string? | Taxpayer’s first name and initials |
TaxPayer.LastName | string? | Taxpayer’s last name |
TaxPayer.Address | string? | Taxpayer’s mailing address |
TaxPayer.SSN | string? | Taxpayer’s Social Security Number |
| Field | Type | Description |
|---|
Employer.NameAndAddress | string? | Employer’s full name and address |
Employer.EmploymentFirstDate | string? | First date of employment |
Employer.EIN | string? | Employer’s Identification Number |
Filing Status and Options
| Field | Type | Description |
|---|
FilingStatus | string? | Taxpayer’s filing status |
Box2cCheckBox | boolean? | Multiple jobs or spouse works indicator |
Dependents and Withholding
| Field | Type | Description |
|---|
Box3 | number? | Total amount claimed for dependents |
Box3ChildrenUnder17 | number? | Amount claimed for children under 17 |
Box3OtherDependents | number? | Amount claimed for other dependents |
Additional Income and Deductions
| Field | Type | Description |
|---|
Box4a | number? | Other income for withholding consideration |
Box4b | number? | Deductions other than standard deduction |
Box4c | number? | Extra amount for tax withholding per paycheck |
Type Definitions
import type {
W4TaxPayer,
W4Employer,
W4,
W4Response,
StrictW4Response
} from '@your-package/models';
Validation Rules
Basic Validation
- All fields are optional by default
Strict Validation
The following fields are required in strict mode:
- TaxYear
- TaxPayer.FirstNameAndInitials
- TaxPayer.LastName
- TaxPayer.SSN
- FilingStatus
Example Usage
import { validateW4 } from '@your-package/models';
// Example W4 data
const w4Data = {
TaxYear: "2024",
TaxPayer: {
FirstNameAndInitials: "John A.",
LastName: "Doe",
SSN: "123-45-6789",
Address: "123 Main St, Springfield, IL 62704"
},
FilingStatus: "Single",
Box2cCheckBox: false,
Box3: 3000.00,
Employer: {
NameAndAddress: "ABC Corp, 123 Corporate Dr",
EmploymentFirstDate: "2024-01-01",
EIN: "12-3456789"
}
};
// Validate the W4
const validatedW4 = validateW4(w4Data);
// Access validated data through result property
console.log(validatedW4.result.TaxPayer.FirstNameAndInitials);
Date Handling
The model accepts dates in multiple formats:
- ISO 8601 datetime strings
- YYYY-MM-DD format
All dates are converted to ISO format during validation.
Best Practices
- Always validate W4 forms:
const w4 = validateW4(w4Data);
- Access data through the result property:
const taxpayer = w4.result.TaxPayer;
- Handle optional fields appropriately:
const box3Amount = w4.result.Box3 || 0;
- Verify required fields in strict mode:
if (!w4.result.TaxPayer?.FirstNameAndInitials || !w4.result.FilingStatus) {
// Handle missing required fields
}
- Handle nested objects carefully:
const employerInfo = w4.result.Employer || {};
const employmentDate = employerInfo.EmploymentFirstDate;