Add a test for Form8959.
[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 ScheduleD, { ScheduleDTaxWorksheet } from './ScheduleD';
10 import Form8959 from './Form8959';
11 import Form8949 from './Form8949';
12 import FormW2 from './FormW2';
13
14 test('w2 wages', () => {
15 const pa = Person.self('A');
16 const pb = Person.spouse('B');
17 const tr = new TaxReturn(2019);
18 tr.addForm(new FormW2({
19 employer: 'AA',
20 employee: pa,
21 wages: 130000.00,
22 fedIncomeTax: 0,
23 medicareWages: 0,
24 }));
25 tr.addForm(new FormW2({
26 employer: 'BB',
27 employee: pb,
28 wages: 36.32,
29 fedIncomeTax: 0,
30 medicareWages: 0,
31 }));
32 const f1040 = new Form1040({ filingStatus: FilingStatus.MarriedFilingJoint });
33 tr.addForm(f1040);
34 tr.addForm(new Schedule2);
35 expect(f1040.getValue(tr, '1')).toBe(130036.32);
36 f1040.getValue(tr, '23');
37 });
38
39 test('interest income', () => {
40 const p = Person.self('A');
41 const tr = new TaxReturn(2019);
42 tr.addForm(new Form1099INT({
43 payer: 'Bank',
44 payee: p,
45 interest: 100,
46 taxExemptInterest: 0
47 }));
48 tr.addForm(new Form1099INT({
49 payer: 'Bank 2',
50 payee: p,
51 interest: 3.50,
52 taxExemptInterest: 95
53 }));
54
55 const f1040 = new Form1040();
56 tr.addForm(f1040);
57
58 expect(f1040.getValue(tr, '2a')).toBe(95);
59 expect(f1040.getValue(tr, '2b')).toBe(103.5);
60 });
61
62 test('dividend income', () => {
63 const p = Person.self('A');
64 const tr = new TaxReturn(2019);
65 const f1099div = new Form1099DIV({
66 payer: 'Brokerage',
67 payee: p,
68 ordinaryDividends: 100,
69 qualifiedDividends: 75,
70 totalCapitalGain: 100
71 });
72 tr.addForm(f1099div);
73 tr.addForm(f1099div);
74
75 const f1040 = new Form1040();
76 tr.addForm(f1040);
77
78 expect(f1040.getValue(tr, '3a')).toBe(75 * 2);
79 expect(f1040.getValue(tr, '3b')).toBe(200);
80 });
81
82 test('capital gain/loss', () => {
83 const p = Person.self('A');
84 const tr = new TaxReturn(2019);
85 tr.addForm(new Form1040({ filingStatus: FilingStatus.Single }));
86 tr.addForm(new FormW2({
87 employer: 'Money',
88 employee: p,
89 wages: 100000
90 }));
91 tr.addForm(new Form1099B({
92 payer: 'Brokerage',
93 payee: p,
94 description: '10 FNDC',
95 proceeds: 1000,
96 costBasis: 800,
97 gainType: GainType.LongTerm,
98 basisReportedToIRS: true
99 }));
100 tr.addForm(new Form8949);
101 tr.addForm(new ScheduleD());
102 tr.addForm(new ScheduleDTaxWorksheet());
103 tr.getForm(ScheduleD).getValue(tr, '21');
104 tr.getForm(Form1040).getValue(tr, '12a');
105 });
106
107 test('require Form8959', () => {
108 const p = Person.self('A');
109 const tr = new TaxReturn(2019);
110 tr.addForm(new FormW2({
111 employer: 'Company',
112 employee: p,
113 wages: 400000,
114 }));
115 const f1040 = new Form1040({
116 filingStatus: FilingStatus.MarriedFilingSeparate,
117 });
118 tr.addForm(f1040);
119 tr.addForm(new Schedule2);
120
121 expect(() => f1040.getValue(tr, '15')).toThrow(NotFoundError);
122 expect(() => f1040.getValue(tr, '15')).toThrow('Form8959');
123 expect(f1040.getValue(tr, '1')).toBe(400000);
124 expect(f1040.getValue(tr, '8b')).toBe(400000);
125 });