Simplify uses of ComputedLine to not type the |tr| argument.
[ustaxlib.git] / src / fed2019 / Form8959.ts
1 import Form from '../Form';
2 import TaxReturn from '../TaxReturn';
3 import { Line, AccumulatorLine, ComputedLine, ReferenceLine } from '../Line';
4
5 import Form1040, { FilingStatus } from './Form1040';
6 import FormW2 from './FormW2';
7
8 export default class Form8959 extends Form<Form8959['_lines']> {
9 readonly name = '8959';
10
11 protected readonly _lines = {
12 '1': new AccumulatorLine(FormW2, '5', 'Medicare wages'),
13 // 2 is not supported (Unreported tips from Form 4137)
14 // 3 is not supported (Wages from Form 8919)
15 '4': new ComputedLine((tr): number => {
16 // Should include 2-3.
17 return this.getValue(tr, '1');
18 }),
19 '5': new ComputedLine((tr): number => {
20 return Form8959.filingStatusLimit(tr.getForm(Form1040).getInput('filingStatus'));
21 }),
22 '6': new ComputedLine((tr): number => {
23 const value = this.getValue(tr, '5') - this.getValue(tr, '4');
24 return value < 0 ? 0 : value;
25 }),
26 '7': new ComputedLine((tr): number => {
27 return this.getValue(tr, '6') * 0.009;
28 }, 'Additional Medicare tax on Medicare wages'),
29
30 // All of Section 2 and 3 skipped.
31
32 '18': new ComputedLine((tr): number => {
33 // Should include 13 and 17.
34 return this.getValue(tr, '7');
35 }),
36
37 '19': new AccumulatorLine(FormW2, '6', 'Medicare tax withheld'),
38 '20': new ReferenceLine(Form8959 as any, '1'),
39 '21': new ComputedLine((tr): number => {
40 return this.getValue(tr, '20') * 0.0145;
41 }, 'Regular Medicare withholding on Medicare wages'),
42 '22': new ComputedLine((tr): number => {
43 const value = this.getValue(tr, '19') - this.getValue(tr, '21');
44 return value < 0 ? 0 : value;
45 }, 'Additional Medicare withholding on Medicare wages'),
46 // 23 is not supported (Additional Medicare Tax withholding on railroad retirement (RRTA) compensation)
47 '24': new ComputedLine((tr): number => {
48 // Should include 23.
49 return this.getValue(tr, '22');
50 }),
51 };
52
53 static filingStatusLimit(filingStatus: FilingStatus): number {
54 switch (filingStatus) {
55 case FilingStatus.Single: return 200000;
56 case FilingStatus.MarriedFilingJoint: return 250000;
57 case FilingStatus.MarriedFilingSeparate: return 125000;
58 }
59 }
60 };