Extract constant values from fed2019 Forms as named definitions.
[ustaxlib.git] / src / fed2019 / Form8960.test.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 { Person } from '../core';
7
8 import W2 from './W2';
9 import Form1040, { FilingStatus } from './Form1040';
10 import Form1099B from './Form1099B';
11 import Form1099DIV from './Form1099DIV';
12 import Form1099INT from './Form1099INT';
13 import Form8949 from './Form8949';
14 import Form8959 from './Form8959';
15 import Form8960 from './Form8960';
16 import Schedule2 from './Schedule2';
17 import ScheduleD from './ScheduleD';
18 import TaxReturn from './TaxReturn';
19
20 describe('net investment income tax', () => {
21 const filingStatusToResult = {
22 [FilingStatus.Single]: 105555,
23 [FilingStatus.MarriedFilingJoint]: 55555,
24 [FilingStatus.MarriedFilingSeparate]: 180555,
25 };
26
27 for (const filingStatus of Object.values(FilingStatus)) {
28 test(`filing status ${filingStatus}`, () => {
29 const p = Person.self('A');
30 const tr = new TaxReturn();
31 tr.addPerson(p);
32 tr.addForm(new Form1040({ filingStatus }));
33 tr.addForm(new Form1099DIV({
34 payer: 'Brokerage',
35 payee: p,
36 ordinaryDividends: 2000,
37 qualifiedDividends: 1500,
38 totalCapitalGain: 55
39 }));
40 tr.addForm(new Form1099INT({
41 payer: 'Bank',
42 payee: p,
43 interest: 3000
44 }));
45 tr.addForm(new Form1099B({
46 payer: 'Brokerage',
47 payee: p,
48 longTermBasisReported: [
49 {
50 description: '100 VTI',
51 proceeds: 4000,
52 costBasis: 3500,
53 }
54 ]
55 }));
56 tr.addForm(new Form8949);
57 tr.addForm(new ScheduleD);
58 tr.addForm(new W2({
59 employer: 'Acme',
60 employee: p,
61 wages: 300000,
62 fedIncomeTax: 0,
63 medicareWages: 0,
64 medicareTax: 0,
65 }));
66 tr.addForm(new Form8959);
67 tr.addForm(new Schedule2);
68
69 const f = new Form8960();
70 tr.addForm(f);
71
72 expect(f.getValue(tr, '1')).toBe(3000);
73 expect(f.getValue(tr, '2')).toBe(2000);
74 expect(f.getValue(tr, '5a')).toBe(555);
75 expect(f.getValue(tr, '8')).toBe(5555);
76 expect(f.getValue(tr, '11')).toBe(0);
77 expect(f.getValue(tr, '12')).toBe(5555);
78 expect(f.getValue(tr, '13')).toBe(305555);
79 expect(f.getValue(tr, '14')).toBe(Form8960.filingStatusLimit(tr));
80 expect(f.getValue(tr, '15')).toBe(filingStatusToResult[filingStatus]);
81 expect(f.getValue(tr, '16')).toBe(5555);
82 expect(f.getValue(tr, '17')).toBe(5555 * 0.038);
83
84 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(5555 * 0.038);
85 });
86 }
87 });
88
89 describe('no net investment income tax', () => {
90 for (const filingStatus of Object.values(FilingStatus)) {
91 test(`filing status ${filingStatus}`, () => {
92 const p = Person.self('A');
93 const tr = new TaxReturn();
94 tr.addPerson(p);
95 tr.addForm(new Form1040({ filingStatus }));
96 tr.addForm(new Form1099DIV({
97 payer: 'Brokerage',
98 payee: p,
99 ordinaryDividends: 2000,
100 qualifiedDividends: 1500,
101 totalCapitalGain: 55
102 }));
103 tr.addForm(new Form1099INT({
104 payer: 'Bank',
105 payee: p,
106 interest: 3000
107 }));
108 tr.addForm(new Form1099B({
109 payer: 'Brokerage',
110 payee: p,
111 longTermBasisReported: [
112 {
113 description: '100 VTI',
114 proceeds: 4000,
115 costBasis: 3500,
116 }
117 ]
118 }));
119 tr.addForm(new Form8949);
120 tr.addForm(new ScheduleD);
121 tr.addForm(new W2({
122 employer: 'Acme',
123 employee: p,
124 wages: 70000,
125 fedIncomeTax: 0,
126 medicareWages: 0,
127 medicareTax: 0,
128 }));
129 tr.addForm(new Form8959);
130 tr.addForm(new Schedule2);
131
132 const f = new Form8960();
133 tr.addForm(f);
134
135 expect(f.getValue(tr, '17')).toBe(0);
136 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(0);
137 });
138 }
139 });