Add license information.
[ustaxlib.git] / src / fed2019 / Schedule3.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 { Form, TaxReturn } from '../core';
7 import { AccumulatorLine, ComputedLine, InputLine, ReferenceLine } from '../core/Line';
8 import { NotFoundError, UnsupportedFeatureError } from '../core/Errors';
9
10 import Form1040, { FilingStatus } from './Form1040';
11 import Form1099DIV from './Form1099DIV';
12 import Form1099INT from './Form1099INT';
13 import Form1116 from './Form1116';
14 import Schedule2 from './Schedule2';
15
16 export interface Schedule3Input {
17 estimatedTaxPayments?: number;
18 };
19
20 export default class Schedule3 extends Form<Schedule3['_lines'], Schedule3Input> {
21 readonly name = 'Schedule 3';
22
23 readonly _lines = {
24 // Part 1
25 '1': new ComputedLine((tr): number => {
26 const f1040 = tr.getForm(Form1040);
27
28 const totalForeignTax = (new AccumulatorLine(Form1099DIV, '7')).value(tr) +
29 (new AccumulatorLine(Form1099INT, '6')).value(tr);
30 const limit = f1040.filingStatus == FilingStatus.MarriedFilingJoint ? 600 : 300;
31
32 if (totalForeignTax < limit) {
33 const sched2l2 = new ReferenceLine(Schedule2, '2', undefined, 0);
34 return Math.min(totalForeignTax, f1040.getValue(tr, '12a') + sched2l2.value(tr));
35 }
36 return tr.getForm(Form1116).getValue(tr, '33');
37 }, 'Foreign tax credit'),
38 // 2 not supported - Credit for child and dependent care expenses. Attach Form 2441
39 // 3 not supported - Education credits from Form 8863, line 19
40 // 4 not supported - Retirement savings contributions credit. Attach Form 8880
41 // 5 not supported - Residential energy credits. Attach Form 5695
42 // 6a not supported - Form 3800
43 // 6b not supported - Form 8801
44 // 6c not supported - Other nonrefundable credits
45 '7': new ComputedLine((tr): number => {
46 // Should include 2-6.
47 return this.getValue(tr, '1');
48 }),
49
50 // Part 2
51 '8': new InputLine<Schedule3Input>('estimatedTaxPayments'),
52 // 9 not supported - Net premium tax credit. Attach Form 8962
53 // 10 not supported - Amount paid with request for extension to file (see instructions)
54 // 11 not supported - Excess social security and tier 1 RRTA tax withheld
55 // 12 not supported - Credit for federal tax on fuels. Attach Form 4136
56 // 13a not supported - Form 2439
57 // 13b is reserved
58 // 13c not supported - Form 8885
59 // 13d not supported - Other refundable credits
60 '14': new ComputedLine((tr): number => {
61 // Should include 9-13.
62 return this.getValue(tr, '8');
63 }),
64 };
65 };