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