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