1 import { Person } from '../core';
2 import { NotFoundError } from '../core/Errors';
4 import Form1040, { FilingStatus } from './Form1040';
5 import Form1099DIV from './Form1099DIV';
6 import Form1099INT from './Form1099INT';
7 import Form1099B, { GainType } from './Form1099B';
8 import Form1099R, { Box7Code } from './Form1099R';
9 import Schedule2 from './Schedule2';
10 import ScheduleD, { ScheduleDTaxWorksheet } from './ScheduleD';
11 import Form8606 from './Form8606';
12 import Form8959 from './Form8959';
13 import Form8949 from './Form8949';
14 import TaxReturn from './TaxReturn';
15 import W2 from './W2';
17 test('w2 wages', () => {
18 const pa = Person.self('A');
19 const pb = Person.spouse('B');
20 const tr = new TaxReturn();
35 const f1040 = new Form1040({ filingStatus: FilingStatus.MarriedFilingJoint });
37 tr.addForm(new Schedule2);
38 expect(f1040.getValue(tr, '1')).toBe(130036.32);
39 f1040.getValue(tr, '23');
42 test('interest income', () => {
43 const p = Person.self('A');
44 const tr = new TaxReturn();
45 tr.addForm(new Form1099INT({
51 tr.addForm(new Form1099INT({
58 const f1040 = new Form1040();
61 expect(f1040.getValue(tr, '2a')).toBe(95);
62 expect(f1040.getValue(tr, '2b')).toBe(103.5);
65 test('dividend income', () => {
66 const p = Person.self('A');
67 const tr = new TaxReturn();
68 const f1099div = new Form1099DIV({
71 ordinaryDividends: 100,
72 qualifiedDividends: 75,
78 const f1040 = new Form1040();
81 expect(f1040.getValue(tr, '3a')).toBe(75 * 2);
82 expect(f1040.getValue(tr, '3b')).toBe(200);
85 test('capital gain/loss', () => {
86 const p = Person.self('A');
87 const tr = new TaxReturn();
88 tr.addForm(new Form1040({ filingStatus: FilingStatus.Single }));
94 tr.addForm(new Form1099B({
97 description: '10 FNDC',
100 gainType: GainType.LongTerm,
101 basisReportedToIRS: true
103 tr.addForm(new Form8949);
104 tr.addForm(new ScheduleD());
105 tr.addForm(new ScheduleDTaxWorksheet());
106 tr.getForm(ScheduleD).getValue(tr, '21');
107 tr.getForm(Form1040).getValue(tr, '12a');
110 test('require Form8959', () => {
111 const p = Person.self('A');
112 const tr = new TaxReturn();
118 const f1040 = new Form1040({
119 filingStatus: FilingStatus.MarriedFilingSeparate,
122 tr.addForm(new Schedule2);
124 expect(() => f1040.getValue(tr, '15')).toThrow(NotFoundError);
125 expect(() => f1040.getValue(tr, '15')).toThrow('Form8959');
126 expect(f1040.getValue(tr, '1')).toBe(400000);
127 expect(f1040.getValue(tr, '8b')).toBe(400000);
130 test('backdoor and megabackdoor roth', () => {
131 const p = Person.self('A');
132 const tr = new TaxReturn();
133 tr.addForm(new Form1099R({
136 grossDistribution: 6000,
138 taxableAmountNotDetermined: true,
139 totalDistribution: true,
141 distributionCodes: [Box7Code._2],
144 tr.addForm(new Form1099R({
147 grossDistribution: 27500,
149 taxableAmountNotDetermined: false,
150 totalDistribution: false,
152 employeeContributionsOrDesignatedRothContributions: 27500,
153 distributionCodes: [Box7Code.G],
156 tr.addForm(new Form8606({
158 nondeductibleContributions: 6000,
159 traditionalIraBasis: 0,
160 distributionFromTradSepOrSimpleIraOrMadeRothConversion: true,
161 contributionsMadeInCurrentYear: 0,
162 distributionsFromAllTradSepSimpleIras: 0,
163 valueOfAllTradSepSimpleIras: 0,
164 amountConvertedFromTradSepSimpleToRoth: 6000
166 const f = new Form1040();
169 expect(f.getValue(tr, '4a')).toBe(6000);
170 expect(f.getValue(tr, '4b')).toBe(0);