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