From 47037c2d094e0ca4e4bdcd0af4b81a8398722faf Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 8 Mar 2020 01:17:52 -0500 Subject: [PATCH] Split Schedule2 into its own file. --- src/fed2019/Form1040.test.ts | 3 +- src/fed2019/Form1040.ts | 82 +-------------------------------- src/fed2019/Form8959.test.ts | 3 +- src/fed2019/Schedule2.ts | 89 ++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 83 deletions(-) create mode 100644 src/fed2019/Schedule2.ts diff --git a/src/fed2019/Form1040.test.ts b/src/fed2019/Form1040.test.ts index 8523a38..6549ac6 100644 --- a/src/fed2019/Form1040.test.ts +++ b/src/fed2019/Form1040.test.ts @@ -2,11 +2,12 @@ import Person from '../Person'; import TaxReturn from '../TaxReturn'; import { NotFoundError } from '../Errors'; -import Form1040, { FilingStatus, Schedule2 } from './Form1040'; +import Form1040, { FilingStatus } from './Form1040'; import Form1099DIV from './Form1099DIV'; import Form1099INT from './Form1099INT'; import Form1099B, { GainType } from './Form1099B'; import Form1099R, { Box7Code } from './Form1099R'; +import Schedule2 from './Schedule2'; import ScheduleD, { ScheduleDTaxWorksheet } from './ScheduleD'; import Form8606 from './Form8606'; import Form8959 from './Form8959'; diff --git a/src/fed2019/Form1040.ts b/src/fed2019/Form1040.ts index 4d9fe8e..8c5d829 100644 --- a/src/fed2019/Form1040.ts +++ b/src/fed2019/Form1040.ts @@ -10,6 +10,7 @@ import Form1099INT from './Form1099INT'; import Form1099DIV from './Form1099DIV'; import Form1099R, { Box7Code } from './Form1099R'; import FormW2 from './FormW2'; +import Schedule2 from './Schedule2'; import ScheduleD, { ScheduleDTaxWorksheet } from './ScheduleD'; export enum FilingStatus { @@ -183,87 +184,6 @@ export default class Form1040 extends Form { }; }; -export class Schedule2 extends Form { - readonly name = 'Schedule 2'; - - protected readonly _lines = { - '1': new ComputedLine((tr): number => { - // TODO - this is just using Taxable Income, rather than AMT-limited - // income - const f1040 = tr.getForm(Form1040); - const taxableIncome = f1040.getValue(tr, '11b'); - switch (f1040.getInput('filingStatus')) { - case FilingStatus.Single: - if (taxableIncome < 510300) - return 0; - case FilingStatus.MarriedFilingJoint: - if (taxableIncome < 1020600) - return 0; - case FilingStatus.MarriedFilingSeparate: - if (taxableIncome < 510300) - return 0; - } - throw new UnsupportedFeatureError('The AMT is not supported'); - }, 'AMT'), - '2': new ComputedLine(() => 0, 'Excess advance premium tax credit repayment'), // Not supported. - '3': new ComputedLine((tr): number => { - // Should include line 2. - return this.getValue(tr, '1'); - }), - - // 4 is not supported (Self-employment tax.) - // 5 is not supported (Unreported social security and Medicare tax from) - // 6 is not supported (Additional tax on IRAs, other qualified retirement plans, and other tax-favored accounts) - // 7 is not supported (Household employment taxes.) - '8': new ComputedLine((tr): number => { - const f1040 = tr.getForm(Form1040); - const wages = f1040.getLine('1').value(tr); - - let niit: boolean; - const filingStatus = f1040.getInput('filingStatus'); - - const additionalMedicare = wages > Form8959.filingStatusLimit(filingStatus); - - switch (f1040.getInput('filingStatus')) { - case FilingStatus.Single: - if (wages > 200000) { - niit = true; - } - break; - case FilingStatus.MarriedFilingJoint: - if (wages > 250000) { - niit = true; - } - break; - case FilingStatus.MarriedFilingSeparate: - if (wages > 125000) { - niit = true; - } - break; - } - - let value = 0; - - if (additionalMedicare) { - const f8959 = tr.getForm(Form8959); - value += f8959.getValue(tr, '18'); - } - - if (niit) { - //const f8960 = tr.getForm('8960'); - } - - return value; - }), - // 9 is not supported (Section 965 net tax liability installment from Form 965-A) - - '10': new ComputedLine((tr): number => { - // Should be lines 4 - 8. - return this.getValue(tr, '8'); - }) - }; -}; - export function computeTax(income: number, filingStatus: FilingStatus): number { if (income < 100000) throw new UnsupportedFeatureError('Tax-table tax liability not supported'); diff --git a/src/fed2019/Form8959.test.ts b/src/fed2019/Form8959.test.ts index 474ca22..ed55f94 100644 --- a/src/fed2019/Form8959.test.ts +++ b/src/fed2019/Form8959.test.ts @@ -3,7 +3,8 @@ import TaxReturn from '../TaxReturn'; import FormW2 from './FormW2'; import Form8959 from './Form8959'; -import Form1040, { Schedule2, FilingStatus } from './Form1040'; +import Form1040, { FilingStatus } from './Form1040'; +import Schedule2 from './Schedule2'; describe('additional medicare tax', () => { const filingStatusToResults = { diff --git a/src/fed2019/Schedule2.ts b/src/fed2019/Schedule2.ts new file mode 100644 index 0000000..aed3406 --- /dev/null +++ b/src/fed2019/Schedule2.ts @@ -0,0 +1,89 @@ +import Form from '../Form'; +import TaxReturn from '../TaxReturn'; +import { ComputedLine } from '../Line'; +import { UnsupportedFeatureError } from '../Errors'; + +import Form1040, { FilingStatus } from './Form1040'; +import Form8959 from './Form8959'; + +export default class Schedule2 extends Form { + readonly name = 'Schedule 2'; + + protected readonly _lines = { + '1': new ComputedLine((tr): number => { + // TODO - this is just using Taxable Income, rather than AMT-limited + // income + const f1040 = tr.getForm(Form1040); + const taxableIncome = f1040.getValue(tr, '11b'); + switch (f1040.getInput('filingStatus')) { + case FilingStatus.Single: + if (taxableIncome < 510300) + return 0; + case FilingStatus.MarriedFilingJoint: + if (taxableIncome < 1020600) + return 0; + case FilingStatus.MarriedFilingSeparate: + if (taxableIncome < 510300) + return 0; + } + throw new UnsupportedFeatureError('The AMT is not supported'); + }, 'AMT'), + '2': new ComputedLine(() => 0, 'Excess advance premium tax credit repayment'), // Not supported. + '3': new ComputedLine((tr): number => { + // Should include line 2. + return this.getValue(tr, '1'); + }), + + // 4 is not supported (Self-employment tax.) + // 5 is not supported (Unreported social security and Medicare tax from) + // 6 is not supported (Additional tax on IRAs, other qualified retirement plans, and other tax-favored accounts) + // 7 is not supported (Household employment taxes.) + '8': new ComputedLine((tr): number => { + const f1040 = tr.getForm(Form1040); + const wages = f1040.getLine('1').value(tr); + + let niit: boolean; + const filingStatus = f1040.getInput('filingStatus'); + + const additionalMedicare = wages > Form8959.filingStatusLimit(filingStatus); + + switch (f1040.getInput('filingStatus')) { + case FilingStatus.Single: + if (wages > 200000) { + niit = true; + } + break; + case FilingStatus.MarriedFilingJoint: + if (wages > 250000) { + niit = true; + } + break; + case FilingStatus.MarriedFilingSeparate: + if (wages > 125000) { + niit = true; + } + break; + } + + let value = 0; + + if (additionalMedicare) { + const f8959 = tr.getForm(Form8959); + value += f8959.getValue(tr, '18'); + } + + if (niit) { + //const f8960 = tr.getForm('8960'); + } + + return value; + }), + // 9 is not supported (Section 965 net tax liability installment from Form 965-A) + + '10': new ComputedLine((tr): number => { + // Should be lines 4 - 8. + return this.getValue(tr, '8'); + }) + }; +}; + -- 2.22.5