Model most of the first page of 1040.
[ustaxlib.git] / src / fed2019 / Form1040.ts
1 import Form from '../Form';
2 import TaxReturn from '../TaxReturn';
3 import { Line, AccumulatorLine, ComputedLine, ReferenceLine } from '../Line';
4
5 export enum FilingStatus {
6 Single,
7 MarriedFilingSingle,
8 MarriedFilingJoint,
9 };
10
11 export interface Form1040Input {
12 filingStatus: FilingStatus;
13 };
14
15 export default class Form1040 extends Form<Form1040Input> {
16 get name(): string { return 'Form 1040'; }
17
18 protected getLines(): Line<any>[] {
19 return [
20 new AccumulatorLine('1', 'W-2', '1', 'Wages, salaries, tips, etc.'),
21 new AccumulatorLine('2a', '1099-INT', '8', 'Tax-exempt interest'),
22 new AccumulatorLine('2b', '1009-INT', '1', 'Taxable interest'),
23 new AccumulatorLine('3a', '1099-DIV', '1b', 'Qualified dividends'),
24 new AccumulatorLine('3b', '1099-DIV', '1a', 'Ordinary dividends'),
25 // 4a and 4b are complex
26 // 4c and 4d are not supported
27 // 5a and 5b are not supported
28 // 6 - Sched D
29 new ReferenceLine<number>('7a', 'Schedule 1', '9', 'Other income from Schedule 1'),
30
31 new ComputedLine<number>('7b', (tr: TaxReturn): number => {
32 const lineIds = ['1', '2b', '3b', '4b', '4d', '5b', '6', '7a'];
33 const lines = lineIds.map(l => this.getValue<number>(tr, l));
34 return lines.reduce((acc, cur) => acc + cur, 0);
35 }, 'Total income'),
36
37 new ReferenceLine<number>('8a', 'Schedule 1', '22', 'Adjustments to income'),
38
39 new ComputedLine<number>('8b', (tr: TaxReturn): number => {
40 return this.getValue<number>(tr, '7b') - this.getValue<number>(tr, '8a');
41 }, 'Adjusted gross income'),
42
43 // 9 - Deduction
44
45 new ComputedLine<number>('10', (tr: TaxReturn): number => {
46 const taxableIncome = this.getValue<number>(tr, '8b');
47 let use8995a = false;
48 switch (this.getInput('filingStatus')) {
49 case FilingStatus.Single: use8995a = taxableIncome <= 160700; break;
50 case FilingStatus.MarriedFilingSingle: use8995a = taxableIncome <= 160725; break;
51 case FilingStatus.MarriedFilingJoint: use8995a = taxableIncome <= 321400; break;
52 };
53 return 0;
54 }, 'Qualified business income deduction'),
55
56 new ComputedLine<number>('11a', (tr: TaxReturn) => {
57 return this.getValue<number>(tr, '9') + this.getValue<number>(tr, '10');
58 }),
59 new ComputedLine<number>('11b', (tr: TaxReturn) => {
60 const value = this.getValue<number>(tr, '8b') - this.getValue<number>(tr, '11a');
61 return value < 0 ? 0 : value;
62 }, 'Taxable income'),
63 ];
64 }
65 };