]> src.bluestatic.org Git - ustaxlib.git/blob - src/fed2019/Form8959.ts
Extract constant values from fed2019 Forms as named definitions.
[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, UnsupportedLine, sumFormLines } 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 {
14 readonly name = '8959';
15
16 readonly lines = {
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']);
22 }),
23 '5': new ComputedLine((tr): number => {
24 return tr.constants.medicare.additionalWithholdingLimit[tr.getForm(Form1040).filingStatus];
25 }),
26 '6': new ComputedLine((tr): number => {
27 return clampToZero(this.getValue(tr, '4') - this.getValue(tr, '5'));
28 }),
29 '7': new ComputedLine((tr): number => {
30 return this.getValue(tr, '6') * tr.constants.medicare.additionalWithholdingRate;
31 }, 'Additional Medicare tax on Medicare wages'),
32
33 // All of Section 2 and 3 skipped.
34
35 '18': new ComputedLine((tr): number => {
36 // Should include 13 and 17.
37 return this.getValue(tr, '7');
38 }),
39
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');
51 }),
52 };
53
54 static filingStatusLimit(tr: TaxReturn): number {
55 const filingStatus = tr.getForm(Form1040).filingStatus;
56 return tr.constants.medicare.additionalWithholdingLimit[filingStatus];
57 }
58 };