Add UnsupportedLine, to formalize a comment convention that exists in fed2019.
[ustaxlib.git] / src / fed2019 / Form8606.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, Person, TaxReturn } from '../core';
7 import { Line, AccumulatorLine, ComputedLine, InputLine, ReferenceLine, UnsupportedLine } from '../core/Line';
8 import { clampToZero, undefinedToZero } from '../core/Math';
9
10 export interface Form8606Input {
11 person: Person;
12 nondeductibleContributions: number;
13 traditionalIraBasis: number;
14 distributionFromTradSepOrSimpleIraOrMadeRothConversion: boolean;
15 contributionsMadeInCurrentYear?: number;
16 valueOfAllTradSepSimpleIras?: number;
17 distributionsFromAllTradSepSimpleIras?: number;
18 amountConvertedFromTradSepSimpleToRoth?: number;
19 };
20
21 class Input<T extends keyof Form8606Input> extends InputLine<Form8606Input, T> {};
22
23 export default class Form8606 extends Form<Form8606['lines'], Form8606Input> {
24 readonly name = '8606';
25
26 readonly supportsMultipleCopies = true;
27
28 person() { return this.getInput('person'); }
29
30 readonly lines = {
31 'person': new Input('person'),
32
33 // Part 1
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'));
46 }),
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'))
54 return l3;
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 UnsupportedLine('Amount attributable to qualified disaster distributions'),
59 '15c': new ComputedLine((tr): number => this.getValue(tr, '15a') - this.getValue(tr, '15b'), 'Taxable amount'),
60
61 // Part 2
62 '16': new ReferenceLine(Form8606 as any, '8'),
63 '17': new ReferenceLine(Form8606 as any, '11'),
64 '18': new ComputedLine((tr): number => this.getValue(tr, '16') - this.getValue(tr, '17')),
65 };
66 };