Split Schedule2 into its own file.
[ustaxlib.git] / src / fed2019 / Schedule2.ts
1 import Form from '../Form';
2 import TaxReturn from '../TaxReturn';
3 import { ComputedLine } from '../Line';
4 import { UnsupportedFeatureError } from '../Errors';
5
6 import Form1040, { FilingStatus } from './Form1040';
7 import Form8959 from './Form8959';
8
9 export default class Schedule2 extends Form<Schedule2['_lines']> {
10 readonly name = 'Schedule 2';
11
12 protected readonly _lines = {
13 '1': new ComputedLine((tr): number => {
14 // TODO - this is just using Taxable Income, rather than AMT-limited
15 // income
16 const f1040 = tr.getForm(Form1040);
17 const taxableIncome = f1040.getValue(tr, '11b');
18 switch (f1040.getInput('filingStatus')) {
19 case FilingStatus.Single:
20 if (taxableIncome < 510300)
21 return 0;
22 case FilingStatus.MarriedFilingJoint:
23 if (taxableIncome < 1020600)
24 return 0;
25 case FilingStatus.MarriedFilingSeparate:
26 if (taxableIncome < 510300)
27 return 0;
28 }
29 throw new UnsupportedFeatureError('The AMT is not supported');
30 }, 'AMT'),
31 '2': new ComputedLine(() => 0, 'Excess advance premium tax credit repayment'), // Not supported.
32 '3': new ComputedLine((tr): number => {
33 // Should include line 2.
34 return this.getValue(tr, '1');
35 }),
36
37 // 4 is not supported (Self-employment tax.)
38 // 5 is not supported (Unreported social security and Medicare tax from)
39 // 6 is not supported (Additional tax on IRAs, other qualified retirement plans, and other tax-favored accounts)
40 // 7 is not supported (Household employment taxes.)
41 '8': new ComputedLine((tr): number => {
42 const f1040 = tr.getForm(Form1040);
43 const wages = f1040.getLine('1').value(tr);
44
45 let niit: boolean;
46 const filingStatus = f1040.getInput('filingStatus');
47
48 const additionalMedicare = wages > Form8959.filingStatusLimit(filingStatus);
49
50 switch (f1040.getInput('filingStatus')) {
51 case FilingStatus.Single:
52 if (wages > 200000) {
53 niit = true;
54 }
55 break;
56 case FilingStatus.MarriedFilingJoint:
57 if (wages > 250000) {
58 niit = true;
59 }
60 break;
61 case FilingStatus.MarriedFilingSeparate:
62 if (wages > 125000) {
63 niit = true;
64 }
65 break;
66 }
67
68 let value = 0;
69
70 if (additionalMedicare) {
71 const f8959 = tr.getForm(Form8959);
72 value += f8959.getValue(tr, '18');
73 }
74
75 if (niit) {
76 //const f8960 = tr.getForm('8960');
77 }
78
79 return value;
80 }),
81 // 9 is not supported (Section 965 net tax liability installment from Form 965-A)
82
83 '10': new ComputedLine((tr): number => {
84 // Should be lines 4 - 8.
85 return this.getValue(tr, '8');
86 })
87 };
88 };
89