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('tax-exempt interest', () => {
95 const p = Person.self('A');
96 const tr = new TaxReturn();
98 tr.addForm(new Form1099DIV({
101 exemptInterestDividends: 100,
103 tr.addForm(new Form1099INT({
107 taxExemptInterest: 50
110 const f1040 = new Form1040();
113 expect(f1040.getValue(tr, '2a')).toBe(150);
116 test('capital gain/loss', () => {
117 const p = Person.self('A');
118 const tr = new TaxReturn();
120 tr.addForm(new Form1040({ filingStatus: FilingStatus.Single }));
126 tr.addForm(new Form1099B({
129 description: '10 FNDC',
132 gainType: GainType.LongTerm,
133 basisReportedToIRS: true
135 tr.addForm(new Form8949);
136 tr.addForm(new ScheduleD());
137 tr.addForm(new ScheduleDTaxWorksheet());
138 tr.getForm(ScheduleD).getValue(tr, '21');
139 tr.getForm(Form1040).getValue(tr, '12a');
142 test('require Form8959', () => {
143 const p = Person.self('A');
144 const tr = new TaxReturn();
151 const f1040 = new Form1040({
152 filingStatus: FilingStatus.MarriedFilingSeparate,
155 tr.addForm(new Schedule2);
157 expect(() => f1040.getValue(tr, '15')).toThrow(NotFoundError);
158 expect(() => f1040.getValue(tr, '15')).toThrow('Form8959');
159 expect(f1040.getValue(tr, '1')).toBe(400000);
160 expect(f1040.getValue(tr, '8b')).toBe(400000);
163 test('backdoor and megabackdoor roth', () => {
164 const p = Person.self('A');
165 const tr = new TaxReturn();
167 tr.addForm(new Form1099R({
170 grossDistribution: 6000,
172 taxableAmountNotDetermined: true,
173 totalDistribution: true,
175 distributionCodes: [Box7Code._2],
178 tr.addForm(new Form1099R({
181 grossDistribution: 27500,
183 taxableAmountNotDetermined: false,
184 totalDistribution: false,
186 employeeContributionsOrDesignatedRothContributions: 27500,
187 distributionCodes: [Box7Code.G],
190 tr.addForm(new Form8606({
192 nondeductibleContributions: 6000,
193 traditionalIraBasis: 0,
194 distributionFromTradSepOrSimpleIraOrMadeRothConversion: true,
195 contributionsMadeInCurrentYear: 0,
196 distributionsFromAllTradSepSimpleIras: 0,
197 valueOfAllTradSepSimpleIras: 0,
198 amountConvertedFromTradSepSimpleToRoth: 6000
200 const f = new Form1040();
203 expect(f.getValue(tr, '4a')).toBe(6000);
204 expect(f.getValue(tr, '4b')).toBe(0);