Include US debt instrument interest as 1040/2b.
[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 interestOnUsSavingsBondOrTreas: 30
59 }));
60 tr.addForm(new Form1099INT({
61 payer: 'Bank 2',
62 payee: p,
63 interest: 3.50,
64 taxExemptInterest: 95
65 }));
66
67 const f1040 = new Form1040();
68 tr.addForm(f1040);
69
70 expect(f1040.getValue(tr, '2a')).toBe(95);
71 expect(f1040.getValue(tr, '2b')).toBe(133.5);
72 });
73
74 test('dividend income', () => {
75 const p = Person.self('A');
76 const tr = new TaxReturn();
77 tr.addPerson(p);
78 const f1099div = new Form1099DIV({
79 payer: 'Brokerage',
80 payee: p,
81 ordinaryDividends: 100,
82 qualifiedDividends: 75,
83 totalCapitalGain: 100
84 });
85 tr.addForm(f1099div);
86 tr.addForm(f1099div);
87
88 const f1040 = new Form1040();
89 tr.addForm(f1040);
90
91 expect(f1040.getValue(tr, '3a')).toBe(75 * 2);
92 expect(f1040.getValue(tr, '3b')).toBe(200);
93 });
94
95 test('tax-exempt interest', () => {
96 const p = Person.self('A');
97 const tr = new TaxReturn();
98 tr.addPerson(p);
99 tr.addForm(new Form1099DIV({
100 payer: 'Brokerage',
101 payee: p,
102 exemptInterestDividends: 100,
103 }));
104 tr.addForm(new Form1099INT({
105 payer: 'Bank',
106 payee: p,
107 interest: 0,
108 taxExemptInterest: 50
109 }));
110
111 const f1040 = new Form1040();
112 tr.addForm(f1040);
113
114 expect(f1040.getValue(tr, '2a')).toBe(150);
115 });
116
117 test('capital gain/loss', () => {
118 const p = Person.self('A');
119 const tr = new TaxReturn();
120 tr.addPerson(p);
121 tr.addForm(new Form1040({ filingStatus: FilingStatus.Single }));
122 tr.addForm(new W2({
123 employer: 'Money',
124 employee: p,
125 wages: 150000
126 }));
127 tr.addForm(new Form1099B({
128 payer: 'Brokerage',
129 payee: p,
130 description: '10 FNDC',
131 proceeds: 1000,
132 costBasis: 800,
133 gainType: GainType.LongTerm,
134 basisReportedToIRS: true
135 }));
136 tr.addForm(new Form8949);
137 tr.addForm(new ScheduleD());
138 tr.addForm(new ScheduleDTaxWorksheet());
139 tr.getForm(ScheduleD).getValue(tr, '21');
140 tr.getForm(Form1040).getValue(tr, '12a');
141 });
142
143 test('require Form8959', () => {
144 const p = Person.self('A');
145 const tr = new TaxReturn();
146 tr.addPerson(p);
147 tr.addForm(new W2({
148 employer: 'Company',
149 employee: p,
150 wages: 400000,
151 }));
152 const f1040 = new Form1040({
153 filingStatus: FilingStatus.MarriedFilingSeparate,
154 });
155 tr.addForm(f1040);
156 tr.addForm(new Schedule2);
157
158 expect(() => f1040.getValue(tr, '15')).toThrow(NotFoundError);
159 expect(() => f1040.getValue(tr, '15')).toThrow('Form8959');
160 expect(f1040.getValue(tr, '1')).toBe(400000);
161 expect(f1040.getValue(tr, '8b')).toBe(400000);
162 });
163
164 test('backdoor and megabackdoor roth', () => {
165 const p = Person.self('A');
166 const tr = new TaxReturn();
167 tr.addPerson(p);
168 tr.addForm(new Form1099R({
169 payer: 'Roth',
170 payee: p,
171 grossDistribution: 6000,
172 taxableAmount: 6000,
173 taxableAmountNotDetermined: true,
174 totalDistribution: true,
175 fedIncomeTax: 0,
176 distributionCodes: [Box7Code._2],
177 iraSepSimple: true
178 }));
179 tr.addForm(new Form1099R({
180 payer: '401k',
181 payee: p,
182 grossDistribution: 27500,
183 taxableAmount: 0,
184 taxableAmountNotDetermined: false,
185 totalDistribution: false,
186 fedIncomeTax: 0,
187 employeeContributionsOrDesignatedRothContributions: 27500,
188 distributionCodes: [Box7Code.G],
189 iraSepSimple: false
190 }));
191 tr.addForm(new Form8606({
192 person: p,
193 nondeductibleContributions: 6000,
194 traditionalIraBasis: 0,
195 distributionFromTradSepOrSimpleIraOrMadeRothConversion: true,
196 contributionsMadeInCurrentYear: 0,
197 distributionsFromAllTradSepSimpleIras: 0,
198 valueOfAllTradSepSimpleIras: 0,
199 amountConvertedFromTradSepSimpleToRoth: 6000
200 }));
201 const f = new Form1040();
202 tr.addForm(f);
203
204 expect(f.getValue(tr, '4a')).toBe(6000);
205 expect(f.getValue(tr, '4b')).toBe(0);
206 });