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