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
6 import { Form, TaxReturn } from '../core';
7 import { AccumulatorLine, ComputedLine, ReferenceLine, UnsupportedLine, sumFormLines } from '../core/Line';
8 import { Literal, clampToZero } from '../core/Math';
10 import Form1040, { QDCGTaxWorksheet, FilingStatus } from './Form1040';
11 import Form1099INT from './Form1099INT';
12 import Schedule1 from './Schedule1';
13 import Schedule2 from './Schedule2';
14 import Schedule3 from './Schedule3';
15 import ScheduleD, { ScheduleDTaxWorksheet } from './ScheduleD';
17 export default class Form6251 extends Form {
18 readonly name = '6251';
22 '1': new ComputedLine((tr): number => {
23 const f1040 = tr.getForm(Form1040);
24 const l11b = f1040.getValue(tr, '11b');
27 return f1040.getValue(tr, '8b') - f1040.getValue(tr, '9') - f1040.getValue(tr, '10');
29 '2a': new ComputedLine((tr): number => {
30 // Not supported: Schedule A, line 7.
31 return tr.getForm(Form1040).getValue(tr, '9');
33 '2b': new ReferenceLine(Schedule1, '1', 'Tax refund', 0), // Not supported - line 8 SALT.
34 '2c': new UnsupportedLine('Investment interest expense'),
35 '2d': new UnsupportedLine('Depletion'),
36 '2e': new UnsupportedLine('Net operating loss deduction'),
37 '2f': new UnsupportedLine('Alternative tax net operating loss deduction'),
38 '2g': new AccumulatorLine(Form1099INT, '9', 'Interest from specified private activity bonds exempt from the regular tax'),
39 '2h': new UnsupportedLine('Qualified small business stock'),
40 '2i': new UnsupportedLine('Exercise of incentive stock options'),
41 '2j': new UnsupportedLine('Estates and trusts (amount from Schedule K-1 (Form 1041), box 12, code A)'),
42 '2k': new UnsupportedLine('Disposition of property'),
43 '2l': new UnsupportedLine('Depreciation on assets placed in service after 1986'),
44 '2m': new UnsupportedLine('Passive activities'),
45 '2n': new UnsupportedLine('Loss limitations'),
46 '2o': new UnsupportedLine('Circulation costs'),
47 '2p': new UnsupportedLine('Long-term contracts'),
48 '2q': new UnsupportedLine('Mining costs'),
49 '2r': new UnsupportedLine('Research and experimental costs'),
50 '2s': new UnsupportedLine('Income from certain installment sales before January 1, 1987'),
51 '2t': new UnsupportedLine('Intangible drilling costs preference'),
52 '3': new UnsupportedLine('Other adjustments'),
53 '4': new ComputedLine((tr): number => {
54 return sumFormLines(tr, this, ['1', '2a', '2b', '2c', '2d', '2e', '2f', '2g', '2h', '2i', '2j', '2k', '2l', '2m', '2n', '2o', '2p', '2q', '2r', '2s', '2t', '3']);
55 }, 'Alternative minimum taxable income'),
58 '5': new ComputedLine((tr): number => {
59 const fs = tr.getForm(Form1040).filingStatus;
60 const exemption = tr.constants.amt.exemption[fs];
61 const phaseout = tr.constants.amt.phaseout[fs];
63 const l4 = this.getValue(tr, '4');
67 // Exemption worksheet:
68 const wl1 = exemption;
71 const wl4 = clampToZero(wl2 - wl3);
72 const wl5 = wl4 * Literal(0.25);
73 const wl6 = clampToZero(wl1 - wl5);
76 '6': new ComputedLine((tr): number => {
77 return clampToZero(this.getValue(tr, '4') - this.getValue(tr, '5'));
79 '7': new ComputedLine((tr): number => {
80 // Not supported - Form 2555.
81 // Not supported - Form1040 directly reporting cap gains on line 6.
83 const f1040 = tr.getForm(Form1040);
85 let part3 = f1040.getValue(tr, '3a') > 0;
87 const schedD = tr.findForm(ScheduleD);
89 const flag = schedD.getValue(tr, '15') > 0 && schedD.getValue(tr, '16') > 0;
90 part3 = part3 || flag;
94 return this.getValue(tr, '40');
96 return computeAmtTax(tr, this.getValue(tr, '6'));
98 '8': new ReferenceLine(Schedule3, '1', 'Alternative minimum tax foreign tax credit'), // Not supported - AMT FTC recalculation
99 '9': new ComputedLine((tr): number => {
100 return this.getValue(tr, '7') - this.getValue(tr, '8');
101 }, 'Tentative minimum tax'),
102 '10': new ComputedLine((tr): number => {
103 let value = tr.getForm(Form1040).getValue(tr, '12a');
104 const sched2 = tr.findForm(Schedule2);
106 value += sched2.getValue(tr, '2');
108 // Not supported - subtracting Schedule3@1 for the AMT FTC.
111 '11': new ComputedLine((tr): number => {
112 return clampToZero(this.getValue(tr, '9') - this.getValue(tr, '10'));
116 '12': new ReferenceLine(Form6251 as any, '6'),
117 '13': new ComputedLine((tr): number => {
118 const schedDTW = tr.findForm(ScheduleDTaxWorksheet);
120 return schedDTW.getValue(tr, '13');
122 const qdcgtw = tr.getForm(QDCGTaxWorksheet);
123 return qdcgtw.getValue(tr, '6');
125 '14': new ReferenceLine(ScheduleD, '19', undefined, 0),
126 '15': new ComputedLine((tr): number => {
127 const value = this.getValue(tr, '13') + this.getValue(tr, '14');
128 const schedDTW = tr.findForm(ScheduleDTaxWorksheet);
130 return Math.min(value, schedDTW.getValue(tr, '10'));
134 '16': new ComputedLine((tr): number => Math.min(this.getValue(tr, '12'), this.getValue(tr, '15'))),
135 '17': new ComputedLine((tr): number => this.getValue(tr, '12') - this.getValue(tr, '16')),
136 '18': new ComputedLine((tr): number => computeAmtTax(tr, this.getValue(tr, '17'))),
137 '19': new ComputedLine((tr): number => {
138 const fs = tr.getForm(Form1040).filingStatus;
139 return tr.constants.capitalGains.rate0MaxIncome[fs];
141 '20': new ComputedLine((tr): number => {
142 const schedDTW = tr.findForm(ScheduleDTaxWorksheet);
144 return clampToZero(schedDTW.getValue(tr, '14'));
146 const qdcgtw = tr.getForm(QDCGTaxWorksheet);
147 return clampToZero(qdcgtw.getValue(tr, '7'));
149 '21': new ComputedLine((tr): number => clampToZero(this.getValue(tr, '19') - this.getValue(tr, '20'))),
150 '22': new ComputedLine((tr): number => Math.min(this.getValue(tr, '12'), this.getValue(tr, '13'))),
151 '23': new ComputedLine((tr): number => Math.min(this.getValue(tr, '21'), this.getValue(tr, '22'))),
152 '24': new ComputedLine((tr): number => this.getValue(tr, '22') - this.getValue(tr, '23')),
153 '25': new ComputedLine((tr): number => {
154 const fs = tr.getForm(Form1040).filingStatus;
155 return tr.constants.capitalGains.rate15MaxIncome[fs];
157 '26': new ReferenceLine(Form6251 as any, '21'),
158 '27': new ComputedLine((tr): number => {
159 const schedDTW = tr.findForm(ScheduleDTaxWorksheet);
161 return clampToZero(schedDTW.getValue(tr, '21'));
163 const qdcgtw = tr.getForm(QDCGTaxWorksheet);
164 return clampToZero(qdcgtw.getValue(tr, '7'));
166 '28': new ComputedLine((tr): number => this.getValue(tr, '26') + this.getValue(tr, '27')),
167 '29': new ComputedLine((tr): number => clampToZero(this.getValue(tr, '25') - this.getValue(tr, '28'))),
168 '30': new ComputedLine((tr): number => Math.min(this.getValue(tr, '24'), this.getValue(tr, '29'))),
169 '31': new ComputedLine((tr): number => this.getValue(tr, '30') * 0.15),
170 '32': new ComputedLine((tr): number => this.getValue(tr, '23') + this.getValue(tr, '30')),
171 '33': new ComputedLine((tr): number => clampToZero(this.getValue(tr, '22') - this.getValue(tr, '32'))),
172 '34': new ComputedLine((tr): number => this.getValue(tr, '33') * 0.20),
173 '35': new ComputedLine((tr): number => this.getValue(tr, '17') + this.getValue(tr, '32') + this.getValue(tr, '33')),
174 '36': new ComputedLine((tr): number => clampToZero(this.getValue(tr, '12') - this.getValue(tr, '35'))),
175 '37': new ComputedLine((tr): number => this.getValue(tr, '36') * 0.25),
176 '38': new ComputedLine((tr): number => sumFormLines(tr, this, ['18', '31', '34', '37'])),
177 '39': new ComputedLine((tr): number => computeAmtTax(tr, this.getValue(tr, '12'))),
178 '40': new ComputedLine((tr): number => Math.min(this.getValue(tr, '38'), this.getValue(tr, '39'))),
182 function computeAmtTax(tr: TaxReturn, amount) {
183 const fs = tr.getForm(Form1040).filingStatus;
184 const limit = tr.constants.amt.limitForRate28Percent[fs];
185 const sub = limit * 0.02; // Difference between the two rates.
188 return amount * Literal(0.26);
189 return (amount * Literal(0.28)) - sub;