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