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