Schema Tax

Automated Income Calculation From Tax Forms

By Schema TaxPublished Updated

Automated income calculation takes values already extracted from tax forms, such as W-2 wages and K-1 ordinary business income, and applies the lender's written rules to return a monthly qualifying figure. Each rule becomes a small function with named inputs. Files with falling income, missing years or flagged fields go back to an underwriter.

Automated income calculation rules written as code

Automated income calculation rules written as code are the underwriting formulas from a rulebook, turned into functions that take extracted values and return a number. A rule such as "use the lesser of the two-year average and the one-year average" becomes one short function. Writing rules this way makes each step visible, testable and tied to its source section.

The rules come from the rulebook for the loan program. For an FHA loan that is the HUD Handbook 4000.1 update issued August 12, 2026; for a loan sold to Fannie Mae it is the Selling Guide. How the two compare is covered in the post on FHA and conventional income verification. This post uses HUD's rules for its example, because they give fixed formulas that translate cleanly into code.

Two HUD rules carry most of the example. For hourly employees whose hours vary, section II.A.4.c.iii says the lender "must use the average of the income over the previous two years." For self-employment income, section II.A.4.c.x says to use "the lesser of" the average over the previous two years and the average over the previous one year. A third rule sets a stop: a decline of more than 20 percent in self-employment income means the file must be downgraded and manually underwritten.

The rules as functions

The code below is an illustration. The variable names describe the IRS box they hold; they are not field names from any product's output.

// Each function cites the rule it implements. Amounts are annual dollars.

// HUD 4000.1 II.A.4.c.iii(C)(2): hourly, hours vary -> two-year average
function twoYearAverage(priorYear: number, recentYear: number): number {
  return (priorYear + recentYear) / 2;
}

// HUD 4000.1 II.A.4.c.x(D): lesser of two-year average and one-year average
function selfEmploymentAnnual(priorYear: number, recentYear: number): number {
  return Math.min(twoYearAverage(priorYear, recentYear), recentYear);
}

// HUD 4000.1 II.A.4.c.x(B)(2): more than 20 percent decline -> manual underwriting
function declineOver20Percent(priorYear: number, recentYear: number): boolean {
  if (priorYear <= 0) return true; // no positive base year: a person decides
  return (priorYear - recentYear) / priorYear > 0.2;
}

function monthly(annual: number): number {
  return Math.round((annual / 12) * 100) / 100;
}

Each function does one thing, and each comment names the section it comes from. When a rulebook changes, the comment shows which function to update. When an underwriter asks why a number came out as it did, the answer is a list of function calls and their inputs.

Some rules do not fit a function. HUD's Appendix 2.0 lets depreciation and similar items from a partnership return be added back in proportion to the borrower's share, which needs figures from the business return. Schedule C add-backs work the same way; the post on Schedule C add-backs lenders allow lists them. Those adjustments stay with a person unless the inputs are available as reviewed fields.

What inputs does an automated income calculation need?

An automated income calculation needs typed fields from each tax form, each tied to a form type, a tax year, a box number and the borrower. W-2s supply wages, K-1s supply the partner's share of business income, and the Form 1040 supplies totals to check against. Values from outside tax forms, such as year-to-date pay, come from other sources.

Inputs from tax forms

FormBox or lineIRS labelUsed for
W-2Box 1Wages, tips, other compensationTaxable wages
W-2Box 5Medicare wages and tipsWages before elective deferrals
W-2Box 12, code DElective deferrals under a section 401(k) cash or deferred arrangementExplains a gap between Box 1 and Box 5
W-2Box bEmployer identification number (EIN)Groups W-2s by employer
K-1 (Form 1065)Box 1Ordinary business income (loss)Partner's share of business income
K-1 (Form 1065)Box 4cTotal guaranteed paymentsPayments to the partner
K-1 (Form 1065)Box 19DistributionsCash actually paid out
Form 1040Line 1aTotal amount from Form(s) W-2, box 1Cross-check of the W-2 total

The W-2 labels come from the IRS General Instructions for Forms W-2 and W-3, which also say elective deferrals to a 401(k) plan are not included in Box 1 but are reported in Box 3. That is why Box 1 and Box 5 can differ for the same job, and why a rule must name the box it uses. The K-1 labels come from the 2025 Schedule K-1 (Form 1065), and line 1a comes from the 2025 Form 1040.

A borrower with several employers has several W-2s per year, and totaling them correctly is its own task. The post on calculating income from multiple W-2s walks through it step by step.

Inputs that are not on tax forms

Some rules need values no tax form holds. Year-to-date earnings come from a pay stub. A current hourly rate comes from a pay stub or a verification of employment. Depreciation and short-term business debt come from the business return's own schedules. A calculation should accept these as separate, labelled inputs entered or confirmed by a person, not guess them.

Schema Tax supplies the tax-form side: it reads W-2s, K-1s and 1040s into typed fields with box numbers and returns them as JSON, CSV or Excel, as the five steps from upload to export describe. It does not read pay stubs or business-return schedules. The post on an income verification API built on tax documents covers how those fields reach a lending system.

An automated income calculation for a W-2 and K-1 borrower

