Add SALT worksheet for determining taxable amount of refunds.
[ustaxlib.git] / src / fed2019 / Schedule1.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 Schedule1, { Schedule1Input, SALTWorksheet } from './Schedule1';
11 import TaxReturn from './TaxReturn';
12
13 test('non-taxable state tax refund', () => {
14 const p = Person.self('A');
15 const tr = new TaxReturn();
16 tr.addForm(new Form1040({
17 filingStatus: FilingStatus.Single
18 }));
19 const w = new SALTWorksheet({
20 prevYearSalt: 90000,
21 limitedPrevYearSalt: 10000,
22 prevYearItemizedDeductions: 25000,
23 prevYearFilingStatus: FilingStatus.Single
24 });
25 tr.addForm(w);
26 const f = new Schedule1({
27 stateAndLocalTaxableRefunds: 17000
28 });
29 tr.addForm(f);
30
31 expect(w.getValue(tr, '1')).toBe(17000);
32 expect(w.getValue(tr, '2')).toStrictEqual([80000, true]);
33 expect(w.getValue(tr, '3')).toBe(0);
34 expect(w.getValue(tr, '9')).toBe(0);
35 expect(tr.getForm(Form1040).getValue(tr, '7a')).toBe(0);
36 });
37
38 test('taxable state tax refund', () => {
39 const p = Person.self('A');
40 const tr = new TaxReturn();
41 tr.addForm(new Form1040({
42 filingStatus: FilingStatus.Single
43 }));
44 const w = new SALTWorksheet({
45 prevYearSalt: 7500,
46 limitedPrevYearSalt: 7500,
47 prevYearItemizedDeductions: 14000,
48 prevYearFilingStatus: FilingStatus.Single
49 });
50 tr.addForm(w);
51 const f = new Schedule1({
52 stateAndLocalTaxableRefunds: 2000
53 });
54 tr.addForm(f);
55
56 expect(w.getValue(tr, '1')).toBe(2000);
57 expect(w.getValue(tr, '2')).toStrictEqual([2000, false]);
58 expect(w.getValue(tr, '3')).toBe(2000);
59 expect(w.getValue(tr, '9')).toBe(2000);
60 expect(tr.getForm(Form1040).getValue(tr, '7a')).toBe(2000);
61 });
62
63 test('unsupported inputs', () => {
64 const keys: (keyof Schedule1Input)[] = [
65 'businessIncome',
66 'otherGainsOrLosses',
67 'rentalRealEstateRoyaltiesPartnershipsSCorps',
68 'farmIncome',
69 'businessExpensesForm2106',
70 'hsaDeduction',
71 'armedForcesMovingExpenses',
72 'deductibleSelfEmploymentTax',
73 'tuitionAndFees',
74 ];
75 for (const input of keys) {
76 const p = Person.self('A');
77 const tr = new TaxReturn();
78 const f = new Schedule1({
79 [input]: 100
80 });
81 tr.addForm(f);
82 expect(() => f.getValue(tr, '9') + f.getValue(tr, '22')).toThrow(UnsupportedFeatureError);
83 }
84 });