From 91099b36b15c56a91881dd716f864e308c92e186 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 21 Feb 2020 08:28:09 -0500 Subject: [PATCH] Model most of the first page of 1040. --- src/fed2019/Form1040.ts | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/fed2019/Form1040.ts b/src/fed2019/Form1040.ts index 28c4c3c..4142fd3 100644 --- a/src/fed2019/Form1040.ts +++ b/src/fed2019/Form1040.ts @@ -1,8 +1,15 @@ import Form from '../Form'; import TaxReturn from '../TaxReturn'; -import { Line, AccumulatorLine } from '../Line'; +import { Line, AccumulatorLine, ComputedLine, ReferenceLine } from '../Line'; + +export enum FilingStatus { + Single, + MarriedFilingSingle, + MarriedFilingJoint, +}; export interface Form1040Input { + filingStatus: FilingStatus; }; export default class Form1040 extends Form { @@ -13,6 +20,46 @@ export default class Form1040 extends Form { new AccumulatorLine('1', 'W-2', '1', 'Wages, salaries, tips, etc.'), new AccumulatorLine('2a', '1099-INT', '8', 'Tax-exempt interest'), new AccumulatorLine('2b', '1009-INT', '1', 'Taxable interest'), + new AccumulatorLine('3a', '1099-DIV', '1b', 'Qualified dividends'), + new AccumulatorLine('3b', '1099-DIV', '1a', 'Ordinary dividends'), + // 4a and 4b are complex + // 4c and 4d are not supported + // 5a and 5b are not supported + // 6 - Sched D + new ReferenceLine('7a', 'Schedule 1', '9', 'Other income from Schedule 1'), + + new ComputedLine('7b', (tr: TaxReturn): number => { + const lineIds = ['1', '2b', '3b', '4b', '4d', '5b', '6', '7a']; + const lines = lineIds.map(l => this.getValue(tr, l)); + return lines.reduce((acc, cur) => acc + cur, 0); + }, 'Total income'), + + new ReferenceLine('8a', 'Schedule 1', '22', 'Adjustments to income'), + + new ComputedLine('8b', (tr: TaxReturn): number => { + return this.getValue(tr, '7b') - this.getValue(tr, '8a'); + }, 'Adjusted gross income'), + + // 9 - Deduction + + new ComputedLine('10', (tr: TaxReturn): number => { + const taxableIncome = this.getValue(tr, '8b'); + let use8995a = false; + switch (this.getInput('filingStatus')) { + case FilingStatus.Single: use8995a = taxableIncome <= 160700; break; + case FilingStatus.MarriedFilingSingle: use8995a = taxableIncome <= 160725; break; + case FilingStatus.MarriedFilingJoint: use8995a = taxableIncome <= 321400; break; + }; + return 0; + }, 'Qualified business income deduction'), + + new ComputedLine('11a', (tr: TaxReturn) => { + return this.getValue(tr, '9') + this.getValue(tr, '10'); + }), + new ComputedLine('11b', (tr: TaxReturn) => { + const value = this.getValue(tr, '8b') - this.getValue(tr, '11a'); + return value < 0 ? 0 : value; + }, 'Taxable income'), ]; } }; -- 2.22.5