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
6 import { Form, TaxReturn } from '../core';
7 import { Line, AccumulatorLine, ComputedLine, ReferenceLine, UnsupportedLine, sumFormLines } from '../core/Line';
8 import { clampToZero } from '../core/Math';
10 import Form1040, { FilingStatus } from './Form1040';
11 import W2 from './W2';
13 export default class Form8959 extends Form {
14 readonly name = '8959';
17 '1': new AccumulatorLine(W2, '5', 'Medicare wages'),
18 '2': new UnsupportedLine('Unreported tips from Form 4137'),
19 '3': new UnsupportedLine('Wages from Form 8919'),
20 '4': new ComputedLine((tr): number => {
21 return sumFormLines(tr, this, ['1', '2', '3']);
23 '5': new ComputedLine((tr): number => {
24 return tr.constants.medicare.additionalWithholdingLimit[tr.getForm(Form1040).filingStatus];
26 '6': new ComputedLine((tr): number => {
27 return clampToZero(this.getValue(tr, '4') - this.getValue(tr, '5'));
29 '7': new ComputedLine((tr): number => {
30 return this.getValue(tr, '6') * tr.constants.medicare.additionalWithholdingRate;
31 }, 'Additional Medicare tax on Medicare wages'),
33 // All of Section 2 and 3 skipped.
35 '18': new ComputedLine((tr): number => {
36 // Should include 13 and 17.
37 return this.getValue(tr, '7');
40 '19': new AccumulatorLine(W2, '6', 'Medicare tax withheld'),
41 '20': new ReferenceLine(Form8959 as any, '1'),
42 '21': new ComputedLine((tr): number => {
43 return this.getValue(tr, '20') * tr.constants.medicare.withholdingRate;
44 }, 'Regular Medicare withholding on Medicare wages'),
45 '22': new ComputedLine((tr): number => {
46 return clampToZero(this.getValue(tr, '19') - this.getValue(tr, '21'));
47 }, 'Additional Medicare withholding on Medicare wages'),
48 '23': new UnsupportedLine('Additional Medicare Tax withholding on railroad retirement (RRTA) compensation'),
49 '24': new ComputedLine((tr): number => {
50 return this.getValue(tr, '22') + this.getValue(tr, '23');
54 static filingStatusLimit(tr: TaxReturn): number {
55 const filingStatus = tr.getForm(Form1040).filingStatus;
56 return tr.constants.medicare.additionalWithholdingLimit[filingStatus];