Add UnsupportedLine, to formalize a comment convention that exists in fed2019.
[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, UnsupportedLine, sumFormLines } 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 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 UnsupportedLine('Excess advance premium tax credit repayment'),
39 '3': new ComputedLine((tr): number => {
40 return this.getValue(tr, '1') + this.getValue(tr, '2');
41 }),
42
43 '4': new UnsupportedLine('Self-employment tax.'),
44 '5': new UnsupportedLine('Unreported social security and Medicare tax from'),
45 '6': new UnsupportedLine('Additional tax on IRAs, other qualified retirement plans, and other tax-favored accounts'),
46 '7': new UnsupportedLine('Household employment taxes.'),
47 '8': new ComputedLine((tr): number => {
48 const f1040 = tr.getForm(Form1040);
49 const wages = f1040.getLine('1').value(tr);
50 const filingStatus = f1040.filingStatus;
51
52 let value = 0;
53
54 // Additional medicare tax.
55 if (wages > Form8959.filingStatusLimit(filingStatus)) {
56 value += tr.getForm(Form8959).getValue(tr, '18');
57 }
58
59 // Net investment income tax.
60 if (wages > Form8960.filingStatusLimit(filingStatus) &&
61 (tr.findForms(Form1099DIV).length || tr.findForms(Form1099INT).length)) {
62 value += tr.getForm(Form8960).getValue(tr, '17');
63 }
64
65 return value;
66 }),
67 '9': new UnsupportedLine('Section 965 net tax liability installment from Form 965-A'),
68
69 '10': new ComputedLine((tr): number => {
70 return sumFormLines(tr, this, ['4', '5', '6', '7', '8']);
71 })
72 };
73 };