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