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
6 import { Form, TaxReturn } from '../core';
7 import { AccumulatorLine, ComputedLine, InputLine, ReferenceLine } from '../core/Line';
8 import { NotFoundError, UnsupportedFeatureError } from '../core/Errors';
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';
16 export interface Schedule3Input {
17 estimatedTaxPayments?: number;
20 export default class Schedule3 extends Form<Schedule3['lines'], Schedule3Input> {
21 readonly name = 'Schedule 3';
25 '1': new ComputedLine((tr): number => {
26 const f1040 = tr.getForm(Form1040);
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;
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));
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');
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
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');