diff --git a/src/forms/Y2020/irsForms/F8889.ts b/src/forms/Y2020/irsForms/F8889.ts index 2e1d20005..abc1f0186 100644 --- a/src/forms/Y2020/irsForms/F8889.ts +++ b/src/forms/Y2020/irsForms/F8889.ts @@ -245,7 +245,7 @@ export default class F8889 extends Form { l14c = (): number => this.l14a() - (this.l14b() ?? 0) l15 = (): number => this.hsas.reduce((total, hsa) => hsa.qualifiedDistributions + total, 0) - l16 = (): number => this.l14c() - this.l15() + l16 = (): number => Math.max(0, this.l14c() - this.l15()) l17a = (): boolean => false // TODO: add in logic for when line 17a is true l17b = (): number | undefined => Math.round(this.l16() * 0.2) diff --git a/src/forms/Y2020/tests/f1040.test.ts b/src/forms/Y2020/tests/f1040.test.ts index d6d3ef05b..3d0bae284 100644 --- a/src/forms/Y2020/tests/f1040.test.ts +++ b/src/forms/Y2020/tests/f1040.test.ts @@ -1,4 +1,4 @@ -import { commonTests } from '.' +import { commonTests, testKit } from '.' jest.setTimeout(40000) @@ -13,16 +13,16 @@ beforeAll(() => { describe('f1040', () => { commonTests.run() - // it('should never produce higher tax than income', async () => { - // await testKit.with1040Assert(async (forms) => { - // const f1040 = commonTests.findF1040OrFail(forms) - // expect(f1040).not.toBeUndefined() - // // tax is less than taxable income - // if (f1040?.l15() ?? 0 > 0) { - // expect(f1040?.l24() ?? 0).toBeLessThan(f1040?.l15() ?? 0) - // } else { - // expect(f1040?.l24() ?? 0).toEqual(0) - // } - // }) - // }) + it('should never produce higher tax than income', async () => { + await testKit.with1040Assert(async (forms) => { + const f1040 = commonTests.findF1040OrFail(forms) + expect(f1040).not.toBeUndefined() + // tax is less than taxable income + if (f1040?.l15() ?? 0 > 0) { + expect(f1040?.l24() ?? 0).toBeLessThan(f1040?.l15() ?? 0) + } else { + expect(f1040?.l24() ?? 0).toEqual(0) + } + }) + }) }) diff --git a/src/forms/Y2021/irsForms/F8889.ts b/src/forms/Y2021/irsForms/F8889.ts index 2e1d20005..e5b5b2f09 100644 --- a/src/forms/Y2021/irsForms/F8889.ts +++ b/src/forms/Y2021/irsForms/F8889.ts @@ -242,10 +242,10 @@ export default class F8889 extends Form { l14a = (): number => this.hsas.reduce((total, hsa) => hsa.totalDistributions + total, 0) l14b = (): number | undefined => undefined - l14c = (): number => this.l14a() - (this.l14b() ?? 0) + l14c = (): number => Math.max(0, this.l14a() - (this.l14b() ?? 0)) l15 = (): number => this.hsas.reduce((total, hsa) => hsa.qualifiedDistributions + total, 0) - l16 = (): number => this.l14c() - this.l15() + l16 = (): number => Math.max(0, this.l14c() - this.l15()) l17a = (): boolean => false // TODO: add in logic for when line 17a is true l17b = (): number | undefined => Math.round(this.l16() * 0.2) diff --git a/src/forms/Y2021/tests/f1040.test.ts b/src/forms/Y2021/tests/f1040.test.ts index 4537f9d0e..f747b8839 100644 --- a/src/forms/Y2021/tests/f1040.test.ts +++ b/src/forms/Y2021/tests/f1040.test.ts @@ -1,4 +1,4 @@ -import { commonTests } from '.' +import { commonTests, testKit } from '.' jest.setTimeout(40000) @@ -13,22 +13,18 @@ beforeAll(() => { describe('f1040', () => { commonTests.run() - // TODO: revisit this test. Commented it out because it will fail - // under certain seemingly legit circumstances. For example, if there - // is no income from W2 or 1099 but an excess distribution from a HSA - // is done, then there will be more tax than income. - // it('should never produce higher tax than income', async () => { - // await testKit.with1040Assert(async (forms) => { - // const f1040 = commonTests.findF1040(forms) - // expect(f1040).not.toBeUndefined() - // if (f1040 !== undefined) { - // // tax is less than taxable income - // if (f1040.l15() ?? 0 > 0) { - // expect(f1040.l24() ?? 0).toBeLessThan(f1040.l15() ?? 0) - // } else { - // expect(f1040.l24() ?? 0).toEqual(0) - // } - // } - // }) - // }) + it('should never produce higher tax than income', async () => { + await testKit.with1040Assert(async (forms) => { + const f1040 = commonTests.findF1040(forms) + expect(f1040).not.toBeUndefined() + if (f1040 !== undefined) { + // tax is less than taxable income + if (f1040.l15() ?? 0 > 0) { + expect(f1040.l24() ?? 0).toBeLessThan(f1040.l15() ?? 0) + } else { + expect(f1040.l24() ?? 0).toEqual(0) + } + } + }) + }) }) diff --git a/src/forms/tests/TestKit.ts b/src/forms/tests/TestKit.ts index 48165c045..ac5a2096e 100644 --- a/src/forms/tests/TestKit.ts +++ b/src/forms/tests/TestKit.ts @@ -37,7 +37,11 @@ export default class TestKit { try { const builder = this.builder.build(info) const pdfs = await builder.f1040Pdfs() - const saveDirName = `Errors ${new Date().getUTCHours()}:${new Date().getMinutes()}:${new Date().getSeconds()}` + const today = new Date() + const dateStr = `${today.getFullYear()}-${ + today.getMonth() + 1 + }-${today.getDate()}` + const saveDirName = `Errors ${dateStr} ${today.toLocaleTimeString()}` const saveDir = path.resolve(logsDir, saveDirName) await fs.mkdir(saveDir, { recursive: true }) await run(pdfs).fold(