1 import Form from '../Form';
2 import TaxReturn from '../TaxReturn';
3 import { Line, AccumulatorLine, ComputedLine, ReferenceLine } from '../Line';
5 export enum FilingStatus {
11 export interface Form1040Input {
12 filingStatus: FilingStatus;
15 const reduceBySum = (list: number[]) => list.reduce((acc, curr) => acc + curr, 0);
17 export default class Form1040 extends Form<Form1040['_lines'], Form1040Input> {
18 readonly name = '1040';
20 protected readonly _lines = {
21 '1': new AccumulatorLine('1', 'W-2', '1', 'Wages, salaries, tips, etc.'),
22 '2a': new AccumulatorLine('2a', '1099-INT', '8', 'Tax-exempt interest'),
23 '2b': new AccumulatorLine('2b', '1009-INT', '1', 'Taxable interest'),
24 '3a': new AccumulatorLine('3a', '1099-DIV', '1b', 'Qualified dividends'),
25 '3b': new AccumulatorLine('3b', '1099-DIV', '1a', 'Ordinary dividends'),
26 // 4a and 4b are complex
27 // 4c and 4d are not supported
28 // 5a and 5b are not supported
30 '7a': new ReferenceLine<number>('7a', 'Schedule 1', '9', 'Other income from Schedule 1'),
32 '7b': new ComputedLine<number>('7b', (tr: TaxReturn): number => {
33 const lineIds = ['1', '2b', '3b', '4b', '4d', '5b', '6', '7a'];
34 const lines: number[] = lineIds.map(l => this.getValue(tr, l as keyof Form1040['_lines']));
35 return reduceBySum(lines);
38 '8a': new ReferenceLine<number>('8a', 'Schedule 1', '22', 'Adjustments to income'),
40 '8b': new ComputedLine<number>('8b', (tr: TaxReturn): number => {
41 return this.getValue(tr, '7b') - this.getValue(tr, '8a');
42 }, 'Adjusted gross income'),
45 '9': new ComputedLine<number>('9', () => 0, 'Deduction'),
47 '10': new ComputedLine<number>('10', (tr: TaxReturn): number => {
48 const taxableIncome = this.getValue(tr, '8b');
50 switch (this.getInput('filingStatus')) {
51 case FilingStatus.Single: use8995a = taxableIncome <= 160700; break;
52 case FilingStatus.MarriedFilingSingle: use8995a = taxableIncome <= 160725; break;
53 case FilingStatus.MarriedFilingJoint: use8995a = taxableIncome <= 321400; break;
56 }, 'Qualified business income deduction'),
58 '11a': new ComputedLine<number>('11a', (tr: TaxReturn): number => {
59 return this.getValue(tr, '9') + this.getValue(tr, '10');
61 '11b': new ComputedLine<number>('11b', (tr: TaxReturn): number => {
62 const value = this.getValue(tr, '8b') - this.getValue(tr, '11a');
63 return value < 0 ? 0 : value;
66 '16': new ComputedLine<number>('16', (tr: TaxReturn): number => {
70 '17': new ComputedLine<number>('17', (tr: TaxReturn): number => {
71 const fedTaxWithheldBoxes = [
72 ['W-2', '2'], ['1099-R', '4'], ['1099-DIV', '4'], ['1099-INT', '4']
74 const withholding = fedTaxWithheldBoxes.map(b => (new AccumulatorLine('F1040.L17+', b[0], b[1])).value(tr));
76 let additionalMedicare = 0;
77 const f8959 = tr.maybeGetForm('8595')
79 additionalMedicare = f8959.getValue(tr, '24');
82 return reduceBySum(withholding) + additionalMedicare;
83 }, 'Federal income tax withheld'),
87 '19': new ReferenceLine<number>('19', '1040', '17', 'Total payments'),
89 '20': new ComputedLine<number>('20', (tr: TaxReturn): number => {
90 const l16 = this.getValue(tr, '16');
91 const l19 = this.getValue(tr, '19');
95 }, 'Amount overpaid'),
97 '23': new ComputedLine<number>('23', (tr: TaxReturn): number => {
98 const l16 = this.getValue(tr, '16');
99 const l19 = this.getValue(tr, '19');
103 }, 'Amount you owe'),