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 { ComputedLine, ReferenceLine, UnsupportedLine, sumFormLines } from '../core/Line';
8 import { clampToZero, undefinedToZero } from '../core/Math';
10 import Form1040, { FilingStatus } from './Form1040';
11 import Schedule1 from './Schedule1';
13 export default class Form8960 extends Form {
14 readonly name = '8960';
18 // Section 6013 elections not supported.
19 '1': new ReferenceLine(Form1040, '2b', 'Taxable interest'),
20 '2': new ReferenceLine(Form1040, '3b', 'Ordinary dividends'),
21 '3': new UnsupportedLine('Annuities'),
22 '4a': new UnsupportedLine('Rental real estate, royalties, partnerships, S corporations, trusts, etc'),
23 '4b': new UnsupportedLine('Adjustment for net income or loss derived in the ordinary course of a nonsection 1411 trade or business'),
24 '4c': new ComputedLine((tr): number => this.getValue(tr, '4a') + this.getValue(tr, '4b')),
25 '5a': new ComputedLine((tr): number => {
26 return (new ReferenceLine(Form1040, '6')).value(tr) +
27 undefinedToZero(new ReferenceLine(Schedule1, '4', undefined, 0).value(tr));
28 }, 'Net gain or loss'),
29 '5b': new UnsupportedLine('Net gain or loss from disposition of property that is not subject to net investment income tax'),
30 '5c': new UnsupportedLine('Adjustment from disposition of partnership interest or S corporation stock'),
31 '5d': new ComputedLine((tr): number => {
32 return sumFormLines(tr, this, ['5a', '5b', '5c']);
34 '6': new UnsupportedLine('Adjustments to investment income for certain CFCs and PFICs'),
35 '7': new UnsupportedLine('Other modifications to investment income'),
36 '8': new ComputedLine((tr): number => {
37 return sumFormLines(tr, this, ['1', '2', '3', '4c', '5d', '6', '7']);
41 // 9a not supported - Investment interest expenses
42 // 9b not supported - State, local, and foreign income tax
43 // 9c not supported - Miscellaneous investment expenses
44 // 9d not supported - 9a+9b+9c
45 // 10 not supported - Additional modifications
46 '11': new ComputedLine(() => 0, 'Total deductions and modifications'), // Not supported - 9d+10.
49 '12': new ComputedLine((tr): number => this.getValue(tr, '8') - this.getValue(tr, '11'), 'Net investment income'),
50 '13': new ReferenceLine(Form1040, '8b', 'Modified adjusted gross income'),
51 '14': new ComputedLine((tr): number => {
52 return Form8960.filingStatusLimit(tr.getForm(Form1040).filingStatus);
54 '15': new ComputedLine((tr): number => clampToZero(this.getValue(tr, '13') - this.getValue(tr, '14'))),
55 '16': new ComputedLine((tr): number => Math.min(this.getValue(tr, '12'), this.getValue(tr, '15'))),
56 '17': new ComputedLine((tr): number => this.getValue(tr, '16') * 0.038, 'Net investment income tax'),
58 // 18 - 21 not supported (Estates and Trusts)
61 static filingStatusLimit(filingStatus: FilingStatus): number {
62 switch (filingStatus) {
63 case FilingStatus.MarriedFilingJoint: return 250000;
64 case FilingStatus.MarriedFilingSeparate: return 125000;
65 case FilingStatus.Single: return 200000;