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, Person, TaxReturn } from '../core';
7 import { Line, AccumulatorLine, ComputedLine, InputLine, ReferenceLine } from '../core/Line';
8 import { clampToZero, undefinedToZero } from '../core/Math';
10 export interface Form8606Input {
12 nondeductibleContributions: number;
13 traditionalIraBasis: number;
14 distributionFromTradSepOrSimpleIraOrMadeRothConversion: boolean;
15 contributionsMadeInCurrentYear?: number;
16 valueOfAllTradSepSimpleIras?: number;
17 distributionsFromAllTradSepSimpleIras?: number;
18 amountConvertedFromTradSepSimpleToRoth?: number;
21 class Input<T extends keyof Form8606Input> extends InputLine<Form8606Input, T> {};
23 export default class Form8606 extends Form<Form8606['_lines'], Form8606Input> {
24 readonly name = '8606';
26 readonly supportsMultipleCopies = true;
28 person() { return this.getInput('person'); }
30 protected readonly _lines = {
31 'person': new Input('person'),
34 '1': new Input('nondeductibleContributions'),
35 '2': new Input('traditionalIraBasis'),
36 '3': new ComputedLine((tr): number => this.getValue(tr, '1') + this.getValue(tr, '2')),
37 '4': new Input('contributionsMadeInCurrentYear'),
38 '5': new ComputedLine((tr): number => this.getValue(tr, '3') - this.getValue(tr, '4')),
39 '6': new Input('valueOfAllTradSepSimpleIras'),
40 '7': new Input('distributionsFromAllTradSepSimpleIras'),
41 '8': new Input('amountConvertedFromTradSepSimpleToRoth'),
42 '9': new ComputedLine((tr): number => {
43 return undefinedToZero(this.getValue(tr, '6')) +
44 undefinedToZero(this.getValue(tr, '7')) +
45 undefinedToZero(this.getValue(tr, '8'));
47 '10': new ComputedLine((tr): number => this.getValue(tr, '5') / this.getValue(tr, '9')),
48 '11': new ComputedLine((tr): number => this.getValue(tr, '8') * this.getValue(tr, '10'), 'Nontaxable portion converted to Roth'),
49 '12': new ComputedLine((tr): number => this.getValue(tr, '7') * this.getValue(tr, '10'), 'Nontaxable portion of distributions not converted to Roth'),
50 '13': new ComputedLine((tr): number => this.getValue(tr, '11') + this.getValue(tr, '12'), 'Nontaxable portion of all distributions'),
51 '14': new ComputedLine((tr): number => {
52 const l3 = this.getValue(tr, '3');
53 if (!this.getInput('distributionFromTradSepOrSimpleIraOrMadeRothConversion'))
55 return l3 - this.getValue(tr, '13');
56 }, 'Total basis in Traditional IRAs'),
57 '15a': new ComputedLine((tr): number => this.getValue(tr, '7') - this.getValue(tr, '12')),
58 '15b': new ComputedLine((): number => 0, 'Amount attributable to qualified disaster distributions'),
59 // 15b not supported - amount on line 15a attributable
60 '15c': new ComputedLine((tr): number => this.getValue(tr, '15a') - this.getValue(tr, '15b'), 'Taxable amount'),
63 '16': new ReferenceLine(Form8606 as any, '8'),
64 '17': new ReferenceLine(Form8606 as any, '11'),
65 '18': new ComputedLine((tr): number => this.getValue(tr, '16') - this.getValue(tr, '17')),