This automated income calculation follows one fictional borrower, Morgan Example, SSN XXX-XX-1234, from extracted fields to a monthly figure under HUD's rules. Morgan is paid hourly with varying hours and owns 30 percent of a partnership. All names and amounts are examples. The result is a first pass, before any business-return adjustments.

The extracted values

Form and yearBoxField (IRS label)Example value
W-2, 2024, Northwind Example Co.Box 5Medicare wages and tips$61,200.00
W-2, 2025, Northwind Example Co.Box 1Wages, tips, other compensation$58,320.00
W-2, 2025, Northwind Example Co.Box 12, code DElective deferrals, 401(k)$6,480.00
W-2, 2025, Northwind Example Co.Box 5Medicare wages and tips$64,800.00
K-1 (1065), 2024, Example Partners LLCBox 1Ordinary business income (loss)$36,000.00
K-1 (1065), 2025, Example Partners LLCBox 1Ordinary business income (loss)$31,500.00
K-1 (1065), 2024 and 2025Box 4cTotal guaranteed payments$0.00
K-1 (1065), 2024 and 2025Box 19Distributions$30,000.00 each year

The formulas and the result

StepRuleFormulaResult
Wages, annualHUD II.A.4.c.iii, two-year average($61,200 + $64,800) / 2$63,000.00
Wages, monthlyDivide by 12$63,000 / 12$5,250.00
K-1 decline checkHUD II.A.4.c.x(B)(2)($36,000 − $31,500) / $36,00012.5%, under 20%
K-1, annualHUD II.A.4.c.x(D), lesser of averagesmin(($36,000 + $31,500) / 2, $31,500)$31,500.00
K-1, monthlyDivide by 12$31,500 / 12$2,625.00
Total, first passSum$5,250 + $2,625$7,875.00 a month

The example uses Box 5 for wages because the 2025 Box 1 of $58,320 plus the $6,480 code D deferral equals the $64,800 in Box 5. A lender's policy may name a different box; the code should follow the policy, not the example.

The K-1 line uses the one-year figure because it is lower than the two-year average of $33,750. That is the "lesser of" rule doing its job: when income falls, the recent year sets the number.

What the first pass leaves open

The $7,875 is not a final figure. HUD's Appendix 2.0 allows depreciation and similar items from the partnership return to be added back in proportion to Morgan's share, and requires income to be reduced by obligations the partnership must pay in less than one year. Both need the Form 1065, which is outside the extracted fields. Under the Fannie Mae Selling Guide, the topic on Schedule K-1 income lets K-1 income count when the borrower has a documented, stable history of cash distributions or the business has enough liquidity. Box 19 above is the on-form signal for the first test.

When should automated income calculation hand off to an underwriter?

Automated income calculation should hand off to an underwriter when a rule says a person must decide, when an input is missing or a year is absent, and when any input field is flagged as uncertain. HUD's decline rule is one trigger. A W-2 total that disagrees with the 1040 is another.

Hand-off triggers

  • Declining income. A decline over 20 percent in self-employment income means manual underwriting under HUD section II.A.4.c.x. The function can compute it; it should then stop. How averaging can hide a decline is covered in the post on self-employed income verification.
  • Missing years. A two-year average with one year present is not a two-year average. The code should refuse to run rather than divide one year by two.
  • Flagged fields. If extraction marked a value as uncertain, the calculation should not use it until a person confirms it on the original page.
  • Conflicts. A W-2 Box 1 total that does not match line 1a of the 1040 for the same year needs an explanation before the numbers are used.
  • Distributions below income. When K-1 Box 19 is lower than the income being counted, a Fannie Mae file needs the liquidity test, which uses balance-sheet figures from the business return.
  • Short histories. Self-employment between one and two years depends on the borrower's earlier career under HUD's rules, which no tax form records.

A hand-off should carry its reason. "Declined 24.1 percent, 2024 to 2025, K-1 Box 1" tells the underwriter where to start. A bare "needs review" does not.

Testing automated income calculation against hand-worked files

Testing automated income calculation against hand-worked files means running the code on closed files that an underwriter already calculated and comparing the two results line by line. Each difference is either a bug in the code, an input the code did not have, or a judgment the underwriter made that the rules do not capture.

Building the test set

Pick closed files that cover the cases the code claims to handle: a single W-2 earner, a borrower with two employers, a K-1 owner with rising income, one with falling income, and one with a short history. For each file, record the extracted values, the underwriter's worksheet and the final qualifying income.

Comparing results

Compare each intermediate step, not only the final number. A matching total can hide two errors that cancel out. Match to the cent where the rule is pure arithmetic, and log every difference with its cause.

Expect three kinds of differences. Code bugs are fixed in the code. Missing inputs, such as an add-back from the business return, show where the calculation must hand off. Judgment differences, where the underwriter chose a lower figure for a reason the rules do not state, are left to the underwriter and noted in the hand-off reasons.

Fannie Mae's own tool sets a useful comparison point. The Fannie Mae Selling Guide topic B3-3.1-03, Income Calculator, describes an optional tool that produces a findings report and says the lender must resolve contradictory information and confirm the data matches the tax returns. A home-built calculation carries the same duty.

The questions to ask a vendor whose product does any part of this, from form coverage to security, are collected in the post on income verification software.

All posts in Income Verification for Lenders