Add license information.
[ustaxlib.git] / src / fed2019 / Form1040.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 import { NotFoundError } from '../core/Errors';
8
9 import Form1040, { FilingStatus } from './Form1040';
10 import Form1099DIV from './Form1099DIV';
11 import Form1099INT from './Form1099INT';
12 import Form1099B, { GainType } from './Form1099B';
13 import Form1099R, { Box7Code } from './Form1099R';
14 import Schedule2 from './Schedule2';
15 import ScheduleD, { ScheduleDTaxWorksheet } from './ScheduleD';
16 import Form8606 from './Form8606';
17 import Form8959 from './Form8959';
18 import Form8949 from './Form8949';
19 import TaxReturn from './TaxReturn';
20 import W2 from './W2';
21
22 test('w2 wages', () => {
23 const pa = Person.self('A');
24 const pb = Person.spouse('B');
25 const tr = new TaxReturn();
26 tr.addPerson(pa);
27 tr.addPerson(pb);
28 tr.addForm(new W2({
29 employer: 'AA',
30 employee: pa,
31 wages: 130000.00,
32 fedIncomeTax: 0,
33 medicareWages: 0,
34 }));
35 tr.addForm(new W2({
36 employer: 'BB',
37 employee: pb,
38 wages: 36.32,
39 fedIncomeTax: 0,
40 medicareWages: 0,
41 }));
42 const f1040 = new Form1040({ filingStatus: FilingStatus.MarriedFilingJoint });
43 tr.addForm(f1040);
44 tr.addForm(new Schedule2);
45 expect(f1040.getValue(tr, '1')).toBe(130036.32);
46 f1040.getValue(tr, '23');
47 });
48
49 test('interest income', () => {
50 const p = Person.self('A');
51 const tr = new TaxReturn();
52 tr.addPerson(p);
53 tr.addForm(new Form1099INT({
54 payer: 'Bank',
55 payee: p,
56 interest: 100,
57 taxExemptInterest: 0
58 }));
59 tr.addForm(new Form1099INT({
60 payer: 'Bank 2',
61 payee: p,
62 interest: 3.50,
63 taxExemptInterest: 95
64 }));
65
66 const f1040 = new Form1040();
67 tr.addForm(f1040);
68
69 expect(f1040.getValue(tr, '2a')).toBe(95);
70 expect(f1040.getValue(tr, '2b')).toBe(103.5);
71 });
72
73 test('dividend income', () => {
74 const p = Person.self('A');
75 const tr = new TaxReturn();
76 tr.addPerson(p);
77 const f1099div = new Form1099DIV({
78 payer: 'Brokerage',
79 payee: p,
80 ordinaryDividends: 100,
81 qualifiedDividends: 75,
82 totalCapitalGain: 100
83 });
84 tr.addForm(f1099div);
85 tr.addForm(f1099div);
86
87 const f1040 = new Form1040();
88 tr.addForm(f1040);
89
90 expect(f1040.getValue(tr, '3a')).toBe(75 * 2);
91 expect(f1040.getValue(tr, '3b')).toBe(200);
92 });
93
94 test('capital gain/loss', () => {
95 const p = Person.self('A');
96 const tr = new TaxReturn();
97 tr.addPerson(p);
98 tr.addForm(new Form1040({ filingStatus: FilingStatus.Single }));
99 tr.addForm(new W2({
100 employer: 'Money',
101 employee: p,
102 wages: 150000
103 }));
104 tr.addForm(new Form1099B({
105 payer: 'Brokerage',
106 payee: p,
107 description: '10 FNDC',
108 proceeds: 1000,
109 costBasis: 800,
110 gainType: GainType.LongTerm,
111 basisReportedToIRS: true
112 }));
113 tr.addForm(new Form8949);
114 tr.addForm(new ScheduleD());
115 tr.addForm(new ScheduleDTaxWorksheet());
116 tr.getForm(ScheduleD).getValue(tr, '21');
117 tr.getForm(Form1040).getValue(tr, '12a');
118 });
119
120 test('require Form8959', () => {
121 const p = Person.self('A');
122 const tr = new TaxReturn();
123 tr.addPerson(p);
124 tr.addForm(new W2({
125 employer: 'Company',
126 employee: p,
127 wages: 400000,
128 }));
129 const f1040 = new Form1040({
130 filingStatus: FilingStatus.MarriedFilingSeparate,
131 });
132 tr.addForm(f1040);
133 tr.addForm(new Schedule2);
134
135 expect(() => f1040.getValue(tr, '15')).toThrow(NotFoundError);
136 expect(() => f1040.getValue(tr, '15')).toThrow('Form8959');
137 expect(f1040.getValue(tr, '1')).toBe(400000);
138 expect(f1040.getValue(tr, '8b')).toBe(400000);
139 });
140
141 test('backdoor and megabackdoor roth', () => {
142 const p = Person.self('A');
143 const tr = new TaxReturn();
144 tr.addPerson(p);
145 tr.addForm(new Form1099R({
146 payer: 'Roth',
147 payee: p,
148 grossDistribution: 6000,
149 taxableAmount: 6000,
150 taxableAmountNotDetermined: true,
151 totalDistribution: true,
152 fedIncomeTax: 0,
153 distributionCodes: [Box7Code._2],
154 iraSepSimple: true
155 }));
156 tr.addForm(new Form1099R({
157 payer: '401k',
158 payee: p,
159 grossDistribution: 27500,
160 taxableAmount: 0,
161 taxableAmountNotDetermined: false,
162 totalDistribution: false,
163 fedIncomeTax: 0,
164 employeeContributionsOrDesignatedRothContributions: 27500,
165 distributionCodes: [Box7Code.G],
166 iraSepSimple: false
167 }));
168 tr.addForm(new Form8606({
169 person: p,
170 nondeductibleContributions: 6000,
171 traditionalIraBasis: 0,
172 distributionFromTradSepOrSimpleIraOrMadeRothConversion: true,
173 contributionsMadeInCurrentYear: 0,
174 distributionsFromAllTradSepSimpleIras: 0,
175 valueOfAllTradSepSimpleIras: 0,
176 amountConvertedFromTradSepSimpleToRoth: 6000
177 }));
178 const f = new Form1040();
179 tr.addForm(f);
180
181 expect(f.getValue(tr, '4a')).toBe(6000);
182 expect(f.getValue(tr, '4b')).toBe(0);
183 });