Fix bugs in Schedule D and implement the QDCG Tax Worksheet.
[ustaxlib.git] / src / fed2019 / Schedule3.test.ts
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
5
6 import { Person } from '../core';
7 import { NotFoundError } from '../core/Errors';
8
9 import Form1040, { QDCGTaxWorksheet, FilingStatus } from './Form1040';
10 import Form1099DIV from './Form1099DIV';
11 import Form1116 from './Form1116';
12 import Form8949 from './Form8949';
13 import Schedule3 from './Schedule3';
14 import ScheduleD from './ScheduleD';
15 import TaxReturn from './TaxReturn';
16
17 test('foreign tax credit, form 1116 not required', () => {
18 const filingStatusToForeignTax = {
19 [FilingStatus.Single]: 200,
20 [FilingStatus.MarriedFilingJoint]: 500,
21 [FilingStatus.MarriedFilingSeparate]: 200
22 };
23
24 for (const filingStatus of Object.values(FilingStatus)) {
25 const p = Person.self('A');
26 const tr = new TaxReturn();
27 tr.addPerson(p);
28 tr.addForm(new Form1040({ filingStatus }));
29 tr.addForm(new Form8949);
30 tr.addForm(new ScheduleD);
31 tr.addForm(new QDCGTaxWorksheet);
32 tr.addForm(new Form1099DIV({
33 payer: 'Brokerage',
34 payee: p,
35 ordinaryDividends: 200000,
36 qualifiedDividends: 70000,
37 totalCapitalGain: 300,
38 foreignTaxPaid: filingStatusToForeignTax[filingStatus],
39 }));
40 const f = new Schedule3();
41 tr.addForm(f);
42
43 expect(f.getValue(tr, '1')).toBe(filingStatusToForeignTax[filingStatus]);
44 }
45 });
46
47 test('foreign tax credit, form 1116 required', () => {
48 const filingStatusToForeignTax = {
49 [FilingStatus.Single]: 400,
50 [FilingStatus.MarriedFilingJoint]: 600,
51 [FilingStatus.MarriedFilingSeparate]: 400
52 };
53
54 for (const filingStatus of Object.values(FilingStatus)) {
55 const p = Person.self('A');
56 const tr = new TaxReturn();
57 tr.addPerson(p);
58 tr.addForm(new Form1040({ filingStatus }));
59 tr.addForm(new Form8949);
60 tr.addForm(new ScheduleD);
61 tr.addForm(new Form1099DIV({
62 payer: 'Brokerage',
63 payee: p,
64 ordinaryDividends: 200000,
65 qualifiedDividends: 70000,
66 totalCapitalGain: 300,
67 foreignTaxPaid: filingStatusToForeignTax[filingStatus],
68 }));
69 const f = new Schedule3();
70 tr.addForm(f);
71
72 expect(() => f.getValue(tr, '1')).toThrow(NotFoundError);
73 }
74 });