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
6 import { Person } from '../core';
7 import { NotFoundError } from '../core/Errors';
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';
22 test('w2 wages', () => {
23 const pa = Person.self('A');
24 const pb = Person.spouse('B');
25 const tr = new TaxReturn();
42 const f1040 = new Form1040({ filingStatus: FilingStatus.MarriedFilingJoint });
44 tr.addForm(new Schedule2);
45 expect(f1040.getValue(tr, '1')).toBe(130036.32);
46 f1040.getValue(tr, '23');
49 test('interest income', () => {
50 const p = Person.self('A');
51 const tr = new TaxReturn();
53 tr.addForm(new Form1099INT({
59 tr.addForm(new Form1099INT({
66 const f1040 = new Form1040();
69 expect(f1040.getValue(tr, '2a')).toBe(95);
70 expect(f1040.getValue(tr, '2b')).toBe(103.5);
73 test('dividend income', () => {
74 const p = Person.self('A');
75 const tr = new TaxReturn();
77 const f1099div = new Form1099DIV({
80 ordinaryDividends: 100,
81 qualifiedDividends: 75,
87 const f1040 = new Form1040();
90 expect(f1040.getValue(tr, '3a')).toBe(75 * 2);
91 expect(f1040.getValue(tr, '3b')).toBe(200);
94 test('capital gain/loss', () => {
95 const p = Person.self('A');
96 const tr = new TaxReturn();
98 tr.addForm(new Form1040({ filingStatus: FilingStatus.Single }));
104 tr.addForm(new Form1099B({
107 description: '10 FNDC',
110 gainType: GainType.LongTerm,
111 basisReportedToIRS: true
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');
120 test('require Form8959', () => {
121 const p = Person.self('A');
122 const tr = new TaxReturn();
129 const f1040 = new Form1040({
130 filingStatus: FilingStatus.MarriedFilingSeparate,
133 tr.addForm(new Schedule2);
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);
141 test('backdoor and megabackdoor roth', () => {
142 const p = Person.self('A');
143 const tr = new TaxReturn();
145 tr.addForm(new Form1099R({
148 grossDistribution: 6000,
150 taxableAmountNotDetermined: true,
151 totalDistribution: true,
153 distributionCodes: [Box7Code._2],
156 tr.addForm(new Form1099R({
159 grossDistribution: 27500,
161 taxableAmountNotDetermined: false,
162 totalDistribution: false,
164 employeeContributionsOrDesignatedRothContributions: 27500,
165 distributionCodes: [Box7Code.G],
168 tr.addForm(new Form8606({
170 nondeductibleContributions: 6000,
171 traditionalIraBasis: 0,
172 distributionFromTradSepOrSimpleIraOrMadeRothConversion: true,
173 contributionsMadeInCurrentYear: 0,
174 distributionsFromAllTradSepSimpleIras: 0,
175 valueOfAllTradSepSimpleIras: 0,
176 amountConvertedFromTradSepSimpleToRoth: 6000
178 const f = new Form1040();
181 expect(f.getValue(tr, '4a')).toBe(6000);
182 expect(f.getValue(tr, '4b')).toBe(0);