Add Schedule A for itemized deductions.
[ustaxlib.git] / src / fed2019 / ScheduleA.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 { UnsupportedFeatureError } from '../core/Errors';
8
9 import Form1040, { FilingStatus } from './Form1040';
10 import ScheduleA from './ScheduleA';
11 import TaxReturn from './TaxReturn';
12 import W2 from './W2';
13
14 test('medical and dental expenses, limited', () => {
15 const p = Person.self('A');
16 const tr = new TaxReturn();
17 tr.addPerson(p);
18 tr.addForm(new W2({
19 employee: p,
20 employer: 'E',
21 wages: 3000,
22 }));
23 tr.addForm(new Form1040({
24 filingStatus: FilingStatus.Single
25 }));
26
27 const f = new ScheduleA({
28 medicalAndDentalExpenses: 250,
29 });
30 tr.addForm(f);
31
32 expect(f.getValue(tr, '2')).toBe(3000);
33 expect(f.getValue(tr, '4')).toBe(25);
34 expect(f.getValue(tr, '17')).toBe(25);
35 });
36
37 test('medical and dental expenses, excluded', () => {
38 const p = Person.self('A');
39 const tr = new TaxReturn();
40 tr.addPerson(p);
41 tr.addForm(new Form1040({
42 filingStatus: FilingStatus.Single
43 }));
44 tr.addForm(new W2({
45 employee: p,
46 employer: 'E',
47 wages: 300000,
48 }));
49
50 const f = new ScheduleA({
51 medicalAndDentalExpenses: 250,
52 });
53 tr.addForm(f);
54
55 expect(tr.getForm(Form1040).getValue(tr, '7b')).toBe(300000);
56 expect(f.getValue(tr, '2')).toBe(300000);
57 expect(f.getValue(tr, '4')).toBe(0);
58 });
59
60 test('state and local taxes, un-limited', () => {
61 const tr = new TaxReturn();
62 tr.addForm(new Form1040({
63 filingStatus: FilingStatus.MarriedFilingJoint
64 }));
65
66 const f = new ScheduleA({
67 stateAndLocalIncomeAndSalesTaxes: 3000,
68 stateAndLocalRealEstateTaxes: 475,
69 stateAndLocalPropertyTaxes: 225,
70 });
71 tr.addForm(f);
72
73 expect(f.getValue(tr, '5d')).toBe(3700);
74 expect(f.getValue(tr, '5e')).toBe(3700);
75 expect(f.getValue(tr, '17')).toBe(3700);
76 });
77
78 test('state and local taxes, limited', () => {
79 const tr = new TaxReturn();
80 tr.addForm(new Form1040({
81 filingStatus: FilingStatus.MarriedFilingJoint
82 }));
83
84 const f = new ScheduleA({
85 stateAndLocalIncomeAndSalesTaxes: 21124,
86 });
87 tr.addForm(f);
88
89 expect(f.getValue(tr, '5d')).toBe(21124);
90 expect(f.getValue(tr, '5e')).toBe(10000);
91 expect(f.getValue(tr, '17')).toBe(10000);
92 });
93
94 test('charitable gifts', () => {
95 const tr = new TaxReturn();
96 tr.addForm(new Form1040({
97 filingStatus: FilingStatus.MarriedFilingJoint
98 }));
99
100 const f = new ScheduleA({
101 charitableGiftsCashOrCheck: 3000,
102 charitableGiftsOther: 100,
103 charitableCarryOver: 22,
104 });
105 tr.addForm(f);
106
107 expect(f.getValue(tr, '14')).toBe(3122);
108 expect(f.getValue(tr, '17')).toBe(3122);
109 });
110
111 test('all inputs', () => {
112 const p = Person.self('A');
113 const tr = new TaxReturn();
114 tr.addPerson(p);
115 tr.addForm(new W2({
116 employee: p,
117 employer: 'E',
118 wages: 3000,
119 }));
120 tr.addForm(new Form1040({
121 filingStatus: FilingStatus.Single
122 }));
123
124 const f = new ScheduleA({
125 medicalAndDentalExpenses: 250,
126 stateAndLocalIncomeAndSalesTaxes: 1000,
127 stateAndLocalRealEstateTaxes: 1000,
128 stateAndLocalPropertyTaxes: 1000,
129 otherTaxes: 1000,
130 unreportedMortgageInterest: 1000,
131 unreportedMortagePoints: 1000,
132 mortgageInsurancePremiums: 1000,
133 investmentInterest: 1000,
134 charitableGiftsCashOrCheck: 1000,
135 charitableGiftsOther: 1000,
136 charitableCarryOver: 1000,
137 casualtyAndTheftLosses: 1000,
138 });
139 tr.addForm(f);
140
141 expect(f.getValue(tr, '17')).toBe(12025);
142 });