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