Add license information.
[ustaxlib.git] / src / fed2019 / Schedule2.ts
1 // Copyright 2020 Blue Static <https://www.bluestatic.org>
2 // This program is free software licensed under the GNU General Public License,
3 // version 3.0. The full text of the license can be found in LICENSE.txt.
4 // SPDX-License-Identifier: GPL-3.0-only
5
6 import { Form, TaxReturn } from '../core';
7 import { ComputedLine } from '../core/Line';
8 import { UnsupportedFeatureError } from '../core/Errors';
9
10 import Form1040, { FilingStatus } from './Form1040';
11 import Form1099DIV from './Form1099DIV';
12 import Form1099INT from './Form1099INT';
13 import Form8959 from './Form8959';
14 import Form8960 from './Form8960';
15
16 export default class Schedule2 extends Form<Schedule2['_lines']> {
17 readonly name = 'Schedule 2';
18
19 protected readonly _lines = {
20 '1': new ComputedLine((tr): number => {
21 // TODO - this is just using Taxable Income, rather than AMT-limited
22 // income
23 const f1040 = tr.getForm(Form1040);
24 const taxableIncome = f1040.getValue(tr, '11b');
25 switch (f1040.filingStatus) {
26 case FilingStatus.Single:
27 if (taxableIncome < 510300)
28 return 0;
29 case FilingStatus.MarriedFilingJoint:
30 if (taxableIncome < 1020600)
31 return 0;
32 case FilingStatus.MarriedFilingSeparate:
33 if (taxableIncome < 510300)
34 return 0;
35 }
36 throw new UnsupportedFeatureError('The AMT is not supported');
37 }, 'AMT'),
38 '2': new ComputedLine(() => 0, 'Excess advance premium tax credit repayment'), // Not supported.
39 '3': new ComputedLine((tr): number => {
40 // Should include line 2.
41 return this.getValue(tr, '1');
42 }),
43
44 // 4 is not supported (Self-employment tax.)
45 // 5 is not supported (Unreported social security and Medicare tax from)
46 // 6 is not supported (Additional tax on IRAs, other qualified retirement plans, and other tax-favored accounts)
47 // 7 is not supported (Household employment taxes.)
48 '8': new ComputedLine((tr): number => {
49 const f1040 = tr.getForm(Form1040);
50 const wages = f1040.getLine('1').value(tr);
51 const filingStatus = f1040.filingStatus;
52
53 let value = 0;
54
55 // Additional medicare tax.
56 if (wages > Form8959.filingStatusLimit(filingStatus)) {
57 value += tr.getForm(Form8959).getValue(tr, '18');
58 }
59
60 // Net investment income tax.
61 if (wages > Form8960.filingStatusLimit(filingStatus) &&
62 (tr.findForms(Form1099DIV).length || tr.findForms(Form1099INT).length)) {
63 value += tr.getForm(Form8960).getValue(tr, '17');
64 }
65
66 return value;
67 }),
68 // 9 is not supported (Section 965 net tax liability installment from Form 965-A)
69
70 '10': new ComputedLine((tr): number => {
71 // Should be lines 4 - 8.
72 return this.getValue(tr, '8');
73 })
74 };
75 };