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